Skip to content

fix(gateway): stop late request failures after shutdown - #136998

Merged
steipete merged 2 commits into
mainfrom
steipete/laughing-bassi-09961b
Sep 4, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/laughing-bassi-09961b

Conversation

@steipete

@steipete steipete commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Related: #127256 (Gateway-generation admission), #136145 (received-work/fixture lifetime), and #136036 (separate Full Access and metadata repair).

What Problem This Solves

Closing or restarting a Gateway while the Control UI was loading could leave asynchronous request preparation running after shutdown completed. In the observed cold-browser case, update.status, taskSuggestions.list, chat.startup, and talk.catalog imports continued into torn-down dependencies after the UI assertion passed.

This repairs the generic pre-handler request-entry boundary. The historical cold case did not reach chat.metadata; the separate Full Access/metadata repair is not claimed to fix this broader entry gap. Stable-tag inspection found the structural gap in v2026.8.2; no introducing commit is attributed.

Why This Change Was Made

One Gateway-instance owner retains credential-mutation waits, router loading, bounded start scheduling, authorization, and nested lazy-handler preparation. Shutdown fences ordinary entry and joins pending preparation before teardown. The final liveness check, ownership release, and actual handler invocation are synchronous. WebSocket, raw in-process, typed-agent, and directly callable lazy-handler paths share this boundary.

Already-started handlers retain their existing lifecycle owners: this is not an all-RPC drain. Ordinary UI/SDK requests remain reconnect-safe, existing disconnect-cancelled operations remain cancelled, and exact pending node progress/results remain available until transport shutdown seals entry. A credential waiter interrupted by shutdown receives retryable UNAVAILABLE before its lease releases, without cancelling or joining its running predecessor.

The handler registry uses the existing rejection-caching lazy-promise helper; the duplicate cache implementation and unsafe family-key assertion are removed. All 97 handler-family mappings and 108 runtime import targets are preserved. Reconciliation retains main's policy-response close ordering, host/caller fences, session-mutation commit guards, combined delivery-recovery shutdown, discovery ownership, and mention/update-check cleanup.

Validation also exposed a separate catalog composition defect: the parent factory restored an untransferred shallow projection of an already-frozen metadata graph. Across module evaluation, replacing its nonconfigurable collection mutators threw Cannot redefine property: clear before a worker could start. The factory now receives canonical parent facts and builds its own transfer input, retaining the original snapshot/cache/normalizer/registry for parent capture. Restoration remains only at the actual cloned child boundary. This removes three production lines and adds a fail-first real-worker regression; it is a functional validation repair, not cosmetic deslop.

Production LOC: +693/-543, net +150. Tests/support: +624/-74, net +550. Docs: +7. The positive production delta supplies the missing shared preparation/execution ownership boundary, while removing duplicate preparation/reconstruction paths. The assertion allowance only shrinks. No new configuration/env option, dependency, database schema, protocol version, timeout, logger suppression, or Vitest patch.

User Impact

A retiring Gateway cannot start an ordinary handler when delayed preparation resumes. Normal reconnect and node-cleanup behavior are preserved. Catalog preparation retains its authoritative parent metadata instead of reconstructing a second graph. The entry contract is documented in Gateway protocol.

The separately coordinated #136146 owns broader received/cooperative execution, startup/disconnect, post-response, and fixture lifetimes. This PR does not claim those guarantees or close the broader linked issues. The source-only cold Talk/plugin-discovery stall is also separate.

Evidence

Current head: 1b34bf0a6367ffd86124db5cefa34145dae40520, based on 3b710e4b75c94675a0e1f1b1c31754635c08a1a6. Both commits' final tree matches the verified 22-path candidate and all 52 recorded source inputs.

  • 340 tests across 23 files passed: 232 Gateway cases in the original recorded per-project failure order, 94 catalog/metadata cases, and 14 delivery-recovery cases. Original assertions and timeouts are unchanged. The Gateway replay used a temporary sequencer only to restore recorded order rather than Vitest's updated failed-first cache order.
  • The original entry regressions produced eight pre-fix failures; two credential-waiter regressions separately failed for missing responses. The new outer-build catalog regression failed on original production with the exact clear error, then passed through a real Worker while preserving parent identity and child cloning.
  • Complete node scripts/check-changed.mjs --base 3b710e4b75c94675a0e1f1b1c31754635c08a1a6 passed, including core/test types, formatting, lint, dead exports, architecture and ownership guards.
  • Full local pnpm build and pnpm plugin-sdk:surface:check passed in an exact-source normal checkout with copied dependencies. The first worktree build detected an ancestor dependency input changing during compilation; the isolated build passed with the consistency guard unchanged. Startup JS was 348,749 B gzip against the unchanged 350,141 B enforcement limit; all 149 public SDK subpaths passed.
  • Full 22-path deslop found no worthwhile behavior-neutral edits. Fresh independent Codex autoreview completed both evidence batches with zero findings at the requested P0 threshold; this is not a broader-priority audit.
  • Final-source AWS run run_7533a481fa76 passed runtime/UI builds and real built-browser/wire flows. All 52 inputs matched nine checkpoints. The catalog card and startup RPCs worked, ordinary TCP loss reconnected, shutdown resolved in 78.00 ms, and the child remained quiet for 20 seconds before natural exit 0. The wire probe observed retryable refusal before close, zero follower handler entries, and a predecessor held until explicit release. Five screenshots and the 25.16-second recording were inspected; the lease is released.

Live fixtures are fresh synthetic loopback auth-none environments, with no hydration, instance role, Tailnet, operator state or operator service. This is not real credential rotation/provider authentication, native hosted-service proof, a green source-only cold Vitest run, or proof of the original warmed metadata path. Broker heartbeat/event warnings were retained; complete downloaded logs and source receipts were verified. Two prior proof-assembly errors stopped before product execution and were repaired only in ignored harness scripts.

The earlier grouped run's timeout/root-count failures are not all attributed to the metadata repair: their exact historical causal chain remains unobserved. The final unchanged-assertion original-order replay passed every case. An isolated base/candidate diagnostic also passed and observed slow startup imports near the baseline deadline, not a proven pairing-read deadlock.

Exact proof, inspected media, and retained earlier-head history. Current main deliberately restored fail-closed audits in #137989 (audit retry hardening). The refreshed head's first CI attempt passed the code/test checks but exhausted four npm advisory attempts and returned incomplete coverage. After a public readiness probe returned valid JSON, only the failed security job and aggregate gate were retried. CI run 33850254675, attempt 2 completed successfully on this exact head. No rebase, audit exception or gate bypass was applied; the strict audit completed rather than being downgraded to a warning. The verified candidate is ready for native prepare/merge.

@clawsweeper

clawsweeper Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: XL maintainer Maintainer-authored PR labels Sep 3, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 3, 2026, 9:54 PM ET / September 4, 2026, 01:54 UTC.

ClawSweeper review

What this changes

The PR adds a Gateway-instance request-entry lifetime that prevents delayed authorization and lazy-handler preparation from entering a retiring Gateway after shutdown begins.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: this protected maintainer PR owns a concrete P1 Gateway shutdown fix. The reviewed request-entry owner fences asynchronous preparation before handler invocation across transport, in-process, typed, and lazy-handler paths; no introduced correctness defect was found, but exact-head CI is still in progress.

Priority: P1
Reviewed head: 75620e92fb72c7390854c62c9e106b2bcbba1101

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The shared owner boundary and focused interleaving coverage are sound on review; exact-head CI remains the final merge gate.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: Not applicable as a member-authored PR under the contributor-proof gate. The supplied PR comment nevertheless reports source-matched built-Gateway browser and WebSocket refusal evidence for this head; the linked artifact could not be independently fetched in this read-only environment because DNS resolution failed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable as a member-authored PR under the contributor-proof gate. The supplied PR comment nevertheless reports source-matched built-Gateway browser and WebSocket refusal evidence for this head; the linked artifact could not be independently fetched in this read-only environment because DNS resolution failed.
Evidence reviewed 6 items Shutdown owner: The lifecycle synchronously begins request-entry closure, then joins pending preparation before other close-prelude owners continue.
Transport entry coverage: Authenticated WebSocket dispatch acquires one request entry before credential waits, router loading, and bounded start scheduling, checks it before dispatch, and releases it only after the response path.
Atomic handler handoff: The shared dispatcher resolves forwarding handlers under the entry lease, performs the final open check, then releases immediately before actual handler invocation; it does not retain arbitrary RPC execution during shutdown.
Findings None None.
Security None None.

How this fits together

Gateway requests arrive through WebSocket, internal agent, and in-process paths, then authorize and resolve lazy handler code before invoking a method. The new lifetime owns that preparation interval and joins it during shutdown, while already-started method execution remains with its existing owner.

flowchart LR
A[Client or internal request] --> B[Gateway request entry]
B --> C[Authorization and handler loading]
C --> D{Gateway still open?}
D -->|Yes| E[Method execution]
D -->|No| F[Retryable refusal]
G[Gateway shutdown] --> B
E --> H[Response or existing lifecycle owner]
Loading

Before merge

  • Resolve merge risk (P1) - This is a shutdown-ordering change on a core Gateway path; merge should remain gated on the in-progress exact-head CI rather than relying on the earlier head's checks.
  • Resolve merge risk (P1) - The reviewed diff has a net production increase of 153 lines for a bug fix; the shared owner is justified by the multiple entry paths, but the scope should not grow further without eliminating an equivalent path.
  • Complete next step (P2) - Wait for the exact current head's required CI and merge gate to complete green before merge.
Agent review details

Security

None.

PR surface

Source +153, Tests +443, Docs +7, Other 0. Total +603 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 11 672 519 +153
Tests 1 443 0 +443
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 14 1123 520 +603

Review metrics

Metric Value Why it matters
Production versus test delta production +153 net; tests +443; docs +7; assertion baseline -1 The production growth supplies the shared preparation owner across several request entry paths; the added tests exercise the shutdown interleavings at the Gateway boundary.

Merge-risk options

Maintainer options:

  1. Complete exact-head Gateway validation (recommended)
    Wait for the current head's required CI and merge gate to finish green before merging this shutdown-ordering change.
  2. Pause if validation cannot complete
    Do not merge the lifecycle change without current-head validation because it changes request availability during close and restart.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Require green exact-head Gateway lifecycle and merge-gate checks.

Technical review

Best possible solution:

Land one shared pre-handler lifetime owner only after the exact refreshed head proves the transport and Gateway lifecycle suites green; retain the explicit handoff so shutdown never becomes an indiscriminate RPC drain.

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

Yes — the new boundary suite provides a high-confidence controlled reproduction by pausing each preparation stage, starting close, and observing that the handler never starts. This read-only review did not execute the test.

Is this the best way to solve the issue?

Yes — a single Gateway-instance owner covers the preparation stages before a synchronous handoff to existing handler owners, avoiding downstream guards or an all-RPC shutdown drain.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against f1e49edfb85c.

Labels

Label justifications:

  • P1: A late request starting during Gateway shutdown can produce a core runtime failure for connected UI or SDK users.
  • merge-risk: 🚨 availability: The PR changes request admission and shutdown ordering while a Gateway is retiring.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable as a member-authored PR under the contributor-proof gate. The supplied PR comment nevertheless reports source-matched built-Gateway browser and WebSocket refusal evidence for this head; the linked artifact could not be independently fetched in this read-only environment because DNS resolution failed.

Evidence

What I checked:

  • Shutdown owner: The lifecycle synchronously begins request-entry closure, then joins pending preparation before other close-prelude owners continue. (src/gateway/server-lifecycle.ts:390, 75620e92fb72)
  • Transport entry coverage: Authenticated WebSocket dispatch acquires one request entry before credential waits, router loading, and bounded start scheduling, checks it before dispatch, and releases it only after the response path. (src/gateway/server/ws-connection/authenticated-request-dispatch.ts:227, 75620e92fb72)
  • Atomic handler handoff: The shared dispatcher resolves forwarding handlers under the entry lease, performs the final open check, then releases immediately before actual handler invocation; it does not retain arbitrary RPC execution during shutdown. (src/gateway/server-methods.ts:514, 75620e92fb72)
  • Boundary regression coverage: The new Gateway test holds router, scheduler, profile, lazy-family, and nested-family preparation, then verifies close waits and the handler never enters; it also verifies a credential-barrier waiter receives retryable UNAVAILABLE without draining its predecessor. (src/gateway/server-request-entry.test.ts:96, 75620e92fb72)
  • Current-main necessity: Current main still begins close without a request-entry fence or pending-entry join, so the central behavior is not already implemented there. (src/gateway/server-lifecycle.ts:383, f1e49edfb85c)
  • Area history: Recent current-main history shows Peter Steinberger repeatedly maintaining these Gateway lifecycle and method-dispatch paths, including the later cloud startup/teardown work. (src/gateway/server-lifecycle.ts, 2640154bcf80)

Likely related people:

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

Rank-up moves

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

  • Wait for the current exact-head CI and merge gate to finish green.

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 (5 earlier review cycles)
  • reviewed 2026-09-03T04:50:33.932Z sha 3f97d26 :: blocked before merge. :: [P1] Reply when shutdown aborts a credential-barrier wait
  • reviewed 2026-09-03T05:39:41.977Z sha 27fe197 :: blocked before merge. :: none
  • reviewed 2026-09-03T05:52:16.215Z sha 27fe197 :: blocked before merge. :: none
  • reviewed 2026-09-04T01:20:32.984Z sha 15ca0925f5d164df5283783aea5f4a01ffe3924e :: blocked before merge. :: none
  • reviewed 2026-09-04T01:37:33.541Z sha 15ca0925f5d164df5283783aea5f4a01ffe3924e :: blocked before merge. :: none

@steipete steipete self-assigned this Sep 3, 2026
@steipete
steipete force-pushed the steipete/laughing-bassi-09961b branch from 3f97d26 to 27fe197 Compare September 3, 2026 05:30
@steipete
steipete marked this pull request as ready for review September 3, 2026 05:31
@steipete
steipete requested a review from a team as a code owner September 3, 2026 05:31
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 3, 2026
@steipete
steipete force-pushed the steipete/laughing-bassi-09961b branch from 27fe197 to 15ca092 Compare September 4, 2026 01:12
@steipete

steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Land-ready — exact head 1b34bf0a6367ffd86124db5cefa34145dae40520

CI33850254675, attempt2 completed successfully, including the strict production-dependency security gate. The initial advisory outage and failed-job retry remain recorded below. No gate, timeout, policy or source change was used to pass. All340 local tests, complete checks, full local build/SDK, independent review and inspected final-source live proof are complete; native prepare/merge may now proceed. Re-review for this head is acknowledged and queued; the prior review’s exact-head-green rank-up is fulfilled.

Refreshed candidate — 1b34bf0a6367ffd86124db5cefa34145dae40520

The request-entry repair is now rebased onto 3b710e4b75c94675a0e1f1b1c31754635c08a1a6, with a separate commit repairing parent catalog metadata ownership found during validation. The published tree matches the complete verified 22-path candidate. Production is +693/-543 (net +150); tests/support +624/-74; docs +7. The metadata repair removes the parent's redundant restoration of an untransferred frozen graph; real worker cloning/restoration is unchanged.

Local verification is complete: 340 tests in 23 files (232 Gateway, 94 catalog/metadata, 14 delivery recovery), complete changed checks, full local build and SDK surface gate. The Gateway group was replayed in its original per-project order, including runtime-services before node-result, with all assertions/timeouts unchanged. The earlier clear exception has a fail-first outer-build regression; the historical timeout/root-count causal chain is not retroactively attributed to that fix. The new snapshot/cache/normalizer/registry checks and a real Worker catalog request pass.

The first full worktree build correctly refused publication because an ancestor dependency input changed during compilation. An exact-source normal checkout outside that dependency tree, using copied dependencies, passed the complete stock build on its first attempt. No compiler guard, dependency pin, timeout or budget changed. Startup JS was 348,749 B gzip / 350,141 B limit. All 149 public SDK subpaths and the separate 345-entrypoint surface gate passed. Full deslop found no worthwhile cosmetic change; fresh independent Codex autoreview returned zero findings across both evidence batches at the requested P0 threshold.

Final-source live proof passed: AWS run run_7533a481fa76. Exact base plus patch SHA-256 a330279f2ec2e03e2d9d835c68b53126f1a361c368cc0603cbe9493e84a3ba41; all 52 input hashes matched nine checkpoints, and the same inputs match the published commit. Runtime/UI builds, real catalog row/card and startup RPCs, and automatic TCP reconnect passed. Direct shutdown resolved in 78.00 ms, followed by 20 seconds without late handler/response/teardown errors and natural exit0. All five screenshots and the 25.16-second recording were inspected; only synthetic data is visible.

The real WebSocket fault probe observed retryable UNAVAILABLE before close, zero queued follower handler entries, and a running predecessor still held until explicit release. Only the credential-handler bodies are deferred synthetic faults; routing, request authorization, serialization, transport and shutdown are real. This is not provider authentication or actual credential rotation. Browser fixtures use fresh loopback auth-none state. No operator state/service, instance role, hydration or Tailnet. Lease cbx_19acde5c4e32 is verified released.

Broker heartbeat and event-append warnings were retained; the complete downloaded archive and all final source/exit receipts were verified. Two earlier proof-assembly errors stopped before product execution (conflicting download destinations, then a generated verifier syntax error). The successful attempt followed local syntax checks of every script and identity checks of all embedded payloads; no product assertion was weakened.

Commands used for the final candidate:

node scripts/check-changed.mjs --base 3b710e4b75c94675a0e1f1b1c31754635c08a1a6
OPENCLAW_VITEST_MAX_WORKERS=2 node scripts/run-vitest.mjs --config .artifacts/gateway-entry/replay-original-order.config.ts src/gateway/server-request-entry.test.ts src/gateway/server-discovery-runtime.test.ts src/gateway/server-startup-early.test.ts src/gateway/server-runtime-services.test.ts src/gateway/server-close.test.ts src/gateway/server-kernel.test.ts src/gateway/server-plugin-in-process-dispatch.authorization.test.ts src/gateway/server/ws-connection/authenticated-request-dispatch.policy-close.test.ts src/gateway/server/ws-connection/authenticated-request-dispatch.abort.test.ts src/gateway/server/ws-connection/authenticated-request-dispatch.server.test.ts src/gateway/server.node-result-close.test.ts src/gateway/server.node-shutdown.test.ts src/gateway/server-import-boundary.test.ts --reporter=verbose

That temporary config imports the canonical Gateway config and supplies only a sequencer restoring the recorded file order; it is retained diagnostic evidence, not a repository configuration change.

OPENCLAW_VITEST_MAX_WORKERS=2 node scripts/run-vitest.mjs src/agents/prepared-model-catalog-worker.metadata.integration.test.ts src/agents/prepared-model-catalog-worker.integration.test.ts src/agents/prepared-model-catalog-worker.mismatch.integration.test.ts src/agents/prepared-model-catalog-worker.scope.integration.test.ts src/agents/prepared-model-catalog-worker.secrets.test.ts src/agents/prepared-model-catalog-worker.test.ts src/agents/prepared-model-runtime.reload-auth.test.ts src/agents/prepared-model-runtime.startup-static.test.ts src/plugins/plugin-metadata-snapshot.test.ts --reporter=verbose
OPENCLAW_VITEST_MAX_WORKERS=2 node scripts/run-vitest.mjs src/infra/session-delivery-queue-runtime.test.ts

The isolated local checkout used Node24.20.0 and pnpm12.1.0:

pnpm --config.package-import-method=copy install --frozen-lockfile
pnpm build
pnpm plugin-sdk:surface:check

Remote proof used the trusted exact-base Node/pnpm bootstrap, the canonical qaRuntime build profile, the unchanged UI builder, and the inspected browser/wire drivers in separate loopback-only network namespaces. qaRuntime does not substitute for the full local declaration build above.

Landing status: new exact-head CI is required before native prepare/merge. Earlier head's CI is historical only. Current main deliberately restored fail-closed audits in PR #137989 — audit retry hardening. This corrects my earlier stale policy description: CI used the intended strict step, not an outdated workflow. Attempt1 of CI33850254675 passed code/test checks but exhausted four advisory attempts and returned unavailableexit2. A public readiness probe then returned valid JSON (HTTP200); a failed-job retry was requested and attempt2 completed successfully. No rebase, exception or bypass was applied; readiness is not audit clearance. The broader received/cooperative/startup/disconnect/fixture work in #136146 and the source-only active Talk stall remain separate. No warmed metadata, all-RPC execution drain, or native hosted-service guarantee is claimed.

Current recording follows the retained history below.

Historical earlier-head proof and CI recovery

Renewed live proof — unchanged head 75620e92fb72c7390854c62c9e106b2bcbba1101

The requested fresh live replay passed. AWS run run_69e0696c2cf6 checked out the published commit directly, built the runtime and unchanged Control UI, and exercised the real Gateway/browser and WebSocket flows. All fifteen retained source hashes match the published head.

The stock synthetic catalog row/card and startup requests worked; ordinary TCP loss reconnected automatically. Shutdown resolved in 86.62 ms, followed by twenty seconds without late handler/response/teardown errors, then natural exit0. The separate queued-request wire probe received retryable UNAVAILABLE before close, entered no follower handler, and left its synthetic predecessor held until explicit release. All five screenshots and the 25.28-second recording were inspected. These are fresh loopback auth-none fixtures, not provider authentication or a real credential rotation; the earlier scope limitations still apply.

Fresh full-branch Codex autoreview also completed both bounded evidence passes with no accepted P0 findings. No production or test source changed; the fourteen affected paths have no intervening main changes, and production remains net+153. Same-head unit/build/check evidence below remains applicable but was not relabeled as a new run.

Lease cbx_3097d9a77e5a was released. No operator state/service, hydration, instance role, or Tailnet was used. A broker event-upload warning occurred after the workload; the complete downloaded report, logs, and source hashes were verified locally.

Landing still requires green CI. CI run 33826888662 attempt3 again timed out in the production npm bulk-advisory request; no vulnerability finding was returned. Only the failed audit/gate was retried after backoff as attempt4; it also finished with the same advisory timeout. Landing remains blocked by the required security/CI gate despite the passing fresh live proof. No further retry is running. No timeout, severity, retry policy, or gate was changed, and native prepare/merge has not run.

Current fresh recording:

Earlier same-head proof and recovery history

Landing blocked on npm advisory availability (2026-09-04). Exact-head CI run 33826888662, attempts 1 and 2, passed all other selected code/test checks, but security-fast failed its production-dependency audit after both existing 60-second requests timed out. Credential and private-key scans passed. The aggregate gate correctly remains red; this PR has not been merged and no gate was bypassed.

The unchanged full audit also timed out locally. A one-package advisory POST timed out with both Node and curl, while the registry ping returned HTTP200 in0.156s. Three further readiness probes, spaced270s apart, all timed out, so no third CI attempt was issued. No dependency, timeout, retry policy, or source change was made to hide the failure. All proof VMs are released and the task branch is clean. Resume with the same-head unsuccessful-job retry once the advisory endpoint responds, then complete the native prepare/merge sequence.


Current published head: 75620e92fb72c7390854c62c9e106b2bcbba1101, parent da7d113b90af21b5cc6d355a6f7706ea3912a8e1.

Resolved the actual conflict with the newly landed hosted-lifecycle repair by retaining both context capabilities. Main's host callback still revalidates the exact live kernel and caller; request-entry lifetime still owns only pre-handler preparation. No new logic was needed. The other twelve task paths—including all thirteen entry regression cases—are byte-identical to the previously reviewed 15ca head. All 97 handler-family mappings/order and 108 runtime imports are preserved; production remains net +153, tests +443.

Fresh final-source proof: 178 tests across twelve suites passed, including hosted lifecycle/kernel callback fences, host preparation/retirement and run-loop ordering, the original entry regressions, policy responses, disconnect cancellation, raw/typed authority, and native-node cleanup. Targeted lint/format, core types and both Gateway test type graphs pass. The complete pnpm build passes, including unchanged UI budgets. Fresh full staged Codex autoreview completed both bounded evidence passes with no accepted P0 findings. This is not a broader-priority review. The preceding 15ca revision additionally passed 226 tests/18 suites, complete changed checks and the SDK surface gate.

Fresh browser and wire proof: AWS run run_f4d33fd0664d built the runtime/UI and passed both flows. All fifteen remote source hashes match this published head. The real built Gateway served the unchanged Control UI with stock synthetic catalog data: exact row/card and startup RPCs, automatic reconnect after TCP loss, close in 88.63 ms, twenty seconds without late handler/response/teardown errors, then natural Node exit 0. All five screenshots and the 25.36-second recording were inspected; synthetic-only.

The separate real WebSocket fault probe received retryable UNAVAILABLE before close, entered no queued handler, and left its synthetic predecessor held until explicit release. Fresh loopback auth-none fixtures are used; this is not a real credential rotation or provider-auth test. Routing, request authorization, transport, serialization and shutdown are real; only the credential-handler body is deferred. The deliberately released execution tail is not a global quiet-teardown claim. Lease cbx_f3f78bbf756a is verified released, with no hydration, instance role, Tailnet, operator state or operator service. A broker stdout-event append timed out after the workload; the complete downloaded reports/logs and source hashes were verified locally.

CI and review: the previous run 33824892253 finished unsuccessfully only because five jobs were cancelled before acquiring a runner (zero steps; GitHub's “not acquired by Runner … even after multiple attempts” annotation), causing its aggregate gate to fail. No executed test/check failure appeared. The genuine main-conflict refresh now has its own exact-head CI; native prepare/merge will wait for green. The latest ClawSweeper review has no correctness finding and asks for that gate. Its reviewed original commit's parent is cd8c74889d21ddcc9f3a2d47fe868224a0e44acb, not the test-merge main mentioned in its provenance sentence; synthesized integration ancestry is not original history.

Fresh focused command:

OPENCLAW_VITEST_MAX_WORKERS=2 node scripts/run-vitest.mjs src/gateway/server-request-entry.test.ts src/gateway/server-kernel.test.ts src/gateway/server-methods/system-agent.host-lifecycle.test.ts src/cli/gateway-cli/host-lifecycle.test.ts src/cli/gateway-cli/run-loop.test.ts src/system-agent/operations.gateway-lifecycle.test.ts src/gateway/server-plugin-in-process-dispatch.authorization.test.ts src/gateway/server/ws-connection/authenticated-request-dispatch.policy-close.test.ts src/gateway/server/ws-connection/authenticated-request-dispatch.abort.test.ts src/gateway/server/ws-connection/authenticated-request-dispatch.server.test.ts src/gateway/server.node-result-close.test.ts src/gateway/server.node-shutdown.test.ts
pnpm build
node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo
node scripts/run-tsgo.mjs -b test/tsconfig/tsconfig.core.test.gateway-root.json test/tsconfig/tsconfig.core.test.gateway-other.json --builders 1
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/gateway/server-methods/shared-types.ts src/gateway/server-kernel-request-runtime.ts

The remote command used the trusted pinned Node/pnpm bootstrap, node --import ./scripts/tsx.mjs scripts/build-all.mts qaRuntime, node scripts/ui.js build, and the retained browser/wire drivers in separate loopback-only network namespaces. Patch SHA-256: 7bab7b4dd48734aef0fb765030e8b6dda025934953f0ea9c6589d6e694bab593.

The original eight fail-first cases and two credential-silence failures remain counterfactual evidence. The source-backed cold Vitest Talk/Jiti stall and broader received/cooperative/startup/disconnect/fixture lifetime remain outside this preparation-only guarantee; no warmed metadata, all-RPC drain, native hosted-service or stock Vitest pass is claimed.

Historical 15ca recording and proof

AWS run run_8c985830afeb passed the preceding head: close87.20ms, twenty seconds quiet observation, natural exit0, and the same barrier-wire invariant. All media were inspected; that revision's lease is released.

attachment-720038797.webm

Current-head recording:

attachment-4073655508.webm
attachment-1273894288.webm

Current inspected recording

Re-review requested for this head.

attachment-3490501288.webm

@clawsweeper

clawsweeper Bot commented Sep 4, 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.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete force-pushed the steipete/laughing-bassi-09961b branch from 15ca092 to 75620e9 Compare September 4, 2026 01:42
steipete added a commit to openclaw/clawsweeper that referenced this pull request Sep 4, 2026
…ginal commits (#1409)

<details>
<summary>Additional instructions</summary>

**MUST:** Keep **Allow edits from maintainers** enabled for this PR so maintainers can help update the branch when needed.

</details>

## What Problem This Solves

Resolves a problem where a ClawSweeper review could attribute a GitHub test merge's main parent to the original PR commit. The [historical review of the Gateway PR](openclaw/openclaw#136998 (comment)), reviewed at `2026-09-04T01:20:32.984Z`, claimed that original head `15ca0925f5d164df5283783aea5f4a01ffe3924e` had current main as its recorded parent. The original raw commit proves otherwise.

The [producer run](https://github.com/openclaw/clawsweeper/actions/runs/33825006229) ran code `8440386ebd92f39c5d6812d74cda3793a67530a3`. Its archived report (`exact-review-33825006229-1`, artifact ID `9919776836`, report SHA-256 `3db6dce3fe4050873ad4131159604ecd62b11432eed98a73fd962cba873772bb`) preserves the incorrect claim; the linked durable comment is mutable and now contains later reviews. The raw report is deliberately not reproduced here.

| Object role | Exact commit | Raw recorded parents, in order |
| --- | --- | --- |
| Original PR head | `15ca0925f5d164df5283783aea5f4a01ffe3924e` | `cd8c74889d21ddcc9f3a2d47fe868224a0e44acb` |
| Historical GitHub test merge | `782c712e2dad405a2e9010354b5291fb94d42fe6` | `3c0eb9fd822f8101dc3117ce40dbd2b0f5e01930`, `15ca0925f5d164df5283783aea5f4a01ffe3924e` |

## Why This Change Was Made

The evidence generator supplied identities and test-merge parents but omitted the original head's raw parents, and the model's prose conflated those distinct identities. Reuse the hardened Git reader and canonical parent parser to provide typed, role-labeled `originalHead` and `checkout` records, and explicitly label `testMerge`. The prompt requires public ancestry claims to keep these roles separate.

Exact object-type checks prevent tag peeling. Reads retain the existing five-second/1 MiB bounds and cap parent lists at eight; unavailable, malformed, or oversized reads return `parents: null`, while only an inspected root returns `[]`. The old scalar head/checkout aliases are removed. This is reviewer input, with no decision schema, dependency, configuration, routing, persistent-data, or publication-authority change and no prose scrubber.

Source preparation materializes the pinned original head. There is no evidence that a historical rebase caused the bad claim, and an integration checkout cannot rewrite an existing original SHA's parent.

## User Impact

Maintainers and contributors receive explicit original-commit ancestry in review evidence, reducing false provenance and ownership claims when the actual checkout, fetched main, merge base, or test merge differs. Unknown inspection remains visibly unknown. Raw parent records alone do not establish causal introduction, authorship, or parent-object availability.

## OpenClaw Bay Impact

Bay is unaffected: the change only adds reviewer-input provenance. No observer data contract, lifecycle/publication authority, queue state, telemetry, routes, or controls change.

## Documentation Impact

Updated the active implementation documentation in `docs/pr-review-comments.md`, section “PR Introduction Evidence,” and the owning reviewer prompt in `prompts/review-item.md`. ClawSweeper review maintainers own this contract; `src/pr-review-evidence.ts` is the source of truth. Verified against this PR's four-file patch; changes to record roles, raw-object bounds, unknown/root semantics, or source acquisition trigger a documentation update. Reviewed `CONTRIBUTING.md`, `docs/README.md`, `README.md`, and `VISION.md`; no other documentation changes are needed. Release-note context is preserved here without editing the changelog.

## Evidence

- Before the production change, the new regressions failed: initial focused run 89 passed / 7 failed; additional boundary cases 2 failed; exact-object-type case 1 failed. With the patch, all four focused files passed, 98/98, under Node 24.20.0 and pnpm 11.10.0 with standard Git configuration.
- Real Git fixtures cover synthetic merges, rebased checkouts, original heads with multiple commits, merge heads, replacement refs, legacy grafts, shallow history, missing objects, trees/tags, malformed raw parents, oversized objects, and genuine roots. Production prompt serialization is exercised, including preservation of introduced versus main-only changes.
- Static checks, all builds, lint, and the existing changed-surface coverage gate passed (13/13). The original full local `pnpm run check` was interrupted under severe host load and did not pass. A representative agent-runner failure was reproduced: that command set `TMPDIR` inside the checkout, which the scanner correctly rejects as `unsafe_path`. The unchanged test passes with the default external temp directory. This diagnoses that local failure only. The full gate subsequently passed in [exact-head Linux CI](https://github.com/openclaw/clawsweeper/actions/runs/33845765111/job/100937182439) on `f1a20200c0b22ccd309d38939879b8ec66fb7a85`; the same run also passed Windows launcher and sparse repair build checks, with no retry. [CodeQL](https://github.com/openclaw/clawsweeper/actions/runs/33845765036) passed at the same head. The hosted scan smoke is dispatch-only and was correctly skipped.
- Fresh isolated Codex reviews before commit and after rebase both passed with no actionable P0–P3 findings. On head `f1a20200c0b22ccd309d38939879b8ec66fb7a85` against base `b4f7d36406ed1e375dc8eac17abc00ff63a93f02`, the production build, exact historical-object probe, and selected rebase/unknown/type/size regression cases passed (3/3). The rebased four-file patch is byte-identical to the original 98/98-tested patch (SHA-256 `e0c149f62c70876b121df9dfb497ec23a6e72fb5cdaf9c8b8cbbfb7387188128`); upstream did not change its evidence or prompt-serialization owners.
- The [initial ClawSweeper review](#1409 (comment)) found no actionable issues or rank-up requests and judged the proof sufficient. No code changes were needed in response; this body now includes the completed CI result.
- Scope: four files, production TypeScript +40/-4 (net +36), prompt +15/-3 (net +12), tests +172/-3 (net +169), documentation +13/-4 (net +9). No other owner's files changed. The related [owner simplification PR](#1407) changes different files.

## Real Behavior Proof

**Claim:** compiled production evidence generation preserves the exact original PR head's raw parents independently of the actual integration/rebased checkout and GitHub test merge, and production prompt assembly carries those roles to the reviewer.

**Surface and scenarios:** `buildPullRequestReviewEvidence` and production `buildReviewPrompt` against real disposable Git histories; additionally, compiled evidence generation against the exact historical original and test-merge objects in a task-owned bare object store. Historical source objects and active PR checkouts were not modified.

**Commands/environment:** local macOS, Node 24.20.0, pinned pnpm 11.10.0, standard Git configuration. Build and focused proof:

```sh
pnpm run build
TMPDIR="$PWD/.artifacts/original-commit-provenance/tmp" CLAWSWEEPER_PROVENANCE_PROOF_DIR="$PWD/.artifacts/original-commit-provenance" node --test test/pr-review-evidence.test.ts test/review-prompt-context.test.ts test/review-prompt-policy.test.ts test/review-provenance.test.ts
```

The post-rebase boundary rerun used the default external temp directory and passed all three selected cases:

```sh
node --test --test-name-pattern='original head parents survive synthetic|unavailable raw commits|invalid or oversized raw parent' test/review-provenance.test.ts
```

The historical probe calls the compiled `buildPullRequestReviewEvidence` with `head.sha=15ca0925f5d164df5283783aea5f4a01ffe3924e`, `base.sha=3c0eb9fd822f8101dc3117ce40dbd2b0f5e01930`, `mergeCommitSha=782c712e2dad405a2e9010354b5291fb94d42fe6`, `mainSha` equal to that base, and the bare fixture's `HEAD` at the test merge. It first verifies both objects with `git --no-replace-objects cat-file -p <exact-sha>` and asserts the following production output:

```text
originalHead: verified, role=original_pr_head
  sha=15ca0925f5d164df5283783aea5f4a01ffe3924e
  parents=[cd8c74889d21ddcc9f3a2d47fe868224a0e44acb]
checkout: verified, role=actual_checkout
  sha=782c712e2dad405a2e9010354b5291fb94d42fe6
  parents=[3c0eb9fd822f8101dc3117ce40dbd2b0f5e01930,15ca0925f5d164df5283783aea5f4a01ffe3924e]
testMerge: verified, role=github_test_merge
  sha=782c712e2dad405a2e9010354b5291fb94d42fe6
  parents=[3c0eb9fd822f8101dc3117ce40dbd2b0f5e01930,15ca0925f5d164df5283783aea5f4a01ffe3924e]
mergeBase: verified, sha=cd8c74889d21ddcc9f3a2d47fe868224a0e44acb
PASS: immutable original-head parentage is separate from integration ancestry.
```

**Artifact/trace:** bounded historical output above, the original producer/artifact identities above, and reproducible real-Git regression assertions in `test/review-provenance.test.ts`. Red/green logs, fixture JSON, and historical production JSON are retained locally; raw reports and agent transcripts are not published on this branch.

**Limits:** this proves evidence generation and prompt assembly, not model compliance, a replay of the historical model session, or GitHub review publication. It does not guarantee that model prose never makes another provenance mistake. No Gateway PR or lifecycle session was changed.
Own router loading, bounded starts, authorization and lazy handler preparation until refusal or atomic handoff. Preserve reconnect-safe requests and exact pending node cleanup without draining arbitrary handler execution.

Related: #127256 and #136145. Separate from the Full Access and metadata repair in #136036. Deferred regressions fail before the repair; source-matched built Gateway/browser proof covers catalog loading, reconnect and quiet shutdown.
Keep parent synthetic-auth capture bound to its original immutable plugin
generation. Construct worker transfer input in the catalog factory and restore
metadata only after actual worker cloning, rather than refreezing a shallow
parent projection.

A retained snapshot from another module evaluation previously failed with
Cannot redefine property: clear before a worker could start. Add a fail-first
outer-build regression covering parent snapshot, cache, normalizer and registry
identity plus a real worker catalog request. Preserve cloned-worker mismatch,
secret-reference, scope and cancellation behavior.

Found while validating the Gateway request-entry repair in #136998. This is
separate from the request-entry lifetime and broader test-fixture ownership.
@steipete
steipete force-pushed the steipete/laughing-bassi-09961b branch from 75620e9 to 1b34bf0 Compare September 4, 2026 07:46
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 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 3ed226a into main Sep 4, 2026
315 of 320 checks passed
@steipete
steipete deleted the steipete/laughing-bassi-09961b branch September 4, 2026 08:16
@steipete

steipete commented Sep 4, 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
)

* fix(gateway): stop late request entry during shutdown

Own router loading, bounded starts, authorization and lazy handler preparation until refusal or atomic handoff. Preserve reconnect-safe requests and exact pending node cleanup without draining arbitrary handler execution.

Related: openclaw#127256 and openclaw#136145. Separate from the Full Access and metadata repair in openclaw#136036. Deferred regressions fail before the repair; source-matched built Gateway/browser proof covers catalog loading, reconnect and quiet shutdown.

* fix(agents): retain canonical parent catalog metadata

Keep parent synthetic-auth capture bound to its original immutable plugin
generation. Construct worker transfer input in the catalog factory and restore
metadata only after actual worker cloning, rather than refreezing a shallow
parent projection.

A retained snapshot from another module evaluation previously failed with
Cannot redefine property: clear before a worker could start. Add a fail-first
outer-build regression covering parent snapshot, cache, normalizer and registry
identity plus a real worker catalog request. Preserve cloned-worker mismatch,
secret-reference, scope and cancellation behavior.

Found while validating the Gateway request-entry repair in openclaw#136998. This is
separate from the request-entry lifetime and broader test-fixture ownership.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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