Repository navigation
fix(gateway): wait for chat recovery before reporting ready - #180924
Conversation
|
🦞👀 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 SummaryThis 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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR makes Gateway readiness and the macOS startup waiter follow the existing fresh-chat recovery gate. Example: A client sends chat immediately after Gateway readiness succeeds during restart recovery.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR fixes a current readiness mismatch, and the introduced hunks contain no actionable correctness or security finding. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Gateway kernel owns startup admission; HTTP probes and the health RPC expose its readiness, which the macOS process manager consumes before reporting the Gateway usable. flowchart TD
A[Startup recovery] --> B[Kernel chat admission]
B --> C[Readiness checker]
C --> D[HTTP ready probe]
C --> E[Health RPC]
E --> F[macOS startup waiter]
Technical reviewBest possible solution: Use the kernel’s existing chat admission state for readiness and let the macOS waiter consume its live coreReady projection. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the mismatch between readiness and chat admission, and the PR records repeated failing baseline requests; this read-only review did not execute target code. Is this the best way to solve the issue? The patch fixes the reporting boundary through existing owners, preserves recovery ordering and startup deadlines, and retains compatibility with Gateways that omit coreReady. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 054ac7af1d04. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +44, Tests +106, Docs +11. Total +161 across 16 files. Added test files: 0. View PR surface stats
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 October 22, 2026, 3:47 PM ET / 19:47 UTC. |
|
Merged via squash.
|
…#180924) * fix(gateway): wait for chat recovery before reporting ready * test(gateway): await readiness before workspace reload * test(gateway): synchronize workspace setup with ready event
Main 784d9ce conflicted in two files. server-methods/health.ts: keep this branch's respondFresh path and runtime-config client filter, and add main's live coreReady (openclaw#180924) to both the cached and the fresh response objects inside the filter. server/health-state.ts: keep this branch's config-key fenced collection loop, and pass main's cronStorePath (openclaw#180875) to its collectGatewayHealthSnapshot call.
What Problem This Solves
Current main can report Gateway ready while rejecting the native app's first
chat.sendwithUNAVAILABLE/startup-sidecars. The startup recovery gate intentionally blocks new chat, but neither/readyznor the app's successful-healthwaiter covered that gate.User Impact
The app now waits until the Gateway can accept fresh chat. Saved-input recovery keeps its ordering, and broken optional channels do not prevent the app from attaching for repair.
The Gateway bundled with released macOS 2026.10.5 (
1b58cb9a1b4f4353e1add63c8506db4d890962e8) predates this chat-admission gate and unlocks all startup methods before sidecar readiness. Its older client still treats successful health as ready, so attaching that client to a current-main Gateway can hit the reproduced failure until the app is updated. The originally reported standaloneSessionMetadataUnavailableError: schema-missingremains unreproduced; this PR does not claim to fix that exception and changes no session schema or standalone code.Why This Change Was Made
Readiness now consumes the kernel's existing
chat.sendadmission set. Startup completion remains separate so it can release recovery's background-work barrier without a cycle. The kernel emits the ready log and trace once when recovery opens admission. ThehealthRPC publishes livecoreReady, and the macOS waiter consumes it using its existing bounded startup wait. Older Gateways that omit the field retain their existing compatibility behavior. No sleep or first-turn retry was added.Evidence
Baseline loose main (
9ccfff0640302a1d4d8e074ef85bd285063f14b6): 40/40 immediate app-stylehealth → chat.sendrequests failed (20 fresh + 20 existing profiles), and all 40 separate five-second controls succeeded./readyz → chat.sendalso failed 2/2;/readyz → agentpassed 40/40, and native Codex controls passed 8/8. The preserved original emitted-JS artifact passed 40/40 native/CLI replays. No attempt reproducedschema-missing.Final production-code proof at
1998d40b210b0848a74a8c6cb486b5ab2d48cf81(production bytes unchanged in final head2811ae1f8b6bc24950727bc235989360ace292e1): 40/40 app-stylehealth.coreReady → chat.sendand 40/40/readyz → chat.sendpassed, each with 20 fresh + 20 existing profiles. Native Codexhealth.coreReady → chat.sendpassed 4/4 (2 fresh + 2 existing), with actual app-server terminal receipts. Every request completed with its expected reply marker; no first-turn retries or forced shutdowns. Wire sends occurred 0.13–0.53 ms after the first observed ready result on the connected socket. Readiness polling and connection establishment are not first-turn retries.Final-head required PR CI: passed, 81/81 jobs completed, run 39844299167. Supplemental isolated macOS proof uses trusted main workflow
bdd736b63cdd623ea6caf62618b3c2d2314bfec8with the exact candidate astarget_ref: https://github.com/openclaw/openclaw/actions/runs/39844320679 . This supplemental run does not replace required PR CI.Focused owner regressions fail before the fix and pass afterward. Commands use
pnpm test <file> --maxWorkers=1:src/gateway/server/readiness.test.tssrc/gateway/server-kernel.test.tssrc/gateway/server-startup-observers.test.tssrc/gateway/server-methods/health.owner-routing.test.tssrc/gateway/server-request-context.test.tssrc/gateway/server-agent-database-startup.test.tssrc/gateway/server-startup-workspace-readiness.test.ts(failed CI cases)The database matrix ran before the final logging-only relocation; the final kernel test verifies actual shared admission, startup/readiness separation, accepted chat, and exactly one ready log/trace. Health tests cover cached and fresh responses. Swift parse/format/source lint, native localization verification, and protocol generation/determinism checks pass. At the final production head, all six native waiter regression cases passed in 0.096 s in macOS test job 120065456501. Two native service-custody failures matched scheduled main run 39832966696: absent-service pause and named-profile stop both dispatched an unexpected
uninstall. Their owning stop paths and fixtures are unchanged. Final-head macOS package build and both macOS Node shards passed. The final-head Swift run reports exactly the same four assertions in those two service-custody tests as scheduled main; no additional native failures. The supplemental full run remains in progress and is not green. Four independent Codex P0–P2 reviews across the implementation and test corrections found no actionable issues.pnpm check:changedcompleted in 573.029 s. Changed-file line-cap, formatting, core/test typechecks, targeted lint, and the other selected guards pass. Three aggregate checks remain red with exact matches on cleanorigin/main(df27c0c): max-lines suppressions (3 unchanged UI files), core test-root budgets (gateway-root 725/720; infra 730/720), and unused exports (42 production / 58 full-tree entries). None of those paths overlap the changed files; no test roots were added. The supplemental full run remains separate from the green required PR gate.CI on the first head exposed two workspace-reload tests that treated
startupSettledas traffic readiness. Both reproduced locally. The first correction used a readiness poll, which hit Vitest's default one-second polling deadline in qualification CI. The final fixture awaits the readiness owner's event with the test abort signal; both cases pass in 25.43 s. All migration/configuration assertions remain intact, and production code is unchanged by these fixture corrections.Prior-head PR run 39840804132 had an Android fake-transport retirement timeout; the entire Android tree and its workflow inputs were identical to its tested main parent. The prior native qualification also exposed existing deadcode dependency/file checks, whose complete failing sets match clean main. These historical failures are retained as failures, not claimed green; final-head results are linked above.
The supplemental full graph has also exposed unchanged baseline failures. Focused clean-main Node replays reproduce the cron root-drain count, Decision cold-load deadline, aborted-runtime signal identity, finalized-statement test observations, and Gateway projection/RFB assertions. The unrelated UI failures use unchanged UI/build inputs: a stale Activity chunk filename expectation, a synthetic RTL geometry check, and a paste-preview timing check. Their failures are retained; they are not claimed green or fixed by this PR.