Skip to content

refactor(gateway): simplify metadata and catalog lifecycles - #168690

Merged
steipete merged 6 commits into
mainfrom
deslop/p05-server-methods-20261010
Oct 11, 2026
Merged

steipete merged 6 commits into
mainfrom
deslop/p05-server-methods-20261010

Conversation

@steipete

@steipete steipete commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Current candidate and proof status

Final exact-head CI 38108100245 is green, including the aggregate CI, security and dependency gates. The earlier source-contract, SDK, canonical fixture and lint failures do not recur. One duplicate PR-context workflow was cancelled when the PR body update superseded it; its replacement passed on the identical head. No CI reruns or green-only pushes were used.

Head after the second conflict-only rebase: b09cf7ae6f38b16f418f6263fc11e827d879a9ec, based on cfcb7bda177. Net production reduction is now 530 lines; tests/support are 1,300 lines smaller. The sole conflict was metadata refresh: main removed a duplicate facts capture for fleet performance; the simplified path already captures once per coalesced refresh, so it retains that improvement without restoring generations. Affected types, both cycle checks and suppression audit pass; fresh metadata proof passes 37/37 (549.50s local wrapper wall including the suppression shard; 368.99s metadata Vitest wall).

Publication settlement was repaired before landing. All 34 originally cancelled CI suites have terminal Testbox results (28 passes, 6 failures); the two lane-caused failures are repaired, and the remaining canonical-cache, SDK-budget and lint failures are attributed below. Those results belong to the original tested merge, not this rebased head. Earlier incomplete attempts below are historical records, superseded by this terminal accounting. The refreshed Gateway-methods type graph passes, runtime cycles are zero, and the suppression audit passes 3/3. The clean-main registered SDK surface command passes as well. Final exact-head hosted CI remains the landing gate.

What Problem This Solves

Reduces the ongoing complexity of Gateway metadata, catalog listing, notifications, and setup by removing machinery that only guarded synthetic interleavings.

User Impact

Features, Gateway payloads, configuration, persistence formats, credential checks, and sandbox policy stay intact. Rare changes during an in-flight read are best effort: callers can receive the prepared result or a retryable failure, and the next request refreshes it. Slow catalog scans keep their slot rather than yielding between pages; the existing response budget still returns cached or pending results.

No schema, durability, retention, permission, dependency, or configuration changes.

Why This Change Was Made

The provenance audit distinguishes human actual-use reports from agent/maintainer PR descriptions and synthetic race tests. Most of the removed mechanisms had only the latter evidence. The smaller owners retain ordinary shutdown settlement, current authorization at effects, bounded queues/caches, and the measured lazy-metadata and catalog-cache improvements.

Net production reduction: 530 lines against the branch base, excluding tests and test support; tests/support are separately 1,300 lines smaller. Test deletions remove only the corresponding synthetic paths; independent privacy, publication, failure, and shutdown coverage remains.

Best-effort tradeoffs accepted

Evidence

Reviewed candidate: b09cf7ae6f38b16f418f6263fc11e827d879a9ec. Two conflict-only rebases preserve main's worker-prepared runtime ownership, formatted event errors, and single-capture metadata refresh. The conflict-resolved metadata owner is byte-identical to the independently reviewed pre-rebase candidate.

  • Retained security effects: final-effect authority proof exercises three real-writer/RPC cases and the actual native client/request adapter over loopback WebSocket: allowed caller sends one thread/fork frame; revocation during awaited preparation sends zero. This is synthetic protocol proof, not a live account or deployed Gateway claim. Those authority modules are unchanged by the repair/rebase.
  • Publication correction: broad proof caught a real early-settlement regression if completion registration throws. The small helper now joins issued work and rethrows the registration error. Both full affected files passed 35/35 (1076.04s local wrapper wall); after the equivalent lint-safe extraction, both retained settlement cases and type-aware lint passed. No custody wrapper was restored.
  • Focused coverage also includes 37/37 catalog/metadata cases after removing only obsolete scheduling expectations; 106 metadata/event cases before deleting the obsolete capture spy; the corrected event file then passed 13/13. The rewind/storage/upstream/incognito run retained 80 passing cases; its two synthetic mid-fork link-change cases were deleted with the removed guard.
  • Bounded refresh regression: a 128-request burst produced 128 captures before coalescing and one after. The existing single-flight test passed; no timeout, skip, retry, suppression or baseline was widened.
  • Fresh post-rebase Gateway-methods type graph passes; runtime cycles are 0; suppression audit passes 3/3. Final metadata/static-cycle results are recorded in the current status above.

Original exact-head CI tested merge b429c1eff7ff658dacce8c6df860e8066f1b0ffb (source a873351c3417a36ad3ef1e4a48ab62feef894352). check-source-contracts failed on duplicate resolveChannelDmPolicy exports in two unchanged channel files; the identical failure reproduced on clean main 97e81ce0d5d96449449b545b80fb0c989c591c78. The aggregate gate failed downstream and 34 jobs were cancelled.

Every cancelled suite was subsequently executed on that immutable merge, using two sequential Testbox leases, now stopped: 38096290073 and 38101073221. 28 passed; six retained failures are individually attributed:

Replacement job Outcome
checks-node-changed-compact-large-2 Obsolete source-link successor assertion removed; all security/source-incarnation/storage cases retained.
checks-node-changed-compact-large-21 Real publication-settlement regression repaired before landing, as above.
checks-node-changed-compact-large-12 Canonical fixture deletions omitted cache receipts. Main fixed this in 7cc1ca64798; the two initiating cases pass on clean main 5ff4d101c72.
checks-node-compact-small-1 SDK export/deprecation budget drift. Both affected budget cases and the actual registered SDK surface command pass on clean main 5ff4d101c72. The Linux-only test itself was not run on macOS.
check-lint-core-1 Unchanged baseline lint debt. Twelve remaining max-lines findings reproduce on clean main across both core jobs; prior cache lint findings were fixed upstream.
check-lint-core-2 Same baseline max-lines reproduction; prior unbound-method finding was fixed upstream. None of the named files or lint budgets was changed here.

Passing replacement proof covers build, 85 Control UI tests, browser extension E2E, package boundaries, nine ratchets, production types, all selected core/root/extension/script test types and all other selected Node rows. Setup-only browser mode and missing-Bun failures were corrected without changing source or weakening guards; only unstarted groups were then run. Old-merge results are reused only for unchanged inputs, never described as final-head hosted CI. No CI rerun or green-only push was requested.

Coverage ledger: every original KEEP row re-evaluated
Owner Provenance and disposition
Metadata superseded settlement/readiness Remove synthetic epochs, per-generation promises and retry loops from #139192.
Metadata lazy preparation/cache bounds Keep measured #149716 improvement (83.535s to 0.276s) and actual-use report #149538; remove surrounding freshness fences. #148411 is itself a harness reproduction, not a human incident.
Optional history/model-list caches Keep nonblocking exact-profile reads and #162326's measured CPU/allocation wins; remove #131613/#162920's post-await and eviction fences.
Personal-account authority Keep live authority before credential-bearing requests; explicit security exception, not an incident claim.
Metadata shutdown Keep ordinary active-work joins, including evicted preparation.
Session change ordering Remove #150270 synthetic churn machinery; retain bounded coalescing and current identity/privacy at publication.
Catalog fairness/admission Remove #149030/#155114/#155670 synthetic per-step/per-provider scheduling; retain global bounded FIFO and cancellation.
Catalog publication tail Remove wrapper; retain plugin consumer settlement and authority before effects.
Catalog lifetime/operations Remove repeated freshness/detachable cache-owner layers; retain 60s delivery expiration, callback detachment, 128-entry bounds, per-client isolation, per-host coalescing and ordinary shutdown.
Catalog planning cache Keep #159900's measured 34.4% allocation and 22.2% instrumented-time improvement.
Catalog adoption/creator identity Keep source-incarnation and provider-versus-local attribution/privacy boundary.
Setup admission Remove #139783 constructor reentrancy guard; retain canonical write lock and ordinary runner/root settlement.
Setup retries Remove #160574 supersession chain; preserve credential authority and one active replacement.
Config write CAS Keep one effect-time check: documented public baseHash contract and ordinary concurrent editor writes.
Config auth response ordering Keep security ordering and documented runtime-application contract; PR explanations alone are not treated as human incidents.
Fork/mutation guards Remove synthetic options/link/registry handshakes and duplicate pre-effect checks; retain source identity, nontransferable authority, current caller/creator, sandbox policy and the effect-time placement check.

@clawsweeper

clawsweeper Bot commented Oct 10, 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: XL labels Oct 10, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR simplifies Gateway metadata refresh, catalog scheduling, session notifications, setup retries, and request-authority bookkeeping.

Example: A second sign-in retry arrives while the first retry is cancelling an unfinished sign-in.

  • Before: The later retry supersedes the queued replacement.
  • After: The later retry receives the existing busy response while the first replacement finishes cleanup.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A coherent, substantially smaller patch with adequate authority-boundary evidence; proof remains synthetic and in process rather than a deployed end-to-end run.
Proof confidence 🦐 gold shrimp (3/6) Sufficient (logs): The supplied authority evidence exercises admitted request bindings through real RPC/persistence owners and the actual native client/request adapter over loopback WebSocket, showing allowed effects and rejection after revocation during awaited preparation. The authority modules match the proof-covered earlier head; this establishes the retained boundary without claiming a live account or deployed Codex process.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes
User problem: Gateway lifecycle machinery adds maintenance cost and redundant metadata captures, while several freshness and scheduling guarantees exceed the accepted product requirements.
Reason: The maintainer-authored direction explicitly accepts the narrower guarantees, and the diff removes substantial machinery while retaining current authorization, bounded work, and ordinary settlement.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR makes a justified simplification with explicitly accepted tradeoffs, and no actionable defect was found in the introduced changes.

Priority: P2
Reviewed head: b09cf7ae6f38b16f418f6263fc11e827d879a9ec

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway RPC handlers consume published model, plugin, session, and caller facts, prepare bounded projections or catalog results, and deliver responses or authorized mutations through their existing lifecycle owners.

flowchart TD
  A[Gateway RPC request] --> B[Caller and target authority]
  B --> C[Metadata and catalog owners]
  C --> D[Bounded preparation and scheduling]
  D --> E[Current visibility and effect checks]
  E --> F[Response or native mutation]
  D --> G[Publication and shutdown settlement]
Loading

Technical review

Best possible solution:

Land the smaller existing owners with retained authority and settlement contracts once the required landing gates pass.

Do we have a high-confidence way to reproduce the issue?

This is a deliberate refactor; source and supplied proof support the refresh-coalescing improvement and retained effect-boundary behavior, with no target code executed during this review.

Is this the best way to solve the issue?

The smaller existing owners fit repository policy, and the publication-registration repair preserves required settlement without restoring the removed wrapper.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against c6d71fae0ed1.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned introduced changes: Reviewed the merge-base-to-head production and test hunks; fetched main still contains the supersession and provider-fairness mechanisms this PR removes. (src/gateway/server-methods/chat-metadata-runtime.ts:307, b09cf7ae6f38)
  • Recorded direction and accepted tradeoffs: The complete PR body explicitly accepts stale in-flight selections, coalesced intermediate notifications, global catalog scheduling, and busy overlapping setup retries while retaining live authority and ordinary settlement; these accepted choices require no renewed product decision. (b09cf7ae6f38)
  • Publication settlement repair: Completion-registration failure now awaits issued publication work before rethrowing; retained registered-plugin tests cover both close failure and release-registration failure. (src/gateway/server-methods/session-catalog-provider-access.ts:50, b09cf7ae6f38)
  • Final-effect authority evidence: The supplied discussion records real RPC/SQLite/transcript outcomes and real loopback WebSocket frames: an allowed fork sends one frame, while revocation during preparation sends zero. GitHub blob identities confirm the changed mutation-authority and fork-guard modules match the proof-covered earlier head. (src/gateway/server-methods/session-mutation-guards.ts:58, b09cf7ae6f38)
  • Retained physical-write authority: The native request adapter carries assertCurrent into dispatchCodexRequestAttempt, which checks it inside the physical writer after asynchronous admission and immediately before writing. (extensions/codex/src/app-server/request-admission.ts:26, b09cf7ae6f38)
  • Authoritative native fork contract: Dependency inspection applies because this PR changes guards used by native Codex forks and its proof exercises thread/fork. Personally inspected the pinned sibling implementation: it reads the selected source thread and creates a fork through the thread manager; loopback proof establishes OpenClaw wire admission, not execution by a real Codex process. (codex-rs/app-server/src/request_processors/thread_processor.rs:4861, a956835d0207)

