# #3416 targeted format correction - 2026-10-30

## Current state and next decision

The targeted correction is implemented and passes its final local checks. Independent review found four gaps in the initial candidate; all are corrected. Root fresh-read the final VERIFIED review, checked the actual diff/source, final hashes, plan and meaningful qualification, and accepts this contributor candidate. The review report SHA-256 isff1ac5a21ffbbcb2c14cf028d0d3376ff7b1b3550d109bebd71f218072c3074d. The report was normalized to LF with one terminal newline after handoff; its content and all reviewed source hashes are unchanged. No blocking source finding remains; live release/recovery/customer receipt remain later gates.

Jonathan authorized "Implement the targeted correction" after reviewing the investigation. This unit covers the correction, regressions, independent review and a read-only recovery plan. Publication/PR/CI, production activation and actual retained-message recovery still need their corresponding authorization. No production record, setting, recipient, campaign or message has been changed. Existing customer delivery is not claimed.

Card #3416 remains open/In Progress, solely Jonathan, linked to this session and watched. This owner retains the card through later authorized release and real destination acceptance. It must not settle the session while the card is incomplete.

## Candidate and ownership

Base: origin/master 8052ad91c4981ab98be67d9c1a803039ee809957.
Task branch: fix/3416-reply-correlation-20261030.
Worktree: /var/www/nuhet/.xherd-worktrees/fix/3416-reply-correlation-20261030.
Owner/cleanup: this root session, pane p_b1e3a620727f. Retain the worktree and its independent vendor copy while the candidate needs release qualification. No running server, test database or mail operation is retained.

Xherd acquisition created Windows UNC Git pointers that Linux could not follow. Native observation established these were the task's newly created branch/directory. The standing approved fallback repaired only its Git pointers, fast-forwarded its branch to the fetched master and restored helper-created mode-only differences before authoring. The shared checkout and other agents' worktrees/changes were preserved. Private Xherd state was not changed; automatic daemon cleanup of this repaired native worktree is not claimed.

## Final behavior

- Reference parsing accepts the observed complete whitespace-delimited bare Message-ID form alongside bracketed identifiers. An exact unique stored delivery identity and all existing tenant/profile/recipient checks remain required; guessed or conflicting references cannot act.
- A tri-state report selection distinguishes a selected DSN from a genuine personal notice and from an ambiguous, incomplete or unsupported report wrapper. The latter is quarantined before personal-reply classification, so a spoofed personal From and absence-looking footer cannot cause forwarding or a pause.
- The attachment walk has explicit completeness, depth8, per-multipart50-part and total100-node bounds. Missing multipart boundaries, missing header/body separation and truncated traversal fail closed. Closing MIME delimiters stop the walk; epilogues are not attachments. Existing encoded message/rfc822 decoding is preserved.
- Wrapped DSNs require a matching unique OUTER stored delivery, company/campaign/stat/email/original verified profile and unchanged recipient since the original send. The selected report's actual Final-Recipient, action and status feed the existing bounce handling. Plain text/footer prose cannot prove a hard bounce.
- Newly unwrapped report effects run under CompanyRetention::whileAvailable from fresh company admission through their bounded writes. The existing top-level report path remains unchanged. The helper receives retryExpired explicitly and keeps existing temporary-failure behavior.
- Any existing retained AutomaticReply with the same company/dedupe identity blocks wrapped-report effects, including review, forwarded and uncertain states. Deployment or reingestion cannot release these rows. The existing forwarding byte/once-only/uncertain-delivery behavior is preserved.

There is no schema, UI, sender-default or production-settings change. No version.json exists, so the conditional version.json bump workflow does not apply.

## Frozen source hashes

