Skip to content

fix(gateway): promote hot-mode reload-drop to error with remediation - #89578

Closed
amittell wants to merge 1 commit into
openclaw:mainfrom
amittell:fix/config-reload-deferred-error
Closed

amittell wants to merge 1 commit into
openclaw:mainfrom
amittell:fix/config-reload-deferred-error

Conversation

@amittell

@amittell amittell commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

In hot reload mode, when a config write touches any restart-required path, the runtime drops the whole reload plan behind a single log.warn. Operators routinely miss this in log aggregator UIs and the runtime quietly serves a stale snapshot until a manual restart.

Promote the log line to error, include the remediation command verbatim, and add a focused regression test.

Real environment tested

This was the production failure mode that motivated the PR. On a deployed gateway, openclaw doctor --fix migrated agents.defaults.models keys from legacy ids to canonical ids (a hot-reloadable change on its own) at the same time as renaming auth.profiles.* keys (restart-required). The auth-profile rename forced the whole plan to be classified as restart-required; in hot mode the whole plan was dropped with a single log.warn. The in-process agent kept resolving the legacy model id for ~4 hours, every Telegram turn aborted with FailoverError: Unknown model: ..., and the only operator-visible signal was admin DMs getting a canned agent failed reply while group messages silently dropped. launchctl kickstart -k of the gateway recovered immediately because the disk config was already correct.

Behavior addressed: hot mode silent config staleness when a restart-required key is in the same write as hot-reloadable keys.

Real environment tested: deployed gateway (macOS, supervised via launchd, hot reload mode), Codex plugin externalized in v2026.6.2, agents.defaults.models and auth.profiles.* renamed in the same doctor --fix change.

Exact steps or command run after this patch:

node scripts/run-vitest.mjs src/gateway/config-reload.test.ts -t "logs an error with remediation"
node scripts/run-vitest.mjs src/gateway/config-reload.test.ts

Evidence after fix:

RUN  v4.1.7 /private/tmp/hot-reload-pr
Test Files  1 passed (1)
Tests  79 passed (79)
Duration  931ms

Mutation-verified: reverting the log.warn -> log.error promotion fails the new test on harness.log.warn was not called.

Observed result after fix: the existing log line is now error level and reads:

[error] config reload requires gateway restart; hot mode ignoring (gateway.port). Run `openclaw gateway restart` to apply these changes.

A level=ERROR alert rule on the gateway log stream will fire on this immediately, giving the operator a real signal instead of a buried warn line. The remediation command is inlined so the operator does not have to look it up.

What was not tested: this PR does not change the policy of dropping the whole plan when restart-required keys are present. Partitioning the plan and applying only hot-reloadable subsets would require key-dependency analysis and is intentionally out of scope.

Verification

  • pnpm test src/gateway/config-reload.test.ts (79 passed locally)
  • oxfmt --check clean on both modified files
  • oxlint clean on both modified files
  • Mutation test: reverting the change makes the new test fail

When the gateway runs in hot reload mode and a config write touches any
restart-required path, the whole plan is dropped behind a single log.warn.
Operators routinely miss this in log aggregator UIs and the runtime quietly
serves a stale snapshot until manually restarted. Observed in production:
`openclaw doctor --fix` migrated agents.defaults.models keys correctly but
the auth.profiles rename in the same change set forced restart-required;
in-memory agent kept resolving the old model id, every turn failed model
lookup for 4 hours before manual launchctl kickstart -k recovered.

Promote the log line to error so level=ERROR alert rules and Loki queries
catch it, and include the remediation command verbatim so the operator does
not have to look it up. Add a focused regression test that fakes hot mode,
emits a restart-required watcher change, and asserts the new error message
shape plus the absence of any hot-reload or restart calls.

Mutation-verified: reverting to log.warn fails the new test on the
'log.warn was not called' expectation.
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 2, 2026
@clawsweeper

clawsweeper Bot commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 2, 2026, 2:28 PM ET / 18:28 UTC.

Summary
The PR promotes hot-mode restart-required config reload drops from warn to error, adds an openclaw gateway restart remediation message, and covers it with a focused regression test.

PR surface: Source +5, Tests +44. Total +49 across 2 files.

Reproducibility: yes. from source inspection: configure hot reload mode, change a restart-required path such as gateway.port, and current main reaches the warn-and-return branch without applying hot reload or queuing restart.

Review metrics: 1 noteworthy metric.

  • Diagnostic severity change: 1 warning promoted to error. This is the operator-visible behavior change and can affect alert rules for restart-required config reload drops.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted after-fix real gateway proof, such as terminal output or logs from a hot-mode reload that shows the new error line and restart remediation.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR includes production pre-fix context and Vitest output, but no after-fix proof from a real gateway; add a redacted terminal/log excerpt showing the promoted error after applying the patch. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] After-fix real behavior proof is still mock-only; the PR does not yet include a redacted real gateway log showing the promoted error and remediation after applying the patch.

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow diagnostic change after the contributor adds redacted after-fix real gateway proof for a hot-mode restart-required reload.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] No automated code repair is needed; the remaining blocker is contributor-supplied after-fix real behavior proof or maintainer acceptance of the proof gap.

Security
Cleared: No concrete security or supply-chain concern was found; the diff changes only a gateway diagnostic log line and a test.

Review details

Best possible solution:

Land the narrow diagnostic change after the contributor adds redacted after-fix real gateway proof for a hot-mode restart-required reload.

Do we have a high-confidence way to reproduce the issue?

Yes from source inspection: configure hot reload mode, change a restart-required path such as gateway.port, and current main reaches the warn-and-return branch without applying hot reload or queuing restart.

Is this the best way to solve the issue?

Yes, this is the narrowest maintainable mitigation for operator visibility; partitioning mixed reload plans would be a larger behavior change outside this PR.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 8bf6206a3e78.

Label changes

Label changes:

  • add P1: The PR addresses an observed gateway config-staleness failure that broke real Telegram turns until an operator restarted the gateway.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR includes production pre-fix context and Vitest output, but no after-fix proof from a real gateway; add a redacted terminal/log excerpt showing the promoted error after applying the patch. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P1: The PR addresses an observed gateway config-staleness failure that broke real Telegram turns until an operator restarted the gateway.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR includes production pre-fix context and Vitest output, but no after-fix proof from a real gateway; add a redacted terminal/log excerpt showing the promoted error after applying the patch. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +5, Tests +44. Total +49 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 7 2 +5
Tests 1 44 0 +44
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 51 2 +49

What I checked:

Likely related people:

  • Hussein Nourelddine: Current-main blame for the hot-mode warning branch, reload planner, and managed reloader wiring points to commit 4a285d5. (role: introduced gateway reload implementation; confidence: high; commits: 4a285d529a00; files: src/gateway/config-reload.ts, src/gateway/config-reload-plan.ts, src/gateway/server-reload-handlers.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. labels Jun 2, 2026
@amittell

amittell commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

Consolidating with #89517.

#89517 (which was opened earlier today, also under this account) addresses the same observed production failure — a hot-mode reload that drops the plan when any restart-required key is in the same change set — but with a stronger fix: instead of just promoting the log line, it actually queues the restart-required reload through the existing onRestart path so the gateway self-heals without operator action. That makes #89578's "make the failure loud" angle redundant — the failure no longer needs to be loud because it no longer happens.

Closing this in favor of #89517. The log-promotion idea here may still be useful as a follow-up if maintainers want a louder signal when hot-mode autoschedules a restart, but I would rather not add it to #89517's diff until that scope is asked for.

The originating incident (openclaw doctor --fix migrated agents.defaults.models correctly but auth.profiles rename was restart-required; in-process agent kept resolving the legacy model id for 4 hours; group messages silently dropped while admin DMs returned a canned error) is the same in both PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant