Repository navigation
fix(gateway): unhealthy channels appear ready after clock rollback - #128222
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 10:50 AM ET / 14:50 UTC. ClawSweeper reviewWhat this changesThis PR makes Gateway health policy, readiness caching, health refreshes, and the background channel monitor reject future-dated observations after a host clock rollback. Merge readinessNo blocking correctness finding remains on the exact PR head: the prior monitor-local rollback gap is now covered. This maintainer-authored, Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherGateway turns channel runtime snapshots into readiness responses, cached health summaries, and restart decisions. Channel lifecycle timestamps enter the shared health policy and determine whether Gateway reports availability or restarts a stalled channel. flowchart LR
A[Channel runtime snapshots] --> B[Shared health policy]
C[Gateway clock] --> B
B --> D[Readiness endpoint]
B --> E[Health summary]
B --> F[Background monitor]
D --> G[HTTP readiness result]
E --> H[Health response]
F --> I[Channel restart]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +27, Tests +280. Total +307 across 10 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Rebase or refresh against current main, retain the shared policy plus monitor-local timestamp gates, and merge after exact-head Gateway readiness and monitor validation succeeds. Do we have a high-confidence way to reproduce the issue? Yes, from source: the focused HTTP, readiness-cache, health-refresh, and pre-existing-monitor regressions construct the rollback sequence and assert the corrected readiness or restart outcome. They were inspected but not executed in this read-only review. Is this the best way to solve the issue? Yes. The repair uses the established future-timestamp predicate at the shared health-policy owner and the three monitor-local gates, rather than adding a downstream readiness-only workaround. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ee6e0251b461. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
|
Addressed the ClawSweeper P1/rank-up on exact head
|
|
Addressed the latest ClawSweeper monitor-owned clock-rollback P1 on exact head
|
|
Merged via squash.
|
…penclaw#128222) * fix(gateway): reject stale health after clock rollback * fix(gateway): fence inherited stale transport after clock rollback * fix(gateway): recover running health monitors after clock rollback
Share completion projection and settlement, reuse existing command gates and session-source preparation, and remove duplicate response/receipt mirrors. Keep private-source authority, approvals, FIFO, transcript durability, bounded retry behavior, and write-capable shutdown settlement at their existing owners. Best-effort tradeoffs accepted: - Idle source/config changes may retain unused capacity until expiry; allocation and private-source transfer still authorize use (#143372, #143410). - Mid-read model configuration and native availability may keep prepared display facts for that read; catalog/account authority remains (#169253). - Cosmetic health topology and clock rollback use normal refresh or an explicit probe; live lifecycle mismatch checks remain (#128222, #128503). - Bootstrap enrollment overlapping shutdown/reload may fail and retry rather than reject every post-await close interleaving (#133037). - Late internal completion reducers are not persisted; completion stays idempotent and final-intent receipt validation remains (#168592). - An in-flight plugin UI catalog may finish against its selected registry; HTTP asset disclosure still checks current authority (#134943, #169449). These removed guards have speculative/synthetic provenance, not cited human actual-use incidents. Keep the human-reported memory-flush retry bound (#85645). The Phase E standalone session memory backend and its tests are untouched.
* refactor(gateway): consolidate reply and worker preparation paths Share completion projection and settlement, reuse existing command gates and session-source preparation, and remove duplicate response/receipt mirrors. Keep private-source authority, approvals, FIFO, transcript durability, bounded retry behavior, and write-capable shutdown settlement at their existing owners. Best-effort tradeoffs accepted: - Idle source/config changes may retain unused capacity until expiry; allocation and private-source transfer still authorize use (#143372, #143410). - Mid-read model configuration and native availability may keep prepared display facts for that read; catalog/account authority remains (#169253). - Cosmetic health topology and clock rollback use normal refresh or an explicit probe; live lifecycle mismatch checks remain (#128222, #128503). - Bootstrap enrollment overlapping shutdown/reload may fail and retry rather than reject every post-await close interleaving (#133037). - Late internal completion reducers are not persisted; completion stays idempotent and final-intent receipt validation remains (#168592). - An in-flight plugin UI catalog may finish against its selected registry; HTTP asset disclosure still checks current authority (#134943, #169449). These removed guards have speculative/synthetic provenance, not cited human actual-use incidents. Keep the human-reported memory-flush retry bound (#85645). The Phase E standalone session memory backend and its tests are untouched. * refactor(gateway): consolidate dispatch and trusted result projections * refactor(workers): trust admitted preparation facts
…2342) * refactor(gateway): consolidate reply and worker preparation paths Share completion projection and settlement, reuse existing command gates and session-source preparation, and remove duplicate response/receipt mirrors. Keep private-source authority, approvals, FIFO, transcript durability, bounded retry behavior, and write-capable shutdown settlement at their existing owners. Best-effort tradeoffs accepted: - Idle source/config changes may retain unused capacity until expiry; allocation and private-source transfer still authorize use (openclaw#143372, openclaw#143410). - Mid-read model configuration and native availability may keep prepared display facts for that read; catalog/account authority remains (openclaw#169253). - Cosmetic health topology and clock rollback use normal refresh or an explicit probe; live lifecycle mismatch checks remain (openclaw#128222, openclaw#128503). - Bootstrap enrollment overlapping shutdown/reload may fail and retry rather than reject every post-await close interleaving (openclaw#133037). - Late internal completion reducers are not persisted; completion stays idempotent and final-intent receipt validation remains (openclaw#168592). - An in-flight plugin UI catalog may finish against its selected registry; HTTP asset disclosure still checks current authority (openclaw#134943, openclaw#169449). These removed guards have speculative/synthetic provenance, not cited human actual-use incidents. Keep the human-reported memory-flush retry bound (openclaw#85645). The Phase E standalone session memory backend and its tests are untouched. * refactor(gateway): consolidate dispatch and trusted result projections * refactor(workers): trust admitted preparation facts
What Problem This Solves
Fixes an issue where operators monitoring Gateway readiness or channel health would continue to see a stopped or disconnected channel reported as healthy after the host clock moved backward. Readiness probes could incorrectly return HTTP 200, cached health snapshots and refresh throttles could remain stale, and the automatic channel-health monitor could skip a restart that should have recovered the channel.
Why This Change Was Made
Gateway health now treats future-dated observations as incapable of proving current readiness, freshness, or an active grace window. Channel lifecycle starts retain their authoritative boundary even when they are future-dated, so heartbeat and disconnect evidence inherited from an earlier lifecycle cannot revive the newer lifecycle; the same existing timestamp predicate validates readiness caches, health snapshots, and request-refresh throttles. Normal startup, reconnect, busy-run, absent-telemetry, and cache/throttle behavior are preserved.
User Impact
Readiness endpoints accurately return HTTP 503 for stopped, starting, recovering, or otherwise disconnected channels after a clock rollback; health requests refresh stale snapshots promptly; and the health monitor resumes restarting channels that can no longer receive messages. No public API, configuration, authentication, protocol, persistent storage, or dependency contract changes.
Evidence
/readyzHTTP 200 for four disconnected lifecycle states and now returns HTTP 503; the channel monitor previously skipped restarting a disconnected channel and now performs the restart.@panzoom/panzoomand@types/pako); both Gateway-owned test shards pass without errors.6507a8fc1e199d382a534d57096bb3ee31472d00.Focused verification commands
OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-gateway-health-vitest-cache node scripts/run-vitest.mjs src/gateway/channel-health-policy.test.ts src/gateway/channel-health-monitor.test.ts src/gateway/server/readiness.test.ts src/gateway/server-http.probe.clock-rollback.test.ts --configLoader runner --reporter=dot OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-gateway-health-vitest-cache node scripts/run-vitest.mjs src/gateway/server-methods/server-methods.test.ts --configLoader runner --reporter=dot -t 'gateway healthHandlers.health cache freshness' node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo node scripts/run-tsgo.mjs -b test/tsconfig/tsconfig.core.test.gateway-root.json --builders 1 node scripts/run-tsgo.mjs -b test/tsconfig/tsconfig.core.test.gateway-other.json --builders 1