| File | SHA-256 |
| --- | --- |
| app/Services/Mail/AutomaticReplyClassifier.php | b1697ce7b384ec8358833d93f74d692545bfde1cdd33782b39e7610df023916e |
| app/Services/Mail/AutomaticReplyCorrelation.php | 5e1936cf2f3dd9860e927f358127cf04bfd75182533240d88eb6848a874e45c1 |
| app/Console/Commands/FetchBounceStats.php | 07c6c9117ec2ec7f1d8c2515082481f90fa81a3ff24db082d99238687c711f1c |
| tests/Feature/AutomaticReplyFormatCompatibilityTest.php | fe7af16c4171acbfdf240e6c3114cf752de5ddb152624bbfcdb3e1204807d1ff |
| tests/Integration/AutomaticReplyWrappedDsnMariaDbTest.php | 1ea760465a730fdda0c4ca9bc40b869694df0fd70f5efbae746ac375592bdbd8 |

## Final verification receipts

Runtime: PHP8.3.31 / PHPUnit11.5.56. All commands used the approved WSL runner with this pane/card ownership. All five PHP files lint; final git diff --check passes. Saved source uses LF, and the Swedish retirement fixture roundtrips correctly.

Final focused suite:120 tests /626 assertions, terminal exit0. Runner request20261030-130852-52732-e9784134. Command:
php8.3 vendor/phpunit/phpunit/phpunit --filter "AutomaticReply|FetchBounceStatsQuarantineTest|HardBounceRecipientSuppressorTest|BounceSpoolWriterTest|ReceiverListEditQueryTest|HardBounceMigrationRecoveryTest|SMTPQueueMailerInvalidReceiverTest|BounceBatchLockResilienceTest" --do-not-cache-result

Actual captured log: K:\AI_docs_tmp\nuhet-3416-follow-up-20261030\final-mail-suite.log,458 bytes, SHA-256 2f0520f6f9f222e1f4fba6db991bf3daa903c25c1b9f61bb8b2448e54129c782. Fresh read confirms the final result. Earlier113/586 and119/617 passes are superseded by this final candidate's result.

The22 new feature regressions cover the observed bare retirement reply forwarding once with exact original bytes, identity/tenant/profile/recipient failures, no implicit release, actual wrapped-DSN spool routing, encoded wrappers, policy and temporary failures, retained rows in multiple states, ambiguous personal-From/absence-footer wrappers, child51 conflicts, nesting bounds, malformed siblings, epilogues and deletion between initial read and availability admission.

Final native qualification:1 test /11 assertions, terminal exit0 on MariaDB10.6.22. Runner request20261030-130924-52264-b5ab97c6. Command:
NUHET_LOCAL_MARIADB_TEST=1 php8.3 vendor/phpunit/phpunit/phpunit tests/Integration/AutomaticReplyWrappedDsnMariaDbTest.php --do-not-cache-result --stop-on-error

Actual captured native log: K:\AI_docs_tmp\nuhet-3416-follow-up-20261030\final-native-dsn.log,374 bytes, SHA-256 16a35ad97d9acbc2ca2e1d9e6987a8c8c10d84e5e46c4940033d064cd28553c8. The test uses separate main/statistics schemas and PDO connections plus a real cross-schema company FK. A competing deletion times out while wrapped-report effects hold the shared company lock; it succeeds after commit. Processing after deletion adds no event. Both constrained, randomly named owned schemas are removed and their absence asserted. A separate fresh schema-prefix query also returned0 after qualification.

The SQLite feature fixture's logical databases share one PDO; this new fixture shares transaction bookkeeping and names the SQLite main schema accordingly. It does not claim real independent-connection behavior; the native regression supplies that proof.

Only the pre-existing PHPUnit XML deprecation remains. No real SMTP or customer Outlook receipt was tested in this local unit. Independent review is recorded separately in automatic-replies-3416-format-review-20261030.md and its final candidate binding is accepted by root. Exact captured logs are also preserved durably in automatic-replies-3416-format-evidence-20261030/final-mail-suite.txt and final-native-dsn.txt with the same hashes; the scratch copies are no longer required recovery dependencies.

## Recovery plan and limits

