# A red check can become a reviewed fix.

> When an eligible check fails, Hive can wake a scoped coding agent with the run, logs, diff and test evidence already attached. The candidate returns on your branch and the next gate decides whether it worked.

Source: https://hiveci.io/self-healing-ci
Language: en
Alternate: https://hiveci.io/de/self-healing-ci

Autofix is opt-in per check. Infrastructure failures and timeouts do not spend an agent run.
## Failure evidence travels with the work.
No log-pasting ritual and no detached chat. The run, the agent and the verifying gate are one traceable chain.
1. **A declared check fails** — Hive classifies what failed and materializes a fixer only when that step opted in and policy allows it.
2. **The evidence is already there** — The agent reads the failing task, bounded logs, named tests, the branch diff and prior verified fixes directly.
3. **A candidate is produced** — The agent edits in an isolated workspace. The wrapper owns scope, budgets, verification and git delivery.
4. **The branch gate runs again** — The pushed candidate triggers a fresh run. That run—not the agent’s prose—is the merge gate.
## A fixer is a step you declare. Nothing wakes one by default.
Two lines in the pipeline file, and they are the whole contract.
fix_step names a dormant agent step; on_failure attaches it to exactly one target. A step without on_failure never wakes an agent, and a pipeline with no fixer declared has no autofix — there is nothing to disable.
The fixer must exist, repair one task, and have no dependencies of its own. The pipeline language rejects anything else at evaluation, before a run is created.
```starlark
fixer = fix_step(target = "test")          # @hive//factory.star (agent, dormant)
hive.pipeline(name = "pr-checks", on = [hive.on.pull_request(branches=["main"])],
    steps = [
        hive.step(name = "test", image = CI, run = "go test ./...", on_failure = fixer),
        fixer,
    ])
```
From the in-pipeline autofix contract. Remove on_failure and the step just fails the gate.
## Three beats, one branch, nothing merged by the agent.
The same run the hero shows, followed through — captured from the committed fixture set, so it is a designed story rather than a customer’s branch.
1. Run #4821 fails on test-2 with three named tests; the diagnosis panel says which and why.
2. The fixer regenerates the stale order fixtures, re-runs pytest to 1262 passing, pushes, and opens a pull request with the root cause.
3. The push triggers a fresh run on the branch head. That run — not the agent’s summary — is what turns the check green, and your merge policy still decides.
## Give the model evidence, not a wall of text.
Hive compiles a bounded task brief from facts it already owns, then exposes narrow tools for the evidence the agent needs next.
- **Failures with names** — Failed tasks, parsed test results, reports and bounded log tails arrive as structured evidence.
- **The exact branch delta** — The triggering SHA and diff keep the agent on the failure that actually happened.
- **Verified fixes, not folklore** — Similar prior outcomes are surfaced only when a later gate proved them green.
- **Calls instead of copied pages** — The agent can inspect the current run and selected checks through reviewed capabilities.
- **Budgets outside the prompt** — Turn, token, scope and delivery rules are enforced by the wrapper the model cannot rewrite.
- **Evidence before delivery** — A candidate must satisfy the lane’s configured verifier before the wrapper can ship it.
## Self-healing does not mean self-authorizing.
The automation acts inside boundaries your pipeline and platform policy declare.
- **You choose which checks wake an agent.** — A new step has no fixer by default. Runtime policy can suppress a misbehaving fixer without changing the pipeline.
- **The candidate still has to pass CI.** — If the fixer fails, exceeds its bounds or cannot verify its work, the original failure stands.
- **The normal branch workflow remains.** — Hive pushes a candidate to the branch. Your required checks, review rules and merge policy stay authoritative.
## What a fixer will not do.
Each line is a rule the wrapper enforces, not a promise the model is asked to keep.
| | |
|---|---|
| No opt-in, no fixer | A step without on_failure never wakes an agent. The default for every new step and pipeline is no autofix, with nothing to switch off. |
| Infrastructure | Timeouts, runner loss and classified infrastructure failures never wake a fixer. Only a failure that looks like code work does. |
| Its own commit | A fixer’s push never wakes another fixer, so a wrong candidate cannot start a loop. |
| Budget and persistent red | Turn and token budgets are enforced outside the prompt, and a step that stays red across candidates stops spending agent runs. |
| Operator override | Runtime autofix policy can suppress a misbehaving fixer without a pipeline change, and re-enable it the same way. |
## The repair loop is one lane in a larger agent system.
- **Direct agents yourself** — Run workstation and cloud sessions, steer them from the browser, and see their branch and CI state.
- **See the CI/CD core** — Pipelines, runners, warm caches, managed test databases and the API underneath the repair loop.
## Bring one repository. See the whole system work.
Start on your own runner, keep your existing CI beside it, and watch Hive turn the next eligible red check into a reviewable fix.
