Skip to content

fix(health): surface restart-required runtime config drift - #89526

Closed
amittell wants to merge 19 commits into
openclaw:mainfrom
amittell:codex/restart-required-reload-diagnostics
Closed

amittell wants to merge 19 commits into
openclaw:mainfrom
amittell:codex/restart-required-reload-diagnostics

Conversation

@amittell

@amittell amittell commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: openclaw health reports ok when the running Gateway still uses an older model, provider, auth or secrets config than the one on disk, for example after an edit under gateway.reload.mode: "off", a failed reload, or while a required restart is pending.

The diagnostic also compared only secrets.providers. Changing secrets.defaults.env, which selects the active provider alias, therefore produced a false ok result even after the reloader completed the new source observation.

User Impact

openclaw health --json includes optional runtimeConfig state:

  • ok: monitored runtime values match the latest completed reload observation.
  • drift: they differ, with redacted path names and default-model labels.
  • unknown: one authoritative source is unavailable.

Text health prints a warning for drift or unknown. The diagnostic never emits config fingerprints, secret values, source paths, parse excerpts, or observation errors.

openclaw health advertises runtime-config-health. Every other client (Control UI, native apps, nodes, third-party v4 clients) receives hello, health events, and health responses without runtimeConfig, the same shape as main.

Since #111527, hot and every mode other than off resolve to hybrid, so lasting drift now mainly comes from mode: "off", failed reloads, writes whose writer skipped runtime application, and restarts that are still pending.

Update behavior: no config, default, SQLite, migration or protocol-version change. A new CLI talking to an older Gateway sends a capability that Gateway ignores, so the field and the text line are simply absent; an older CLI talking to a new Gateway doesn't advertise it and sees today's payload.

Why This Change Was Made

The config reloader owns one generation-fenced, immutable latest-completed source observation. The shared health owner compares that observation with the published runtime source snapshot. RPC, connection hello, broadcasts, cached health, and CLI text all read the same redacted projection. Monitoring canonical parent secrets covers provider declarations, provider-default selection, and the restart-owned egress proxy without adding another config or API surface.

Every reloader transaction that reads the source publishes that read when it finishes, and only while its source revision is current. A write's own same-source watcher echo is published by the echo's reload pass: main removed the in-transaction echo catch-up in #168980. That covers watcher reloads, in-process writes (which publish the canonical reread their notification carries), and plugin lifecycle applications.

The alternative was to read disk or reconstruct reload state in each health consumer. That would duplicate policy and recreate mixed-generation results during debounce, in-flight reads, supersession, and bootstrap awaits.

runtimeConfig is sent only to clients that advertise the runtime-config-health client capability, so existing strict v4 decoders never see it (details under Protocol compatibility).

Protocol compatibility

An ungated field is rejected by the pre-change strict v4 decoder. Measured at a78f6e3c2fd with its own lockfile: that head's sendGatewayHello, carrying a drift value from its real buildRuntimeConfigHealth, validated with TypeBox Value.Check against the pre-change strict v4 decoder (snapshot.ts byte-identical to bf83a4dde8f; frames.ts has no diff between base and head, so HelloOkSchema is the same with the base snapshot swapped in):

head HelloOkSchema, drift hello                      : true
base HelloOkSchema, control hello (no runtimeConfig) : true
base HelloOkSchema, drift hello                      : false
  /snapshot/health  additionalProperties  "must not have additional properties"  {"additionalProperties":["runtimeConfig"]}
base SnapshotSchema, drift snapshot                  : false
  /health           additionalProperties  "must not have additional properties"  {"additionalProperties":["runtimeConfig"]}

So the field is capability-gated. It uses the negotiation the protocol already has (GATEWAY_CLIENT_CAPS in client-info.ts, ConnectParams.caps, hasGatewayClientCap) and adds one entry, RUNTIME_CONFIG_HEALTH: "runtime-config-health". The field is projected per connection on all three surfaces:

  • hello-ok: the cached snapshot is projected per connection; on the uncached path the diagnostic is read only for advertising clients.
  • health events: through the broadcaster's existing per-recipient projection hook in server-connection-state.ts. The node-subscription fanout has no per-client caps in scope, so it always drops the field.
  • health RPC: both the cached and the refreshed response.

The shared health cache is never mutated by the projection. The closed HealthSnapshotSchema is reachable only through hello-ok's snapshot: the health RPC result already carries modelRuntime, which no schema in packages/gateway-protocol declares, and I found no payload schema there for the health event. I gated all three anyway so a client never sees the field without asking for it; a hello-only gate would be about 20 production lines smaller.

Which contract to keep is the Gateway owners' call, and nothing here claims that decision. One set of data points for it, each measured with git show <sha> | grep -E 'GATEWAY_CLIENT_CAPS|hasGatewayClientCap' (0 hits each): main has added optional fields to closed v4 hello-snapshot objects without a capability gate, for example suspension in #136220 (e0ab9907621), presence clientId in #145559 (0141569e798), health ingressFailed/ingressPressure in #123234 (b233ea79575), and, since the last review, health childRuntime in #157190 (92c86fefcd4).

Evidence

Current revision: October 24

Pushed 74a5bb3048320571d7be4f5234ffabcb1c1c9a64, tree 3e50c559c9bd4a15d57f2dfd5130e6d6fcb021de, by a normal push after verifying the remote still held 24431ac4acf68f7508e389126588782e33004ca6. The merge preserves that head and upstream 1d9da0d5dce9ea92065015cb5de0671d2e68db8b as parents. It picks up the public-startup readiness fixture repair in #181700 and the worker-recovery fixture repair in #181816.

The previous CI run 39971742215 executed merge 43cbeb2d78a66105d5293779dd0f75581e3ef5ce with actual base be6b43f3c52b5e6b53504312554287135c302283. Replayed the original selected groups on those exact sources before testing the candidate:

Proof Complete result
Original seven-file hook group, exact base and exact CI merge Both runs: 53 passed, 2 failed. Both named hook cases failed hello.ok with UNAVAILABLE, reason startup-sidecars.
Same hook group, candidate 55 passed, 0 failed. Both original failures passed.
Original worker-startup group, exact CI merge 171 passed. The hosted worker-recovery failure did not reproduce in this one-worker replay.
Same worker group, candidate 173 passed across 18 files.
Original runtime-config group, exact CI merge Five individual passes, then the unchanged 300000 ms no-output watchdog; exit 143, no suite total.
Same runtime-config group, exact base 56 passed, 1 failed, 10 skipped, plus one failed suite. The include-only operation's teardown timed out at server.close; a later suite could not acquire plugin metadata while shutdown remained pending. This is a baseline cleanup failure, not a reproduction of the watchdog termination.
Same runtime-config group, candidate 67 passed, 0 failed. The include-only case completed in 5508 ms, versus 292905 ms before the base reported its hook timeout.
Candidate PR contract tests Nine files, 127 passed, 0 failed: CLI projection, reload observations, health cache/publication, RPC, hello, event projection, and protocol schema.
Candidate static checks Format parity on 28 files passed; typed lint on 26 files reported 0 warnings and 0 errors; node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo exited 0.

These runs used Linux, Node 24.22.1, pnpm 12.15.0, pinned Bun 1.4.4-canary.1+ef37c31de, frozen installs, and one test worker. The base and merge have byte-identical dependency inputs and used Vitest 5.0.3; the candidate's integrated main uses 5.0.5. The candidate passed the replay, but the watchdog's cause has not been isolated. Hosted CI used two workers, so the local controls do not reproduce its concurrency. Source-tree guards passed around every candidate run.

The original group plans are recorded in hook job 120476682644, worker job 120476682315, and runtime-config job 120476682472. Replays used each logged OPENCLAW_NODE_TEST_GROUPS_JSON through node --import tsx scripts/ci-run-node-test-shard.mts, with OPENCLAW_CI_TEST_RUNTIME_POLICY=bun-all, OPENCLAW_NODE_TEST_PLAN_CONCURRENCY=1, the one-worker override, and OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=300000.

The focused candidate command was:

OPENCLAW_VITEST_RUNTIME=bun node scripts/run-vitest.mjs \
  src/commands/health-runtime-config.test.ts \
  src/commands/health.snapshot.runtime-config.test.ts \
  src/commands/health.plugins.test.ts \
  src/gateway/config-reload.observation.test.ts \
  src/gateway/server-connection-state.test.ts \
  src/gateway/server-methods/health.runtime-config.test.ts \
  src/gateway/server/health-state.test.ts \
  src/gateway/server/ws-connection/connect-hello.update-scope.test.ts \
  packages/gateway-protocol/src/schema/snapshot.test.ts --maxWorkers=1

Fresh source review covered all 29 complete patches and 70 hunks against pinned main, with no actionable P0-P2 finding. It used patch context and did not execute these tests. The committed tree matches the reviewed and tested tree.

Current-head CI run 40126705412 is running. At 2026-10-24T19:46:10Z, the complete capture contained 49 check runs: 13 successful, 21 skipped, 15 in progress. These are incomplete CI results. The separate openclaw/ci-gate and openclaw/security-sensitive-review commit statuses require fresh maintainer approval; the notice names this exact head. The Gateway-owner contract decision remains open.

Earlier measurements below are historical author reports at the SHAs they name. They are not current-head proof.

Historical revision: October 20

Pushed 426d7295459be24e2d18d968f6dc8f1411e4abf2, tree 9190bd4b0c36a0219455cec5566bedf0b9b65b4c, as an additive merge of 832a0c2cffae34863248e9d29a44925995148a04 and upstream f629720edbb9f4b458adae30c7506c1dc5d1adc6. The normal push and remote head were verified. CI run 39499291024 completed successfully: 112 jobs, 89 successful and 23 skipped, with no failed, running or queued jobs. The fully paginated capture at 2026-10-20T23:42:26.369785+00:00 records filter=all: 180 completed checks (1 neutral, 57 skipped, 122 success); filter=latest: 180 completed checks (1 neutral, 57 skipped, 122 success). The preflight job checked out merge 5c19327872dac9e8382503fe89163559452f54b4, tree 29fc941f9313770bccb92a973fad06d5fdd00492, with parents 8f0973e37405d683e242e217f4d7c30a1efc4118 and this head 426d7295459be24e2d18d968f6dc8f1411e4abf2. That executed merge differs from the locally validated integration tree. The last queued shard is included in the terminal result.

The integration preserves upstream health-summary and hello-on-demand behavior alongside the optional runtime-config capability. It also fixes two demonstrated defects:

  • The runtime-config event projection could restore agents and sessions after the broadcaster had removed them for a summary-only client. The existing per-recipient callback now applies both projections before serialization. The generic broadcaster matches pinned main. Production callback, eight serialized-event combinations.
  • Clearing and republishing the runtime snapshot can reuse a numeric revision. The cache key now compares the reload-observation generation and the runtime owner's stable publication object identity, so a different publication cannot reuse stale cached or in-flight health. The key remains internal. Freshness checks, cached and pending reset cases. These cases call the actual runtime reset/publication owner and summary builder with controlled collection and reload observations; they are not a full Gateway restart test.

The hello table covers all 16 combinations of cached health, runtime-config capability, hello-on-demand and health-summary capability.

Executed on the private Linux builder with Node v26.8.2, pnpm 12.12.1, frozen dependencies and one Vitest worker:

Control Result and scope
Event-composition regression before the repair, tree f84da04ee18080546e35ac732673768b22516d81 One intended payload assertion failure with runtimeConfig present; the absent case passed, eight unrelated cases skipped. The loop stopped at its first affected recipient, so this is one observed failure. Exit 1, 144.13 seconds, no timeout.
Actual reset/republication regressions with the old numeric key, tree de0fdb18b3033c0876e41a261bb4d65e1d89ee62 Two intended failures: stale cache returned instead of invalidation, and stale pending collection returned instead of recollection. 24 skipped, exit 1, 57.23 seconds, no timeout.
Final tree 9190bd4b0c36a0219455cec5566bedf0b9b65b4c Five suites, 114 tests passed, exit 0, 79.31 seconds. Both reset cases, all event and hello combinations, RPC controls and broadcaster serialization are included.
Scoped static checks on final tree Incremental core TypeScript: exit 0, 6.26 seconds. Gateway-server test TypeScript: exit 0, 7.55 seconds. Seven-file typed lint: zero warnings/errors, exit 0, 13.82 seconds.
Source identity and review Before/after index trees and all 58,328 tracked blob hashes match the final tree. Two separate source reviews found no actionable P0-P2 issue; the reviewers did not execute target tests. The peer review independently inspected the complete positive/negative logs and identity receipts.

Reproduce the positive set:

OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs run \
  --config test/vitest/vitest.gateway.config.ts \
  src/gateway/server/health-state.test.ts \
  src/gateway/server-connection-state.test.ts \
  src/gateway/server/ws-connection/connect-hello.update-scope.test.ts \
  src/gateway/server-methods/health.runtime-config.test.ts \
  src/gateway/server-broadcast.serialization.test.ts --maxWorkers=1

For the event negative control, retain the final tests and remove only summary composition from the runtime-config per-recipient replacement, then run the connection-state cases. For the reset control, retain the tests but replace publication-identity comparison with the old observation-generation/numeric-revision key, then run the two reset cases. Restore the exact production bytes after each control. Neither mutation is in the branch. The final runs reported no remaining process-group children; tracked-blob checks do not certify untracked files or the entire runtime environment.

The integration includes upstream b6bd9e8bd0cad400b31a223a0c44f8494f5cfb87, which fixes the missing createDeferredCore import reported by the previous head's static jobs. Those old failures also occur in the exact-base main CI; the old runtime jobs completed. The earlier SIGKILL/137 remains unexplained and is not classified as OOM.

The fresh hosted review completed October 20 at 21:30 UTC on 426d7295459be24e2d18d968f6dc8f1411e4abf2, against main 4b065f50d724f380dca1fa09b387c2b0e42a80a0, with zero findings. It accepts the supplied historical Gateway proof and current regression evidence. This was source inspection, not an independent execution of the target code. Its two remaining items are Gateway-owner acceptance of the capability-gated health contract and current-head maintainer security approval. Primary CI is now complete as recorded above. The separate openclaw/security-sensitive-review and aggregate openclaw/ci-gate commit statuses remain failure; openclaw/dependency-review is success.

