Harness rollback

From Intense-Visions/harness-engineering · View interactive version

Harness rollback is an AI agent skill from the GitHub repository Intense-Visions/harness-engineering. > Post-ship circuit breaker. Proposes a full-context **revert PR** when a shipped PR fails post-merge evaluation or crosses a signal threshold. v1 is **propose-only** — it NEVER auto-merges. A human m

How to use this skill

Skill file

Harness Rollback

Post-ship circuit breaker. Proposes a full-context revert PR when a shipped PR fails post-merge evaluation or crosses a signal threshold. v1 is propose-only — it NEVER auto-merges. A human merges the revert.

When to Use

Process

Iron Law

v1 never auto-merges a revert. It opens a revert PR and stops. A human decides.

Auto-merging code — even a revert — is a high-blast-radius write, and a wrong revert is itself an incident. The trust model earns auto-merge authority only after the propose loop has demonstrably proposed _correct_ reverts over time (recorded via the rollback_event breadcrumb). Until then, the workflow carries pull-requests: write but not contents: write and no self-approving PAT. If you find yourself merging a revert automatically, STOP — that is a separate, deferred trust tier (see ADR 0063).


Phase 1: RESOLVE — Identify the target

  1. Take the target merged PR number (--pr <n>) and the trigger (signal or eval).
  2. Resolve the PR's merge commit and changed files via gh. If the PR is not merged (no merge commit), stop with a structured skipped decision — there is nothing to revert.
  3. Determine the merge shape: a two-parent merge commit reverts against parent 1 (-m 1); a squash/rebase merge is single-parent and reverts against its sole parent. This repo uses both — never assume a two-parent merge.

Phase 2: CLASSIFY — Is it revert-ready?

Run classifyRevert (core). A target is revert-ready only when BOTH hold:

blastRadius and migrationWarnings are context only, never gates — they enrich the PR body so the human reviewer sees the stakes; they do not decide revert-readiness.

Phase 3: COMPOSE — Open the revert PR (or dry-run)

  1. If --dry-run, print the PR body and stop — open no PR.
  2. Otherwise open a revert PR: title revert: <original> (automated rollback), marker label harness:rollback, body = the full context block (trigger, target, revert-ready verdict, classification reasons, blast-radius, migration warnings, and the --reason if given).
  3. Idempotency: if an open PR labeled harness:rollback already references the target (#<n>, word-boundary matched — #42 must not match #420), skip — do not open a duplicate.

Phase 4: RECORD — Breadcrumb

Append one rollback_event to .harness/signals/: { targetPr, trigger, revertReady, action, prUrl, reason, ts }. This append-only record is what later justifies (or refuses) the auto-merge trust tier — it is not backfillable, so it is written on every evaluation.


Triggers

Harness Integration

Success Criteria

  1. A revert PR is opened only for a revert-ready target (clean revert + no dependent later merge); non-clean/blocked/unmerged targets yield a structured skipped/blocked decision and no PR.
  2. The revert PR body carries trigger, target, blast-radius, and migration warnings.
  3. Re-running against the same target opens no duplicate PR (label + word-boundary idempotency).
  4. Every evaluation appends one rollback_event breadcrumb.
  5. No revert is auto-merged — a human merges the PR.
  6. The eval arm produces no PR while rollback.evalTrigger.enabled is false.

Gates

Rationalizations to Reject

| Rationalization | Reality |

| --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |

| "The eval clearly failed, so I should auto-merge the revert to stop the bleeding" | v1 has no auto-merge authority. Open the PR; a human merges. Auto-merge is a deferred trust tier (ADR 0063). |

| "git revert -n in a temp index is fine for the readiness check" | -n still writes the working tree. Use git merge-tree --write-tree — pure in-memory, no side effects. |

| "It's a merge commit, so -m 1 is safe" | Squash/rebase merges are single-parent; -m 1 computes a meaningless revert. Check the parent count first. |

| "The signal fired, so every PR in the window should be reverted" | Only revert-ready targets are proposed, and only the human merges. A crossing is a signal to _evaluate_, not to revert blindly. |

Examples

Example: Signal-threshold crossing proposes a revert

Context: harness.config.json sets rollback.signals.error-rate = { threshold: 50, direction: "above", window: "24h" }. The hourly rollback-propose workflow runs harness rollback sweep.

sweep reads .harness/signals/timeline.json → error-rate crosses 50 (edge, not plateau)
→ resolves PRs merged in the 24h window: #<pr>
→ evaluate --pr <pr> --trigger signal
   RESOLVE:  #<pr> merged, two-parent merge commit
   CLASSIFY: merge-tree revert clean; no later merge touches its files → revert-ready
   COMPOSE:  opens "revert: Add tiered discount pricing (automated rollback)"
             labeled harness:rollback, body carries trigger + blast-radius + migration warning
   RECORD:   appends rollback_event { targetPr: 758, trigger: signal, action: proposed, ts }
→ A human reviews and merges the revert PR. Autopilot never merges it.

Example: Blocked because a later merge depends on the target

Context: Manual invocation harness rollback evaluate --pr 740 --dry-run.

CLASSIFY: a later PR merged after the target and touches the same files (dependent merge)
→ revertReady: false, action: "blocked"
→ no PR opened; decision reports "a later merge depends on this PR's files"

Escalation

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.