Skip to content

fix(gateway): keep received work inside its state lifetime - #136146

Merged
steipete merged 19 commits into
mainfrom
steipete/gateway-lifetime-compact
Sep 4, 2026
Merged

steipete merged 19 commits into
mainfrom
steipete/gateway-lifetime-compact

Conversation

@steipete

@steipete steipete commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #136145 — Gateway test state released before received work finishes. Related: #134274 holds historical browser and protected-audit evidence.

Not ready to merge: protected audit acceptance and the scanner-refused ClawSweeper review remain outstanding. Hosted CI is green on the final head.

Problem and resulting behavior

Gateway fixtures could restore environment selectors and delete temporary roots while received requests, refreshes, or timed-out native callbacks were still executing. Early response, cancellation, and timeout describe the caller's observation; they do not establish that the original operation finished.

This repair remains necessary after #136998. That change owns request preparation and its atomic handoff, which this PR preserves. GatewayConnectionWork owns received execution through router, agent command, terminal outcome, and media cleanup, even when raw or typed in-process calls acknowledge early. Controller publication rechecks the exact request-entry lifetime after awaited session admission.

Shutdown now has one preparation phase and one completion phase. Preparation fences ingress and cancels this Gateway's work before joining it; restart alone retains its grace and recovery markers. Completion obtains final cleanup handles after admitted work settles, then releases shared dependencies. The monolithic close factory, duplicate cleanup joins, and redundant post-abort polling are removed.

Connected owners follow the same boundary:

  • MCP requests compose caller cancellation with owner shutdown. Browser sessions retain the original native close promise, descendant cleanup, and late stderr when the SDK initiates close.
  • Connection-dependent workers stop before their supervisor transport retires. Failed required cleanup retains that owner and its dependencies for recovery.
  • Fixture acquisition is owned before yielding. Failed startup cleanup preserves both errors and retains selectors, root, and metadata. CLI close failure exits unsuccessfully and cannot admit a successor into an unclean generation.
  • Plugin replacement timeout does not start another unbounded startup join. Final close retains the original stop promise; independent teardown proceeds after the existing grace, while plugin state and shared dependencies remain until cleanup settles.
  • Delayed question sends capture the exact question generation before prompt/queue work. Actual restored queue custody cannot bind an old payload to a replacement question. Clear, owner retirement, and the existing retention deadline fence old captures; unbound controls become “Unavailable: request a new question.” Nested delivery retains its original cleanup owner.

Pending approvals, questions, and pairing decisions remain pending when observers disconnect. The existing plugin SDK registration signature, question protocol, queue representation, timeout/retention durations, and stored approval shape are unchanged. There are zero new configuration options, protocol versions, SQLite schemas, migrations, or approval-retention policies. device-scope-upgrade changes observation lifetime only. Gateway and plugin lifecycle docs describe the resulting contract.

Integration and cleanup

Pinned main 65417dfc01deb9109cf373a4f83d7aa4d3412791 is integrated. Its request handoff, WebSocket lifecycle, RPC diagnostics, node-capability checks, cron/reload ownership, captured restart-reply cancellation, and compiled test consumers remain. #138379's category-only drain reports and phase-start traces pass through both close phases using a shared timer. Named shutdown steps still aggregate errors and stop at failed required joins; drain budgets are unchanged.

Final review found and repaired two startup regressions. Public close redundantly awaited the startup result after received-work drainage, turning a normal startup failure into a false cleanup failure that blocked CLI recovery. That join is deleted; the public startup promise keeps its original error. Early failure could also leave post-ready work waiting on a barrier whose normal timer was never armed. The startup catch now releases it before cleanup drains that work; synchronous close preparation fences the owner before continuation resumption.

Removed duplicate handler registration, unused in-memory approval state, forwarding adapters, QA finalization, and test polling. The nonminimal sidecar fixture uses compiled plugin artifacts through the existing pretest owner; selected config remains authoritative instead of admitting sibling consumers through aliases. Agent fixtures use the canonical execution tracker and join dispatch. Two Code Mode files adopt #138238 exactly, removing redundant mocks.

Against pinned main, judged LOC is production +3,828/−3,328 = +500; tests +10,961/−3,953 = +7,008; support/tooling/declarations +1,376/−341 = +1,035; docs +59/−3 = +56; shrink-only ratchets −7. Moves cancel in net counts. Production growth establishes execution, acquisition, cleanup, and exact question-delivery owners; no speculative global export cache was added.

Main’s subsequent MCP stderr repair (#138399) is incorporated through the PR’s existing close owner: retained native/tree cleanup and readable completion precede bounded, redacted logging. The internal stderr helper stays a synchronous getter, avoiding a second completion promise and preserving the unspawnable-command path. Existing EOF, descendant, forced-close and redaction tests cover the upstream scenario. Main’s new device mutation cases (#138492) retain every authority assertion while joining original dispatch promises; redundant handler-finished signals are removed. The live Code Mode build prerequisite and worker credential-revocation coverage are retained.

CI exposed two stale fixture contracts. A Gateway suite deleted and recreated the same state root while ordinary database close retained process-level schema validation; its second shutdown case then opened an uninitialized session database. Both fixture cleanup owners now use the existing test reset scoped to their own root, including closed-path validation and unopened failure latches, after all Gateway work is released. Other roots and ordinary runtime reopen/eviction behavior are preserved. The Signal partial-delivery fixture supplied a question payload and mocked answer endpoint without creating the host question; it now mocks that corresponding registration boundary and asserts the exact accepted-message binding. No existing delivery, abort, lifetime, or no-replay assertion was removed. Main subsequently fixed recreated-database validation in #137424 and introduced its canonical validation-cache owner. This PR preserves that production repair and keeps only selective fixture retirement in the existing reset helpers. Closed-path validation and unopened failure latches are cleared only for the released fixture root; a two-root regression proves unrelated state stays live. These helper changes add no runtime behavior.

The settings-layout test also reloaded immediately after each composer appeared, cancelling otherwise successful startup scripts and then treating those native cancellations as errors. A natural Linux reproduction recorded HTTP 200 fetches followed by net::ERR_ABORTED at the reload; console/page errors stayed empty. Main independently repaired this in #138482. The reconciled test keeps its three cold documents—New Session, Chat, and model-provider Settings—alive through the assertions and joined route cleanup. It removes diagnostic-only request maps and phase tracking while preserving both error assertions, network reasons/status, provider-copy isolation, and all-page failure capture. Existing sibling tests cover the Settings shortcut and prewarmed navigation. The full layout file now has six cases because the earlier two table rows become one three-document case.

The final main reconciliation also retains exact Gateway resolver identity for queued replies, preserves outer local-tool admission bindings, and owns dashboard builds started by later enablement through the existing sidecar. No duplicate lifetime owner was introduced. The real queued-reply test proves exact-host recovery marking and cancellation; its separate detached delivery is released and joined by fixture teardown, so that result is not a universal queued-delivery quiescence claim.

Independent review caught one additional fixture mismatch: the native context mock lacked the new pages() API, replacing an intentional body error with TypeError during diagnostics. The failure was reproduced before the fixture-only repair. The mock now models a retained closed page and no live context pages; real diagnostics remain enabled and the original body/close error assertions are unchanged.

The participant suite now calls the database reset through a zero-argument teardown callback. Vitest supplies its test context to hooks; passing the helper directly treated that context as the optional fixture root. The four hosted teardown failures reproduce locally, then all seven cases pass with the adapter. A caller audit found no other unsafe callback registrations.

Validation

Candidate: b75584050c1325744893f6aecf1e40c7a40b446a (tree 0880123356610be6c90c2e5e9d5da90ccd750615, 238 changed paths). Results below are source-bound; overlapping counts are not a unique-test aggregate.

Scope Source and observed result
Final hosted CI Run 33925115108, exact published head b75584050c1325744893f6aecf1e40c7a40b446a: 122 jobs passed, 12 skipped, zero failures. Includes both Windows shards and every previously failing Node, Signal, Settings and participant-test job.
Final participant hook repair Tree 0880123356610be6c90c2e5e9d5da90ccd750615: the full seven-case file reproduces 4 failures / 3 passes before the adapter, then passes 7 / 7 with zero skips in 52.17 seconds. All 238 changed-path hashes match; this one-line fixture change is the only source difference from ffeec174773a. Independent review against that actual published head reports zero actionable P0–P2 findings. Focused config/test types, all three export scans, type-aware lint, formatting and selected structural guards pass.
Final main reconciliation The two-root reset regression fails before its repair and passes afterward. Tree 9822ba9603385482b037d857a5e052205c545681 passes 413 runtime tests / 12 files with four existing platform-specific skips; another 8 Gateway fixture tests / 0 skips pass locally, including the retained-state subprocess in 75.849 seconds under its unchanged 90-second deadline. All 237 changed paths match. On the identical tree, macOS Chromium with the production preview passes 20 browser tests / 3 files / 0 skips, including all six layout cases and both navigation siblings; 237 changed-path hashes plus four sibling/config/lock hashes match before and after, and three synthetic screenshots were inspected. Full repository checks pass all type, three export-scan, full lint, format and structural lanes. Initial independent review found the missing native UI mock API; that exact case fails before the correction. Final tree 439fd8a91b9507a999fcd6e5d1e25a9b52b89878 changes only that fixture and passes all 12 native UI ownership tests / 0 skips; all 237 source paths verified again. Focused checks after the fixture correction pass, and a fresh complete ten-pass independent review reports zero actionable P0–P2 findings.
Prior CI fixture repairs (ae3119b3b0e5) Tree a735c6de5064f0c01576b186954724510e574b69: all 236 changed paths verified locally; fresh independent review of the seven-file delta against published ee7285870c6 found zero actionable P0–P2 defects. Full applicable backend/Signal checks pass. UI checks passed after fixing one shadowed variable and rerunning focused lint; i18n, UI test types, all three export scans and formatting pass. Original Node, Signal and scoped-reset failures were reproduced before their repairs.
Linux fixture and owner replay Disposable Linux run, tree 8b8862bda0a1a9c9b87b94ff6df4eb1703c333eb: 30 tests / 6 files / 0 skips, including database cache/lease owners, both Node shutdown modes, the retained-fixture subprocess and Signal delivery/reactions. The native fixture finishes in 13.009 seconds with its unchanged 90-second limit. Seven source hashes were checked before execution and worker generation was verified afterward; no separate post-run seven-file hash check is claimed. Only the UI test's mechanical variable rename follows this tree.
Prior UI startup and Settings navigation (superseded by the main reconciliation) Natural Linux RED records HTTP 200 script fetches followed by native net::ERR_ABORTED during the fixture's reload. Linux GREEN passes both focused cold starts and all 7 settings-layout tests / 0 skips on UI overlay tree 0e0aa750c253c348620f6670f2855b2717b958fa. Final UI source, SHA-256 a3d6acb8602dcc2ba12e073257ceab841bc1c6e49c7c135038851be9b37d7e40, passes both local built-preview flows after the subsequent comment, screenshot-name and variable-name changes. Four synthetic captures were inspected; no screenshots were uploaded.
Prior main integration (ee7285870c6) Tree 3420ed12762a6c4b3059e4c0a6b374dd8c3bd62d: 489 tests / 16 files / 0 skips (107 build-admission, 166 Gateway, 73 CLI, 143 browser), including successful runner cleanup; all 231 changed paths verified. Real MCP shutdown diagnostics, descendants, forced close, missing command and 2 MiB stderr, plus the real authenticated WebSocket flow, pass. Fresh five-pass independent review found zero actionable P0–P2 defects. Full check-changed passed the selected core-test, plugin, plugin-test, script and tooling lanes: types, three export scans, lint, formatting, doctor contracts and dependency/structural guards, including Docker, HTTP/2, database, media, sidecar and import-cycle checks.
Prior startup, kernel, post-attach, shutdown, CLI (02c2b8e1198) Tree 60e5a9dfafbce0d227a48f27f2a3a66b1c169c60: 191 tests / 5 files / 0 skips; all 230 changed paths verified. The real listener stays alive until held work finishes, then closes with root work released and secrets snapshot cleared.
Startup regression RED Two public-close cases failed on 87c47d3a0db44e02c756ea01d2e0709f2629c4a3 because cleanup contained the extra startup error. The barrier case failed on 580ad12231466fed27875120e34b0ea6bbe236a3 because drain entered while the actual barrier remained held. Its emergency release ran only in fixture cleanup. Both defects were reproduced before production edits.
Prior repository checks and source review (02c2b8e1198) On that tree: production/source-test types, all three Knip scans, focused type-aware lint, formatting and all structural/database/media/sidecar/import-cycle/webhook/pairing guards pass. Independent Codex review completed all 15 passes with zero actionable P0–P2 findings and verified unchanged source.
Diagnostics integration Tree 44504a6d0969c0d195686ab8608f448d30a9e47a: full build on frozen dependencies including directly inspected @openclaw/fs-safe 0.7.2; 445 tests / 14 files / 0 skips covering Gateway, infrastructure, SDK, native CLI, CLI and harness; full types, three dead-export scans, lint and structural checks. All 229 paths verified. Predates the two startup repairs.
Question generation and final effects 6c9cc4359b0, tree b84cace01e05627d0c159b9c2964d4fa0b42753a: 75 tests / 7 files / 0 skips, full repository checks and clean independent source review; all 229 paths verified. Real manager, dispatcher, SQLite queue/recovery, and SDK reaction store with synthetic channel transport and injected RPC. Pre-fix delivery, recovered/retried reactions, retention expiry and owner-finalization cases failed. No live channel is claimed.
Earlier main integration Tree f27d7f8896560564b2ba0c23f7c297848f0be51c: 1,228 tests / 15 files / 0 skips; all 224 paths verified. Predates question repair.

The hosted failure on 2f1e8527a42 reproduced locally: three partial agent contexts lacked the execution tracker and retained session claims, causing six failures. Reusing makeContext() passed all 302 cases in the exact original order, with zero skips and unchanged assertions, timers, and continuation tests; source hashes matched 9196afe07d0. The earlier Code Mode alignment matched the successful upstream owning shard.

Historical native proof remains bound to its recorded sources, principally caffe38670590b521ae26f76b2de094226c504c6 and its 237-path manifest:

  • Build and runtime proof: full build; 687 selection/build-admission tests; 251 fixture/contract tests; 17 dispatch cases; 312 HTTP/plugin/WebSocket tests in the original failed CI's 27-file order. Final runtime replay: repeats all 312 cases with zero skips and all 237 paths verified before/after. Other packed-job contention is outside this replay.
  • Owner proof: 249 lifecycle/admission tests. Original execution order: full build and 55 tests; subsequent scoped execution/startup/CLI/catalog runs passed 57/11/72/58 respectively.
  • Browser orders, on 959c6a9: 10 cases with zero skips per order and 60 captures inspected. Orders: MCP→auth transports→agent files→Logs→Usage, and MCP→Logs→auth transports→Usage→agent files. Native worker/policy proof observes an allowed final marker and absence of a forbidden post-close marker; it is not a complete desktop/full-Gateway native chain.
  • MCP cleanup: 157 tests after three reproduced late-stderr failures. Worker stops: 33 tests after both retention cases failed. Earlier integration: 231 tests on its recorded overlay.

The acting lead directly inspected Codex 5af6979986a23fcd6bbeb1ef7b206cbc96e9a0a2, codex-rs/core/src/tasks/mod.rs:890–1025: cancellation notification, completion and abort cleanup are distinct events. Source review and dependency inspection do not certify protected runtime acceptance.

Remaining acceptance and follow-ups

The declared pathname/process/FD-metadata audit remains unaccepted. Historical coverage gaps and a verifier repair refused by its configured service remain unresolved. Acceptance must bind the final candidate and both browser orders; ordinary runtime success cannot substitute. No universal buffer-I/O, mmap, callback-purity, subsystem, or descendant-process quiescence claim is made.

The latest inspected ClawSweeper attempt, on ffeec174773a, stopped at its input scanner without a verdict. Its redacted diagnostic identifies two unverified URI literal_not_reviewed findings in base 65417dfc's immutable blob 2bac28122b940cddb40d5f534d1cc5eb8a16bcdf. The source SHA and path hash were verified: extensions/browser/src/browser/server-context.list-profiles.test.ts:430, an existing mocked loopback-CDP credential-redaction fixture. The trusted fixture-review owner must qualify it. The fixture and scanner policy remain unchanged, no manual retry was requested, and no final-head acceptance is inferred. The last completed review's description, validation and scope improvements are incorporated here.

CI on the preceding ffeec174773a head completed with 120 successful jobs and 12 skips. Its only failing test job was checks-node-compact-small-6, from the participant hook fixed above; the aggregate gate also failed. The earlier Node shutdown, Signal delivery, Settings layout, and both Windows jobs passed. The final-head run linked above passes all selected CI jobs, including the repaired participant shard and the aggregate gate.

Named follow-ups: explain the earlier isolated native fixture timeouts on this Mac (two unchanged 90-second deadlines without a child result; the final merged candidate now passes locally under the same limit, while the earlier Linux case passed in 13 seconds; no root-cause attribution for the timing difference); profile cold source plugin loading during configured-model normalization (about 292 seconds in CI versus 5.7 seconds after full build; dominant callee unmeasured); reproduce disabled-plugin normalization ordering; prove forced-failure child cleanup in the direct-stop fixture (successful teardown joins streams, failure hook sends SIGKILL without explicitly joining child close); attribute the nonfatal UI startup-JavaScript size advisory (342.2 KiB gzip versus 341.9 KiB) against pinned main.

The original incident's ambient operator-store impact remains unassessed. This task did not inspect or repair operator state; native proof used an owned secretless VM without operator mounts, instance-role credentials, Tailnet, or auth hydration.

@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review blocked

Automated review did not run, so no review verdict was produced.

Reason: The input-safety check rejected material in this revision. No detected value, path, or scanner output is reproduced here.

ClawSweeper will not retry this unchanged revision.

Next step: If this is a genuine credential, remove and rotate it. If it is an intentional test fixture, a maintainer must review and qualify it.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Sep 2, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 5:46 AM ET / 09:46 UTC.

ClawSweeper review

What this changes

This PR makes Gateway-owned WebSocket work reject new shutdown-era requests while draining already admitted work and connection cleanup before teardown.

Merge readiness

⛔ Blocked before merge - 6 items remain

Authority-chain proof required: the active PR adds a coherent received-work owner that current main lacks, but its declared exact-head browser and final-effect acceptance remains pending.

Priority: P2
Reviewed head: 959c6a960280c3f03fe9f62c12950d2595d016d4

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) PR readiness rating was derived from proof quality, review findings, security review, and reviewer confidence.
Proof confidence 🌊 off-meta tidepool Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Evidence reviewed 7 items Connection-work owner: The PR introduces the owner that records connection closures, drains admitted work, and surfaces cleanup failure after draining.
Shutdown admission boundary: WebSocket message handling marks shutdown-era frames as continuations and suppresses non-node frames before dispatch; method handling then limits continuations to pending owned work.
Lifecycle caller and drain: Gateway shutdown fences connection work in the close prelude and the startup-failure sequence requires its drain before later teardown.
Findings None None.
Security None None.

How this fits together

The Gateway accepts WebSocket requests and worker frames, executes them through request handlers, then shuts down shared runtime state. The new connection-work owner spans frame admission through socket cleanup so dependent state is not released early.

flowchart LR
  A[WebSocket requests and worker frames] --> B[Connection work owner]
  B --> C[Request and worker handlers]
  D[Gateway shutdown begins] --> E[Fence new work]
  E --> B
  B --> F[Drain admitted work and cleanup]
  F --> G[Release Gateway dependencies]
Loading

Before merge

  • Resolve merge risk (P1) - The change controls shutdown-era worker authority and dependency release; exact-head evidence has not yet shown that admitted work drains while forbidden post-close work cannot reach final effect.
  • Resolve merge risk (P1) - Reported production growth is substantial for a bug fix; the new owner is justified only if exact-head proof confirms that the existing request-entry lifetime cannot own this later connection-cleanup boundary.
  • Complete next step (P2) - Provide accepted exact-head proof that admitted work drains, forbidden post-close work cannot reach final effect, and the protected browser/metadata gate passes before merge.
  • Resolve review confidence - ClawSweeper must reach high confidence before merge readiness is known.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production versus test/support delta production +765/-47 (net +718); test/support +3902/-1002 (net +2900) The PR's reported accounting shows a material new lifecycle boundary, so exact-head evidence must justify the production expansion.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/gateway/device-scope-upgrade.ts, unknown-data-model-change: src/gateway/device-scope-upgrade.ts, unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Complete exact-head lifecycle acceptance (recommended)
    Demonstrate that pre-close admitted work drains and post-close work cannot produce a final effect, then complete the declared browser/metadata gate on the pinned head.
  2. Pause pending proof
    Keep the PR open until the exact-head proof can establish the shutdown authority and availability invariants.

Technical review

Best possible solution:

Retain the single connection-work owner, then complete exact-head lifecycle and browser/final-effect acceptance demonstrating both drain and refusal behavior before merge.

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

No: source and focused tests make the lifecycle scenario reproducible, but this read-only review did not execute a current-head failure or after-fix run.

Is this the best way to solve the issue?

Unclear: the owner-boundary design is coherent and avoids a downstream workaround, but exact-head final-effect evidence is still required to establish it as the best fix.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded Gateway reliability repair with meaningful shutdown impact but no demonstrated current user outage.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
  • remove P1: Current review triage priority is P2, so this older priority label is no longer current.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded Gateway reliability repair with meaningful shutdown impact but no demonstrated current user outage.
  • merge-risk: 🚨 security-boundary: The patch changes which worker/node continuation frames may proceed after shutdown begins.
  • merge-risk: 🚨 availability: The patch changes the ordering that drains received work before Gateway dependencies are released.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Evidence

Acceptance criteria:

  • [P1] Exact-head lifecycle trace proving admitted pre-close work drains.
  • [P1] Exact-head negative proof that forbidden post-close work cannot reach final effect.
  • [P1] Protected browser/metadata acceptance on the pinned PR head.

What I checked:

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.

  • Tighten the PR description with what changed, how it was validated, and any remaining risk.

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 (6 earlier review cycles)
  • reviewed 2026-09-02T08:14:52.061Z sha 8759df8 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T09:33:49.170Z sha 76934a7 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T15:16:01.516Z sha 45cc121 :: found issues before merge. :: [P1] Fence fresh worker frames when Gateway close begins
  • reviewed 2026-09-02T16:34:03.952Z sha cff270c :: needs real behavior proof before merge. :: [P1] Fence fresh worker frames once connection work starts closing
  • reviewed 2026-09-02T23:27:25.084Z sha b496fb9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-03T01:05:26.302Z sha b496fb9 :: needs real behavior proof before merge. :: none

@steipete
steipete force-pushed the steipete/gateway-lifetime-compact branch from 8759df8 to 76934a7 Compare September 2, 2026 09:22
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 2, 2026
@steipete
steipete marked this pull request as ready for review September 2, 2026 09:26
@steipete
steipete requested a review from a team as a code owner September 2, 2026 09:26
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 2, 2026
@steipete
steipete force-pushed the steipete/gateway-lifetime-compact branch from 76934a7 to 45cc121 Compare September 2, 2026 15:04
steipete added a commit that referenced this pull request Sep 2, 2026
Fence ingress without disconnecting the supervisor needed for worker cleanup,
then join received work before releasing the remaining Gateway dependencies.
Preserve exact pending-node authority during direct and restart shutdown.

Keep startup logging and sidecar acquisition owned independently of fail-fast
readiness, and retire published plugin services only through their actual owner.
Join portal cleanup before reporting sibling shutdown failures.

Record positive test-Gateway closure at its owner. Retain fixture state and
selectors after incomplete shutdown, including across module reload, without
confusing a post-close diagnostic with an unfinished producer. Cover that
boundary through an isolated real-Gateway counterfactual and regression.

Consolidate UI finalization with the shared QA cleanup owner and separate the
lazy handler registry from dispatch without changing loading or method order.
Derive handler families from typed descriptor rows and remove the old casts.

Follow-up repair for the state-lifetime boundary in #136145 and #136146.
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed P2 Normal backlog priority with limited blast radius. 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 2, 2026
@steipete
steipete force-pushed the steipete/gateway-lifetime-compact branch from 45cc121 to cff270c Compare September 2, 2026 16:16
Integrate main 65417df after
GitHub reported conflicts that prevented PR CI from starting.

Keep #137424's canonical agent validation cache and recreated-schema
repair. Selective fixture retirement clears only its released root,
including closed-path validation and unopened failure latches. A real
two-root regression fails on the global reset before the integration.

Keep #138482's three independent cold browser documents and joined
cleanup. Remove redundant request maps and phase tracking without
weakening startup-copy, network-error or provider-page assertions.

Preserve upstream exact Gateway resolver ownership for queued replies,
local-tool admission and dashboard builders enabled after startup.

Refs #136146, #136145. Protected metadata acceptance, the refused
ClawSweeper input review and final-head hosted CI remain separate gates.

Local verification on tree 9822ba9603385482b037d857a5e052205c545681:
441 passing tests across 16 files; four existing platform-specific skips.
This includes both real Node shutdown modes, agent recreation in one
Gateway, queued-reply restart recovery, 20 browser cases, and all eight
fixture lifecycle cases. The native subprocess finishes in 75.849s
under its unchanged 90s deadline. All 237 changed paths were verified.

Review also found a native UI context mock missing main's new pages()
diagnostic API. The original close-failure case reproduces replacement
of its body error by TypeError. An eight-line fixture correction models
the retained closed page; all 12 native UI ownership cases pass with
original assertions and deadlines. Final tree:
439fd8a.

Full applicable repository checks passed before the final fixture-only
correction; focused checks passed after it. Fresh independent Codex
review of the complete candidate finished all ten passes with zero
actionable P0-P2 findings, with the final source verified.
Wrap the participant suite teardown in a zero-argument callback. Vitest
passes TestContext to registered hooks; the reset helper now accepts an
optional root path for selective fixture retirement.

The full seven-case file reproduced four teardown failures before this
change and passes all seven afterward. Assertions and cleanup semantics
are unchanged. The callback audit found no other direct registrations.

Refs #136146, #136145.
@steipete
steipete merged commit 0d830e9 into main Sep 4, 2026
194 of 195 checks passed
@steipete
steipete deleted the steipete/gateway-lifetime-compact branch September 4, 2026 23:02
obviyus added a commit to NianJiuZst/openclaw that referenced this pull request Sep 4, 2026
Port the acquisition test from 0d830e9 (openclaw#136146). Preserve socket-close, server ownership, and selector assertions while joining disposable workers for intentionally retained raw acquisitions.
steipete added a commit that referenced this pull request Sep 5, 2026
Cancel pending reconnect and startup admission waits through the owning connection scope while retaining admitted work through completion. Share the admission wait lifecycle and cover abort/resume races.

Join child process closure before deleting fixture directories, await environment restoration, and align browser EOF proof with Windows process termination. Follow-up to #136146.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
…aw#138037)

Keep the complete awaited authentication callback inside the shared WebSocket acquisition owner. Roll back newly acquired servers before restoring selectors, preserve setup and cleanup errors independently, and capture the E2E helper config-path mutation. Extend native failure-boundary coverage without changing production runtime or timeout budgets. Builds on openclaw#137982 and openclaw#137924; fixture lifetime accounting remains with openclaw#136146.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
…136146)

* fix(gateway): keep received work inside its state lifetime

Join original WebSocket dispatch, cooperating refreshes and connection cleanup before releasing Gateway dependencies. Retire passive approval/question/run observers without inventing durable decisions, and preserve test state until native callbacks and first browser closes settle.

Remove the unused process-local approval implementation and forwarding adapters. The refactor removes 404 production lines from the initial repair while retaining boundary regressions and moving manager tests onto the real durable path.

Verified under enforced credential-free isolation: 2,143 distinct owner/native/process tests, a final 77-test rerun, changed gates, product/UI builds and scoped-clean Codex P0 review. Protected exact-order browser replay remains a pre-merge gate; historical incomplete audits are not acceptance.

* fix(gateway): join worker cleanup before closing transport

Fence ingress without disconnecting the supervisor needed for worker cleanup,
then join received work before releasing the remaining Gateway dependencies.
Preserve exact pending-node authority during direct and restart shutdown.

Keep startup logging and sidecar acquisition owned independently of fail-fast
readiness, and retire published plugin services only through their actual owner.
Join portal cleanup before reporting sibling shutdown failures.

Record positive test-Gateway closure at its owner. Retain fixture state and
selectors after incomplete shutdown, including across module reload, without
confusing a post-close diagnostic with an unfinished producer. Cover that
boundary through an isolated real-Gateway counterfactual and regression.

Consolidate UI finalization with the shared QA cleanup owner and separate the
lazy handler registry from dispatch without changing loading or method order.
Derive handler families from typed descriptor rows and remove the old casts.

Follow-up repair for the state-lifetime boundary in openclaw#136145 and openclaw#136146.

* fix(gateway): fence worker frames during ordinary close

Reject newly received worker frames once their connection generation starts closing, while retaining queued work and its completion owners. Cover the live-socket window through the real worker protocol and a checked synthetic node sink.

Synchronize the update-failure UI test with its intended Updates recovery navigation before reopening the Inbox.

Follow-up for openclaw#136146 (Gateway received-work lifetime), addressing the shutdown-admission gap from review.

* fix(browser): join SDK-initiated MCP transport cleanup

Route SDK initialization failure and transport close through the existing
Chrome MCP process owner before native close clears the child PID. Capture
the native closer separately so concurrent callers join one cleanup path
without recursion or losing descendant ownership.

Collect startup diagnostics after cleanup and stderr completion, while
never-spawned commands skip the unused pipe. Preserve cleanup failures and
the existing launch, environment, and process-group behavior. Exercise late
stderr, descendant cleanup, forced termination, ENOENT, and backpressure
through real subprocesses.

* fix(gateway): retain supervisors after worker shutdown failure

Require connection-dependent sidecars to stop successfully before draining their supervisor transports or releasing runtime dependencies. Cover public and startup-failure shutdown, retained-owner retry, and late sidecar registration.

* test(gateway): join policy writers after releasing handler gates

Preserve policy-revocation and response-order coverage under the received-work dispatcher completion contract. Retain all held calls and release/join them in finally so tests cannot wait on their own unreleased gates.

* fix(gateway): retain execution through required shutdown

Preserve early acknowledgements while joining original raw, typed, and
agent execution through final cleanup. Cancel this Gateway's runs before
the join, and fence late admission at controller publication.

Retain failed startup acquisitions and plugin cleanup owners, preserve both
startup and cleanup errors, and prevent CLI successors after incomplete
retirement. Keep deferred startup hooks and sentinel refresh in their owner.
Remove the monolithic close factory and redundant post-abort polling.

Declare compiled plugin dependencies for the full lifecycle fixture through
the existing pretest owner. Align the QA publishing reference with main.

Validated isolated before/after regressions, original-order execution,
startup/CLI/plugin suites, full build, types, lint, and Codex review.
The protected metadata audit remains unaccepted; this is not merge approval.

Refs openclaw#136145, openclaw#136146.

* test(agents): align Code Mode fixtures with main

Adopt the SessionManager fixture and structured-result classification from
openclaw#138238, preserving the attempted hidden namespace call and the checks that
neither the original preparer nor action executes. Remove redundant pass-through
mocks with the upstream fixture.

Both files match the successful upstream CI head ce42af5 exactly. Gateway
runtime code is unchanged; this resolves the parallel test-fix merge conflict.

* test(gateway): reuse tracked agent contexts

Replace three partial agent-handler contexts with the shared fixture. The missing
execution tracker threw after admission handoff and leaked session claims into
later continuation tests. Preserve their assertions, timers, and original order.

The complete 302-case file reproduces all six CI failures before this repair and
passes afterward in the same order. Type checks, type-aware lint, formatting,
and independent Codex review pass. No production code changes.

* test: fix gateway, Signal, and UI fixture lifetimes

Reset agent database handles, validation, and terminal latches only within
retired fixture roots before deleting or recreating their files. Preserve
ordinary runtime reopen behavior and unrelated roots.

Model the pending host question in Signal's partial-delivery fixture and
assert the accepted reaction binding. Use actual Settings navigation from
independent cold UI contexts so document reloads do not abort startup
scripts and masquerade as asset failures. Preserve existing assertions.

Reproduced the Node and Signal failures locally and the UI cancellation on
Linux. The Linux owner replay passes 30 tests across six files, the full
settings suite passes seven, and the final UI revision passes both cold
routes locally. Static checks and independent source review pass. The
isolated native fixture still times out on this Mac; Linux completes its
unchanged case in 13 seconds. Protected audit acceptance and final-head
hosted checks remain separate landing requirements for PR openclaw#136146.

* test(sessions): call database reset without hook context

Wrap the participant suite teardown in a zero-argument callback. Vitest
passes TestContext to registered hooks; the reset helper now accepts an
optional root path for selective fixture retirement.

The full seven-case file reproduced four teardown failures before this
change and passes all seven afterward. Assertions and cleanup semantics
are unchanged. The callback audit found no other direct registrations.

Refs openclaw#136146, openclaw#136145.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: signal Channel integration: signal cli CLI command changes docs Improvements or additions to documentation extensions: browser extensions: ollama gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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]: Gateway test state can be released before received work finishes

1 participant