Likely related people:

  • Peter Steinberger: Raw commit db9e3bf adds src/gateway/server-methods/chat-metadata-runtime.ts:223 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: db9e3bff62ee; files: src/gateway/server-methods/chat-metadata-runtime.ts)
  • Jason (Json): Raw commit 77f7560 adds src/gateway/server-methods/chat-metadata-runtime.ts:252 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 77f7560b4184; files: src/gateway/server-methods/chat-metadata-runtime.ts)
  • Vincent Koc: Raw commit da27b33 adds src/gateway/server-methods/session-mutation-guards.ts:230 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: da27b336c0e9; files: src/gateway/server-methods/session-mutation-guards.ts)
  • stevenlee-oai: Raw commit 2079ed9 adds src/gateway/server-methods/system-agent-setup-wizard.ts:53 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 2079ed92a57d; files: src/gateway/server-methods/system-agent-setup-wizard.ts)

PR surface

Source -530, Tests -1300. Total -1830 across 33 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 14 278 808 -530
Tests 19 95 1395 -1300
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 33 373 2203 -1830

Review metrics

Metric Value Why it matters
Production versus tests Production +278/−808, net −530; tests +95/−1,395, net −1,300. The reduction removes explicitly retired lifecycle mechanisms and their corresponding tests while retaining authority, bounded-resource, publication, and shutdown coverage.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A useful internal simplification with accepted behavior tradeoffs, without an established urgent user-facing regression.
  • 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-10T22:56:07.381Z sha 91964e6eccc2d10c146a300eae28432f6e63028d :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T23:41:18.698Z sha a873351 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-11T00:42:52.638Z sha a873351 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-11T00:54:32.935Z sha a873351 :: needs maintainer review before merge. :: none

Reviewed October 10, 2026, 11:28 PM ET / October 11, 2026, 03:28 UTC (Revision 5).

@steipete
steipete force-pushed the deslop/p05-server-methods-20261010 branch from 91964e6 to a873351 Compare October 10, 2026 23:30
@steipete
steipete marked this pull request as ready for review October 10, 2026 23:33
@steipete

Copy link
Copy Markdown
Contributor Author

Final-effect authority proof for a873351

The requested additional proof is complete without changing the candidate or weakening a guard.

Binding to real persistence: node scripts/run-vitest.mjs src/gateway/session-lifecycle-source-authority.test.ts src/gateway/server.agent-runtime-authority-proof.test.ts --maxWorkers=1 -t 'source preparation through in-process Stop authority|revoked caller before the real reset transaction|actually committed reset' passed all 3 selected tests (722.63s wrapper wall; compilation and real Gateway/SQLite fixtures dominate). Other cases were not selected for this targeted proof.

The first test carries an admitted caller through bindInProcessRequestMutationAuthority, bindGatewayRequestHandlerMutationAuthority and readGatewayRequestMutationAuthority to the real createSessionLifecyclePersistenceOwner, then reads the persisted killed state. The two Gateway-kernel tests use the registered RPC dispatcher and actual reset/transcript owners: an authorized reset changes persisted lifecycle/transcript state, while revoking the admitted caller during the awaited reset hook rejects before the real transaction and leaves both unchanged. Inference is substituted; the binding, authorization registry, lifecycle writer, SQLite and transcript owners are not.

