# Automatic replies, card #3416

Verified local candidate; independent root acceptance is pending. Branch `feature/automatic-replies-3416`, base `origin/master` 4168cba27ba15a81fbd75824d613e3587364d0f5. Worktree: `\\wsl.localhost\Ubuntu\var\www\nuhet-automatic-replies-3416` (Linux `/var/www/nuhet-automatic-replies-3416`). No deployment, publication, customer message or live write authorized. Jonathan must explicitly approve actual implemented screenshots before go-live. No commit has been made.

## Verified checkpoint, 2026-10-07

- Mandatory central, WSL runner/health, Nuhet MCP, GitHub access and delegation/lifecycle documents read by worker. All WSL commands use the shared runner, owner/AgentId codex-3416-implementation, TaskId 3416.
- Existing local dependencies were copied without installation. ReflectionClass confirms App classes resolve the candidate worktree. Original `/var/www/nuhet` remains untouched by this worker; no live `.env` or credentials were used.
- Separate retained-notice, outgoing-reference, company/email pause and campaign-skip tables and services are implemented. Forward/Handle policy and category cooldowns persist; modes hide saved choices without discarding them. Migration defaults existing/new profiles to Forward all and never silently adds pauses. Forwarding activation for eligible legacy profiles is an explicit release behavior documented in `automatic-replies.md`.
- True MIME DSNs retain the existing bounce/hard-suppression pipeline. Useful automatic notices are retained separately with confidence/review evidence and binary-safe originals; personal/service notices do not increment bounce statistics.
- Correlation actions require original-message proof and verified original company/campaign/profile/recipient. Allowlisted envelope destinations reject conflicting tags; guessed tags/spoofed From alone cannot act. Stored random outgoing Message-IDs or authenticated structurally attached legacy originals provide proof. Later campaign-profile changes do not redirect notices.
- Pauses use original receipt time, dedupe before action, never shorten expiry, preserve active/package counts, and apply company/email-wide across duplicates. Dispatcher and fresh SMTP guards preserve all existing suppression restrictions. Persisted campaign skips prevent old campaign replay after expiry/clear. Deliberate permission-checked company-scoped clear rejects stale sources.
- Real forwarding through array transport passes, with original attachment bytes intact. Success/blocked/retry/uncertain outcomes are persisted, duplicate delivery and loops prevented; ambiguous SMTP outcomes do not auto-retry.
- Existing Nuhet Bootstrap/forms are used. Root verified actual save/reload at 17 days, hiding with Forward preserved 17, restoring Handle showed 17, then restoring the agreed 14/0 fixture values. Manual clear is outside the existing recipient edit form.
- Root-review findings corrected and covered: insufficient original-message proof; invalid empty Return-Path; quoted-body/subject false absence; campaign replay after expiry/clear; raw non-UTF8 MIME storage corruption; bare vacation-topic words incorrectly triggering absence. The final correction requires actual Swedish absence phrasing and preserves acknowledgements about vacation courses; three genuine Swedish vacation fixtures still classify as absence. Classifier/test source is frozen again after 80/370 verification.

## Automated evidence

Targeted suite command:

```sh
php vendor/phpunit/phpunit/phpunit --filter "AutomaticReply|FetchBounceStatsQuarantineTest|HardBounceRecipientSuppressorTest|BounceSpoolWriterTest|ReceiverListEditQueryTest|HardBounceMigrationRecoveryTest|SMTPQueueMailerInvalidReceiverTest"
```

Result: **80 tests, 370 assertions, pass**. Runner request `20261007-151112-35456-560ccc33`; approximately three seconds, 64.5 MB. One existing PHPUnit XML deprecation remains. Coverage includes modes/0/14, Swedish MIME/quote exclusion, actual DSNs, same-company duplicate email and profiles, cross-company isolation, receipt/duplicate/delay/expiry/clear, queued-before-reply and final-before-SMTP protection, durable campaign replay prevention, forwarding proof/idempotency/loops/retries/outcomes, exact original bytes, saved forms and manual-clear authorization.

