Repository navigation
fix: prevent duplicate generated images after queued send failures - #155804
valkyriweb wants to merge 1 commit into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesThe branch carries outbound queue custody into agent delivery results and saved recovery evidence, then dead-letters generated-media completion jobs instead of starting another send while outbound recovery owns the retry. Review scores
Merge readiness⛔ Blocked before merge - 8 items remain This remains useful work distinct from the related session-queue timeout fix. Both prior findings remain unresolved at the pinned head, and no merged replacement establishes that the outbound-custody problem is solved. Priority: P1 Decision needed
Before merge
Findings
Agent review detailsHow this fits togetherGenerated-media completion jobs run through the requesting session and send their results through the durable outbound queue. Delivery evidence determines whether the completion job settles, retries, or stops after a failure. flowchart TD
A[Generated media completion] --> B[Requesting session turn]
B --> C[Durable outbound queue]
C --> D[Channel transport]
C --> E[Delivery evidence]
E --> F{Outbound custody held}
F -->|Yes| G[Stop parent retry]
F -->|No| B
Technical reviewBest possible solution: Keep outbound recovery as the sole send-retry owner, preserve custody through production persistence, and give the parent an explicitly approved outcome that does not misrepresent delivery. Do we have a high-confidence way to reproduce the issue? Yes, source establishes a focused path: a failed generated-media send retains outbound custody, but saved terminal projection discards it before restart recovery evaluates whether to rearm. No runtime reproduction was executed in this read-only review. Is this the best way to solve the issue? Unclear overall: extending the existing custody owner is appropriate, but the production persistence path is incomplete and permanent parent failure needs an explicit settlement-policy choice. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 800fce298ba8. Merge-risk optionsMaintainer options:
SecurityNone. EvidenceWhat I checked:
PR surfaceSource +24, Tests +264. Total +288 across 8 files. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed October 7, 2026, 6:55 AM ET / 10:55 UTC (Revision 5). |
Closeout handoff — draft / not merge-readyBranch + commit: Issue / PR: this PR; related #151964 and #154064. Why incomplete: I verified ClawSweeper's P1 finding in Next action: preserve exact held custody in that production builder and first route the resumed regression through it to establish a failing test. Then add a real persisted-state round trip (both legacy records without custody and new held-custody records), demonstrate recovery ownership without a second parent send in an isolated test/candidate, repair the test type error below, and rerun affected suites plus independent review. Explicit maintainer acceptance of parent dead-lettering without eventual-success reconciliation remains required. Do not restart, roll, or mutate production to gather proof. Verification state: 4 new producer tests, 5 consumer tests, and 64 existing delivery tests passed locally; these are bounded mocked-boundary proofs, not production-path or transport-wide exactly-once proof. Local targeted lint/format/ratchets passed. Full local typecheck timed out, and the broader gateway failures remain disclosed in the body. CI now reports:
Support needed: maintainer policy decision before merge; no production approval requested. Work is preserved for follow-up, not complete or merge-ready. Yield misuse remains out of scope. |
Related: #151964
What Problem This Solves
Fixes duplicate generated-image sends when a failed automatic delivery is still queued for outbound recovery, but the generated-media completion job starts another send.
User Impact
A transient transport failure no longer makes the completion job replay media that the outbound queue already owns. Outbound recovery keeps its existing retry behavior.
This is a fail-closed duplicate-prevention fix: the parent completion job is dead-lettered with an explicit custody diagnostic, not marked delivered. It does not reconcile eventual outbound success back into the media task, retrofit terminal evidence recorded before this patch, or fix the underlying WhatsApp listener error. No configuration or database migration is required.
Why This Change Was Made
The outbound error already records retained queue custody, but agent delivery status discarded it. The session queue then interpreted missing delivery evidence as permission to advance the agent attempt, producing a fresh outbound send alongside the original recovery job.
Preserve the existing custody fact through the agent result and restart-recovery evidence, then prevent the parent from rearming. This keeps the outbound queue as the sole retry owner without bypassing its write-ahead queue or inventing another receipt store.
This is separate from #154064, which addresses media-producer timeouts while waiting for the session queue. The status projection moves into the existing delivery-result module solely to meet the repository's over-cap file-growth rule; the existing large test files remain unchanged.
Evidence
delivery.custody.test.ts4/4 passed (124.7 s wall; 74.8 s Vitest duration);server-restart-sentinel-agent-delivery.test.ts5/5 passed (179.0 s wall, 366 ms total test bodies). These use real agent delivery/result and session-delivery entry points with mocked transport/queue writes, including persisted restart-evidence normalization. Held, released, absent, partial-failure, resumed, and ordinary no-custody retry cases are covered.delivery.test.ts: 64/64 passed after moving the status projection (59.4 s wall; 42.3 s Vitest duration).pnpm exec vitest run <file> --maxWorkers=1(gateway files additionally selecttest/vitest/vitest.gateway.config.ts). Large wall times were dominated by local transform/import work, not added timers or polling.git diff --check: passed. Independent read-only autoreview: no actionable findings.Validation gaps: The broader gateway file run (
pnpm test src/gateway/server-restart-sentinel.test.ts --maxWorkers=1, before relocating the new tests) had 99 passes, one restart-notice continuation assertion failure, and seven ENOENT failures after its temporary namespace disappeared (520.9 s wall). The unchanged continuation test passed alone afterward; that does not establish the full-run failure is fixed. No unrelated fixture changes are included.pnpm tsgo:coreexceeded 600 seconds without diagnostics and was stopped; full build/check/test were not completed. CI results and CI timing remain pending. No production restart, rollout, or live-channel test was performed; these tests do not establish transport-wide exactly-once delivery.