Maintainer security approval and Gateway-owner acceptance of the optional runtimeConfig contract remain open. A successful Security Review workflow does not grant the required approval. The historical sections below retain their original heads and are not new executions at 426d7295.

Historical integration: October 19

Head 832a0c2cffae34863248e9d29a44925995148a04 is an additive merge of the previous head 56b8e57fe36d33313e80af541820b11e02ab9a2e and upstream main 2cd23b665868c75bfb02537cef9eb9f2b329667a. GitHub reports the conflicts resolved. No rebase or force-push.

The six conflict resolutions retain main's health-event deduplication, pinned config paths, connection-row delivery-loss handling, and hello-health-on-demand behavior alongside this PR's runtime-config capability gate. Clients advertising both health capabilities receive an empty hello health snapshot; requests and events still carry the opted-in diagnostic. The hello tests cover all eight combinations of cached health, runtime-config capability, and hello opt-out.

A new health-owner regression reproduced an old ok diagnostic being broadcast after its observation was superseded. The pre-fix resolved tree was 022244e3589d615e8b58745e6ab6ca9cd7edb9c8; it failed with expected generation: 7, received generation: 8 while both values carried state: ok. The fix removes the async helper hop between the final config check and publication. A separate regression checks that an equivalent diagnostic at a newer generation refreshes the cache key without another event.

Local author-run validation of the current tree (a08c6662c26a9fb90f366284fadae4dceec13144):

  • Four focused Gateway suites: 88 passed, wrapper wall time 266.55 seconds. This includes the red-to-green publication regression, strict legacy decoder controls, capability projection for hello/events/RPC, and main's health deduplication tests.
  • Core production TypeScript: passed, 47.75 seconds. Gateway-server test TypeScript shard: passed, 48.38 seconds.
  • Targeted type-aware lint and formatting on the repaired files: passed. git diff --check against pinned main: passed.
  • Workboard's asset build, the consumer previously affected by capability-registry changes: passed, 5.14 seconds. This is a focused consumer build, not a full build claim.
  • Independent canonical autoreview: three completed passes, scoped-clean through P2 on the full candidate diff against pinned main. The reviewer assessed supplied patches and did not execute tests. Helper SHA-256: b95e51b79d9f68fe445cdc9d6c1e07b01507188bba1bfe8a59f14c378e5ac3a5.

Reproduce the focused runtime checks from this head with its frozen dependencies and repository test wrapper:

node scripts/run-vitest.mjs src/gateway/server/health-state.test.ts src/gateway/server/ws-connection/connect-hello.update-scope.test.ts src/gateway/server-connection-state.test.ts src/gateway/server-methods/health.runtime-config.test.ts --maxWorkers=1
node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.gateway-server.json --incremental

Exact-head CI run 39320268759 finished with two failing jobs plus the aggregate gate, both in a file this PR does not touch. check-test-types-core-4: src/gateway/local-http-probe.test.ts(154,25): error TS2304: Cannot find name 'createDeferredCore'. check-lint-core-1: src/gateway/local-http-probe.test.ts:178:53 (prefer-promise-reject-errors). #177670 (2cc639d7023) broke that file on main and b6bd9e8bd0c fixed it at 2026-10-19 21:24Z; the run's base 0548086d6a95 predates the fix. Every other job passed or was skipped, so the earlier SIGKILL in checks-node-changed-compact-large-22 (run 39007736518) did not repeat. openclaw/security-sensitive-review is the open approval gate below, not a test result.

The Gateway-owner contract decision below and the maintainer security approval remain open; this update claims neither approval nor landing readiness with green CI.

Historical author-reported evidence

The evidence below belongs to the named earlier heads and has not been promoted to current-head proof.

Head 8606a2df718: six commits on the earlier head 5d5ad44f5f6. 6d62aefe5a1 merges main@6b2afbfe981 (the branch was CONFLICTING), 32548a164ba moves the external-change audit appender out of config-reload.ts, 82be5c6edc6 fixes the plugin lifecycle publication gap, 759130f4cc7 brings the health mocks inside main's mock-export ratchet, 3ee3413ef5e rechecks cached health after its awaited reads, and 8606a2df718 removes three mock-shaped tests. git merge-tree --write-tree against main@f3f9bf90c69 (2026-10-09) exits 0.

Since then, 615fde1ef66 merges main@bb642e181e1 and 56b8e57fe36 merges main@4af30f64ca7. Neither changes an added or removed line of this branch's own diff; the merge notes below cover both.

Plugin lifecycle publication (the P2 from the last review)

applyPluginLifecycleChange reads and applies the source outside runReload. It could consume a pending write and accept that write's watcher echo, and accepting the echo cleared the queued reload, so nothing published the source it applied. It now publishes through the same per-transaction tracker. Regression in config-reload.observation.test.ts, run on the same tree with and without the three production lines:

without the fix   publishes a plugin lifecycle read that consumes a pending write and accepts its echo
                  AssertionError: expected { generation: 15, …(1) } to deeply equal { generation: 16, …(1) }
                  observation still agents.defaults.model = openai/gpt-5.6-sol; readSnapshot called twice, onHotReload once
                  Tests  1 failed | 10 passed (11)
with the fix      Tests  11 passed (11)

Cached health after awaited reads (the P2 from the re-review)

The cached branch of the health RPC read the shared snapshot, awaited the delivery-queue and context-engine summaries, then answered from the captured copy even when a config observation had retired that snapshot in between. It now rereads the shared cache after the awaits and answers from a refresh when the snapshot is no longer the current one. Regression in health.runtime-config.test.ts, run with and without the production change:

without the fix   refreshes when the cached snapshot is retired during its diagnostic reads
                  AssertionError: expected { state: 'ok' } to deeply equal { state: 'drift', …(3) }
                  Tests  1 failed | 2 passed (3)
with the fix      Tests  3 passed (3)

Tests and gates on 8606a2df718

Run on an M4 Pro, Node 26, on the tree CI tests: main@f3f9bf90c69 merged with this head.

  • 20 affected test files (config-reload, config-reload.observation, config-reload.plugin-drain, config-reload.lease-retry, server-reload-handlers, health-state, connect-hello.update-scope, connect-hello.setup-completion, server-connection-state, server-methods, health.owner-routing, health.runtime-config, the seven commands health suites, and the protocol snapshot schema): 601 passed, 0 failed.
  • The CI ratchet step with --base at that main: max-lines, line-cap ("OK: 26 changed source files; no new violations or over-cap growth"), assertion-safety, database-worker, test-timeout-race and test-mock-exports ("Mock factory ratchet OK: 10238 grandfathered factories") pass, as do config:docs:check and plugins:inventory:check.
  • run-tsgo.mjs 0 errors on tsconfig.core.json and the gateway-root, gateway-server, gateway-other, gateway-methods, commands and packages test shards.
  • oxfmt clean and oxlint 0 warnings, 0 errors on the 26 changed code files. plugins:assets:check: generated assets match the committed bytes. Import cycles: 0 (measured at 82be5c6edc6; no import changed since).
  • Not run: the full check-changed, the other core test shards, full lint:core, knip, and the docs MDX and link checks.

Test cost. Wall is pnpm test <file> --maxWorkers=1 on the M4 Pro with the compiled-worker cache warm. CI is the sum of per-test times for that file in run 37976193929 (82be5c6edc6).

Test file Tests Wall CI
src/gateway/config-reload.observation.test.ts (new) 11 7.10 s 2.49 s
src/commands/health-runtime-config.test.ts (new) 5 1.24 s 1 ms
src/commands/health.snapshot.runtime-config.test.ts (new) 5 1.23 s 4 ms
src/gateway/server-methods/health.runtime-config.test.ts (new) 3 8.36 s 0.64 s (2 tests)
src/gateway/server/health-state.test.ts 30 9.12 s 10.18 s (33 tests)
src/gateway/server/ws-connection/connect-hello.update-scope.test.ts 43 6.23 s 0.27 s
src/gateway/server-connection-state.test.ts 8 15.93 s 7.52 s
packages/gateway-protocol/src/schema/snapshot.test.ts 13 1.60 s 0.10 s

The two rows with a test count in the CI column changed after that run: one case added, three removed. The observation suite runs on main's shared reload harness with fake timers and deferreds; it adds no real timers, sleeps or Gateway boot.

Process proof at 82be5c6edc6

Isolated Gateway on an M4 Pro: env -i with a temp HOME, OPENCLAW_STATE_DIR and OPENCLAW_CONFIG_PATH, OPENCLAW_SKIP_CHANNELS=1, loopback port 28797, token auth, gateway.reload.mode: "off", started with pnpm openclaw gateway run --port 28797 --bind loopback --verbose. Clients: openclaw health --json (advertises the capability) and openclaw gateway call health --json (does not).

before the edit
openclaw health --json               16 top-level keys | runtimeConfig = {"state": "ok", "liveDefaultModel": "openai/gpt-5.5", "observedDefaultModel": "openai/gpt-5.5"}
openclaw gateway call health --json  15 top-level keys | runtimeConfig absent

an unused gateway.auth.password added on disk, a restart-required path
[reload] config change detected; evaluating reload (gateway.auth.password)
[reload] config reload disabled (gateway.reload.mode=off)
[reload] config source revision 1 accepted (file)

after the edit
openclaw health --json               16 top-level keys | runtimeConfig = {"state": "drift", "liveDefaultModel": "openai/gpt-5.5", "observedDefaultModel": "openai/gpt-5.5", "driftPaths": ["gateway.auth"], "message": "Live gateway runtime config differs from the latest completed reload observation for model/provider/auth paths; restart is required or pending."}
openclaw gateway call health --json  15 top-level keys | runtimeConfig absent
openclaw health (text)               Runtime config: warning (live gateway differs from latest completed reload observation for gateway.auth; restart required or pending; live=openai/gpt-5.5 observed=openai/gpt-5.5)

Neither the token nor the password appears in the 9,401 bytes of captured client output. The Gateway was stopped by the pids recorded at launch ([shutdown] completed cleanly in 193ms).

This run covers the health RPC for one advertising and one non-advertising client after the merge. The hello and event projections, the echo and reread races, and the plugin lifecycle case are covered by the regressions, not by this run. The earlier process run at 59271bb6847 also captured hello-ok with and without the capability (absent without it); that part was not repeated here. Not rerun at 8606a2df718: the three later commits change tests and the cached branch of the health RPC, which the regression above covers.

Observation publication (the two P2s from the review before that, measured at 59271bb6847)

Each regression failed on the rebased pre-fix code and passed at 59271bb6847; config-reload.observation.test.ts went from 6 passed / 5 failed to 11/11:

slow in-process write accepts its own watcher echo   before: generation 13, expected 14; observation still held the prior model
reread after a read failure                          before: published the queued model, expected null
reread after a missing file                          before: same
reread after an invalid file                         before: same
reread after replaced bytes                          before: published the queued model, expected the replacement

Not re-measured as before and after at this head. Main changed the contract under the four reread cases: a write notification now carries the writer's canonical reread, and the reloader no longer rereads. They are now three cases that drive the notification's snapshot (missing, invalid, replaced bytes) and pass. The read-failure case is deleted with the reread it covered. The echo case passes unchanged apart from building its write with makeWrite.

Regression with the pre-change strict v4 decoder

connect-hello.update-scope.test.ts builds the decoder a client had before this change (the current closed SnapshotSchema with runtimeConfig removed from the closed health object). On both the cached and uncached hello paths it accepts what a non-advertising client now receives, and that client's health has no runtimeConfig. An advertising client still gets runtimeConfig, which the current schema accepts and the pre-change decoder rejects. server-connection-state.test.ts and health.runtime-config.test.ts pin the event and RPC projections.

Pre-gate control, measured at 183d408dcee with the gate commit's six production files reverted and runtime-config-cap.ts removed: 4 failed, 37 passed (the hello, broadcast, and cached and uncached RPC cases). With the gate, all four pass.

Merge notes (6d62aefe5a1)

  • config-reload.ts: main moved source observation into src/config/source.ts (fix(config): apply Gateway writes without waiting for file events #157372), and a write notification now carries the writer's canonical reread (fix(config): settle Gateway writes after invalid canonical rereads #161868). The tracker keys on source.observation.revision. Main's refactor(gateway): simplify session and reload bookkeeping #168980 removed the in-transaction echo catch-up, so the accepted-echo marker this PR had added is gone too. The echo's own reload pass publishes that read, one pass later; both echo regressions still observe the next generation. The pending-write path records the notification's snapshot because the reloader no longer rereads it. config-reload-watcher.ts is deleted: main dropped the polling resolver it held.
  • server-connection-state.ts: main's per-recipient projection hook returns { payload }, so the health projection returns that shape. This file merged without a textual conflict and failed typecheck until adapted.
  • server-methods/health.ts: the capability projection wraps main's inlined cached-health object and its live childRuntime read.
  • snapshot.ts: runtimeConfig sits beside main's childRuntime. health.ts: the text line joins main's formatter loop.
  • Tests: makeContext in connect-hello.update-scope.test.ts takes { caps, client }. The observation suite uses main's makeWrite. The four pending-write "reread" cases became three that drive the notification's snapshot; the read-failure case is deleted with the reread it covered.
  • Line cap: the ratchet rejects any growth in config-reload.ts. The observation wiring adds nine counted lines and the resolver that used to pay for it is gone from main, so 32548a164ba moves the external-change audit appender (it only reads the watched path) verbatim to config-reload-audit.ts.
  • health.plugins.test.ts (56b8e57fe36, main@4af30f64ca7): main's shared health.test-fixtures.js import sits beside this branch's installHealthConfigMock import. config/test-mock-exports-baseline.txt auto-merged; it is main's baseline minus this branch's three entries.

CI on 82be5c6edc6 (run 37976193929)

Four jobs were red.

  • checks-fast-baseline-ratchets: this PR. check:test-mock-exports rejected six mock factories the branch adds or changes. Fixed in 759130f4cc7.
  • checks-ui-e2e (7/8), chat-flow.history-recovery.e2e.test.ts ("Timed out waiting for 1 chat.history requests"): red on main. The scheduled main runs at 18:38Z, 19:31Z and 20:33Z failed the same test at the same line, as did 21 other PR runs on 14 branches between 18:28Z and 20:39Z. This PR does not touch ui/.
  • checks-node-changed-5, gateway-node-exec-approvals.e2e.test.ts: the test passed and the job failed on an unhandled rejection of node returned invalid exec approvals payload. The test attaches .rejects to that request two awaits after starting it (lines 168-181). Neither the test nor the exec-approvals path is in this diff. 3 of 3 local runs passed without the error.
  • checks-node-changed-compact-large-14-1, src/gateway/server-reload-handlers.test.ts: 9 failed of 254, starting with three fake-timer cases that timed out at 120 s waiting on a write-triggered reload. Not reproduced: the same 18 files on the exact tree CI tested (164210c355e merged with 82be5c6edc6) pass 254/254, the base alone passes 253/253, and the file passed 8 more times in a row on a later main merged with this branch, 4 of them under background QoS. The test file is not in this diff and did not fail in the 10 scheduled main runs or the 99 other failed PR runs I checked from that day. This branch changes config-reload.ts, which those cases drive, so I can't rule it out; I have no mechanism and no reproduction.

openclaw/security-sensitive-review is the maintainer approval gate for connect-hello.ts.

Review metrics

  • Against main@4af30f64ca7: production +470/-76 in 14 files; tests and test support +1155/-21 in 12 files; docs +23/-3; the mock-export baseline -3. One optional, read-scoped health field behind one new client capability.

Decision needed

For Gateway owners (CODEOWNERS has no entry for these paths): accept the additive, capability-gated health.runtimeConfig field, accept it with the gate on hello only, or close. With #89517 closed, this is the only place an operator sees reload-disabled or restart-pending drift.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime commands Command implementations size: M 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: blocked before merge.

What this changes

Adds an optional, capability-gated health diagnostic comparing running configuration with the reloader’s latest completed source observation.

Example: With gateway.reload.mode="off", an operator adds an unused gateway.auth.password while the Gateway continues using its loaded configuration.

  • Before: openclaw health provides no runtime configuration drift warning.
  • After: JSON reports runtimeConfig.state="drift" and driftPaths=["gateway.auth"], and text output warns that a restart is required or pending.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Production-path evidence and focused regressions support the implementation; the unresolved public-contract decision caps overall readiness.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Supplied isolated-Gateway output exercises normal health CLI JSON and text through an ok-to-drift transition and a non-advertising client control; current-head causal regressions cover subsequent summary composition and reset invalidation repairs.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Operators cannot tell from CLI health whether monitored configuration changes remain unapplied.
Reason: The diagnostic has demonstrated operator value, but acceptance of its additive public health contract remains explicitly undecided.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this PR adds useful CLI diagnostics absent from main, with no actionable correctness finding; Gateway-owner acceptance of the public contract and enforced security approval remain unresolved.

Priority: P2
Reviewed head: 426d7295459be24e2d18d968f6dc8f1411e4abf2
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should Gateway health support the proposed capability-gated, read-scoped runtimeConfig diagnostic?
  • Recommendation: Accept the proposed contract: Support the redacted diagnostic with capability gating across hello, events, and RPC.
  • Why: This adds a public diagnostic contract, and the author explicitly leaves its acceptance to Gateway owners without a recorded owner decision.

Before merge

  • Complete next step - A maintainer must review connect-hello.ts at 426d729 and satisfy the enforced security-sensitive approval gate.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Agent review details

How this fits together

The Gateway reloader publishes completed source observations, and the shared health owner compares them with runtime snapshots before serving redacted diagnostics through CLI RPC, hello, and events.

flowchart TD
  A[Configuration changes] --> B[Config reloader]
  B --> C[Completed source observation]
  D[Published runtime snapshot] --> E[Shared health owner]
  C --> E
  E --> F[Client capability projection]
  F --> G[CLI health and Gateway clients]
Loading

Technical review

Best possible solution:

Have Gateway owners settle the optional health contract, retaining the shared observation owner and negotiated legacy-client compatibility if accepted.

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

Main’s health owner does not compare loaded and observed configuration; the supplied isolated-Gateway trace demonstrates the proposed diagnostic on a mode-off edit.

Is this the best way to solve the issue?

The proposal uses the reloader for source observation and the existing health owner for publication, preserving legacy payloads through capability negotiation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4b065f50d724.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit b4ced69 adds src/gateway/server/health-state.ts:130 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b4ced6976b6f; files: src/gateway/server/health-state.ts)
  • Vincent Koc: Raw commit 74e7b8d adds src/commands/health.types.ts:11 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 74e7b8d47b18; files: src/commands/health.types.ts)

PR surface

Source +436, Tests +1304, Docs +22, Other -3. Total +1759 across 29 files. Added test files: 4.

View PR surface stats
Area Files Added Removed Net
Source 15 525 89 +436
Tests 11 1356 52 +1304
Docs 2 25 3 +22
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 3 -3
Total 29 1906 147 +1759

Review metrics

Metric Value Why it matters
Production versus test changes Production +510/-89; tests and test support +1371/-52 Growth covers completed observations, shared publication freshness, and distinct transport compatibility boundaries; the supplied causal regressions justify the lifecycle coverage.
Public surface One optional health field and one client capability; zero config options Owner acceptance concerns a supported diagnostic contract rather than a new operator setting.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Improves advanced operator diagnosis of reload-disabled, failed, or restart-pending configuration drift.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (51 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-18T19:13:40.411Z sha 183d408dceeb618b4c8756e8a0c19e8ea662b4ec :: blocked before merge. :: [P2] Carry the accepted watcher epoch into observation publication | [P2] Record the pending write's actual reread result
  • reviewed 2026-09-23T09:40:28.119Z sha 3ab9fea0825b20e2970c14219704c0fbff759867 :: blocked before merge. :: [P2] Publish observations from plugin lifecycle applications too
  • reviewed 2026-09-23T17:23:53.375Z sha f55e8fd5015d68348dd94254253554421e5cb68d :: blocked before merge. :: [P2] Publish observations from plugin lifecycle applications too
  • reviewed 2026-09-23T21:58:40.309Z sha 5d5ad44 :: blocked before merge. :: [P2] Publish plugin lifecycle reads to the health observation
  • reviewed 2026-10-09T18:59:18.346Z sha 82be5c6 :: blocked before merge. :: [P2] Recheck cached health after awaited diagnostic reads
  • reviewed 2026-10-09T22:29:16.090Z sha 82be5c6 :: blocked before merge. :: [P2] Recheck cached health after awaited diagnostic reads
  • reviewed 2026-10-10T03:53:34.989Z sha 8606a2d :: blocked before merge. :: none
  • reviewed 2026-10-19T20:43:56.860Z sha 832a0c2 :: blocked before merge. :: none

Reviewed October 20, 2026, 5:30 PM ET / 21:30 UTC (Revision 52).

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jun 2, 2026
@amittell
amittell force-pushed the codex/restart-required-reload-diagnostics branch 2 times, most recently from 54af744 to b069b83 Compare June 8, 2026 21:07
@clawsweeper clawsweeper Bot removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jun 8, 2026
@amittell
amittell force-pushed the codex/restart-required-reload-diagnostics branch from b069b83 to 4f42877 Compare June 9, 2026 02:04
@amittell

amittell commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Status update (2026-06-08): pushed 4f42877628 addressing all three rank-up moves with the hot-mode policy split out to PR #89517 so each PR carries a single concern.

Rank-up move 1 (redacted real-behavior proof)

Captured on a sandbox gateway on this Mac (loopback port 28790, dist built from this branch). Scenario: gateway started with mode: "hot", agents.defaults.model: "openai/gpt-5.5", gateway.auth.token: "sandbox-token-OLD". After the gateway is ready, the disk config rotates the token from OLD to NEW. With mode: "hot" default behavior (no opt-in), the runtime keeps the old token. The new openclaw health summary catches the drift:

Before the disk edit:

{
  "state": "ok",
  "liveSourceFingerprint": "ZwpkNbonhuhHUcZIX-RpCpmDO_T0pI9-mhfmpnEx0Cw",
  "diskSourceFingerprint": "ZwpkNbonhuhHUcZIX-RpCpmDO_T0pI9-mhfmpnEx0Cw",
  "liveDefaultModel": "openai/gpt-5.5",
  "diskDefaultModel": "openai/gpt-5.5"
}

After the disk edit, before any restart:

[reload] config change detected; evaluating reload (gateway.auth.token)
[reload] config reload requires gateway restart; hot mode ignoring (gateway.auth.token)
{
  "state": "drift",
  "liveSourceFingerprint": "ZwpkNbonhuhHUcZIX-RpCpmDO_T0pI9-mhfmpnEx0Cw",
  "diskSourceFingerprint": "bmf1fqlb1l44OQU6Q71ZlZHQZwVl7pFQ9ZO_G11lzzE",
  "liveDefaultModel": "openai/gpt-5.5",
  "diskDefaultModel": "openai/gpt-5.5",
  "driftPaths": ["gateway.auth"],
  "message": "Live gateway runtime config differs from disk for model/provider/auth paths; restart is required or pending."
}

Text-rendering path:

Runtime config: warning (live gateway differs from disk for gateway.auth; restart required or pending; live=openai/gpt-5.5 disk=openai/gpt-5.5)

The fingerprint values are visible here because the openclaw health CLI passes includeFingerprints: true; see rank-up move 2.

Rank-up move 2 (gate or remove config fingerprints from non-admin health output)

buildRuntimeConfigHealthSummary now takes an explicit opts.includeFingerprints parameter that defaults to omitted, and only the gateway-auth-gated openclaw health CLI summary path passes true. Any future call site (a richer probe endpoint, a Control UI badge, a transcript export) has to make a conscious decision at the call site before fingerprint values appear in their output. Operator log correlation via fingerprints continues to work on the CLI path.

Implementation in src/commands/health.ts:250-323 and src/commands/health.ts:781-786.

Rank-up move 3 (resolve hot-mode semantic change)

Split off to PR #89517 so this PR is purely about drift detection on the health surface and contains no upgrade-sensitive runtime-policy change. With mode: "hot" on main, the warn-and-keep behavior continues to apply; this PR adds the drift summary that makes the warn observable to operators.

Additional fix while capturing proof

The earlier draft listed auth in RUNTIME_CONFIG_DRIFT_PATHS, but config auth lives under gateway.auth, so readConfigPathValue(cfg, "auth") never matched and a real gateway.auth.token rotation slipped past the drift detector. Updated to gateway.auth; the proof above relies on this. Existing snapshot test (agents.defaults.model drift case) and the broader 336/336 reload-shard tests still pass; tsgo clean.

Happy to add an explicit gateway.auth.token drift test alongside the existing agents.defaults.model snapshot if the maintainer team wants the path mismatch pinned to a regression.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 9, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label Jun 9, 2026
@amittell
amittell force-pushed the codex/restart-required-reload-diagnostics branch from 4f42877 to eb88804 Compare June 9, 2026 20:34
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Jun 9, 2026
@amittell

amittell commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up to the 2026-06-09 02:20 UTC re-review (pushed eb88804f13):

P1 finding — Gate fingerprints on sensitive health snapshots (src/commands/health.ts:782-784)

The previous push had a single call site that always passed includeFingerprints: true, which the verdict correctly flagged as feeding the cached healthCache, the broadcastHealthUpdate payload, and any non-admin probe response derived from the same builder. Now threaded through the existing includeSensitive decision:

// `getHealthSnapshot` line 789
const runtimeConfigHealth = buildRuntimeConfigHealthSummary(runtimeConfigState, {
  includeFingerprints: includeSensitive,
});

Only sensitive snapshots (the admin-scoped path via server-methods/health.ts:127 where includeSensitive = scopes.includes(ADMIN_SCOPE)) pass true; the cached and broadcast paths inherit false and the fingerprint values are omitted from the runtimeConfig summary entirely.

New regression test omits runtime config fingerprints from non-sensitive snapshots used by cache/broadcast paths calls getHealthSnapshot({ includeSensitive: false }) and asserts both liveSourceFingerprint and diskSourceFingerprint are absent while drift state, drift paths, and default-model labels remain present.

P2 finding — Include provider auth paths in drift detection (src/commands/health.ts:176-183)

RUNTIME_CONFIG_DRIFT_PATHS now covers auth.profiles and auth.order alongside gateway.auth, so a provider-auth fix that rotates auth.profiles.primary.mode from token to chatgpt (for example) surfaces as drift instead of silently reporting state: "ok" while a restart-pending repair sits stale on disk.

const RUNTIME_CONFIG_DRIFT_PATHS = [
  "agents.defaults.model",
  "agents.defaults.models",
  "agents.list",
  "models",
  "gateway.auth",
  "auth.profiles",
  "auth.order",
  "secrets.providers",
] as const;

New regression test detects drift on top-level auth.profiles when provider-auth rotates on disk asserts the auth.profiles path is reported correctly.

Tests

node scripts/run-vitest.mjs src/commands/health.snapshot.test.ts — 15/15 pass. pnpm tsgo --noEmit -p tsconfig.json clean.

@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. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 9, 2026
@amittell
amittell force-pushed the codex/restart-required-reload-diagnostics branch from eb88804 to 305b321 Compare June 10, 2026 11:29
Rebased onto upstream/main (2cb62af). The pre-rebase hash (98845c86) was
built from a stale base; regenerating with plugins:assets:build on the
rebased tree converges to main's current 47a66f39. plugins:assets:check
passes.
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

Main 6b2afbf conflicted in eight files. Resolution notes:

- config-reload.ts: main moved source observation into src/config/source.ts
  (openclaw#157372) and write notifications now carry the writer's canonical reread
  (openclaw#161868). The observation tracker keys on source.observation.revision,
  the accepted-echo marker lives in config-reload-observed.ts, and the
  pending-write path records the notification's snapshot because it no
  longer rereads. config-reload-watcher.ts is removed: main dropped the
  polling resolver it held.
- snapshot.ts: runtimeConfig sits beside main's childRuntime (openclaw#157190).
- server-methods/health.ts: the capability projection wraps main's inlined
  cached-health object and its live childRuntime read.
- server-connection-state.ts: the health event projection returns main's
  { payload } projection shape.
- health.ts: the runtime-config line joins main's formatter loop.
- connect-hello.update-scope.test.ts: makeContext takes { caps, client }.
- config-reload.observation.test.ts: writes use makeWrite; the reread cases
  now drive the notification's snapshot, and the read-failure case is gone
  with the reread it covered.
…ng module

The line-cap ratchet rejects any growth in config-reload.ts. The observation
wiring adds counted lines there, and the polling resolver this branch used
to move out for the same reason no longer exists on main. The
external-change audit appender only reads the watched path, so it moves
verbatim to config-reload-audit.ts and the file ends below main's count.
applyPluginLifecycleChange reads and applies the config source outside
runReload. It can consume a pending write and accept that write's watcher
echo, and accepting the echo clears the queued reload, so nothing published
the source it applied: health kept comparing the new runtime config with the
previous observation and reported drift on a monitored path.

The operation now records its read on the same per-transaction tracker as
runReload and publishes it in its finally while its revision, or an echo it
accepted, is still current.
@amittell

amittell commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged main 6b2afbfe981 into the branch (a merge commit, no rebase or force-push) and fixed the P2 the last review left open. Head: 82be5c6edc6.

Publish plugin lifecycle reads to the health observation (P2, src/gateway/config-reload.ts). Reproduced before touching it. A config write, then applyPluginLifecycleChange for that write before the write's own reload runs, with the write's watcher echo landing while the plugin runtime applies: the operation consumed the pending write, its checkpoint accepted the echo and cleared the queued reload, and nothing published the source it had applied. readSnapshot ran twice and onHotReload once, but the observation still held openai/gpt-5.6-sol at the old generation, so health would report drift on agents.defaults.model against a runtime that had already taken the change.

82be5c6edc6 runs the operation's read through the same per-transaction tracker as runReload and publishes it in the operation's finally, only while its source revision, or an echo it accepted, is still current. Regression: publishes a plugin lifecycle read that consumes a pending write and accepts its echo in config-reload.observation.test.ts.

without the fix   expected { generation: 15, … } to deeply equal { generation: 16, … }    Tests 1 failed | 10 passed (11)
with the fix      Tests 11 passed (11); buildRuntimeConfigHealth against the applied runtime returns ok

Merge. GitHub had the branch at CONFLICTING. Eight files conflicted and one auto-merged file no longer typechecked:

  • config-reload.ts: main moved source observation into src/config/source.ts (fix(config): apply Gateway writes without waiting for file events #157372), and a write notification now carries the writer's canonical reread (fix(config): settle Gateway writes after invalid canonical rereads #161868). The tracker keys on source.observation.revision, the accepted-echo marker moved into config-reload-observed.ts (a WeakMap keyed by the observation), and the pending-write path records the notification's snapshot because the reloader no longer rereads it. config-reload-watcher.ts is deleted: main dropped the polling resolver it held.
  • server-connection-state.ts: main's per-recipient projection hook returns { payload } now, so the health projection returns that shape.
  • server-methods/health.ts, snapshot.ts, health.ts, connect-hello.ts: the capability projection wraps main's inlined cached-health object and its live childRuntime read, runtimeConfig sits beside childRuntime in the closed schema, and the text line joins main's formatter loop.
  • Tests: makeContext in connect-hello.update-scope.test.ts takes { caps, client }, and the observation suite uses main's makeWrite. The four pending-write "reread" cases became three that drive the notification's snapshot (missing, invalid, replaced bytes). The read-failure case is deleted with the reread it covered.

Line cap. check-line-cap-ratchet rejects any growth in config-reload.ts. The observation wiring adds nine counted lines, and the polling resolver I had moved out to pay for it no longer exists on main. 32548a164ba moves the external-change audit appender, which only reads the watched path, verbatim to config-reload-audit.ts. The ratchet passes against 6b2afbfe981.

Checks on 82be5c6edc6 (M4 Pro, Node 26):

  • 19 affected health, reload and hello test files: 489 passed, 0 failed.
  • run-tsgo clean on tsconfig.core.json and on the gateway-root, gateway-server, gateway-other, gateway-methods, commands and packages test shards.
  • Line-cap ("26 changed source files; no new violations or over-cap growth"), max-lines, oxfmt and oxlint (0 warnings, 0 errors on 26 files), import cycles (0), plugins:assets:check ("match the committed bytes").
  • Fresh process proof: isolated Gateway with gateway.reload.mode: "off". After adding an unused gateway.auth.password on disk, openclaw health --json goes from ok to drift / ["gateway.auth"] and the text warning renders, while openclaw gateway call health --json has no runtimeConfig before or after. Output is in the body.
  • git merge-tree --write-tree against main@4db022470af6 exits 0.
  • Not run: full check-changed, the other core test shards, docs MDX and link checks.

The two red test jobs on 5d5ad44f5f6 failed in files this PR does not touch: checks-node-compact-large-16 in src/skills/workshop/service.test.ts (OPENCLAW_STATE_LEASE_LOST), and checks-node-compact-large-21 in src/infra/push-web.test.ts > lazily persists successful targets across reopen until terminal replacement. openclaw/security-sensitive-review is the maintainer approval gate for connect-hello.ts; this push needs a fresh /allow-security-sensitive-change.

Still open for Gateway owners: whether health carries the optional, capability-gated runtimeConfig at all. One more data point since the last review: #157190 (92c86fefcd4) added childRuntime to the same closed v4 health object with no capability gate (0 hits for GATEWAY_CLIENT_CAPS|hasGatewayClientCap in that commit). The body is updated for this head, with per-file test cost.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

…atchet

Main's check:test-mock-exports (openclaw#164673) arrived with the merge and rejects
six mock factories this branch adds or changes. The two health-state mocks
now pass the real module through. The config, device-bootstrap,
setup-completion and health-owner mocks stay closed because isolating that
state is their purpose, and each says so in a mock-isolation line.

The baseline drops the four entries those edits retire.
…gnostic reads

The cached health RPC branch reads the shared snapshot, then awaits the
delivery-queue and context-engine summaries. A config observation or runtime
publication that completes during those awaits retires the snapshot, but the
handler still answered from the captured copy, so a client advertising
runtime-config-health could receive the old `ok` after the owner had already
rejected that cache.

The handler now rereads the shared cache after the awaits and answers from a
refresh when the snapshot it captured is no longer the current one.
One only asserted the arguments passed to a replaced builder, which the
publication and hello-projection cases already pin. The other two made the
mocked builder change the observation or the runtime revision in the middle
of a synchronous comparison, which the real builder cannot do. The deferred
whole-collection case keeps covering the asynchronous publication boundary.
@amittell

Copy link
Copy Markdown
Contributor Author

CI on 82be5c6edc6 (run 37976193929) came back red in four jobs. One was mine, and this push also has the P2 from the re-review. Head: 8606a2df718.

checks-fast-baseline-ratchets (mine). check:test-mock-exports rejected six mock factories this branch adds or changes. That ratchet reached the branch with the main merge (#164673) and I had not run it; my earlier list covered line-cap and max-lines only. In 759130f4cc7 the two health-state.test.ts mocks pass the real module through. The config, device-bootstrap, setup-completion and health-owner mocks stay closed with a // mock-isolation: line each, because isolating that state is their purpose. The baseline loses the four entries those edits retire. Run the way CI runs it, on main f3f9bf90c69 merged with this head and --base at that main, the whole ratchet step passes: Mock factory ratchet OK: 10238 grandfathered factories, plus max-lines, line-cap, assertion-safety, database-worker, test-timeout-race, config:docs:check and plugins:inventory:check.

Recheck cached health after awaited diagnostic reads (P2, src/gateway/server-methods/health.ts). Correct. The cached branch read the shared snapshot, awaited the delivery-queue and context-engine summaries, then answered from the captured copy even when an observation had retired it in between. 3ee3413ef5e rereads getHealthCache() after the awaits and answers from a refresh when the snapshot is no longer the current one. Regression: refreshes when the cached snapshot is retired during its diagnostic reads in health.runtime-config.test.ts.

without the fix   expected { state: 'ok' } to deeply equal { state: 'drift', …(3) }    Tests 1 failed | 2 passed (3)
with the fix      Tests 3 passed (3)

Low-value tests. 8606a2df718 removes the three health-state.test.ts cases the review named. What they pinned beyond call shape is still covered: getHealthCache() identity in publishes one redacted runtime-config diagnostic to cache and broadcasts, the generation bump in projects current config for hello while RPC and broadcast await full recollection, and the mid-collection revision bump in recollects the whole snapshot when the runtime revision advances.

The other three red jobs

  • checks-ui-e2e (7/8), chat-flow.history-recovery.e2e.test.ts, "Timed out waiting for 1 chat.history requests": red on main itself. The scheduled main runs at 18:38Z, 19:31Z and 20:33Z (37974737910, 37980853905, 37987811729) failed the same test at the same line, and so did 21 other PR runs on 14 branches between 18:28Z and 20:39Z. This PR does not touch ui/.
  • checks-node-changed-5, gateway-node-exec-approvals.e2e.test.ts: the test passed (1/1, 118.7 s) and the job failed on an unhandled rejection of node returned invalid exec approvals payload. The test starts that request, awaits two other things, and only then attaches .rejects (lines 168-181), so the rejection can land first; the log has the matching PromiseRejectionHandledWarning. The test, exec-approvals.ts, the node invoke handlers and packages/gateway-client are all outside this diff. 3 of 3 runs on an M4 Pro passed without the error. Not fixing a main test in this PR.
  • checks-node-changed-compact-large-14-1, src/gateway/server-reload-handlers.test.ts: 9 failed of 254. Three fake-timer cases timed out at 120 s waiting on a write-triggered reload (joins admitted config restart ... after managed shutdown starts twice, then pauses deferred restart A before external hot config B fails SecretRef preflight). The six later failures came after those, and four of them show leftover lease demand ("channel reload proceeding ... caller(s) waiting for the plugin lifecycle lease held by this reload"). Not reproduced: the same 18 files on the exact tree CI tested (164210c355e merged with 82be5c6edc6) pass 254/254, the base alone passes 253/253, and the file passed 8 more times in a row on main 156412fec38 merged with 759130f4cc7, 4 of them under background QoS. The test file is not in this diff, and it did not fail in the 10 scheduled main runs or the 99 other failed PR runs I checked from that day. I can't rule this branch out, since it changes config-reload.ts, which those cases drive. I have no mechanism and no reproduction, so this one stays open.

Checks on 8606a2df718 merged with main f3f9bf90c69 (M4 Pro): 20 affected test files, 601 passed, 0 failed, including server-reload-handlers.test.ts; run-tsgo clean on core and on the gateway-root, gateway-server, gateway-methods, gateway-other, commands and packages test shards; oxfmt and oxlint clean on the 26 changed code files; plugins:assets:check matches the committed bytes.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

config-reload.ts: take main's renamed candidates (GatewayConfigReloadCandidate, activeConfigCandidate, retryCandidate) and its finally-block cleanup, and keep the reload observation tracking around them; main removed the in-transaction echo catch-up from applySnapshot, so the observationReads cache and the acceptEcho call go with it.
config-reload-observed.ts: drop acceptEcho, which lost its only caller; a watcher echo's own reload pass now reads and publishes the source (observation tests updated to say so).
health-state.ts: keep main's completion-order publication without generations, published through publishPublicHealthSnapshot with its config key.
health-state.test.ts: keep this branch's runtime-snapshot mock, which already spreads the real module as main's does.
connect-hello.ts: keep main's remote Control UI ingress import and helloWriteStarted, after this branch's health finalization.
connect-hello.update-scope.test.ts: keep both mock sets; HelloOk becomes a type import now that main dropped the GATEWAY_SERVER_CAPS cases.
snapshot.test.ts: keep main's trimmed suite plus this branch's runtime-config health case.
src/commands/health.plugins.test.ts: keep main's shared health.test-fixtures.js import beside this branch's installHealthConfigMock import.
Merge pinned main while retaining runtime-config capability gating, health-event deduplication, and hello health opt-out. Publish config health in the same synchronous frame as its final generation check.

Focused Gateway tests: 88 passed. Core and Gateway server test TypeScript checks, targeted lint, workboard assets, and scoped P0-P2 autoreview passed. A pre-fix regression reproduces stale health publication after the observation generation advances.
@amittell

Copy link
Copy Markdown
Contributor Author

Updated to 832a0c2cffae34863248e9d29a44925995148a04. The six conflicts are resolved, and the health owner no longer yields between its final config-generation check and publication. The regression failed before the fix and passes now; the four focused Gateway suites pass all 88 tests. Type checks, targeted lint, the workboard asset build, and independent P0-P2 autoreview also passed. Exact commands and limits are in the updated Evidence section.

Fresh CI and maintainer security approval are still pending. The old SIGKILL/137 remains an unexplained failure, not an OOM diagnosis or a proven fix.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Merge pinned main to resolve hello capability conflicts. Compose runtime-config
and summary filtering in the per-recipient owner, and fence health snapshots by
runtime publication identity so reset/republication cannot reuse a revision key.
@amittell

Copy link
Copy Markdown
Contributor Author

Pushed 426d7295459be24e2d18d968f6dc8f1411e4abf2 with the upstream integration and two measured fixes: summary-only clients no longer regain health details through the runtime-config projection, and runtime snapshot reset/republication invalidates cached and pending health even when numeric revisions repeat. The updated Evidence section links the production paths and regressions.

Final tree 9190bd4b0c36a0219455cec5566bedf0b9b65b4c: 114 tests passed across five suites; core/Gateway typechecks and seven-file typed lint exited 0. The event control produced one intended failure with an unaffected pass; the actual-runtime reset controls produced two intended failures. Two source reviews found no actionable P0-P2 issue; they did not independently execute target tests.

New-head CI is queued. Maintainer security approval and the Gateway-owner contract decision remain open. The historical SIGKILL/137 cause remains unknown.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

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.
Merge upstream main at 1d9da0d to pick up the startup readiness fixtures from openclaw#181700 and openclaw#181816 and the current test runtime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-review-required security-sensitive-changed size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. triage: blank-template Candidate: PR template appears mostly untouched.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants