Skip to content

fix(cli): pending system and skill reads outlive interruption - #187504

Merged
obviyus merged 7 commits into
openclaw:mainfrom
Alix-007:fix/alix-system-query-cancel-20261029
Oct 29, 2026
Merged

obviyus merged 7 commits into
openclaw:mainfrom
Alix-007:fix/alix-system-query-cancel-20261029

Conversation

@Alix-007

@Alix-007 Alix-007 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Related: #187512

What Problem This Solves

Fixes pending System and skills-discovery reads continuing after the CLI accepts Ctrl-C or SIGTERM, then printing late results instead of completing cleanup.

User Impact

system presence, system heartbeat last, skills search <query> and queryless Trending reads stop without late output and exit 130/143. Already-accepted system events and heartbeat changes still wait for their receipt. Ordinary results and errors keep their existing behavior; no configuration or migration is required.

Why This Change Was Made

Both contributor fixes share the existing invocation AsyncWorkScope signal. Read actions explicitly pass it to the existing Gateway or native ClawHub request owner, which retains deadline composition, body cleanup and read-only retry policy. The CLI suppresses output after accepted read cancellation. Mutations and unrelated callers do not acquire ambient cancellation.

This combines #187512 into the earlier #187504 and retains both original Alix-007 commits: 3f8d8c4 and 09cb779, plus their latest synchronization repair 6e3a20a. No new supervisor, signal handler, protocol or persistence owner is introduced.

Regression coverage reuses the existing System registration and skills rendering fixtures. Both test-line allocations are removed; whole-change test delta is 0, production +41 lines. Native deadline and GET/POST retry coverage remains. The extra native cancellation fixtures are covered by stronger built-CLI observed-boundary proof. The contributor's synchronization repair is retained in history, while the combined PR keeps its consolidated zero-growth test surface without a guessed sleep or production instrumentation.

Evidence

Observed built-CLI before/after results, mutation controls and backoff-specific negative control.

  • Main c8a27378eeca twice and candidate 46210b846134 twice, 19 cases per run on Node 24.22.1 Linux: all four affected commands under SIGINT/SIGTERM, native retry cancellation, ordinary results/errors, and accepted event/heartbeat receipts.
  • Final head 989919049688 preserves the contributor's latest follow-up and has the exact same tracked tree as the built/proven 46210b846134 (tree 784eec7761e9de10b26e35498465142657db2114). No proof input changed; the existing runtime and focused checks remain applicable.
  • Main's 20 interrupted reads remain pending until peer/timer release and print late results. All 20 candidate reads exit naturally 130/143 before release, with empty stdout and no ordinary error. The mutation controls retain their receipt lifetime on both builds.
  • Partial-body and retry cases synchronize on actual reader consumption and actual retry-timer installation. Removing only abortable backoff makes the observed-backoff control fail; restoring it and rebuilding passes the complete candidate matrix. No system clock is changed.
  • 56 focused tests passed, one existing macOS-only skip; formatting and lint passed. Three consolidated regression assertions fail on main for the intended missing-signal/late-output reasons. Final CLI build passed. Broad verification belongs to hosted CI.

Limits: actual public CLI, invocation scope and native transports against synthetic loopback service peers, with isolated profiles and OPENCLAW_NO_RESPAWN=1. This observes natural CLI cleanup, not a separate default-respawn-launcher matrix. No live Gateway/ClawHub service, server-side mutation persistence, external credentials or cross-platform result is claimed.

Merge Danger

Two-way door: reverting restores the old interruption behavior without a data migration. Blast radius is these four CLI reads and explicitly signalled native ClawHub reads. Incorrect wiring could leave a read pending, suppress its output, or cancel it too early; accepted mutation receipts and unrelated callers intentionally retain their existing lifetime.

@clawsweeper

clawsweeper Bot commented Oct 29, 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 docs Improvements or additions to documentation cli CLI command changes size: S labels Oct 29, 2026
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Cancels interrupted system queries and skills searches without late output while preserving accepted mutation receipts.

Example: SIGINT arrives while openclaw system presence --timeout 60000 --json awaits a response.

  • Before: The read remains pending and can print late JSON.
  • After: The connection closes and the CLI exits naturally with status 130 and empty stdout.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused repair with discriminating shipped-entry-point evidence, retained regression coverage, and no actionable findings; broad exact-head CI is still pending.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The collaborator records repeated public openclaw.mjs comparisons on Linux/Node 24.22.1 using isolated profiles and real Gateway/HTTP clients against synthetic peers: interrupted reads exit 130/143 before release without stdout, including partial-body and observed retry waits, while ordinary results/errors and accepted mutation receipts remain intact; identical tree hashes make the proof applicable to the reviewed head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Pending system and skills reads can continue after accepted interruption and print late results.
Reason: The repair restores expected interruption behavior without adding configuration, persistence, or competing lifecycle machinery, and the collaborator has integrated and proven the combined direction.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a current-main interruption bug through existing lifecycle owners, with convincing CLI proof and no actionable findings; exact-head CI remains pending.

Priority: P2
Reviewed head: 989919049688569aff256a2bf952ac8e89720dc1

Before merge

None.

Findings

None.

Agent review details

How this fits together

CLI read actions pass invocation cancellation through Gateway RPC or ClawHub HTTP owners, which return results or settle cancellation before command cleanup completes.

flowchart TD
  A[CLI read command] --> B[Command action]
  C[Invocation cancellation] --> B
  B --> D[Gateway RPC client]
  B --> E[ClawHub HTTP client]
  D --> F[Service peer]
  E --> F
  B --> G[Results or quiet cancellation]
Loading

Technical review

Best possible solution:

Land the focused signal forwarding and output guards through the existing invocation, Gateway, and ClawHub owners once required CI passes.

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

Current-main source establishes the missing cancellation path, and supplied base/head CLI observations reproduce it; this read-only review executed no target code.

Is this the best way to solve the issue?

This is the smallest complete repair: explicitly forward cancellation through existing owners and suppress cancelled read output while preserving mutation settlement.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • System registration and error handling keeps the original intent (fd3914e: Consolidate registration while preserving command-specific contracts; fix(cli): return structured system event errors #123614 separately establishes structured ordinary errors.)
  • Skills rendering and regression consolidation keeps the original intent (c928f7a: Share version-label policy while preserving raw JSON, owner references, sanitization, and parent/leaf JSON options; those contracts remain represented.)
  • ClawHub request deadlines and cleanup keeps the original intent (fix(clawhub): bound streaming metadata and error responses #109092: Keep deadlines active through metadata/error consumption while retaining archive, cleanup, authentication, and read-only retry behavior.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit fd3914e adds src/cli/system-cli.ts:111 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: fd3914e0af3f; files: src/cli/system-cli.ts)

PR surface

Source +41, Tests 0, Docs +6, Other -1. Total +46 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 48 7 +41
Tests 2 58 58 0
Docs 2 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 9 112 66 +46

Review metrics

Metric Value Why it matters
Production versus test growth Production +48/-7 (net +41); tests +58/-58 (net 0) The bounded production growth connects existing cancellation owners, while consolidated fixtures retain rendering and mutation controls.

Root-cause cluster

Relationship: canonical
Canonical: #187504
Summary: This PR consolidates the system and skills read-cancellation repairs.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Interrupted diagnostic and discovery reads can linger and print unwanted results, with limited impact outside these CLI commands.
  • 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 (1 earlier review cycle)
  • reviewed 2026-10-29T08:47:00.553Z sha 3f8d8c4 :: needs maintainer review before merge. :: none

Reviewed October 29, 2026, 6:06 AM ET / 10:06 UTC (Revision 2).

@obviyus

obviyus commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Combined built-CLI proof for #187504 and #187512

Both original contributor commits are retained: system 3f8d8c4eac67d3731a7b98affede8c8262456dd4 and skills 09cb7796e4f29b8b6b69adcbb8acf2b80b868a2a, along with the contributor's latest synchronization repair 6e3a20afa4ebb6e7301f0d3e37a4919780c3ca64. Final head is 989919049688569aff256a2bf952ac8e89720dc1; the runtime was built and proven at 46210b8461340175ff0c62d4223c20cf1221afd9. Both commits have the identical tracked-tree hash 784eec7761e9de10b26e35498465142657db2114: the history-only integration retains the consolidated zero-growth test surface and changes no source, test, documentation or configuration input. The applicable proof is reused rather than rebuilding identical code. Baseline main is c8a27378eecac4f7cb82110f682ca0284d0493a9.

Both artifacts were built in a secretless Linux container on Node 24.22.1. The actual public openclaw.mjs entry, Commander actions, invocation scope, Gateway client and native ClawHub HTTP/body/retry owners execute unmocked. Only the external WebSocket/HTTP service peers are fixtures. Every run uses an explicit isolated profile, home, state and configuration; the built binary's config file --json confirms the selected path. These remote query commands do not select an agent transcript database. No live Gateway, ClawHub account or credentials are used.

Repeated observations

Each build ran the same 19 cases twice (76 complete cases total):

Cases per run Main, twice Candidate, twice
system presence, system heartbeat last, skills search cancel-fixture, and queryless skills search, each under SIGINT and SIGTERM (8) Still pending with connection open before peer release; prints late JSON afterward Closes the read and exits naturally 130/143 before release; stdout empty
Skills search interrupted during an observed native retry sleep, both signals (2) Still pending before timer release; later prints results Exits 130/143 before release; stdout empty, one GET
Ordinary completion for all four commands (4) Expected output, exit 0 Same
Ordinary RPC and HTTP error controls (2) Expected failure, exit 1 Same
Already-accepted event, heartbeat enable and heartbeat disable controls (3) Remains pending/open for the delayed receipt, then prints it once and exits with the accepted signal status Same

Thus all 20 candidate interrupted reads exit before release with no late output or ordinary error; all 20 baseline interrupted reads remain pending and later print output. Every configuration remains byte-for-byte unchanged. The three accepted mutation controls retain their existing receipt lifetime in every run.

The collector uses OPENCLAW_NO_RESPAWN=1 so the observed result is the CLI's natural cleanup status, not a launcher's forced-kill backstop. Exit codes are 130 for SIGINT and 143 for SIGTERM. This does not claim a separate default-respawn-launcher matrix or server-side persistence effects.

Deterministic native body and retry boundaries

This also addresses the P3 synchronization finding on #187512 without adding production instrumentation or a guessed pre-abort sleep:

  • The partial-body case signals only after the real response reader has consumed the fixture's 12-byte JSON prefix; the remaining body is still held.
  • The retry case signals only after the real 59-second Retry-After timer is installed. The observer records the native retry stack. Timer release is process-local; the system clock is never changed.
  • Discriminating negative control: remove only the abortable-backoff sleep option, retaining every other signal-forwarding change. After observed retry entry and accepted SIGINT, that variant remains alive until timer release. The candidate's prompt-exit assertion fails for the intended reason; it eventually exits 130 with empty output. Restore the single line and rebuild: the complete candidate comparisons pass, including both backoff signals. This catches removal of backoff cancellation rather than accidentally testing only initial fetch cancellation.
  • The negative control was also rebuilt directly from final head 989919049688, with only sleep: undefined substituted. It records defaultSleep beneath the actual native retry stack, remains alive at the 800 ms observation before timer release, then exits 130 with empty stdout and one GET. Thus the one-line negative remains discriminating on the exact final source tree, not only the earlier contributor snapshot.

Focused checks and simplification

56 focused tests passed, with one existing macOS-only skip, across System CLI, skills-search CLI, native ClawHub client, deadline and skills tests. Two canonical shards completed in 8.58 seconds wrapper wall time. Changed-file formatting parity and lint passed; the final CLI build passed.

The consolidated committed regressions fail on main for missing read-signal forwarding and late presence output (three expected failures); the accepted-event unit control still passes. The existing System registration fixture and skills rendering fixture now cover cancellation instead of duplicating large setup blocks. All version/no-version variants, owner refs, legacy slug fallback, trust labels, sanitized metadata, parent/leaf JSON paths and raw JSON version bytes remain covered.

Both test-line allocations are removed: whole-change test delta is 0. The extra native cancellation fixtures are covered by the stronger observed-boundary built-CLI proof above; existing native deadline and GET/POST retry tests remain. Alix-007 also repaired the original 20 ms synchronization issue in 6e3a20a; that original commit is retained in ancestry, while this combined PR keeps the consolidated zero-growth test surface rather than the larger fixture table. Production remains a bounded +41 lines in the existing invocation, RPC and HTTP owners. No ambient cancellation default, supervisor, protocol, schema, permission or SDK surface is added. Already-accepted mutations are intentionally not opted into the read signal.

The first pilot's synthetic search response omitted source: "clawhub"; its result-shape assertion failed. The corrected wire fixture passed both complete main comparisons. That partial pilot is not counted among the 76 complete cases.

@obviyus obviyus changed the title fix(system): stop interrupted presence and heartbeat queries fix(cli): pending system and skill reads outlive interruption Oct 29, 2026
@obviyus

obviyus commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 29, 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-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 29, 2026
@obviyus
obviyus merged commit 241614b into openclaw:main Oct 29, 2026
129 checks passed
@obviyus

obviyus commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Landed in 241614b. Thanks @Alix-007. Accepted CLI reads now stop on Ctrl-C or a service stop.

@Alix-007

Copy link
Copy Markdown
Contributor Author

Thanks @obviyus for consolidating the cancellation fixes and preserving the commits. Really appreciate the thorough CLI validation!

obviyus added a commit that referenced this pull request Oct 29, 2026
fix(cli): stop video downloads cleanly on Ctrl-C and SIGTERM

An interrupted video download kept downloading and left its staging file behind. The download now uses the existing invocation signal, as other accepted CLI reads do since #187504. It stops on the first signal, leaves no target or staging file, prints no success result and exits with 130 or 143.

Evidence: full builds on Node 24.22.1 with a real slow MP4 download through the bundled DeepInfra provider. On main the download continued and the staging file stayed after SIGINT and after SIGTERM (twice each); with this change the CLI exited 130 or 143 in 36 to 45 ms with no target, staging file or success output (twice each). Completed-download controls pass on both refs. Details: #187563 (comment).

Thanks @SunnyShu0925.

Co-authored-by: SunnyShu <0668000539@local>
Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 30, 2026
…aw#187504)

fix(cli): stop accepted CLI reads on Ctrl-C and SIGTERM

Four CLI commands that read from the Gateway over RPC or HTTP after the request was accepted didn't pass the command's interrupt signal to their read adapters. After SIGINT or SIGTERM they stayed pending and printed late results. The RPC and HTTP read adapters now take the existing invocation signal, so the reads stop and the command exits with 130 or 143 and nothing late. Mutations that were already accepted keep their existing lifetime and settlement. This includes the fix from openclaw#187512.

Evidence: built CLI against synthetic peers, 19 cases per ref. On main, all four reads stayed pending after SIGINT or SIGTERM and printed late results (twice); with this change they exited 130 or 143 before release with empty stdout (twice). Normal results and errors, and accepted event and heartbeat receipts, behave the same on both refs. Details: openclaw#187504 (comment).

Thanks @Alix-007.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 30, 2026
fix(cli): stop video downloads cleanly on Ctrl-C and SIGTERM

An interrupted video download kept downloading and left its staging file behind. The download now uses the existing invocation signal, as other accepted CLI reads do since openclaw#187504. It stops on the first signal, leaves no target or staging file, prints no success result and exits with 130 or 143.

Evidence: full builds on Node 24.22.1 with a real slow MP4 download through the bundled DeepInfra provider. On main the download continued and the staging file stayed after SIGINT and after SIGTERM (twice each); with this change the CLI exited 130 or 143 in 36 to 45 ms with no target, staging file or success output (twice each). Completed-download controls pass on both refs. Details: openclaw#187563 (comment).

Thanks @SunnyShu0925.

Co-authored-by: SunnyShu <0668000539@local>
Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation 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: S 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