Repository navigation
fix(gateway): accept concurrent first sends in shared sessions - #159371
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 maintainer review before merge. Reviewed September 28, 2026, 11:12 AM ET / 15:12 UTC (Revision 17). ClawSweeper reviewWhat this changesThe branch lets the Gateway admit concurrent first messages to one shared session and updates Gateway admission and test-fixture coverage. Merge readiness✅ Ready for maintainer review This PR remains useful: current main still rejects concurrent first sends from a captured empty session, and the proposed guard preserves rejection after a physical-session change. The prior review reported no code findings; the current head has downstream checks running after the earlier preflight concern. Priority: P1 Review scores
Verification
How this fits togetherControl UI clients send messages to the Gateway with the conversation's physical session ID and displayed transcript leaf. Gateway admission checks those values before dispatching work and writing the message to the session transcript. flowchart LR
A[Control UI clients] --> B[Chat send request]
B --> C[Gateway admission]
C --> D{Session and leaf still valid?}
D -->|Yes| E[Queued agent work]
E --> F[Session transcript]
D -->|No| G[Branch change response]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +19, Tests +109. Total +128 across 8 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Land the scoped admission guard through the native PR gates, retaining the physical-session fence and strict Stop and recovery behavior. Do we have a high-confidence way to reproduce the issue? Yes. Current-main source explains the empty-leaf rejection, and the linked issue supplies a real Gateway and Control UI reproduction; this review did not execute the current head. Is this the best way to solve the issue? Yes. The exception stays at message admission, requires the matching physical session, and leaves Stop and recovery guards strict. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 03f92a56beca. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (16 earlier review cycles; latest 8 shown)
|
|
Thanks @chopin-op60 for the follow-up fixes. I'm retaining the stop/recovery leaf fences and the reserved-listener fixture repair with its regression coverage. I'm removing only the remaining diagnostics-channel assertions from |
|
Maintainer landing override for exact head Review. The ClawSweeper review is ready on this SHA, and the security-sensitive review found no sensitive product changes. CI. Fresh run 36440816784, attempt 2, finished with no cancelled selected jobs. The SDK retention lane that failed in attempt 1 passes. The only failures are mocked-Gateway Control UI browser tests. This PR touches no UI files, and those tests don't exercise chat-send admission, the active-leaf fence, or the e2e-ws harness:
|
|
Landed in b4e3631. Concurrent first sends now accept a captured empty starting point only within the same physical session; branch switches, Stop, and recovery retain their fences. The real 12-client Gateway comparison changed from 1 accepted / 11 rejected to all 12 accepted exactly once, with ordering, idempotency, and branch-switch controls; the reconciled focused Gateway suite passed 271 tests. Maintainer CI disposition is recorded in #159371 (comment). Thank you @chopin-op60 for the fix and follow-up safeguards, and @vyctorbrzezowski for the detailed report and reproduction in #159330. The issue is closed. |
…law#159371) * fix(gateway): accept concurrent first sends in shared sessions * test(gateway): retain fixture ports and verify worker reads * fix(gateway): retain leaf fences for stop and recovery * test(gateway): use current host SQL observer signature * test(gateway): adopt reserved listener in fixture lifecycle * test(gateway): keep history worker assertions out of chat admission fix --------- Co-authored-by: Ayaan Zaidi <[email protected]>
Fixes #159330
What Problem This Solves
Concurrent first sends to an empty shared conversation can fail with a branch-change error even though nobody changed branches.
User Impact
Participants can submit from the same empty starting point without manually retrying valid messages. Actual branch changes and physical-session replacements remain fenced; no configuration or migration is needed.
Why This Change Was Made
Message admission now treats the empty starting point as a valid ancestor when the request pins the matching physical session. Stop and recovery checks retain their stricter captured-leaf fence. The generic transcript classifier, writer barrier, authorization, and callers without a session ID remain unchanged.
The Gateway WebSocket test harness also retains its bound listener through startup rather than releasing the port before the Gateway adopts it. Regression coverage proves a competing listener cannot steal that socket and verifies cleanup. The unrelated residual history-worker diagnostics assertions were removed; main's deterministic held-read coverage remains intact.
No overlap with Pash/Sarah changes.
Evidence
Real Gateway/WebSocket comparison on main
92b337d61552and candidate3f942bc92bf9547acd4abf9bfaa60ab76d897a96, with fresh Gateway/UI builds, isolated state, and a credential-free synthetic loopback Responses provider:INVALID_REQUEST / active-leaf-changed. Candidate: all 12 accepted.integrity_check=ok.chat.send: the switch succeeded, the send was rejected withactive-leaf-changed, and no raced message entered the transcript.This is controlled real-transport concurrency, not a 30-browser load test or external-provider test. The runtime results remain attributed to the earlier tested head, not the refreshed commit.
The refreshed branch preserves the contributor's follow-up commits, merges main
026348d107c729ac905d8075114f582336d4bfd1, and retains the stop/recovery and reserved-listener fixes. On the reconciled source:--maxWorkers=1.gateway-root,gateway-server, andgateway-methodstype graphs passed; type-aware lint and formatting passed for all eight remaining changed files.Earlier CI attempts encountered history-projection, Gateway port-collision, and history-broadcast timing failures. The refreshed head is
bbdad3aa3a2ba47918e79121b9f474749d50c83d.