Skip to content

fix(status): cancel deep gateway reads on Ctrl+C - #198651

Merged
obviyus merged 5 commits into
openclaw:mainfrom
wangmiao0668000666:fix/status-deep-read-cancel
Nov 14, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
wangmiao0668000666:fix/status-deep-read-cancel

Conversation

@wangmiao0668000666

@wangmiao0668000666 wangmiao0668000666 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes delayed or forced CLI exit when Ctrl-C or SIGTERM interrupts a pending deep Gateway read in status reports.

User Impact

status --deep, status --deep --json, and status --all stop promptly with the normal signal exit code instead of waiting for cleanup to force-kill the command. Ordinary results and failure messages are unchanged. No configuration, protocol, storage, dependency, or migration changes.

Why This Change Was Made

Forward the command's existing abort signal through the shared Gateway read owner, preserve cancellation through best-effort error conversion, and consume it at the existing report boundaries. This completes the deep-read path beside #197969 and #197909.

Log-tail collection stays in its original module; flattening its existing helper avoids an unrelated extraction. Existing test cases are consolidated while adding a pending-read cancellation regression. Production +94/-64; tests +52/-55 (net -3). The contributor's three commits are retained.

Evidence

At 2fb210e25cd064a84a8a880a0b407fa940dbc340, the production code is identical to the source-tier real-Gateway proof, which used a configured channel health probe targeting a nonanswering address, not a proxy holding replies. Each of the three command forms was interrupted twice with each signal on both revisions. Base exited 137 after about 2 seconds; candidate exited 130/143 within 0.135–0.442 seconds, with no report output after interruption.

Uninterrupted deep/plain/all/JSON controls exit 0 on both revisions. Same-container comparisons preserve report wording and nonvolatile fields; only live measurements and elapsed ages differ. The initial-probe control still stops promptly on both, with the same inherited source-runtime AbortError/exit 1.

Vitest-source regression: base 16 passed / 2 failed; final candidate Docker 18 passed (52.23 seconds including cold preparation). The commands test-types leaf, changed-file formatting, and lint passed. Contributor execution stayed in secretless Docker.

Full-tier Docker build with declarations, canonical self-contained package validation, clean packed installation, and packed CLI version/help/status-JSON smoke passed on the final head.

Detailed proof: #198651 (comment)

Revert is a two-way door: no persisted state changes. Blast radius is cancellation and failure handling in status reports; a defect could delay exit or suppress a report after interruption.

@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: S labels Nov 14, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 14, 2026
@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Forward command cancellation through deep Gateway reads and stop interrupted status reports quietly.

Example: Send SIGINT while openclaw status --deep --json waits for a channel health probe.

  • Before: The recorded baseline required a forced kill and exited 137.
  • After: The candidate exited 130 without printing a late report.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused repair with real CLI cancellation evidence, retained failure behavior, resolved prior findings, and successful exact-head CI.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The linked collaborator proof exercises the source CLI against a real isolated Gateway with a pending channel-health request: both signals stop all three affected report forms with exits 130/143 and no late output, while uninterrupted controls preserve results.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Ctrl+C or SIGTERM during a deep status read leaves the command waiting until forced termination or a late failure report.
Reason: Prompt cancellation restores established CLI behavior without changing options, output contracts, or persisted state.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current cancellation gap and is ready for normal landing consideration: prior findings are resolved, supplied runtime proof is sufficient, and exact-head CI is green.

Priority: P2
Reviewed head: 2fb210e25cd064a84a8a880a0b407fa940dbc340

Before merge

None.

Findings

None.

Agent review details

How this fits together

Status commands combine local diagnostics and Gateway RPC results into text or JSON, using the CLI work scope to receive cancellation.

flowchart TD
  A[CLI signal] --> B[Existing work scope]
  B --> C[Shared status Gateway reads]
  C --> D[Gateway transport]
  D --> E[Gateway health and diagnostics]
  C --> F[Status report boundaries]
  F --> G[Text or JSON output]
Loading

Technical review

Best possible solution:

Land the focused cancellation repair through the existing shared Gateway-read and command-report owners.

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

Current-main source exposes the missing signal path, and supplied real-Gateway comparisons demonstrate forced baseline exits during pending deep reads; this read-only review executed no target code.

Is this the best way to solve the issue?

The patch repairs the shared read owner, preserves ordinary error results, and reuses established interrupt reporting without introducing another cancellation mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 45e2704c8456.

Provenance checked

  • Shared Gateway query and best-effort failure conversion keeps the original intent (6725e57: Consolidate status Gateway queries while retaining caller-specific failure projections.)
  • Runtime snapshot and JSON health-error suppression keeps the original intent (88aa814: Share runtime collection between status report forms; later consolidation preserved visible ordinary health failures.)
  • Quiet command interrupt handling keeps the original intent (7cd1837: Stop interrupted status scans quietly while preserving reports for other failures.)
  • Status-all log collection keeps the original intent (fix(status): keep unreadable logs visible in diagnostic reports #177316: Keep unreadable logs visible while allowing missing logs to remain quiet.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +30, Tests -3. Total +27 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 94 64 +30
Tests 1 52 55 -3
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 146 119 +27

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test changes Production +94/-64; tests +52/-55 Production growth supplies cancellation propagation and existing-boundary catches without adding modules or state; regression cases replace consolidated fixtures.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Interrupting diagnostic commands can require forced termination, with limited impact outside the status workflow.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • 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 (5 earlier review cycles)
  • reviewed 2026-11-14T04:56:41.472Z sha ff705c1 :: needs real behavior proof before merge. :: [P2] Consume canonical interrupts before CLI failure reporting
  • reviewed 2026-11-14T08:36:06.442Z sha 15b577b :: blocked before merge. :: [P2] Stop status --all after consuming an interrupted overview scan | [P3] Report ordinary overview failures only once
  • reviewed 2026-11-14T10:29:24.171Z sha eccd5ac :: blocked before merge. :: none
  • reviewed 2026-11-14T11:22:03.038Z sha 29f5d30 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-14T11:46:37.008Z sha 2fb210e :: blocked before merge. :: none

Reviewed November 14, 2026, 7:18 AM ET / 12:18 UTC (Revision 6).

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Round-2 disposition of the two blocking items:

  1. P2 (interrupts reaching generic failure reporting) — fixed. Canonical aborts are now consumed at the existing command boundaries using the existing reportStatusScanFailureUnlessInterrupted helper:

    • status.command.ts / status-json-command.ts: the resolveStatusRuntimeSnapshot call is wrapped with that helper and early-returns quietly, same idiom as the scan phase two calls above it.
    • status-all.ts: the overview catch switches to the interrupt-aware variant (line-neutral) and the withProgress body gets the same outer catch. readStatusAllLogTails extracted to status-all-log-tails.ts purely to stay under the file's line-cap ratchet (mechanical, no behavior change).
    • Round-1 behavior intentionally retained: queryStatusGateway forwards the work signal; JSON suppressHealthErrors re-throws aborts instead of collapsing them into a {error} value; a late interrupt cannot publish a half-built snapshot.
  2. Real behavior proof — added to the PR body Evidence: shipped source-CLI entry (src/entry.ts, same argv/command tree as the packaged CLI) against a real in-process shipped Gateway (startGatewayServer, auth none) with a WS forwarding proxy that answers scan RPCs and holds the deep health {probe:true} reply. HEAD: transport closed within 1s of SIGINT (proxy logs CLIENT_CLOSE), exit 130, no late output. BASE (same fixture): the read outlives the interrupt by ~12s, then prints a post-interrupt gateway timeout after 11764ms caution before the launcher cleanup deadline exits 130.

  3. Test note: the mock-call-shape-only test was removed; the two behavior tests (interrupt propagation; JSON suppression escape) remain, red on base, green on head.

Not tested (unchanged from body): SIGTERM-specific variant (same shared-scope path).

@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 14, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Nov 14, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. labels Nov 14, 2026
@obviyus

obviyus commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 14, 2026
@obviyus

obviyus commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 14, 2026
@obviyus
obviyus merged commit 0640d39 into openclaw:main Nov 14, 2026
124 checks passed
@obviyus

obviyus commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

Landed in 0640d39. Thanks @wangmiao0668000666.

steipete added a commit that referenced this pull request Nov 14, 2026
…#198863)

Make MEMBER_ROLE_PRESETS private and reuse the independent service activation fixture across test consumers. Keep reportStatusScanFailure private after its last external caller moved to the interrupt-aware wrapper.

Fixes unused-export regressions from #197739 (4fc7acf) and #198651 (0640d39). Document the existing worker-GC logging mock isolation exposed by check:changed, introduced in #198857 (1b3e37b).

Production bodies are unchanged; net production LOC 0. Full deadcode scan and 247 focused tests pass. Codex autoreview is scoped-clean through P2.
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Thanks for merging this! Appreciate the review and the help landing it.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 15, 2026
fix(status): stop deep Gateway reads on Ctrl-C and SIGTERM

`openclaw status --deep`, `--json` and `--all` did not pass the command's abort signal to the deep Gateway reads (health, diagnostics.stability, last-heartbeat). A Ctrl-C or SIGTERM during a pending read did not stop it: the CLI waited until the cleanup deadline killed it. The signal now reaches those reads, and the interrupt is handled at the command boundary. Uninterrupted output and exit codes are unchanged. No new text.

Evidence: vitest-source, the regression has 2 failing abort cases on the merge base and passes here. Source tier with an isolated Gateway whose Telegram health probe targets an address that never answers, so the deep read naturally waits; each mode and signal twice per revision. Base exited 137 about 2 s after the signal (forced cleanup); this change exits 130 or 143 within 0.14-0.44 s with no late report. Uninterrupted runs print the same report and exit 0 on both; the earlier probe interrupt (openclaw#197969) still works. Full build with declarations and the packed CLI smoke pass. Net -3 test lines. Details: openclaw#198651 (comment).

Thanks @wangmiao0668000666.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 15, 2026
…openclaw#198863)

Make MEMBER_ROLE_PRESETS private and reuse the independent service activation fixture across test consumers. Keep reportStatusScanFailure private after its last external caller moved to the interrupt-aware wrapper.

Fixes unused-export regressions from openclaw#197739 (4085249) and openclaw#198651 (0dd531e). Document the existing worker-GC logging mock isolation exposed by check:changed, introduced in openclaw#198857 (4b33bc7).

Production bodies are unchanged; net production LOC 0. Full deadcode scan and 247 focused tests pass. Codex autoreview is scoped-clean through P2.
@wangmiao0668000666
wangmiao0668000666 deleted the fix/status-deep-read-cancel branch November 17, 2026 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants