Repository navigation
fix(gateway): settle lifecycle rows outside producer scopes - #170231
Conversation
Detach lifecycle row preparation from the completed producer scope while retaining Gateway publication draining and current projection authority. Delayed session list updates now survive queued Swarm launch cleanup. Add a deterministic publication and drain ordering regression.
|
🦞👀 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. What this changesThis PR lets committed session lifecycle notifications finish after their producer’s work scope closes. Example: Row preparation for agent:main:lifecycle-publication pauses while its producer drains.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep this PR open: it repairs a source-confirmed lifecycle publication failure still present on main, with no introduced defect found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Gateway lifecycle handler turns committed session events into prepared session rows and recipient-filtered WebSocket notifications. flowchart LR
A[Committed lifecycle event] --> B[Lifecycle handler]
B --> C[Gateway publication owner]
C --> D[Prepared session rows]
D --> E[Current recipient authorization]
E --> F[WebSocket subscribers]
Technical reviewBest possible solution: Retain committed lifecycle publications under the existing Gateway publication owner while preserving cancellation for caller-owned reads. Do we have a high-confidence way to reproduce the issue? Current source establishes the failure path: producer draining aborts the signal captured by prepared row consumption; the submitted regression deterministically controls that ordering, but no tests were executed during this read-only review. Is this the best way to solve the issue? The existing work-scope escape fixes the ownership mismatch at the lifecycle handler without weakening shared read cancellation or adding another publication owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6b2bfd1d63bb. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +4, Tests +51. Total +55 across 2 files. Added test files: 0. View PR surface stats
LabelsLabel 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 Reviewed October 12, 2026, 4:55 PM ET / 20:55 UTC. |
…nclaw#170231) Committed lifecycle events belong to the Gateway publication owner. Prepare their rows outside the completed producer work scope while retaining publication draining and recipient authority. Proof: prepared-row 7/7; queued collector 26/26; production-only inverse reproduces the producer-drain AbortError with the regression unchanged. Exact PR types, lint, contracts, Madge and ratchets passed; prior unchanged-source Knip passed. Two untouched board profile-readiness failures reproduce on scheduled main. Direct-main ruleset refusal required the authorized PR fallback.
…0231) Committed lifecycle events belong to the Gateway publication owner. Prepare their rows outside the completed producer work scope while retaining publication draining and recipient authority. Proof: prepared-row 7/7; queued collector 26/26; production-only inverse reproduces the producer-drain AbortError with the regression unchanged. Exact PR types, lint, contracts, Madge and ratchets passed; prior unchanged-source Knip passed. Two untouched board profile-readiness failures reproduce on scheduled main. Direct-main ruleset refusal required the authorized PR fallback. (cherry picked from commit e1462be)
…0555) Backport adaptation: release keeps the inline dispatcher (no sibling-module move) and lacks openclaw#170231 and the publication test-support harness, so the regression uses the existing mocked lifecycle handler in server-runtime-subscriptions.test.ts. (cherry picked from commit ac8de4f)
…nclaw#170231) Co-authored-by: RomneyDa <[email protected]>
A queued Swarm launch can finish and drain its work scope while a committed
sessions.changedevent is still preparing its row. The publication inherits the completed producer's cancellation signal and throwsAbortError, even though the Gateway publication owner still retains the event. Scheduled main run 38298274614 records this in the queued-collector test, with an associated unhandled rejection.Run lifecycle row preparation outside the inherited producer work scope. The existing Gateway publication owner continues tracking and draining the promise. Projection replacement, row generation, recipient sharing and private-session checks remain in place; committed publications may settle after their producer returns, but current Gateway projection and recipient authority still govern delivery. The regression calls the actual lifecycle handler, holds row preparation until the producer drains, and requires publication to precede publication-drain completion.
Source history identifies
5ab3ae253694508f6eee4039354cb9be3f518574(#163834), which added inherited cancellation to prepared row reads, as the source-supported exposure. This is not a first-bad runtime bisect. The standalone patch7f28400fb43aae3800d9ecfe65352eaa072b4900has the exact reviewed and tested two-file blobs. Against cached mainca0a172d2927c8e203da82f1b224d849faa2be13, both patch preimages and all six named dependency/test blobs still match. The later actor-receipt change in #170127 changes history-read facts and SQL reuse; source inspection found no change to publication ownership, cancellation, recipient authority or drain semantics. This supports scoped proof reuse, not whole-tree equivalence.At composed head
8d087040fefe324e5ff7fa76faf497fadb542c08,pnpm test src/gateway/session-event-prepared-row.test.ts --maxWorkers=1passed 7/7 tests (732.94s Vitest; 904.34s wrapper), andpnpm test src/gateway/session-utils.queued-collector.test.ts --maxWorkers=1passed 26/26 (1161.78s Vitest; 1272.80s wrapper). Both receipts record exit 0, the exact final head, a clean checkout, no surviving processes and no restoration blocks. The production-only inverse control kept the regression byte-identical and failed exactly that producer-drain case withAbortErrorfromAsyncWorkScope.beginClose/drain(1 failed, 6 skipped; 293.96s Vitest, 429.02s wrapper). The original and inverse production hashes match the source patch; restoration returned the exact V21 head to a clean checkout with no surviving processes or restoration blocks. One Codex review was scoped-clean. At that composed head, CI run 38298120555 passed build artifacts, production and core test types, core lint, source contracts, dependencies, architecture and baseline ratchets; these are prior-head scoped results, not a claim that the full run or final standalone integration is green.Scope: two files, +102/-47, including indentation around the existing publication callback; the production change is an import and the existing work-scope escape around the existing publication owner. No SQL/T1 reduction is claimed. No checks, permissions, schema or public API contracts change. An update cell is not required: this changes per-event publication ownership, not Gateway/service startup, shutdown orchestration, restart, updater, Doctor, migration or plugin loading. Only the named two-file patch is included; no diagnostic or HOLD changes are part of this repair.
The standalone branch is rebased onto
31ec669615b9272b74b1b87ecf475d664f609bc9; both changed blobs remain byte-identical to the reviewed and locally tested source. Direct-main publication was refused by the repository ruleset for this emergency lane, so this repair uses the authorized PR fallback.Final qualification: exact PR CI 38306832436 passed selected production/test types, lint, source contracts, architecture and ratchets. Its architecture job executed Madge and reported zero cycles. The dedicated Knip scan was not selected for this PR; validation composition
83712e949c8810e8456ced68b8f2c311190c6fdb, containing the unchanged reviewed patch, passed its dependency scan. The only test failures are the two untouchedserver-broadcast.board.test.tsprofile-catalog cases, identical to scheduled main 38305224828/job114997828778. Both changed-file preimages remain exact on main4b20e4d20da623e53abbb2334605c97d7a80ad21. Landing uses the authorized inherited-failure exception; no final-main or whole-run green result is claimed.