Repository navigation
Conversation
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.
|
🦞👀 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: needs changes before merge. What this changesThis PR replaces agent-wide restart-recovery blocking with session-specific admission waits so reads and unrelated conversations can proceed. Example: agent:main:startup-resuming is recovering while agent:main:startup-healthy receives a message.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this maintainer-owned startup fix is useful, but bare session aliases bypass the new recovery barrier. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway startup discovers interrupted sessions, registers recovery waits with the database startup owner, and admits recovered and fresh inputs into the existing session queues. flowchart TD
A[Gateway startup] --> B[Recovery discovery]
B --> C[Database startup owner]
D[Incoming reads and turns] --> C
C --> E[Ready reads and unrelated sessions]
C --> F[Recovering session wait]
F --> G[Existing session queue]
Technical reviewBest possible solution: Use the existing canonical session-routing owner before recovery lookup so every supported address for a conversation joins the same wait. Do we have a high-confidence way to reproduce the issue? Current main visibly waits for recovery before unlocking input; source also establishes the introduced alias bypass without running target code. Is this the best way to solve the issue? Session-specific waits fit the existing startup owner and preserve the intended ordering contract once lookup uses the same canonical identity as session routing. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 11a13b63d492. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +138, Tests +312, Docs +7, Other +349. Total +806 across 35 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 9, 2026, 8:26 AM ET / 13:26 UTC. |
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.
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. |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 00ef8ccdb7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (sessionKey && options.cfg) { | ||
| const { canonicalizeMainSessionAlias } = await import("../config/sessions/main-session.js"); | ||
| sessionKey = canonicalizeMainSessionAlias({ cfg: options.cfg, agentId, sessionKey }); |
There was a problem hiding this comment.
Canonicalize ordinary session aliases before recovery lookup
When agent:main:resuming is recovering, a supported chat.send request with agentId: "main" and sessionKey: "resuming" bypasses this barrier: canonicalizeMainSessionAlias leaves ordinary bare keys unchanged, so the recovery map lookup for resuming finds nothing. The subsequent session loader resolves that same key to agent:main:resuming, and chat-send-input-dispatch.ts can durably persist the fresh input before recovery admits its resume and retained FIFO inputs. The later canonical-key wait during reply dispatch is too late to prevent that persistence. Resolve the key through the same canonical store-key owner used by the session loader before selecting the recovery promise.
AGENTS.md reference: AGENTS.md:L97-L97
Useful? React with 👍 / 👎.
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.
…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.
|
Landing note (maintainer review). Team r302 (2026-11-09 12:05Z) spent 8.9 s of readiness waiting for startup restart resume. It rejected 181 requests as startup UNAVAILABLE meanwhile (incl. 9 chat.send). Readiness and startup methods now unlock once resume discovery has prepared each marked session. Fresh turns wait only behind their own session's recovery, with per-session FIFO preserved across chat.send, agent routing, channels, cron and auto-reply. Owner-ready reads proceed immediately. Synthetic: ready phase 2,748 → 81 ms, startup UNAVAILABLE 156 → 0. |
) * 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
Gateway readiness and startup reads waited for every interrupted session's recovered input to enter its queue. Connected dashboards received repeated startup
UNAVAILABLEresponses even when their data owners were ready.User Impact
Readiness and owner-ready
models.list,mentions.list, andsessions.github.optionsnow proceed while interrupted sessions resume. Unrelated sessions can accept turns; fresh input for a recovering session waits behind its resumed turn and retained FIFO inputs. No runtime configuration or schema change is required.Why This Change Was Made
The existing database startup observation now owns waits keyed by physical agent and canonical session. Discovery installs them before startup unlock, and deferred preparation installs them before native write admission. Input entry points resolve their session and wait before reading mutable session state or persisting fresh input. The router's agent-wide recovery rejection is removed. Database readiness, live authority, failure settlement and shutdown stay with their existing owners.
Control UI already backs off startup failures from 500 ms through eight seconds (#190159); no UI runtime change was needed. Production code is net +136 lines for session completion/lifetime bookkeeping and the admission callers. The 316 added test lines have an exact per-change allocation under the documented policy; the shared scalar is unchanged.
Bare-key FIFO correction
The held P2 finding was real at
112c36ecd9b502117365f0d4f252175d6303df77: admission expanded main aliases but failed to qualify an ordinary bare session key. It could miss the recovery promise keyed by the canonical persisted session and let fresh input overtake resume. Admission now reusesresolveSessionStoreKeyfor requests carrying config and its existingcanonicalizeSessionKeyForAgenthelper for config-less channel/recovery paths. The separate normalization is removed; logical session identity remains separate from physical store ownership. All chat, agent-routing, command, channel, cron and auto-reply callers were checked.The existing real-Gateway regression holds recovery for
agent:main:startup-resuming, then sendschat.sendwithagentId: "main"andsessionKey: "startup-resuming". It fails on112c36ecbecause the fresh input is persisted before recovery is released, and passes with the repair. Readiness, the three reads, unrelated-session progress and resumed-before-fresh transcript/provider ordering remain covered. All 59 selected tests passed, including shared-store/main-alias/failure/cancellation and caller suites. Codex autoreview is scoped-clean through P2. The correction-scopepnpm check:changed --base 112c36ec --timedcompleted: production and all core-test typechecks, format, lint, database, boundary and architecture checks passed; its only failures were the same archived-changelog attribution and unusedauthorDisplayNameexport failures attributed below. This correction is production LOC-neutral and extends the existing regression by one line, covered by its exact allocation; it adds no test boot, config, schema or cache.The PR remains held and unmerged; auto-merge stays disabled. The performance measurements below are retained evidence from the earlier runtime head and were not rerun for this key-identity correction. Prior-head green CI is not claimed as correction-head proof.
Wrapper closure correction
The wrapper closure test passes on current main
b76460823ef0and reproduces the 159 missing-file failure ata12c5796. All 159 were reached through the canonical-resolver import added by that bare-key correction: four Gateway session modules and 155 protocol modules pulled in bysession-request-error.tsimporting the protocol barrel. The startup benchmark scripts were not the cause.The error adapter now imports the same
ErrorCodesanderrorShapevalues directly from their existing owners, keepingErrorShapetype-only. That removes 151 unnecessary protocol files from the new closure. The wrapper inventory explicitly adds the eight remaining runtime inputs. Both the failing dynamic-closure test and eager wrapper inventory test pass; 27 session-key/request-agent tests, production typechecks, targeted lint and formatting pass. Codex autoreview is scoped-clean through P2. No test assertions or workflow gates were weakened. This repair is production LOC −2, inventory +8; total PR production delta is now +136.ClawSweeper’s open P2 filed on
a859d606is the bare-session-key FIFO issue fixed bya12c5796; this closure repair preserves that fix. The actual prior UI log reaches Chromium tests:chat-transcript-geometry-updates.browser.test.tsx > holds deferred reader compensation without interrupting native scrollingexpected scroll position 510 and received 480. The FetchTimeout matches were printed checkout-helper source, not the terminal failure. This transcript-area failure is outside the authorized repair scope and is not claimed as inherited or fixed. Exact-head CI run 42659606400 is pending on1d9b42b618649334ce824f9325d430c5e986f956. Its build is queued forblacksmith-4vcpu-ubuntu-2404with no runner assigned; the tooling and UI shards are still queued. Green CI is not yet verified, and the PR must stay unmerged.Evidence
The real public-Gateway regression fails on exact parent
7c78826284047427953b13ed70006e24b4ec5709with readiness 503 while resume authority is held. It passes here, proving the three reads, unrelated-session progress, and resumed-before-fresh ordering in both provider requests and persisted transcript. Exact-key/session-ID regressions also fail on the parent before reading recovered state and pass here. Focused recovery, routing, startup, state, cron and transport tests, affected Chromium post-deploy tests, and the signed-in retained-input FIFO E2E passed.Acceptance: readiness must progress while resume admission is held, owner-ready reads must stop receiving startup refusals, all nine roots must recover, and same-session FIFO must hold. CPU and memory use are compared at a matched completion endpoint.
Five interleaved synthetic A/B pairs plus four unchanged-parent controls used 10,000 sessions across eight agents, a 35.093 GiB agent DB, 12.032 GiB shared state, 62,000 workspace files/1.100 GiB, 46 synthetic plugins, nine interrupted roots and 155 stale rows. Inference was local and synthetic; probes ran every 500 ms. Each successful boot resumed nine roots, skipped 155 stale rows, reached nine inference requests and shut down cleanly. CPU/RSS cover the same recovery, inference and maintenance endpoint.
The seven remaining responses were model-catalog revision retries. Initial A/A readiness was 22.063/19.726 s; closing controls were 20.164/20.286 s. CPU and RSS are near-neutral observations, not a resource-optimization claim. With five samples, p95 is the maximum. One failed candidate timing boot is retained separately, so the table is conditional on successful startup.
Workload:
node --import ./scripts/tsx.mjs scripts/bench-gateway-startup.ts --case teamBoot --team-scale --restart-sessions 9 --fixture-root <fixture> --entry <pinned-dist/entry.js> --gateway-runtime <node> --runs 1 --warmup 0. Both arms used matching production builds, fresh processes and disabled compile caches. Native qualification after each APFS clone was recorded separately and excluded from startup. Cloning also invalidated credential bindings, so both arms performed existing credential repair/integrity work. APFS restored-state measurements do not predict an exact production btrfs saving. These measurements use runtime00ef8ccd; the subsequent bare-key identity correction was not benchmarked again. Saved measured-runtime artifacts were restored and hash-verified after the earlier test builds.Allocation proof is partial: two parent controls sampled 4.563/4.538 GB of main-isolate allocation volume; two paired parents sampled 4.526/4.525 GB and candidates 4.476/4.475 GB. The candidate observations encountered host contention and a seven-minute post-qualification delay. A separately labeled immediate-start repeat sampled 4.486 GB and removed the long pre-Gateway delay. The original observations remain recorded; there is no completed five-pair allocation or precise allocation-improvement claim. The parent CPU profile covers 31 isolates; candidate profiling failed before bind, and a final qualified diagnostic failed native temp-root setup. Complete candidate post-resume CPU-profile coverage is unavailable.
Checks and Remaining Limitations
pnpm check:changedran fully; own type errors were corrected and affected checks rerun. Core test types, scripts types, targeted lint/format and the exact test-line budget pass. SQLite T1 calls remain 167 → 167, with no portability violations or runtime import cycles. Codex autoreview of the production change and later corrections is clean through P2.CI exposed and this PR repairs missing wrapper source dependencies, the Workshop mock's missing
onPreparedcallback, and two older fixture mismatches. The signed-in FIFO fixture needed its existing graceful-stop option (#192444). The finalizer fixture still expected state refusal despite #195902 deliberately preserving accepted-finalizer access; the exact parent reproduces that assertion mismatch. The existing owner test passes for both admission during drain and refusal after host closure. Both Workshop cases pass on the pinned Bun runtime; its following registry-change error did not recur.The focused macOS finalizer E2E remains locally red on unchanged shutdown checks: SIGTERM took 11.694 s against ten (the exact parent also took 10.659 s), and a later managed stop stalled in final shared-state retirement after the clean-shutdown log. These are unresolved observations, not claimed fixed or attributed as inherited. Thresholds remain unchanged. The earlier Linux CI run failed the stale finalizer expectation but not those timing assertions. Prior-head CI run 42641889584 passed on
112c36ecd9b502117365f0d4f252175d6303df77, includingopenclaw/ci-gate.Separate main defects have exact-parent reproduction and inspected introducing changes: archived changelog attribution (#194364,
266a7aa0fe69), dead dashboard export (#194455,cde34f111b4d), and pre-bind SQLite cold admission (#157413,8b16e5328ecd). In the latter, successful preparation exhausts a five-second budget, leaving the first lease write withbusyTimeoutMs=0against a concurrent writer. Failed boots on both arms remain in the evidence; no timeout policy, schema, or filesystem safety guard was changed to bypass them.This PR remains held for review of the correction and must stay unmerged; auto-merge is disabled.