Repository navigation
fix(gateway): refresh health after runtime inspection failure - #127174
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 7:55 AM ET / 11:55 UTC. ClawSweeper reviewWhat this changesThe PR treats failed live runtime inspection as an unverified Gateway health cache, then adds Gateway and JSON CLI regression coverage for fresh success or structured failure. Merge readinessKeep open: current main still marks a runtime-inspection failure as an unchanged cache and can return stale success, while this branch forces the existing foreground refresh/error path. No actionable patch defect found; exact-head CI and rebase confirmation remain before merge. Likely related people: steipete (high) and Vincent Koc (medium). Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherGateway health compares its cached status with the live channel runtime before replying to health RPC callers. The routed CLI commands render that RPC result as JSON and use its success or failure for their process exit status. flowchart LR
A[Health CLI command] --> B[Gateway health RPC]
B --> C[Cached health snapshot]
C --> D{Live runtime inspection}
D -->|Verified unchanged| E[Return cached health]
D -->|Changed or unavailable| F[Collect fresh health]
F --> G[Fresh snapshot or typed unavailable error]
G --> H[JSON output and exit status]
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +79. Total +79 across 3 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the fail-closed cache decision at the health-handler owner boundary, then merge only after the rebased exact head preserves the focused Gateway and CLI contracts. Do we have a high-confidence way to reproduce the issue? Yes, from source: with a fresh cached snapshot, make runtime inspection throw and make refresh reject; current main returns cached success while the branch returns UNAVAILABLE. Is this the best way to solve the issue? Yes. The health handler owns the cached-versus-refresh decision, and marking failed inspection as unverified reuses its existing foreground refresh and typed-error contract without new surface area. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cb563bb16d94. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Closes #127167
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
What Problem This Solves
Fixes an issue where operators or monitoring scripts running
openclaw health --jsonoropenclaw gateway health --jsonwould receive a stale healthy snapshot and exit code zero when live channel-runtime inspection failed and health collection could not refresh that snapshot.Why This Change Was Made
The documented cache contract permits reuse only when a fresh snapshot is verified unchanged against live channel runtime. Treat an inspection failure as an unverified cache and reuse the existing foreground passive refresh: successful collection returns fresh data, while failed collection returns the existing typed
UNAVAILABLEGateway request error. This changes one production token without adding a branch, protocol field, fallback, retry, configuration, or dependency.User Impact
Both machine-readable health commands now report a structured
gateway_request_errorand exit nonzero if the Gateway cannot produce a verified health snapshot. If collection succeeds despite the unavailable runtime snapshot, callers receive the fresh health snapshot. Verified cache hits, background refreshes, explicit probes, account/lifecycle invalidation, and successful health collection remain unchanged.Evidence
respond(true, { ok: true, ... }, undefined, { cached: true })instead of the existingUNAVAILABLEerror or newly collected snapshot.tbx_01m0j12s2rh7xc41hc3h6xkrx1; prepared run: https://github.com/openclaw/openclaw/actions/runs/32477121136.+1/-1(net0); regression tests:+79/-0.