Repository navigation
fix(gateway): keep listener live when restart state is invalid - #120966
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Land-ready at Root cause: config-reload restart admission preflighted candidate secrets but not fresh successor-owned database state. A healthy process could therefore close its listener, reset task runtime ownership, and only then discover that a fresh shared-state/agent database open was invalid. The fix checks current persisted database readiness through fresh read-only maintenance contracts before secrets preparation or signal emission. Failed readiness remains on the existing retry owner; no SIGUSR1, supervisor handoff, task-registry reload, or replacement listener occurs until repair succeeds. Proof:
Production LOC: +86/-8 (net +78), justified by the new restart safety/ownership boundary and shared-state plus registered-agent sibling coverage. Tests: +182/-12. Known proof gaps: none. |
|
Merged via squash.
|
…law#120966) * fix(gateway): preflight database state before reload * fix(gateway): wire managed restart readiness
Related: #35862
What Problem This Solves
Fixes an issue where a config write that required a Gateway restart could close a healthy listener even when the persisted SQLite state could not be reopened by the successor lifecycle. The restart then failed before returning a server handle, leaving the process alive without a listener and preventing an external supervisor from restoring service cleanly.
Why This Change Was Made
Config-reload restart admission now performs a fresh, read-only database readiness check before resolving config secrets or emitting the restart signal. It verifies the canonical shared-state schema and every registered agent database with the same maintenance-owned contracts startup relies on. If readiness fails, the existing bounded retry owner keeps the current lifecycle serving, logs Doctor guidance, and retries without signaling, resetting task registries, writing a supervisor handoff, or starting a duplicate listener.
The readiness loader stays behind a lazy runtime boundary so this safety check does not expand the cold Gateway startup import graph. This is AI-assisted work; the implementation and owner boundaries were inspected directly.
User Impact
Operators keep a reachable Gateway when a restart-required config change coincides with noncanonical persisted database state. After
openclaw doctor --fixrepairs the state, the already-owned retry can proceed normally.Evidence
check:changed: formatting, max-lines, dependency/architecture guards, dead-code scans, production/test typechecks, lint, database-first guards, and import cycles passed.