Skip to content

Inherited failures: fail fast on a red Base branch, or fix it with a Base fix #221

Closed
4 of 4 issues completed

Description

@JacobStephens2

Problem Statement

When the Base branch's CI is broken, every Run on that repository fails, and a Merge run never reaches its Self-merge, until someone fixes the Base branch by hand. thirdshift treats every red check as the branch's to fix. So each Run spends a CI-fix Repair rediscovering that the check also fails on the Base branch, and then ends as a Declined CI fix with a cause that doesn't say why (JacobStephens2/cascade#19, JacobStephens2/chart35#71). A user who trusts thirdshift to look after the codebase ends up fixing the Base branch's CI themselves, or asking an agent to, outside thirdshift.

Solution

thirdshift recognises an Inherited failure itself, before any Repair. That's a failed check on the head of the Issue branch that also failed, under the same check name, on the Base branch commit the head last merged in. By default the Run fails at once, starts no Repair, and gives a cause that names the checks and the Base branch: CI red on <check>, which also fails on <base> at <short sha>; fix <base> first. Nothing merges, and no pull request is left ready, past red CI.

A user who wants thirdshift to go further can allow a Base fix, by flag or in the User config. The Run then opens an issue for the Inherited failure and starts a Merge run into its Base branch to fix it. Once that merges, the Run merges the fixed Base branch in and carries on. See ADR 0008 and the Inherited failure and Base fix entries in CONTEXT.md.

User Stories

  1. As a thirdshift user, I want a Run whose only red checks also fail on the Base branch to fail without starting a CI-fix Repair, so that I don't pay for a session that can't help.
  2. As a thirdshift user, I want the cause of such a failure to name each failing check, the Base branch and the Base branch commit, so that I know what to fix and where.
  3. As a thirdshift user, I want the cause to tell me to fix the Base branch first, so that the next step is obvious from the Run notification alone.
  4. As a thirdshift user, I want a Run whose failing checks fail only on the branch to behave exactly as it does today, so that real regressions still get a CI-fix Repair.
  5. As a thirdshift user, I want a Run with some checks red on both and some red only on the branch to start a CI-fix Repair for the branch-only checks, so that the branch's own failures still get fixed.
  6. As a thirdshift user, I want that Repair's prompt to list the Inherited failures separately and tell the agent not to fix them, so that the agent doesn't change unrelated code or weaken checks.
  7. As a thirdshift user, I want a Run whose branch-only checks turn green while Inherited failures stay red to fail with the Inherited failure cause, so that the outcome names the real blocker.
  8. As a thirdshift user, I want a check with no finished result on the Base branch commit (no CI on pushes, missing, or still pending) not to count as an Inherited failure, so that thirdshift never assumes the Base branch is red without evidence.
  9. As a thirdshift user, I want thirdshift never to trigger CI on the Base branch, or wait for it, just to make this comparison, so that a Run never stalls on the Base branch's CI.
  10. As a thirdshift user, I want thirdshift to decide Inherited failures from check names and conclusions only, never from log text, so that the decision is deterministic, consistent with the Self-merge never reading GitHub's error text.
  11. As a thirdshift user, I want a Run that meets Inherited failures after the Base branch has moved on to merge the newer Base branch and watch CI again, counted as a Base move, so that a Base branch someone just fixed lets the Run succeed.
  12. As a thirdshift user, I want a Run that fails on Inherited failures to put its pull request back to a draft, so that "ready for review" keeps meaning green.
  13. As a thirdshift user running a Merge run, I want an Inherited failure never to be merged past, so that no code merges unbuilt or untested.
  14. As a thirdshift user running a Spec run, I want a Ticket's Run to compare against the Spec branch (its Base branch), so that the rule is the same everywhere.
  15. As a thirdshift user running a Spec run, I want the Tickets checklist and the Spec run's Run notification to show the Inherited failure cause for each Ticket that hits it, so that I can see the whole Spec run was blocked by one broken check.
  16. As a thirdshift user, I want the Spec PR's own Repair loop to treat Inherited failures the same way, so that the Spec PR isn't Repaired against a red Base branch either.
  17. As a thirdshift user who trusts thirdshift with upkeep, I want to turn on Base fixes in the User config, so that every Run on my machine may fix a broken Base branch without me passing a flag.
  18. As a thirdshift user, I want a base-fix flag to allow a Base fix for one Run, and a no-base-fix flag to forbid it for one Run when the User config allows it, so that I can override the default either way.
  19. As a thirdshift user, I want base-fix and no-base-fix together to be rejected as contradictory, so that a typo can't silently pick one.
  20. As a thirdshift user, I want Setup to ask about Base fixes when merging is on, and otherwise write the setting out at its default, so that the User config shows the option without asking about it when it doesn't apply.
  21. As a thirdshift user who allowed Base fixes, I want a Run that meets an Inherited failure to open an issue naming the failing checks, the Base branch, its short sha, the check URLs and the Run's pull request, so that the fix has a record and a home.
  22. As a thirdshift user, I want that issue labelled base-fix and ready-for-agent, so that it's recognisable and the triage vocabulary holds.
  23. As a thirdshift user, I want the Base fix to be a Merge run into the Run's Base branch, whatever the Run's own goal, so that the fix actually reaches the Base branch and the Run can go on.
  24. As a thirdshift user, I want the Run to wait for its Base fix, then merge the fixed Base branch in and watch CI again, so that the original work finishes in the same invocation.
  25. As a thirdshift user, I want a Run to start at most one Base fix, so that a Base branch that stays broken can't loop forever.
  26. As a thirdshift user, I want a Run whose Base fix fails, or whose checks are still Inherited failures after the Base fix merged, to be a Failed run whose cause links the Base fix issue, so that I know where to look.
  27. As a thirdshift user, I want a Base fix to treat every red check as its own and never start a Base fix of its own, so that it can fix the very check that is red on its Base branch and can't recurse.
  28. As a thirdshift user, I want a Base fix to send no Run notification of its own, and the Run that started it to report its outcome, so that I get one message per thing I asked for.
  29. As a thirdshift user running several Runs on one repository, I want a Run to wait on an open Base fix issue that already covers its Inherited failures instead of starting another, so that one broken Base branch gets one fix.
  30. As a thirdshift user running a Spec run, I want Tickets that hit the same Inherited failure to share one Base fix, so that parallel Tickets don't race to fix the same check.
  31. As a thirdshift user running a Spec run, I want a Ticket's Base fix to target the Spec branch, so that the fix reaches the real Base branch through the Spec PR, like the rest of the Spec's work.
  32. As a thirdshift user, I want the Self-merge of a Base fix to close its issue, so that nothing is left open once the Base branch is green.
  33. As a thirdshift user, I want progress lines that say when a check is an Inherited failure, when a Base fix starts, and when the Run waits on one, so that a long wait is never silent.

