Repository navigation
Conversation
Let the SDK host drain own the shared-state fence after received work and custody settle. Preserve terminal cleanup failures as shutdown failures rather than sending them through startup recovery. No retry, timeout, schema, or configuration changes.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Landing note (maintainer review): Team r300's planned shutdown at 2026-11-09 10:03Z exited 1 because an accepted connection finalizer settled after the restart-drain signal had already closed plugin shared-state admission. Its worktree run lease release failed three times ("plugin shared-state admission is closed"), custody was retained, and the failure surfaced through the startup error path ("Gateway failed to start"). The SDK resource host now fences shared-state work only when its own close runs, after ingress/scheduler cancellation and accepted finalizers have drained. Terminal cleanup failures are classified as shutdown failures, not startup failures. Production −1 line; synthetic trials 0/5 → 5/5 clean closes; exact-head CI green. |
…ners Signal discovery completion from the Workshop startup mock. Expect accepted finalizers to retain state access during drain, matching the documented change in #195902, while preserving terminal refusal and shutdown timing checks. Extend the exact per-change test allocation by the three added mock lines.
* fix(gateway): serve startup reads while sessions resume Install per-session recovery admission before readiness unlock so fresh turns preserve resume and retained-input ordering without holding unrelated sessions. Let catalog reads use owner readiness and remove the agent-wide recovery rejection. Include synthetic restart benchmarking and real Gateway ordering regressions. * test(gateway): use graceful shutdown for retained-input restart proof The signed-in restart fixture introduced in #192444 canceled process-tree custody while expecting a clean Gateway exit. Select the existing bounded graceful-stop path so the unchanged exit, marker, authority and FIFO assertions exercise restart recovery. The original failure reproduces on parent 7c78826; the corrected full flow passes. * chore(gateway): complete startup admission proof inventories Include the two session-key modules reached by startup admission in the materialized PR wrapper. Allocate exactly 312 regression-test lines for distinct Gateway readiness/FIFO, session-ID hydration, and shared-store admission contracts; leave the shared test budget scalar unchanged. * test(gateway): align startup and finalizer fixtures with lifecycle owners Signal discovery completion from the Workshop startup mock. Expect accepted finalizers to retain state access during drain, matching the documented change in #195902, while preserving terminal refusal and shutdown timing checks. Extend the exact per-change test allocation by the three added mock lines. * fix(gateway): canonicalize session keys before recovery admission * fix(gateway): keep canonical session routing wrapper closure complete
…penclaw#195902) * fix(gateway): preserve state admission through shutdown finalizers Let the SDK host drain own the shared-state fence after received work and custody settle. Preserve terminal cleanup failures as shutdown failures rather than sending them through startup recovery. No retry, timeout, schema, or configuration changes. * test(gateway): await shutdown fixture cleanup directly
) * fix(gateway): serve startup reads while sessions resume Install per-session recovery admission before readiness unlock so fresh turns preserve resume and retained-input ordering without holding unrelated sessions. Let catalog reads use owner readiness and remove the agent-wide recovery rejection. Include synthetic restart benchmarking and real Gateway ordering regressions. * test(gateway): use graceful shutdown for retained-input restart proof The signed-in restart fixture introduced in openclaw#192444 canceled process-tree custody while expecting a clean Gateway exit. Select the existing bounded graceful-stop path so the unchanged exit, marker, authority and FIFO assertions exercise restart recovery. The original failure reproduces on parent 0d97c79; the corrected full flow passes. * chore(gateway): complete startup admission proof inventories Include the two session-key modules reached by startup admission in the materialized PR wrapper. Allocate exactly 312 regression-test lines for distinct Gateway readiness/FIFO, session-ID hydration, and shared-store admission contracts; leave the shared test budget scalar unchanged. * test(gateway): align startup and finalizer fixtures with lifecycle owners Signal discovery completion from the Workshop startup mock. Expect accepted finalizers to retain state access during drain, matching the documented change in openclaw#195902, while preserving terminal refusal and shutdown timing checks. Extend the exact per-change test allocation by the three added mock lines. * fix(gateway): canonicalize session keys before recovery admission * fix(gateway): keep canonical session routing wrapper closure complete
What Problem This Solves
Fixes planned Gateway restarts exiting with failure and printing “Gateway failed to start” when accepted plugin-origin work still needs to release a worktree lease or persist subagent completion.
User Impact
Accepted finalizers can finish their state writes during shutdown. Genuine cleanup failures still fail and are reported as shutdown failures. No configuration, schema, timeout, retry, or recovery-data changes.
Why This Change Was Made
The close plan already joins received connection work and run-end custody before draining the SDK host. The host additionally fenced state access on the earlier restart and scheduler cancellation signals, closing the store's admission underneath those finalizers. Remove those premature checks; the SDK host's existing drain/close remains the canonical fence and joins accepted state operations before retirement.
Final shared-state cleanup errors now pass through the run loop's existing shutdown classifier. Actual startup failures still propagate with their cleanup errors. Retained or uncertain lease custody is not silently reported as a successful release.
Production LOC is net −1. The regressions add 109 net test lines, allocated specifically for real lease/Git custody, plugin-origin subagent settle persistence, and CLI cleanup error classification; the subagent proof extends its existing cohort fixture. No UI-imported modules changed.
Evidence
pnpm check:changed --base 35523ba3e4ff: completed all planned checks. Two local findings (line-cap growth and an async test cleanup callback) were repaired; focused line-cap/lint rechecks and the affected regression pass. Core/test typechecks, state ratchets, format, dead-export scans, and other planned gates passed. The unrelated changelog-attribution failure reproduces with the exact parent's changelog bytes and identical checker (20 identical violations), introduced by266a7aa0fe69/ fix(release): align attribution gate with human credit policy #194364. It remains an unresolved main regression.Synthetic Linux/btrfs owner proof used 5,000 session rows, a 35.11 GiB admitted agent database, and 62,000 workspace files / 1.1 GB. Five serial AB/BA pairs with the same 300 ms hold:
Baseline A/A wall: 394.197 / 426.351 ms; CPU: 22.358 / 42.246 ms. The candidate does the durable delete and Git unlock refused by the baseline; additional CPU/allocation pays for successful cleanup. This is correctness proof, not a general performance claim.
Limits: real owner composition, no whole-Gateway/model/systemd test. Database size includes fixture-only zero-BLOB padding; 140 sessions contain transcript payloads. The large agent DB was open, while lease cleanup touched shared SQLite and a small linked checkout; the 62k-file inventory was present but unscanned. btrfs ran in a Linux VM over an APFS-backed loop, not a production block device. CPU includes worker threads but excludes child Git; allocation covers the main isolate. Setup/admission were outside timing. No real user data was copied. Task container, loop, and large fixture were removed.