Repository navigation
fix(gateway): deliver queued WebChat replies after source completion - #116649
Conversation
|
Codex review: needs changes before merge. Reviewed August 25, 2026, 8:09 PM ET / August 26, 2026, 00:09 UTC. ClawSweeper reviewWhat this changesThe PR binds queued WebChat reply batches to their originating Gateway admission so a late queue drain is finalized to the original WebSocket client or explicitly dropped. Merge readinessNeeds changes before merge: the source-bound dispatcher is still lost by overflow retry cloning, and collect mode can collapse distinct Gateway admissions into the last admission’s dispatcher. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherA WebChat request enters the Gateway and may be deferred into the follow-up queue while another turn runs. When the queued work completes, the queue must deliver its result through the original Gateway admission rather than a later session dispatcher. flowchart TD
A[WebChat request] --> B[Gateway admission]
B --> C[Follow-up queue]
C --> D[Source-bound delivery decision]
D --> E[Transcript and WebSocket final]
C --> F[Explicit dropped outcome]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +190, Tests +208. Total +398 across 13 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Carry the source delivery binding through every queue clone and partition collect batches by a stable source-admission key unless one aggregate final is explicitly owned by all sources. Do we have a high-confidence way to reproduce the issue? Yes, source inspection gives a high-confidence path: force queue overflow after a WebChat admission, or enqueue two same-device WebChat turns in collect mode, then observe the omitted or last-only disposition. Is this the best way to solve the issue? No. The single-source callback is the right owner boundary, but the implementation does not preserve that boundary through all queue transformations. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c28d11f78014. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (23 earlier review cycles; latest 8 shown)
|
f49969a to
0a73fdf
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
6e1766b to
22788e3
Compare
22788e3 to
724d257
Compare
|
Land-ready verification on exact head 724d257: A WebChat reply produced after its original request completed lost its delivery and persistence owner. Preserve canonical delivery ownership until the asynchronous reply settles without duplicating persistence. Delayed assistant replies reach the authenticated WebSocket client and appear exactly once in durable chat history. 247 focused tests and an authenticated real Gateway/WebSocket conversation plus actual SQLite chat.history prove exactly one assistant row; exact CI and fresh full-branch P1 review pass. A reviewer suspected duplicate persistence; the real authenticated Gateway conversation and direct SQLite-backed chat.history conclusively disproved it. No SQLite schema changes. |
|
Merged via squash.
|
Problem
A WebChat answer queued behind an active turn could finish after its initiating chat request already terminalized. The reply then disappeared silently or reused a later same-session dispatcher, risking delivery under the wrong source.
Fix
Bind every queued reply batch to its originating Gateway admission and authoritative channel. Preserve ownership through queue collection, finalize through the existing WebChat transcript/broadcast owner, and settle delivery or record an explicit drop for unavailable, mismatched, duplicate, or failed work. Preserve queue-cap logging and cancellation ownership.
Storage boundary
No SQLite schema, migration, persistent-store design, or persistence-semantics changes; this reuses the current canonical transcript finalizer.
Proof
The absent queued-followup callback first failed on unmodified main. A real isolated Gateway with an authenticated Control UI WebSocket performed a real chat request, observed its original final, and then received the delayed answer as a second WebSocket final under its own run ID. All 247 Gateway, queue, followup, and lifecycle tests pass across five files; focused lint, formatting, and independent review are clean.