automatic-replies-3416-recovery-plan-20261030.json was produced from a fresh bounded Nuhet MCP SELECT and freshly verified:55 unique IDs, all review with zero attempts. It has no apply path and contains no raw customer MIME or reusable credential.

- IDs4/33: two retirement candidates; their actual bare references matched stored original delivery identities during investigation. Fresh current state and original bytes must still be revalidated before an explicitly approved once-only release.
- ID37: absence with no reference header; retain manual review.
- Fifty-one verified-reference wrapped-DSN candidates: individually validate actual report recipient/disposition and reconcile existing bounce history before any approved recovery. Do not blindly forward or duplicate historical bounce events.
- One plain unverified NDR: retain manual review.

The plan does not claim this candidate parsed all55 live raw originals. Representative sanitized formats and real application paths were tested locally. Keep all existing rows held until exact recovery scope is approved. No campaign replay, bulk pending update, pause clearing or suggested-contact substitution is included.

## Review/correction and incident ledger

Initial independent review rejected four source acceptance gaps: retained-DSN replay, ambiguous fallback to personal actions, incomplete MIME traversal and missing company availability locking. These formed one coherent review correction cycle. Subsequent helper extraction briefly exposed an unbound classifier, then remaining sendout/retry locals; qualified checks identified these as two additional product correction cycles, not syntax-only incidents. A later boundary/completeness finding on malformed multipart siblings was resolved within the same reviewed traversal requirement and separately recorded as another unsuccessful candidate check. Total unsuccessful outcome cycles4; the default10-cycle limit is not exhausted. There is no PR validation round yet.

Expected-red old-parser assertions were diagnostic, not failures of a repaired deliverable. Fixture setup/serialization and shared-PDO bookkeeping failures, a wrong retry-directory assertion, and a rejected CommandClass=test were execution/fixture incidents, kept separate. After two same-harness incidents the path was reassessed: inspect the actual helper/connection contract, use one correct SQLite connection model and add native two-connection qualification. Recovery began around12:03UTC with12:33UTC expiry; it resolved by final passing checks around12:09UTC. No deadline or failure budget was renewed.

The initial worktree-helper failure was reconciled rather than blindly retried. An initial slow vendor-copy call's output-only reporter did not preserve its process session; fresh observation established copy completion, then executable/bootstrap/tests verified its dependencies. Later consequential requests and exits were retained. No uncertain production mutation or unresolved recovery remains.

## Policy and effort custody

Root and independent reviewer verified/adopted policy release20261030-mistmord-3661-storage-v1 at this safe boundary. The pointer manifest and applicable source/mirror hashes match; changed central AGENTS v7.27.14 was read fully. Operative workflow, lifecycle and delegation rules are unchanged; no task/claim/deadline/budget renewal follows. Existing Xile skill pin7c74db139e09d443732f8e2b48f7f3725fe64f7e remains held.

Implementation timer began11:46UTC and remains active only through useful preparation/review/preservation. Investigation logged24 minutes; earlier intake is unmeasured. Stop active time before the human release wait. Preserve the original90-minute estimate and report actual added effort without overwriting the historical estimate.

## Maintenance and recovery inventory

FetchBounceStats.php is889 physical lines. Existing deferred split: extract delivery-status parsing/verification and spool retry/quarantine orchestration behind the stable command interface, preserving proof/retention/retry and regression behavior. No broader split was performed here.

Task source inventory: three changed application PHP files,22-test feature regression, native integration regression, read-only recovery-plan JSON, this receipt and the independent review report. No other application source is changed. The original investigation report remains task-owned in the shared checkout; pre-existing .phpunit.result.cache, docs/ops/company-6-renewal-recovery.md and tmp/ remain untouched.

Next: root accepts final independent review, preserves the local candidate and records exact commit/card/time state. Publication and deployment approval is a real external-write gate under global AGENTS; the current authorization covers implementation. This session retains follow-up ownership and its card watch through CI/release and real destination acceptance when authorized.
