Repository navigation
fix(gateway): deliver session catalog updates from slow hosts - #138674
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: blocked before merge. Reviewed September 4, 2026, 11:09 PM ET / September 5, 2026, 03:09 UTC. ClawSweeper reviewWhat this changesPreserves slow-host session catalog updates after the initial response while tracking completion through connection retirement and Gateway shutdown. Merge readiness⛔ Blocked before merge - 1 item remains This remains a useful fix for the linked catalog-delivery bug: current main still clears subscribers prematurely. No blocking correctness findings remain, and the prior completion-contract concern has an explicit maintainer disposition. Priority: P2 Review scores
Verification
How this fits togetherThe session catalog combines local and paired-host sessions for OpenClaw’s session browser. The Gateway returns an initial snapshot and sends progressive host updates over WebSockets. flowchart LR
A[Session browser] --> B[Gateway catalog owner]
B --> C[Local and paired hosts]
C --> D[Initial snapshot]
D --> A
C --> E[Owned late completions]
E --> F{Connection and privacy valid}
F -->|Yes| G[Host update]
G --> A
F -->|No| H[Suppress delivery]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +320, Tests +1416, Docs +21, Other +2. Total +1759 across 33 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one catalog lifetime composed with existing Gateway work tracking; separate delivery retirement from completion settlement because subscriber retention alone cannot safely release captures and join shutdown. Do we have a high-confidence way to reproduce the issue? Yes: current main clears subscribers at aggregate settlement, so a subsequent host callback has no recipient. The linked report records this over a real Gateway WebSocket; this review did not execute it. Is this the best way to solve the issue? Yes. The repair addresses the aggregate lifecycle owner and both fail-soft native adapters; increasing deadlines or retaining subscribers indefinitely would leave completion accounting and retirement unresolved. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 790fbf0304a6. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
133b930 to
ee50e34
Compare
ee50e34 to
3d1a09e
Compare
|
@clawsweeper re-review The current head is The previous merge-risk item is explicitly accepted under the documented bounded-completion contract. Existing native deadlines and shutdown policy remain unchanged. A registered promise that never settles remains active work; the held-then-released shutdown proof establishes ordering and cleanup, not settlement for a broken provider. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…aw#138674) * fix(gateway): deliver session catalog updates from slow hosts * test(gateway): activate mocked session catalog registries * fix(gateway): retain catalog completion on its admitted work scope
* refs/remotes/origin/main: (602 commits) fix(plugins): trace trust refusals and repair legacy provenance (openclaw#138746) perf(sqlite): reuse compiled plugin state point reads (openclaw#138758) refactor: type chat prefetch dependencies and clean loading tests (openclaw#138793) ci: reduce Doctor test startup and core lint jobs (openclaw#138796) feat(update): retain run history and share outcome reports (openclaw#138690) chore(deps): update @openclaw/fs-safe to 0.8.1 (openclaw#138500) fix: preserve global board ownership from pinning to notifications (openclaw#138675) fix(gateway): deliver session catalog updates from slow hosts (openclaw#138674) perf(sessions): index pending conversation replies (openclaw#127182) perf(auth): reuse ordered provider alias entries (openclaw#138805) docs(diagnostics): clarify whole-process CPU metrics (openclaw#138804) perf(memory): narrow source reads and stream embedding cache rows (openclaw#138766) fix: allow older source on newer Testbox checkouts (openclaw#138782) fix(agents): preserve recovered task progress and lifecycle ownership (openclaw#138785) perf(codex): reduce rollout tail scan CPU (openclaw#138784) perf(gateway): stop projecting history deltas at the byte budget (openclaw#138655) fix(build): bound native declaration inputs to checkout (openclaw#138742) fix(cli): preserve foreground Gateway argument handling (openclaw#138765) fix(ui): align task toolbar with side-panel tabs (openclaw#138769) fix(logbook): drain accepted work before closing SQLite (openclaw#138754) ... # Conflicts: # src/agents/embedded-agent-runner/compact.queued.ts
Let in-flight catalog reads finish across registry reactivation while retaining current caller visibility, provider execution authority, disconnect handling, and shutdown settlement. Config and registration changes still invalidate subsequent requests. Remove map-identity checks around captured usage entries: displaced refreshes cannot overwrite their replacement. Keep all usage-cache behavior tests and remove only epoch/reactivation-only catalog cases. Best-effort tradeoffs accepted: rare mid-read registry/context replacement can return the original catalog, and epoch-only reactivation may retain a bounded stale page until refresh. Provenance: #138674 addressed slow-host delivery; #159457 added bounded stale catalog results.
Let in-flight catalog reads finish across registry reactivation while retaining current caller visibility, provider execution authority, disconnect handling, and shutdown settlement. Config and registration changes still invalidate subsequent requests. Remove map-identity checks around captured usage entries: displaced refreshes cannot overwrite their replacement. Keep all usage-cache behavior tests and remove only epoch/reactivation-only catalog cases. Best-effort tradeoffs accepted: rare mid-read registry/context replacement can return the original catalog, and epoch-only reactivation may retain a bounded stale page until refresh. Provenance: #138674 addressed slow-host delivery; #159457 added bounded stale catalog results.
Closes #138668
What Problem This Solves
Users browsing native sessions can miss slow-host results when a host finishes after the catalog’s partial response. The aggregate list previously discarded its subscribers at return, even though the provider still owned a publication that could finish later.
Why This Change Was Made
One catalog lifetime now owns delivery and registered completion separately. Codex and Claude register their full publication promise with the admitted work; disconnect and registry retirement revoke delivery immediately while that work remains owned until it settles. Replacement connections inherit no subscription. Once the aggregate and its last subscriber finish, the owner releases delivery captures without losing completion accounting.
The optional SDK hooks preserve existing providers and document completion registration. The owner captures the original Gateway work tracker at provider admission, so an external callback cannot attach completion to an unrelated async context. Its finalizer joins before the Gateway releases dependencies. Codex also checks retirement before starting another page, classification or adopted read; already-issued requests remain owned until settlement.
User Impact
Active subscribers receive slow-host updates after the initial response, with current session privacy filtering. Disconnects and plugin retirement suppress stale delivery. Shutdown joins work already started instead of releasing its dependencies early. This repairs progressive results and ownership; it does not claim whole-request latency or CPU improvement.
Result-cache timing, native deadlines, configuration, persistence and Gateway wire payloads are unchanged. A callback TTL or unconditional subscriber retention would leave lifecycle and privacy ownership unresolved.
Evidence
Fresh Linux proof against main
66fa0bd2be4f811a6c6dbee8bd5dd102dae8e544plus the complete candidate passed 277 tests: 146 Gateway, 113 native provider, 8 registry and 10 SDK cases. Two regressions failed on the original lifetime owner for the intended assertions, then passed on the repair. The full canonical changed-code gate passed in 1007.81s andpnpm build sourcePerformancepassed in 31.94s. Testbox run.The real built synthetic Gateway passed four wire scenarios: early/late follower delivery, disconnected-connection isolation, current privacy projection after session replacement, and shutdown with a held completion. The held completion remained accounted for after the partial response, rejected retired delivery, released its captures and settled before socket closure and Gateway exit. Gateway cleanup completed in 323ms with exit 0 and no escalation. Source, installed dependencies, tool binaries and proof outputs were sealed before/after; all 33 local candidate postimages matched the retained proof. The owned Testbox is stopped.
Canonical commands included
node scripts/run-vitest.mjsover the four named owner suites,node scripts/check-changed.mjs --base 66fa0bd2be4f811a6c6dbee8bd5dd102dae8e544 -- <33 changed paths>, andpnpm build sourcePerformance. The real Gateway fixture used an isolated state directory and synthetic provider over authenticated WebSockets. This proves the Gateway lifecycle and delivery boundary; it is not an authenticated Codex/Claude service run, a browser recording or a Team performance measurement.After rebasing onto
c748cd5714b8160f0ce0a895071f039877082f08, all task-owned runtime production postimages stayed byte-identical. The only two changed postimages combine independently added SDK exports and preserve main'sGatewayClientRegistrytest fixture. Freshpnpm install --frozen-lockfileandpnpm plugin-sdk:surface:checkpassed; the latter counts exactly 4435 public exports and 2620 callable exports. All 55 focused integration tests passed on the published head3d1a09e6a5d2a2e7252d3e7a497f5ce26eb18409(WebSocket lifecycle, returned catalog shutdown, completion owner, and SDK report). A fresh independent P2 review completed all four passes with no actionable findings. Exact-head hosted CI completed successfully on3d1a09e6a5d2a2e7252d3e7a497f5ce26eb18409.Final staged-diff structured P2 review completed four partitions with no actionable findings. An earlier review caught the pre-integration staged owner, and the missing tracked completion was corrected before the clean final review. The earlier exact-head CI visibility failure exposed four test fixtures that supplied an active registry without activating its lifecycle; those fixtures now model the actual runtime setup and retain their privacy/streaming assertions.
Earlier proof-infrastructure failures and all raw outcomes are retained. No timeout or assertion was relaxed to make a run pass.
Production LOC: +379/-59 (net +320), providing the missing completion/delivery owner and private retirement notification while removing disposal at list return. Tests/support: +1737/-321 (net +1416, including moved fixtures/cases); documentation +21; SDK accounting net +2. No new timeout, configuration, schema, persistence or native protocol surface. The separately owned stale-page refresh path is outside this repair.
ClawSweeper merge-risk disposition
Retain the documented optional bounded-completion contract. Registered work stays accounted for until it actually settles; existing native deadlines and shutdown policy remain unchanged. A broken provider that never settles can still prolong drain. The held-then-released proof establishes ordering and cleanup, not eventual settlement for such a provider. Releasing active work early or adding a detached timeout would hide the lifecycle defect.