cast: structured failure detection + advance over Skipped phases#104
Merged
Conversation
Re-applies the two improvements the Copilot SWE bot wrote on PR #98's branch (commit 438690b) but never landed on main, adapted to the current quest.rs surface (phases 7-10 evolved it further). The original PR #98 was overtaken by the squash-merges of #99 and #100; this commit brings the bot's fix forward on its own so reviewers can read it independently. The two changes: 1. **Structured failure detection.** Today's `handoff_reason` keyed off string patterns (`failed`, `error`, `exit 1`, `interrupted`) which misclassified non-zero exit codes other than 1 (e.g. exit 2, 137, 130) as success framing. New `phase_failed(summary)` helper checks `exit_code != 0` first, then falls back to the status-string match for cases where exit_code is `None` (interrupted runs). 2. **Advance over Skipped phases.** `advance` (and `skip_phase` when nudging the cursor) now uses a new `next_pending_index` helper so the cursor never lands on a Skipped or Complete row. Previously the shell loop carried a defensive `if matches!(..., Skipped { .. })` guard to walk past those rows; that guard still exists as a safety-net for a hypothetical async UX that mutates `cursor` directly, but the common path is now correct at the data layer. Two new tests pin the behaviour: - `advance_skips_over_skipped_phases_and_preserves_skip_reason` - `non_zero_exit_codes_use_failure_handoff_reason` `skip_phase_advances_cursor_and_marks_status` updated to assert quest exhaustion (instead of "cursor lands on the skipped row") since the new cursor advances past Skipped. Gates: cargo fmt clean, cargo clippy --tests -D warnings clean, 346 unit + 4 smoke tests pass (2 new). Co-Authored-By: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Cast quest state machine (cast::quest) to (1) classify phase failures based on structured exit codes rather than brittle status-string matching, and (2) ensure quest cursor progression never lands on already-Skipped or Complete phases—keeping the data-layer cursor consistent with the shell loop’s expectations.
Changes:
- Add
phase_failed(summary)to treat any non-zeroexit_codeas failure (with a status-string fallback whenexit_codeis missing). - Add
next_pending_index(quest, start)and use it fromadvanceandskip_phaseso the cursor always moves to the next Pending phase (or tophases.len()when exhausted). - Update and add unit tests to lock in the new cursor and failure-framing behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Re-applies the two improvements the Copilot SWE bot wrote on PR #98's branch (commit `438690b`) but that never reached main. The original PR was overtaken by the squash-merges of #99 and #100, and the bot's follow-up commit was orphaned.
This commit brings the bot's fix forward on its own, adapted to the current `quest.rs` surface (phases 7–10 evolved it further). All three open review threads on PR #98 are genuinely resolved by this change.
What changes
Tests
Two new and one updated:
Gate results
Attribution
Authored by `@Copilot` SWE bot on the PR #98 branch; co-authored on this commit so the bot keeps proper credit. Closes the loop on the three `copilot-pull-request-reviewer` threads from #98 that flagged the underlying issues.
Test plan
🤖 Generated with Claude Code