Skip to content

The Failed run path #5

Closed
Closed

Description

@JacobStephens2

Parent

#2

What to build

The Failed run path, from the spec's "Failure path" and "Cleanup" decisions. Any failure after the worktree exists goes through it:

  • In the worktree, commit everything including uncommitted work as the failure commit: thirdshift: failed run (<reason>), a blank line, then <ISO timestamp>, host <hostname>. Uncommitted work at the time of failure is included in this commit. An unfinished merge is aborted first.
  • If the Issue branch has no changes against the Base branch, skip the commit and push; otherwise push.
  • If an open PR exists for the Issue branch, convert it to a draft.
  • Print the most recent session log path to stderr and exit non-zero. Cleanup still runs.

Failure triggers covered here: claude exits non-zero, no PR found, PR targets the wrong base, and SIGINT/SIGTERM (Ctrl-C). Also: a PR the agent left as a draft is marked ready with gh pr ready and the run still succeeds.

Acceptance criteria

  • claude exiting non-zero → failure commit with reason claude exited <code>, containing the agent's uncommitted work, pushed to origin
  • No PR after the session → failure with reason no PR found; PR against the wrong base → failure naming both bases
  • No changes against the Base branch → no failure commit and no push (no Issue branch on origin)
  • An open PR is converted to a draft on failure
  • A draft PR left by the agent is marked ready, and the run exits 0
  • SIGINT while the session runs → session stopped, reason interrupted, same failure path, cleanup done
  • Every failure: non-zero exit, log path on stderr, nothing on stdout unless a PR exists, no worktree, local Issue branch, or temp directory left

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions