Skip to content

fix(gateway): settle lifecycle rows outside producer scopes - #170231

Merged
steipete merged 1 commit into
mainfrom
dbasync/redmain-lifecycle-publication
Oct 12, 2026
Merged

steipete merged 1 commit into
mainfrom
dbasync/redmain-lifecycle-publication

Conversation

@steipete

@steipete steipete commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

A queued Swarm launch can finish and drain its work scope while a committed sessions.changed event is still preparing its row. The publication inherits the completed producer's cancellation signal and throws AbortError, 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 patch 7f28400fb43aae3800d9ecfe65352eaa072b4900 has the exact reviewed and tested two-file blobs. Against cached main ca0a172d2927c8e203da82f1b224d849faa2be13, 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=1 passed 7/7 tests (732.94s Vitest; 904.34s wrapper), and pnpm test src/gateway/session-utils.queued-collector.test.ts --maxWorkers=1 passed 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 with AbortError from AsyncWorkScope.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 untouched server-broadcast.board.test.ts profile-catalog cases, identical to scheduled main 38305224828/job114997828778. Both changed-file preimages remain exact on main 4b20e4d20da623e53abbb2334605c97d7a80ad21. Landing uses the authorized inherited-failure exception; no final-main or whole-run green result is claimed.

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.
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Oct 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: Inherited cancellation rejects publication with AbortError.
  • After: The Collector A session update publishes before Gateway publication draining completes.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch and deterministic regression are persuasive, while supplied behavior evidence remains harness-based.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its supplied validation exercises the lifecycle handler in process and reports an inverse control, rather than a shipped Gateway flow.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A completed queued Swarm producer can cancel a committed session update, leaving subscribers without the expected refreshed row.
Reason: This maintainer-authored repair restores the existing Gateway lifetime contract with a focused production change and an observable ordering regression.

Regression provenance

Possible 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
Reviewed head: 7f28400fb43aae3800d9ecfe65352eaa072b4900

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not demonstrate the delayed lifecycle update through a running Gateway and real WebSocket subscriber.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Galin Iliev: Raw commit 0bbad56 adds src/gateway/session-event-prepared-row.test.ts:2 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 0bbad56fa809; files: src/gateway/session-event-prepared-row.test.ts)

PR surface

Source +4, Tests +51. Total +55 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 51 47 +4
Tests 1 51 0 +51
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 102 47 +55

Labels

Label changes:

  • add P2: A focused runtime reliability fix prevents rejected lifecycle notifications and stale session-list updates after producer completion.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A focused runtime reliability fix prevents rejected lifecycle notifications and stale session-list updates after producer completion.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Capture a queued collector’s delayed lifecycle update reaching a real Gateway WebSocket subscriber after producer completion.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 12, 2026, 4:55 PM ET / 20:55 UTC.

@steipete
steipete merged commit e1462be into main Oct 12, 2026
117 of 122 checks passed
@steipete
steipete deleted the dbasync/redmain-lifecycle-publication branch October 12, 2026 21:01
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…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.
RomneyDa pushed a commit that referenced this pull request Oct 14, 2026
…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)
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Oct 16, 2026
…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)
wheakerd pushed a commit to wheakerd/clawdbot that referenced this pull request Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant