fix(step): keep diagnostics from every started job when another job fails #1642
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 #1642"
general
weight: 0.35
jdx
<!-- entire-trail-link-start -->
https://entire.io/gh/jdx/hk/trails/218
<!-- entire-trail-link-end -->
Problem
When a step fans out into several jobs (a
workspace_indicatorstep, or a batched step) and one job's check fails, the step's other jobs were aborted wherever they happened to be. A job aborted after its command finished but before it recorded its output left no diagnostics, so--sarif,--format jsonand MCP results were incomplete after a failure, and which jobs were missing depended on timing.This also hit
--no-fail-fast, which should report everything.run_all_jobsreturned on the first failing job regardless of that setting and dropped itsJoinSet, aborting the sibling jobs.Example: two workspaces,
apifails at once,webtakes 0.3s and then reports[W1], both withdiagnostic_format = "gcc":Change
run_all_jobsnow waits for every job task (join_jobsinsrc/step/execution.rs) instead of returning on the first error:--no-fail-fast, or a failure allowed byallow_failure: siblings run to completion and record their diagnostics.abort_running_steps), then waits for the siblings to return. Commands are still killed immediately; a sibling whose command had already finished records its diagnostics before it exits. A 10s grace period aborts any job that still has not returned, so a stuck job cannot hang the run. Ctrl-C gets the same 10s bound (without being treated as a failure), and a job waiting onmise envstops when the run is cancelled. A user's Ctrl-C always ends the step as cancelled (exit 1,command was cancelled, as before this PR), even if no job had started a command yet: the cancel token decides, not the jobs' results. A step waiting on a dependency stops waiting when the run is cancelled, and a cancelled step always wakes its dependents, so nothing hangs.The returned error is still the first one, except that a not-allowed error (for example a job that could not start) replaces an earlier allowed command failure and also triggers fail-fast cancellation, so it is no longer hidden. Under fail-fast the step group ignores cancellation errors from siblings once a failure has aborted them, so the original failure is always the one reported. Exit codes and output are otherwise unchanged apart from the recovered diagnostics. Errors from siblings that were cancelled are only logged at debug level.
I chose this over per-job cancel hooks or recording in an abort path: a dropped task cannot run code, and awaiting the tasks reuses the existing cancellation token with a small change.
Limits
--fail-fast(30 of 30 under--no-fail-fast). Follow-up: keep the partial output of a cancelled command (needs an ensembler change).JoinSet. Draining it would hang steps waiting on a failed dependency, so it needs separate handling. Follow-up.Validation
test/diagnostics.bats(each withHK_LIBGIT2=1and0):--no-fail-fastSARIF and JSON keep both jobs' diagnostics (fail on main, deterministic:A1only), and fail-fast kills a 30s sibling in under 15s while keeping the failing job's diagnostics.join_jobs(waits after a failure, cancel then drain, grace-period abort, all-success).test/diagnostics.bats: 18/18 ok (plan 1..18). 16 other bats files touching fail-fast,depends,allow_failure, batching, junit and staging: all ok. 30 repeated runs of the new tests: 30/30.cargo test step::passes locally (165) and on the Windows CI box (150);cargo fmt --checkandcargo clippy --all-targets -- -D warningsare clean.builtins_tests.bats.🤖 Generated with Claude Code
AI-assisted — Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: unavailable.
<!-- CURSOR_SUMMARY -->
---
<!-- /CURSOR_SUMMARY -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
Bug Fixes
Fail-fast runs now stop sibling jobs after a failure while preserving diagnostics from the job that failed.
Cancellation is handled more consistently: Ctrl-C stops running commands, dependency waits, and stalled environment resolution, while the original failure remains visible when one occurred first.
Allowed failures continue to permit dependent steps when the run was not interrupted by Ctrl-C.
* Diagnostic reports now retain results from jobs that finish when fail-fast is disabled.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->