Skip to content

fix(gateway): deliver session catalog updates from slow hosts - #138674

Merged
steipete merged 3 commits into
mainfrom
codex/team-catalog-lifetime-publish-20260904
Sep 5, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/team-catalog-lifetime-publish-20260904

Conversation

@steipete

@steipete steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

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 66fa0bd2be4f811a6c6dbee8bd5dd102dae8e544 plus 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 and pnpm build sourcePerformance passed 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.mjs over the four named owner suites, node scripts/check-changed.mjs --base 66fa0bd2be4f811a6c6dbee8bd5dd102dae8e544 -- <33 changed paths>, and pnpm 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's GatewayClientRegistry test fixture. Fresh pnpm install --frozen-lockfile and pnpm plugin-sdk:surface:check passed; the latter counts exactly 4435 public exports and 2620 callable exports. All 55 focused integration tests passed on the published head 3d1a09e6a5d2a2e7252d3e7a497f5ce26eb18409 (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 on 3d1a09e6a5d2a2e7252d3e7a497f5ce26eb18409.

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.

@steipete steipete self-assigned this Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 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 docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts extensions: anthropic extensions: codex size: XL maintainer Maintainer-authored PR labels Sep 4, 2026
@steipete
steipete marked this pull request as ready for review September 4, 2026 22:32
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 11:09 PM ET / September 5, 2026, 03:09 UTC.

ClawSweeper review

What this changes

Preserves 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
Reviewed head: 3d1a09e6a5d2a2e7252d3e7a497f5ce26eb18409

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent lifecycle repair with strong reported production-boundary proof, focused regressions, and an explicitly accepted provider-contract tradeoff.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The captured Linux report exercises the built Gateway catalog owner through authenticated WebSockets with delayed synthetic hosts, showing late delivery, disconnected-client isolation, current privacy projection, and completion before dependency teardown; native-service and browser behavior are not claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The captured Linux report exercises the built Gateway catalog owner through authenticated WebSockets with delayed synthetic hosts, showing late delivery, disconnected-client isolation, current privacy projection, and completion before dependency teardown; native-service and browser behavior are not claimed.
Evidence reviewed 11 items Current main still contains the failure: The list handler clears progressSubscribers in its finalizer even though native providers can publish after their fail-soft response. The linked report describes the same failure through an authenticated Gateway WebSocket: #138668.
Completion belongs to the original admitted work: The lifetime captures the async work tracker before provider entry, retains the admitted root, and tracks publication finalizers through settlement. Retirement releases delivery captures without declaring unfinished work complete.
Delivery authority remains current: Each publication checks subscriber liveness and rebuilds session privacy projection from current configuration and canonical session entries. WebSocket retirement aborts the host-owned connection signal before asynchronous cleanup.
Findings None None.
Security None None.

How this fits together

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

Before merge

  • Resolve merge risk (P1) - Providers publishing after their list settles must register completion; a registered promise that never settles can prolong Gateway draining. This residual provider-contract risk is documented and explicitly accepted by the maintainer.
Agent review details

Security

None.

PR surface

Source +320, Tests +1416, Docs +21, Other +2. Total +1759 across 33 files.

View PR surface stats
Area Files Added Removed Net
Source 15 379 59 +320
Tests 16 1739 323 +1416
Docs 1 21 0 +21
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 2 +2
Total 33 2143 384 +1759

Review metrics

Metric Value Why it matters
Production versus test growth Production net +320; tests/support net +1416; tooling net +2; docs +21 Production growth supplies the missing completion/delivery owner and retirement notifications; moved test fixtures do not count as new behavior.
Plugin contract additions 2 optional lifecycle inputs and 1 shared publication export; 0 wire parameters added Providers gain explicit completion ownership while existing query payloads and native invocation deadlines remain unchanged.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #138668
Summary: This PR is the explicit implementation candidate for the linked slow-host publication defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Retain the accepted completion contract (recommended)
    Keep documented bounded registration and actual settlement accounting, preserving the maintainer’s explicit disposition.

Technical review

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured Linux report exercises the built Gateway catalog owner through authenticated WebSockets with delayed synthetic hosts, showing late delivery, disconnected-client isolation, current privacy projection, and completion before dependency teardown; native-service and browser behavior are not claimed.

Label justifications:

  • P2: Repairs progressive native-session discovery when hosts outlast the partial response, with limited workflow impact.
  • merge-risk: 🚨 compatibility: The optional SDK contract defines post-list publication ownership and extends registered work accounting through Gateway drain.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The captured Linux report exercises the built Gateway catalog owner through authenticated WebSockets with delayed synthetic hosts, showing late delivery, disconnected-client isolation, current privacy projection, and completion before dependency teardown; native-service and browser behavior are not claimed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured Linux report exercises the built Gateway catalog owner through authenticated WebSockets with delayed synthetic hosts, showing late delivery, disconnected-client isolation, current privacy projection, and completion before dependency teardown; native-service and browser behavior are not claimed.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • shakkernerd: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-04T22:41:17.775Z sha 133b9308c9c4863e2a06c14bac0d7062c09e1bd4 :: blocked before merge. :: none
  • reviewed 2026-09-04T23:02:13.529Z sha ee50e34 :: blocked before merge. :: none

@steipete
steipete force-pushed the codex/team-catalog-lifetime-publish-20260904 branch from ee50e34 to 3d1a09e Compare September 5, 2026 03:00
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The current head is 3d1a09e6a5d2a2e7252d3e7a497f5ce26eb18409. Main's received-work lifecycle exposed a required composition repair after the previous review: the catalog now captures the original work tracker and admitted root before provider entry, so a later external callback cannot register completion under a foreign async owner. Two exact owner regressions fail before that repair; the final Linux candidate passed 277 tests, the complete changed-code gate, sourcePerformance build, and four real built Gateway wire cases. The rebased head additionally passed all 55 focused integration cases and the canonical SDK surface check. Full proof and qualifications are in the updated PR body.

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.

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete merged commit f214454 into main Sep 5, 2026
186 of 187 checks passed
@steipete
steipete deleted the codex/team-catalog-lifetime-publish-20260904 branch September 5, 2026 03:13
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
…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
vincentkoc added a commit to LiuwqGit/openclaw that referenced this pull request Sep 5, 2026
* 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
steipete added a commit that referenced this pull request Oct 10, 2026
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.
steipete added a commit that referenced this pull request Oct 11, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: anthropic extensions: codex gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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.

Bug: native session catalog drops results from hosts that finish after the partial response

1 participant