Repository navigation
fix(gateway): skip restart sentinel for hot-applied config writes - #144764
wangyan2026 wants to merge 2 commits into
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. |
03f5041 to
c7b0f92
Compare
|
Codex review: needs maintainer review before merge. What this changesPersist restart sentinels and include Doctor hints only when a config write requires a Gateway restart. Example: Change agents.defaults.model from old-model to new-model while the Gateway hot-applies config.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current Gateway bug at its producer, preserves legitimate restart notices, and has sufficient Gateway protocol proof with green exact-head CI. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway config.patch and config.apply handlers classify committed changes, persist restart notices through the shared-state worker, and return an acknowledgement; startup consumes pending notices. flowchart TD
A[Config RPC] --> B[Commit and apply config]
B --> C[Existing restart classification]
C --> D[Hot apply acknowledgement]
C --> E[Worker sentinel persistence]
E --> F[Startup notice consumer]
Technical reviewBest possible solution: Keep the existing config-write owner’s requiresRestart gate while preserving restart-required and update sentinel handling. Do we have a high-confidence way to reproduce the issue? Current-main source shows hot writes creating a sentinel that startup later consumes; the linked issue supplies affected-release observations, but no target code was executed during this review. Is this the best way to solve the issue? The smallest complete fix is to prevent irrelevant notices at the existing producer using its established restart classification. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 87fe64a3f50e. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +2, Tests +230. Total +232 across 5 files. Added test files: 1. 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 HistoryReview history (10 earlier review cycles; latest 8 shown)
Reviewed October 19, 2026, 9:40 PM ET / October 20, 2026, 01:40 UTC (Revision 11). |
c7b0f92 to
28bebd5
Compare
d266aa9 to
7702b23
Compare
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
af90081 to
90c549f
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
87068c4 to
82f617e
Compare
82f617e to
a4247ef
Compare
Related to #144063
What Problem This Solves
A hot-applied
config.patch(e.g.agents.defaults.model) requires no Gateway restart, butresolveGatewayConfigRestartWriteResultpersisted a restart sentinel unconditionally. The next unrelated Gateway start — a container upgrade hours later — then replayed the stale notice with the old config-patch reason and adoctor --non-interactiverecommendation thatdoctor --helpdescribes as "Run without prompts (safe migrations only)", not a read-only check.Why This Change Was Made
The restart sentinel is now persisted only when the config write actually requires a Gateway restart.
resolveGatewayConfigRestartWriteResultgatestryWriteRestartSentinelPayloadonrestartRequirement.requiresRestart. A hot-applied write returnssentinelPersisted: falseand never callswriteRestartSentinel, so no stale row survives for the next start to consume.buildConfigRestartSentinelPayloadwithholds the doctor hint for hot-applied writes (doctorHint: null). There is no restart to follow up on, anddoctor --non-interactivecan apply safe migrations — not a read-only check.gateway.port,reload.mode: off,plan.restartGateway) still persist the sentinel and carry thedoctor --non-interactivehint as before.loadRestartSentinelStartupTask) is unchanged. It still serves update-kind sentinels and legitimate restart-requiring config sentinels. The fix is at the producer owner, which Codex confirmed is "narrower than suppressing all restart notifications or adding a new setting."formatDoctorNonInteractiveHintis unchanged. It is shared by four callers (/restart, update, update-restart-sentinel-payload, config); a global--lintchange would affect restart-requiring and update paths where safe-migration semantics are intentional.User Impact
Owners no longer receive a stale "Gateway restart config-patch ok" notice on an unrelated later Gateway start after a hot-applied config change. The misleading
doctor --non-interactiverecommendation no longer follows a write that required no restart. Restart-requiring config writes are unaffected.Evidence
Current main persists the restart sentinel for every
config.patch/config.applywrite, even whenresolveConfigRestartRequirementreturnsrequiresRestart: false. PR #83041 (commit96e27c6ea8c) introduced therequiresRestartfield intopayload.statsbut did not connect it to the persistence gate. Codex review (2026-09-10) confirmed: "a successful hot-applicable config.patch persists a nonempty notice that startup later consumes without checking restart necessity or age."Exact head gates persistence on
requiresRestart. Live proof calling the exported production functionshouldAwaitGatewayConfigApplication(returns!requiresRestart):Regression tests verify the gate and the conditional doctor hint (mocked sentinel persistence):
The hot-applied test asserts
sentinelPersisted === false,writeRestartSentinelnot called, anddoctorHint === null. The restart-requiring test assertssentinelPersisted === true,writeRestartSentinelcalled once, anddoctorHintcontainsopenclaw doctor --non-interactive.Real persistence proof (no mocks on
writeRestartSentinel; real temp SQLite state DB viaOPENCLAW_STATE_DIR):The hot-applied integration test reads the real
gateway_restart_sentineltable afterresolveGatewayConfigRestartWriteResultand asserts thecurrentrow isundefined— no stale row survives for a later startup to consume. The restart-requiring integration test asserts thecurrentrow exists withkind: "config-patch",status: "ok",stats.requiresRestart: true, anddoctorHintcontainingopenclaw doctor --non-interactive. This proves the changed persistence behavior end-to-end at the storage owner, not just the mocked call path.Config-write/startup flow proof (real Gateway + config.patch RPC + DB + startup consumer input):
This exercises the full flow: a real
startGatewayServerCoreGateway receivesconfig.patchover WebSocket, the producer gates persistence onrequiresRestart, thegateway_restart_sentinelSQLite table reflects the gate, andreadRestartSentinel()— the input toloadRestartSentinelStartupTaskon the next Gateway start — returnsnullfor hot-applied writes (no startup task, no stale notice) and a payload for restart-requiring writes (startup task preserved).Adjacent sentinel suites pass with no regressions:
The
server.config-policy-response.test.tssuite (4 cases covering token/origin revocation policy-close ordering) was adapted: the pre-acknowledgement hold moved from thewriteRestartSentinelspy to areplaceConfigFilespy. Hot-applied writes skip sentinel persistence (#144063), so the sentinel spy no longer fires for them —replaceConfigFileis awaited before the RPC acknowledgement incommitGatewayConfigWriteand runs for both write kinds, preserving the barrier that keepspeer.closed,writer.didClose(), andstaleReadassertions deterministic before the writer's socket is retired. TherequiresRestartassertion moved to the ack'ssentinel.payloadwhere it is always available. All 4 cases pass.Production code is net +11 lines. The growth gates sentinel persistence on the existing
requiresRestartclassification and makes the doctor hint conditional. Tests are net +219 lines across three files (mocked unit tests, real-persistence integration test, policy-close ordering adaptation). Formatting (oxfmt --check) andgit diff --checkpass.Preexisting unrelated CI failure
The
checks-node-core-test-nondist-shardreported one failure inextensions/memory-core/src/memory/manager-temporal-ranking.test.ts:156— the test asserts FTSavailable: falsebut the runtime reportsavailable: true. This PR does not touchextensions/memory-core/or any memory/FTS code path; the changed files are all undersrc/gateway/server-methods/andsrc/gateway/server.config-policy-response.test.ts. This failure is preexisting on main and unrelated to this PR.What was not tested
Full Gateway runtime with a real Telegram channel across a container upgrade (the issue's exact 14-hour delivery path) was not exercised. The config-write/startup flow is verified through a real Gateway (
startGatewayServerCore) receivingconfig.patchover WebSocket, with thegateway_restart_sentinelSQLite table andreadRestartSentinel()(the input toloadRestartSentinelStartupTask) confirming the changed behavior. TheformatDoctorNonInteractiveHintglobal function is unchanged.Why Telegram Test Server E2E was not provided
The
proof: telegram-e2elabel requests Telegram Test Server proof, but this is not feasible for an external contributor and is not the right boundary for this fix:Credential gate: AGENTS.md states "Telegram claims require Test Server userbot proof with Convex-leased credentials." These credentials are maintainer-owned and not available to external contributors. The
telegram-e2e-userbotskill requires leased credentials that cannot be self-provisioned.Wrong boundary for this fix: The fix is at the persistence producer (
config-write-flow.ts), not the Telegram delivery layer. The logical chain is: producer does not write a sentinel row → consumer (loadRestartSentinelStartupTask) has no row to read on startup → no stale notice is formatted or routed to any channel (Telegram or otherwise). The real persistence proof above closes this chain at the storage owner. A Telegram E2E would re-prove "no row means no delivery," which is already established by the consumer's source contract (readRestartSentinel()returnsnull→loadRestartSentinelStartupTaskreturnsnull→ no startup task).Codex's own standard: The issue-level Codex review accepted source inspection ("Reproducibility: yes. by source inspection... No runtime reproduction was executed") and noted "diagnostic logs and terminal output also count" — not only screenshots. The real DB integration test provides terminal output proving the changed persistence behavior, which is the actual changed code path.
Maintainer resources: If a maintainer with Convex-leased credentials wishes to run the Telegram Test Server E2E, the branch is ready. The scenario would be:
config.patchagents.defaults.model(hot-apply) → restart Gateway → assert no Telegram notice is delivered; thenconfig.patchgateway.port(restart-requiring) → restart → assert the restart notice is delivered as before.AI Assistance 🤖
Risks and Mitigations
Highest-risk area: Restart sentinel persistence for config writes — a regression here could either re-introduce stale notices (if gate is removed) or suppress legitimate restart notices (if gate is too broad).
Mitigation: The gate is strictly
restartRequirement.requiresRestart ? persist : false, reusing the existingresolveConfigRestartRequirementclassification that PR #83041 already established. Restart-requiring writes still persist. Two regression tests assert both branches. Adjacent sentinel suites pass with no regressions.Compatibility impact: No breaking change. Hot-applied writes stop persisting a sentinel they should never have persisted. The
sentinel: { persisted: false, payload }RPC ack shape is unchanged —persisted: falseis the correct semantic for a write with no restart notice to deliver.Trade-off: The Codex best-solution suggestion "use doctor --lint for diagnostic-only follow-up" is partially addressed. Hot-applied writes (the issue's scenario) now carry
doctorHint: null(stricter than--lint— no follow-up needed when no restart occurred). Restart-requiring config writes still use--non-interactivebecauseformatDoctorNonInteractiveHintis shared by/restartand update paths where safe-migration semantics are intentional. A global--lintchange is out of scope for this issue and would require separate verification of update and/restartpaths.