Representative bounded observations from the run:

{"phase":"reset","mode":"revoked","registryLive":false,"gatewayLive":false,"admittedLive":false,"closureCount":1,"pendingCount":0,"transcriptChanged":false,"rpcOk":false,"authorityError":true,"rowChanged":false,"sessionPreserved":true}
{"phase":"reset-committed","registryLive":true,"gatewayLive":true,"admittedLive":true,"closureCount":0,"pendingCount":0,"transcriptChanged":true,"rowChanged":true,"sessionPreserved":true}
{"phase":"reset-after-close","registryLive":false,"gatewayLive":false,"admittedLive":false,"closureCount":1,"pendingCount":0,"transcriptChanged":true,"rpcOk":false,"authorityError":true,"executionCalls":0}

Binding to native transport: a task-local script on the same asserted HEAD initialized the real CodexAppServerClient over a real loopback WebSocket server, then called the real createCodexCatalogRequestSnapshot().forkThread(...). Its assertCurrent was read from a handler passed through the changed in-process and handler mutation bindings. The native client's existing withCurrent hook held asynchronous wire preparation; the negative case revoked the synthetic caller during that await. The server counted received thread/fork frames, not mocked calls:

{"proof":"native-fork-wire","revoked":false,"forkFramesReceived":1,"rejected":false}
{"proof":"native-fork-wire","revoked":true,"forkFramesReceived":0,"rejected":true}

This is synthetic loopback protocol proof, not a live-account or real Codex-process claim. The transport and request admission implementation are real. No provider request, credential, real conversation or external endpoint was used. The existing fork source-incarnation, creator/sandbox, transaction authority and storage tests remain separate coverage; the removed upstream-link freshness test is not being restored as authority.

The reviewed final-effect callbacks remain in place. Please evaluate this evidence against the requested binding-to-writer and binding-to-wire concerns; no source head changed.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The requested final-effect proof is now recorded in #168690 (comment) and the PR body: live admitted request binding through real SQLite/transcript writers, plus allowed/revoked fork requests through the real native client and a loopback WebSocket transport. The reviewed head remains a873351c3417a36ad3ef1e4a48ab62feef894352; no source change or CI rerun is requested.

@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels 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.
Remove synthetic-only supersession, per-step and per-provider fairness, event tombstone, request-container identity, and fork freshness machinery. Keep current authorization at effects, ordinary shutdown settlement, measured caches, global resource bounds, and config CAS.

Coalesce refresh bursts into one pending operation plus a follow-up flag; the new regression demonstrated 128 redundant captures before this repair. Remove only tests of retired mechanisms and retain publication, privacy, failure and shutdown contracts.

Best-effort tradeoffs accepted: in-flight metadata and upstream forks retain their prepared selections; intermediate notifications coalesce; slow catalog sources may hold a bounded slot. Provenance and coverage are recorded in the lane ledger and PR body. No public shape, schema, retention, permission or dependency change.
@steipete
steipete force-pushed the deslop/p05-server-methods-20261010 branch from a873351 to b09cf7a Compare October 11, 2026 03:21
@steipete
steipete merged commit c3924e7 into main Oct 11, 2026
136 of 137 checks passed
@steipete
steipete deleted the deslop/p05-server-methods-20261010 branch October 11, 2026 03:34
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
…#168690)

Remove synthetic metadata supersession, catalog fairness/freshness, setup retry,
and duplicate mutation checks while preserving current effect authority,
bounded resources, public contracts and ordinary publication/shutdown settlement.

Accept best-effort mid-read configuration changes and slow-provider contention;
the PR records provenance and each accepted tradeoff. Net production: -530 LOC.

Focused tests, affected types, suppression audit and both cycle checks pass.
Exact-head CI 38108100245 passes; no rerun or admin exception was needed.
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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

1 participant