Implementation Decisions

  • Where detection lives: in the Run's Repair loop, between watching CI go red and starting a CI-fix Repair. thirdshift does it itself; no agent session is involved.
  • The comparison: the failed checks on the head (check runs and commit statuses, as the CI watcher already reads them) are matched by name against the checks on the Base branch commit that head last merged in. That's the origin/<base> commit the loop merged just before pushing. A check counts as an Inherited failure only if it is Failed on both. Pending, Passed or missing on the Base branch commit means it isn't one. No waiting, no triggering CI, no log text.
  • The result of watching CI grows to separate the branch's own failures from Inherited failures, so the loop can:
    • start a CI-fix Repair for the branch's own failures only, with Inherited failures listed in the prompt as "also failing on <base>; don't fix",
    • when only Inherited failures remain: go round if the Base branch moved (counted as a Base move), otherwise start a Base fix if allowed and not yet used, otherwise fail with the Inherited failure cause.
  • Cause text: CI red on <check>[, <check>…], which also fails on <base> at <short sha>; fix <base> first. When a Base fix fails or doesn't clear it, the cause names the Base fix issue URL.
  • Failed run handling is unchanged: the pull request goes back to a draft, as for any Run that isn't green.
  • The same loop serves the Spec PR, so the Spec PR gets the same behavior against the real Base branch, and Tickets get it against the Spec branch.
  • Configuration: a new User config setting, base.fix (a boolean, default false), parsed and validated like merge.always. New command keywords base-fix and no-base-fix (with -- forms), mutually exclusive like merge and no-merge. Setup asks about it only when merging is on, and otherwise writes it at its default.
  • Base fix flow:
    1. Search open issues labelled base-fix for one whose title names the same Base branch and checks. If one is found, wait for it to close (its PR merged), then go round.
    2. Otherwise create the issue from a fixed template written by thirdshift (no agent session), labelled base-fix and ready-for-agent, titled CI red on <base>: <check>[, <check>…].
    3. Start a child thirdshift Run on it from the same Launch directory, as a Merge run into the Run's Base branch, with no Run notification, the way a Spec run starts Ticket Runs (ADR 0006). The Base fix Run is marked so it never detects Inherited failures and never starts a Base fix.
    4. On success, merge the new Base branch in and watch CI again. On failure, the original Run fails naming the Base fix issue.
  • Spec runs share one Base fix among Tickets in-process: a Ticket that meets an Inherited failure already being fixed for the same Spec branch waits on that one.
  • The cap is one Base fix per Run (started or waited on), separate from the Repair cap.

Testing Decisions

  • Test external behavior only, through the real binary with the fake gh and fake claude (tests/support::Scenario): what's on stdout/stderr, the exit code, which sessions were logged, the pull request's state on the fake GitHub, and the issues created. Don't test the loop's internals.
  • One seam: the existing black-box seam. gh fake checks <sha> '<json>' already sets checks per commit, so Inherited failure tests set red checks on both the head and the Base branch commit.
  • The fake gh grows issue creation with labels and an issue search (gh issue create --label, gh issue list --label --search) for the Base fix.
  • Prior art:
    • the CI tests (Declined CI fix, Base move, Repair cap): Inherited failure detection and cause, mixed failures, pending/missing on Base, Base moved
    • the Merge run tests: no Self-merge past Inherited failures
    • the Spec run tests: Ticket against the Spec branch, shared Base fix, Tickets checklist cause
    • the User config and Setup tests: base.fix parsing and Setup's question
    • the command surface tests: base-fix / no-base-fix and their contradiction
  • A Run whose checks fail only on the branch must keep passing the existing CI tests unchanged. That's the regression guard for acceptance criterion 3 of Inherited failures fail the Run without a Repair #103.

Out of Scope

  • Ending the loop when a Repair makes no commit (Repair loop keeps re-checking the same commit after a CI-fix Repair makes no change #102, done).
  • Triggering, re-running or waiting on the Base branch's CI to get a comparison.
  • Merging past red CI in any form, including behind an opt-in (rejected in ADR 0008).
  • Stopping a whole Spec run early once one Ticket meets an Inherited failure.
  • Reading CI log text to tell different failures in the same check apart.
  • A Base fix that isn't a Merge run.

Further Notes

Sub-issues

Sub-issues

4 of 4 Issues completed
Loading 4 sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions