Repository navigation
fix(policy): stop watch promptly when interrupted - #186562
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR cancels Policy watch polling on SIGINT or SIGTERM while allowing an active evaluation to settle. Example: Interrupt
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it repairs a current Policy watch cancellation bug without actionable findings; current-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe bundled Policy plugin registers a CLI watch command that reads workspace policy evidence, evaluates conformance, and emits attestation drift reports between polling waits. flowchart TD
A[Policy watch CLI] --> B[Evaluate workspace evidence]
B --> C[Emit drift report]
C --> D[Abortable polling wait]
D --> B
E[SIGINT or SIGTERM] --> F[Command cancellation owner]
F --> D
F --> G[Join evaluation and exit]
Technical reviewBest possible solution: Land the command-owned abortable wait and evaluation-settlement repair after current-head CI passes. Do we have a high-confidence way to reproduce the issue? Current-main source shows the uncancellable wait, and the supplied built-CLI comparison confirms both signal failures; no target code was executed during this read-only review. Is this the best way to solve the issue? The smallest complete repair belongs in the existing watch command: cancel its wait, retain active evaluation settlement, suppress subsequent reports, and release listeners without changing shared evaluation or error owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d18dc4e06727. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +32, Tests -3, Docs +4. Total +33 across 4 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed October 28, 2026, 4:57 AM ET / 08:57 UTC (Revision 3). |
|
Updated the lifecycle test to use the existing public SDK helper imports. The 49 focused/boundary tests and fresh built-CLI signal/control proof pass at @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Built CLI proof on Linux arm64, Node v24.22.1, with isolated profile/HOME/config/state/workspace and a real authored Main Candidate emitted no report after the interrupt. Baseline processes were force-stopped by the harness only after observing that they remained alive beyond five seconds. Controls on both refs:
All child groups were stopped/joined. No system-clock changes, Gateway, model, channel, or paid credentials. 42 focused tests passed after consolidation, including exact listener cleanup, first-signal precedence within the command, held evaluation, once/no-signal, interval cap and error NDJSON. On base the two held-signal regressions fail and the no-signal control passes. Test delta is -3 lines, no ceiling raised. Lint/format/whitespace checks passed. |
|
Thanks @obviyus for reviewing this and running the extra verification! |
fix(voice-call): stop voicecall tail on Ctrl-C and SIGTERM openclaw voicecall tail ignored SIGINT and SIGTERM while it followed the call log, so it kept running and printing records after Ctrl-C or a service stop. It now stops on the first signal and exits with the conventional status, following the pattern policy watch uses (#186562). Evidence: built Linux CLI on Node 24.22.1. On main tail stayed alive and printed a later JSONL record after each signal (twice each); with this change it exited with 130 or 143 in 41 to 46 ms, with no later output (twice each). The SQLite-backed tail also exits correctly, and no-signal and finite-run controls pass. If stdout is never read, the process now stops through the launcher's SIGTERM after about 1.1 s; on main it never stops in that case. Details: #186691 (comment). Thanks @Alix-007. Co-authored-by: Ayaan Zaidi <[email protected]>
fix(cron): stop cron run --wait on Ctrl-C and SIGTERM cron run --wait (and the automations alias) ignored SIGINT and SIGTERM while it polled for the job result, so it kept polling after Ctrl-C or a service stop. It now stops on the first signal, exits with the conventional status and prints no final result. It doesn't cancel the job itself, matching policy watch (#186562) and voicecall tail (#186691). Evidence: built CLI on Node 24.22.1 with both aliases (48 real processes). On main the waiter stayed alive more than 5 s after each signal and made 201 more polls in total (twice each); with this change it exited with 130 or 143 in 20 to 32 ms, with no later polls, no final-result output and no cancel RPC (twice each). Completed, deadline, no-wait and zero-wait controls behave the same on both refs. The Gateway side was a recorded WebSocket fixture. Details: #186750 (comment). Thanks @Alix-007. Co-authored-by: Ayaan Zaidi <[email protected]>
fix(policy): stop policy watch promptly when interrupted openclaw policy watch ignored SIGINT and SIGTERM while it waited for the next poll, so Ctrl-C or a service stop left it running until it was killed. The watch loop now ends on the first signal, waits for any in-flight policy read to finish, and exits with the conventional signal status. Evidence: built CLI on Node 24.22.1. On main the watch stayed alive for more than 5 s after SIGINT or SIGTERM (twice each); with this change it exited with 130 or 143 within 26 to 49 ms (twice each). Single-shot, invalid-input and no-signal runs, plus a signal that arrives during a held policy read, behave correctly on both refs. Details: openclaw#186562 (comment). Thanks @Alix-007. Co-authored-by: Ayaan Zaidi <[email protected]>
fix(voice-call): stop voicecall tail on Ctrl-C and SIGTERM openclaw voicecall tail ignored SIGINT and SIGTERM while it followed the call log, so it kept running and printing records after Ctrl-C or a service stop. It now stops on the first signal and exits with the conventional status, following the pattern policy watch uses (openclaw#186562). Evidence: built Linux CLI on Node 24.22.1. On main tail stayed alive and printed a later JSONL record after each signal (twice each); with this change it exited with 130 or 143 in 41 to 46 ms, with no later output (twice each). The SQLite-backed tail also exits correctly, and no-signal and finite-run controls pass. If stdout is never read, the process now stops through the launcher's SIGTERM after about 1.1 s; on main it never stops in that case. Details: openclaw#186691 (comment). Thanks @Alix-007. Co-authored-by: Ayaan Zaidi <[email protected]>
…#186750) fix(cron): stop cron run --wait on Ctrl-C and SIGTERM cron run --wait (and the automations alias) ignored SIGINT and SIGTERM while it polled for the job result, so it kept polling after Ctrl-C or a service stop. It now stops on the first signal, exits with the conventional status and prints no final result. It doesn't cancel the job itself, matching policy watch (openclaw#186562) and voicecall tail (openclaw#186691). Evidence: built CLI on Node 24.22.1 with both aliases (48 real processes). On main the waiter stayed alive more than 5 s after each signal and made 201 more polls in total (twice each); with this change it exited with 130 or 143 in 20 to 32 ms, with no later polls, no final-result output and no cancel RPC (twice each). Completed, deadline, no-wait and zero-wait controls behave the same on both refs. The Gateway side was a recorded WebSocket fixture. Details: openclaw#186750 (comment). Thanks @Alix-007. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
policy watchkeeps its polling wait alive after an interrupt, delaying CLI cleanup until the next interval. Long intervals make an otherwise completed watch appear stuck.User Impact
SIGINT/SIGTERM stop a waiting watch promptly with exit status 130/143. An already admitted evaluation still settles, but does not emit another report after interruption.
--once, interval validation, findings, and attestation semantics remain unchanged.Why This Change Was Made
Keep cancellation with the watch command: one private AbortController owns the polling wait and first signal result, while a
finallyremoves both listeners. Existing evaluation and error owners remain intact; no new signal API, configuration, permission, or policy-enforcement behavior.Evidence
Observed runtime capture.
Built CLI, Linux arm64, Node 24.22.1, isolated HOME/profile/config/state/workspace and a real authored
policy.jsonc. Commands usepolicy watch --json --interval-ms 60000; signals arrive after the first report.--oncesuccess, invalid-interval rejection, and no-signal behavior.Simplification: reused the existing Policy CLI harness and consolidated related watch/status/overlay tables, removing duplicate temp-directory, process, and output setup. All distinct cases remain; the contributor's public-helper import repair is retained. Production +43/-11, tests +103/-106 (net -3), docs +4. No ceiling raised.
Two-way door: reverting restores delayed interruption; no migrations or persisted format changes. Blast radius is Policy watch cancellation and cleanup, not policy enforcement or attestation contents.