Final lint: **34 changed non-Blade PHP files pass**. UTF-8/Nordic mojibake scan passes. Runner request `20261007-150848-124000-ab1b3d4d`. Fresh `git diff --check` passes. Source/UI frozen for root's final independent review; subsequent worker changes are documentation only.

## Safe preview and ownership

Root owns current `storage/app/automatic-replies-3416-preview.sqlite`, task-supervised `nuhet-3416-preview.service`, loopback 127.0.0.1:3416, baseline source views and screenshot output. Do not reset or alter preview fixtures during capture. Root recovery is separately maintained in `automatic-replies-3416-root-recovery.md`; worker does not edit it.

Router `scripts/automatic-replies-preview.php` uses actual controllers/Blade fragments, fixed nonsecret testing configuration, SQLite and array transport. It runs only under loopback PHP CLI server. Root-staged exact base fragments use `NUHET_PREVIEW_BASELINE_VIEWS`; `?baseline=1` renders before views. Routes: `/senderprofile/2/edit`, `/senderprofile/1/edit`, `/receiver/1/edit`, `/automatic-replies`, `/automatic-replies/1`, `/sendout/11/receivers`. No production route or live server was started by the worker. Full operating details are in `automatic-replies.md`.

## Customer investigation evidence supplied by root

A bounded read-only Nuhet MCP trace found an actual Svensk Energiutbildning AB notice at `bounce/quarantine/20261004081804-7fcd598337-2026_10_01_1790835235.4582.mail`. Top-level To was `19812_4967_1073674_bounce@post.nuhet.se`; Auto-Submitted was auto-replied. The Swedish quoted-printable HTML notice states retirement. The attached original has From and Reply-To `inbjudan@svenut.se`, Precedence bulk and the tagged bounce envelope address. Original Message-ID matches In-Reply-To. Original profile 19959 was used on campaign 4967; new profile 45459 is separately verified. The contact is currently active without confirmed hard-bounce state. This proves a useful reply from the actual Oct 1 campaign reached Nuhet and quarantine; it does not establish total reply volume or all provider suppression causes. The search was bounded. A separate plain gateway NDR from that sendout lacked structured DSN evidence and remains uncertain/reviewable. No personal reply body or alternative-contact details are reproduced here.

## Deferred file split recommendation

`app/Console/Commands/FetchBounceStats.php` is 824 lines and mixes MIME/DSN classification, spool retry/recovery and database effects. A follow-up could extract `DeliveryStatusParser.php` and `BounceSpoolRecovery.php`, leaving command orchestration and verified-recipient updates behind stable interfaces. `app/Console/Commands/QueueMailer.php` is 1000 lines and mixes queue lifecycle, SMTP construction, limits and statistics; a follow-up `CampaignMailSender.php` could own construction/submission behind the existing guard/result interface. Extract pure parsing/recovery first with the existing targeted regression suite, then SMTP construction with queue/guard tests; preserve command signatures, correlation and stat-update rules. This broader refactor is outside the current feature scope and remains unperformed.

## Pending / next action

Root owns final independent review, genuine desktop/mobile before/after screenshots and contact sheet, final acceptance and any later publication. Application source/UI is frozen. If review finds a defect, root will explicitly return the bounded correction; any visible change requires screenshot refresh. No go-live before Jonathan's explicit screenshot approval. Generated `.phpunit.result.cache` in this candidate is not a feature deliverable and should not be committed. Dependency/preview artifacts are excluded from publication.

Worker has one known compaction and reread task-lifecycle after recovery. No child successor is needed at this final checkpoint; root retains final acceptance.

Uncommitted features:

1. Automatic reply policy, verified intake/forwarding, retained review notices and company/email pauses with campaign cooldown guards and UI.
2. Safe actual-page preview fixtures, targeted automated coverage and feature/recovery documentation.