fix(step): report steps stopped by Ctrl-C as cancelled instead of failed #1643
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1643"
general
weight: 0.35
jdx
<!-- entire-trail-link-start -->
https://entire.io/gh/jdx/hk/trails/219
<!-- entire-trail-link-end -->
Problem
Interrupting
hk checkwith Ctrl-C reported the interrupted step asfailed, as if its command had errored. Automation reading--format jsonlor the MCP result saw a failed step (and a failed run) for something the user stopped on purpose.Reproduction: one step running
sleep,hk --format jsonl check --all, then SIGINT.Before (origin/main,
HK_LIBGIT2=1and0identical):After:
(The step-event values above are copied from real runs of the two binaries; the summary lines are abbreviated from the terminal output.)
What changes
is_cancelled_run_error(a cancellation error while the run's cancel token is cancelled), decides that an error is a cancellation. Thejoin_jobsfailure callback, the per-job error path, and the step group's error fallback use it throughstatus_error: a cancellation ends the step cancelled and never callsmark_step_failed.failedand keep the failure text.cancelledwith nofailuretext. The MCP server reports a run whose result sayscancelledascancelled, matching a run stopped bycancel_run.cancelledinstead of a redERRORfor the interrupted step (fail-fast aborts still sayaborted).docs/agents.md(and the sea shanty page, restamped) now state thecancelledstep and run statuses. Thecancelledstatus already existed for steps stopped by a fail-fast abort; no schema change.Unchanged: the process exit status is 1 with
command was cancelledin stderr, exactly as on main (measured on both). The hook-levelhk ERROR check: hook finished with errorlog line is still printed. Real failures,--no-fail-fast, allowed failures, diagnostics recording and dependency wake-ups from #1642 behave as before. A real failure that happened before the Ctrl-C still reportsfailed; only the interrupted step iscancelled.Validation
test/ctrl_c_cancelled.batsunderHK_LIBGIT2=1and0: interrupted sleeping step iscancelledwith acancelledrun, no failed steps,command was cancelledin stderr and exit 1; a real failure still reportsfailed; a Ctrl-C after a real failure (--no-fail-fast) keepsbadfailed and cancels onlyslow. Tests 1 and 3 fail against the main binary and pass here.HK_LIBGIT2values.cargo test step::,mcp,--bin hk cli::pass; fmt andclippy --all-targets -D warningsclean.Not verified: a Windows run, and an MCP-level test of an externally interrupted hk (the
cancelledmapping inmcp.rsis exercised only by reading;mcp_cancel_runcovers thecancel_runpath). Thehk agent stop-hookcommand is not on this branch, so it was not touched.🤖 Generated with Claude Code
AI-assisted — Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: unavailable.
<!-- CURSOR_SUMMARY -->
---
<!-- /CURSOR_SUMMARY -->