Skip to content

fix(tether): propagate supervised command failures - #4598

Merged
max-sixty merged 6 commits into
mainfrom
nightly/clean-40282242240
Nov 5, 2026
Merged

max-sixty merged 6 commits into
mainfrom
nightly/clean-40282242240

Conversation

@worktrunk-bot

@worktrunk-bot worktrunk-bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

wt step tether returned success even when the command it supervised failed, which hid a failed dev server or other supervised task from scripts and hook logs. It now passes the command's exit status through when the command exits on its own. It still sweeps the process group first, and it uses the same child-status error as the other command runners. Two cases are not reported as a failure of the command:

  • Ctrl-C exits silently as interrupted, by SIGINT. Cancellation is checked before the child status, as in src/commands/custom.rs.
  • Worktree removal is tether's normal teardown, and it exits 0.

To make these distinctions, tether waits with forward_to_children plus wait_shared_child instead of ForegroundSignals::wait. The latter classifies any child that dies from SIGTERM as foreground cancellation, so tether's own teardown SIGTERM surfaced as an interruption (exit 143). Cancellation now counts only signals that wt itself received.

Verification: the step_tether integration tests cover all three outcomes. sh -c 'exit 7' exits 7. Removing the worktree exits 0. Ctrl-C exits by SIGINT with empty stderr. All five pass locally, and before the wait change the removal and Ctrl-C assertions failed with exit 143. The child.wait() I/O-error arm is uncovered, which the maintainer accepted.

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If child.wait() returns an I/O error, the Err(e) arm marks the trace failed, but failed_status remains None and step_tether returns Ok(()) after the sweep. That reports a failed supervisor wait as a successful command. Propagate the wait error after the final sweep, as the previous commit did.

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codecov/patch fails at 85.71% (6 of 7 added executable lines covered). The uncovered line is the child.wait() error arm (Err(e) => trace.fail(e)); the exit-status regression test covers the normal wait path. The code change resolves the prior wait-error finding, but the repository's Coverage rule in AGENTS.md requires explicit maintainer approval before merging with a failing patch check.

# Conflicts:
#	src/commands/step/tether.rs
@max-sixty

Copy link
Copy Markdown
Owner

@worktrunk-bot two changes: check outcome.cancellation before reporting the exit status, as src/commands/custom.rs:161-181 does, so Ctrl-C exits silently as interrupted instead of printing "killed by signal"; and pass the status through only when the command exits on its own, since teardown on worktree removal is tether's normal job and shouldn't log as a failure. The uncovered child.wait() error arm can stay uncovered.

This was written by Claude Code on behalf of max-sixty

Ctrl-C now returns WorktrunkError::Interrupted before the child's status is
considered, so wt exits by SIGINT without a "killed by signal" report.
A command the reaper tears down after worktree removal exits 0; only a
command that exits on its own passes its status through.

The wait no longer goes through ForegroundSignals::wait, which classifies a
child's SIGTERM death as foreground cancellation: the reaper's own teardown
SIGTERM was surfacing as cancellation (exit 143) on both paths.
@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Both changes are in dec9121.

  • Ctrl-C: cancellation is checked before the child status, as in custom.rs. wt now exits by SIGINT and writes nothing to stderr.
  • Worktree removal: the reaper records that it tore the command down, and in that case wt exits 0. Only a command that exits on its own passes its status through.

Checking outcome.cancellation alone wasn't enough. ForegroundSignals::wait goes through wait_foreground_child, which treats any child that dies from SIGTERM as a cancellation. The reaper's own SIGTERM therefore showed up as cancellation = Some(15) on both paths, and the process exited 143. Tether now waits with forward_to_children plus wait_shared_child, so cancellation counts only signals that wt itself received.

The removal and Ctrl-C integration tests now check the exit status, and the Ctrl-C test also checks that stderr is empty. All five step_tether tests pass locally. Before the wait change, both new assertions failed with exit 143. The child.wait() error arm is still uncovered, as you said it could be.

@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

CI on dec9121 is green except codecov/patch, which hits 94.73% of the diff (18 of 19 lines) against a 98.62% target. I couldn't get the miss's line number because the Codecov compare API returned a rate-limit error. The only added line without a test is the child.wait() error arm (Err(e) => trace.fail(e)), which you said can stay uncovered. Under the coverage rule, merging with this check red still needs your explicit approval.

@max-sixty
max-sixty merged commit cf5b015 into main Nov 5, 2026
35 of 36 checks passed
@max-sixty
max-sixty deleted the nightly/clean-40282242240 branch November 5, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants