A Regret Miner Without a Precision Gate Is a Context File With Opinions
Twelve hundred same-author commit pairs. Nine hundred twenty-five inside the advertised sixty-minute window. Ninety-four survive the message filter. Forty-th...
Twelve hundred same-author commit pairs. Nine hundred twenty-five inside the advertised sixty-minute window. Ninety-four survive the message filter. Forty-three are real. Those four numbers are the entire argument of this article, and only the last one is a measurement of regret.
The Synthetic Scars series proposes a Rapid-Regret Miner: scan git log for consecutive commits by the same author, keep pairs where Δt ≤ 60 minutes and the two revisions touch a non-empty set of shared AST symbols, and treat the earlier commit as the trap, the CI failure in the gap as the wound, and the follow-up patch as the reflex worth remembering. The pitch: it filters out 99% of routine commit noise and extracts domain-specific scars from a ten-year-old repository with no transcript.jsonl flight logs.
I implemented it and ran it against five of my own repositories: 1,480 commits, Go and TypeScript and Python, single-author, agent-assisted. The mechanism works; the precision claim does not survive contact with the data.
The 60-minute window removes 22.9% of your commit pairs
Walking git log --reverse and keeping only consecutive commits by the same author email gives 1,200 pairs across the five repos. The median gap is 11.7 minutes. A third of the pairs (33.5%) land inside five minutes. And 77.1% land inside the hour.
def walk_pairs(repo: str) -> list[tuple[Commit, Commit]]:
# --reverse so pairs read oldest-first; a binary diff walk would be faster
# but produces the same ordering for a linear history, which is all we need.
out = run_git(repo, "log", "--reverse", "--pretty=format:%H%x1f%at%x1f%ae%x1f%s")
rows: list[Commit] = []
for record in out.splitlines():
sha, epoch, author, subject = record.split("\x1f")
rows.append(Commit(sha, int(epoch), author, subject))
pairs: list[tuple[Commit, Commit]] = []
for older, newer in zip(rows, rows[1:]):
if older.author != newer.author:
continue
gap = newer.epoch - older.epoch
if gap < 0:
continue # rewritten history or skewed committer dates
pairs.append((older, newer))
return pairs
So the window discards 275 of 1,200 pairs — 22.9%, not 99%. On a solo repository where an agent commits every few minutes, the sixty-minute boundary is almost never the binding constraint. The threshold was calibrated for a human team: an engineer returns the next morning, pushes a fix, and an eight-hour gap marks the boundary between "same work session" and "new task". Replace that human with an agent committing at tool-call granularity and the distribution collapses well inside the window. A filter parameterised by human attention spans stops discriminating when the author is a process.
The window is a session boundary heuristic wearing a temporal disguise. Measure the session length of whoever is actually committing before you hard-code one hour.
The conjunction does the work, and two of its three terms are not timestamps
Add the rest of the advertised filter — a corrective verb in the follow-up subject, plus non-empty file overlap — and 925 pairs drop to 94. That is the real 90% reduction, and it comes from a regex over English commit messages.
FIX_VERB = re.compile(
r"\b(fix|fixes|fixed|bug|hotfix|revert|oops|regret|patch"
r"|broken|typo|whoops|forgot|missed|wrong|repair)\b",
re.IGNORECASE,
)
# Generated artifacts share whole lines by construction and poison the overlap test.
NOISE = re.compile(r"(\.lock$|bun\.lock|go\.sum|\.md$|assets/|dist/|CHANGELOG)")
def candidates(repo: str, pairs, window_s: int = 3600) -> list[Candidate]:
found: list[Candidate] = []
for older, newer in pairs:
if newer.epoch - older.epoch > window_s:
continue
if not FIX_VERB.search(newer.subject):
continue
shared = {
path for path in (files_in(repo, older.sha) & files_in(repo, newer.sha))
if not NOISE.search(path)
}
if not shared:
continue
found.append(Candidate(older, newer, shared))
return found
Two hundred thirty-five of my 1,200 pairs carry a corrective verb inside the window, so the verb alone removes 80%. File overlap then removes another 60% of what remains. The timestamp is the weakest of the three terms and the one the proposal foregrounds.
That is a portability problem. A verb regex is a natural-language oracle: locale-dependent, idiom-dependent, and biased toward authors who write conventional-commit prefixes. Feed it a repository whose commits read "correct off-by-one in window stride", "tidy the pagination", or "that was the wrong index" and the recovery rate falls off a cliff with no signal that it did. The miner returns fewer scars, looks cleaner, and reports nothing.
- Measured: 1,200 pairs, median gap 11.7 min, 77.1% inside the hour.
- Verb filter: 925 → 235, a 75% cut driven entirely by prose.
- File overlap: 235 → 94, a 60% cut driven by the diff.
- Timestamp: 22.9%, the smallest contribution of the three.
A pair is not a scar until you prove the follow-up reverted the earlier line
The filter above produces candidates. The proposal treats the candidate as the scar, which is where the precision claim breaks: a 22-minute pair touching the same file can be two commits of forward progress on one feature, not a trap and a rescue.
So I added a fourth gate. Extract the normalized lines the older commit added and the lines the newer commit removed, and keep the pair only when the intersection is non-empty. One line written and then unwritten inside the window is the cheapest available evidence of regret.
IDENT = re.compile(r"[A-Za-z_][A-Za-z0-9_]{3,}")
def reversal_lines(repo: str, older: Commit, newer: Commit, shared: set[str]) -> set[str]:
# --unified=0 keeps the diff to changed lines only; context lines would
# trivially intersect and inflate precision to 100% while proving nothing.
added = changed_lines(repo, older.sha, sign="+", paths=shared)
removed = changed_lines(repo, newer.sha, sign="-", paths=shared)
reverted = added & removed
# A bare "}" or an "else {" is a reversal in text and noise in meaning.
return {line for line in reverted if len(line) >= 10 and IDENT.search(line)}
That gate is where the honest number appears. Of the 94 candidates, 55 share any reverted line at all — 58.5%. Require the line to be at least ten characters and contain an identifier and it falls to 43 of 94, or 45.7%.
Operationally: a scar corpus is injected into the agent's context on every turn. If 54.3% of the mined entries are two commits of the same feature rather than a wound and a reflex, the corpus is half filler — and filler in an always-loaded context file is the exact failure mode the series is trying to fix.
The research on repository instruction files quantifies the direction. The median AGENTS.md carries 39 instructions and has grown +226% over its lifetime, gaining a net +4.9 instructions per commit while almost never shedding one. Instruction-following degrades as constraints accumulate, and irrelevant rules drawn from real context files measurably reduce compliance. A miner with 46% precision manufactures that condition automatically.
A scar miner is a context-file writer with a regex instead of a human. It inherits every consequence of prompt growth and answers to the same precision budget.
What the false positives actually are
The rejected pairs are not random noise. They cluster into four failure modes, each reproducible in my run and each a legitimate commit pair that passes the advertised filter exactly as specified.
Generated artifacts share lines by construction. Two commits both rewriting CHANGELOG.md share "", "}", and "## [1.4.1]"; two lockfile regenerations share hundreds. My first pass without a noise filter reported 58.5%, and among those hits were ten pairs whose only overlap was a changelog heading.
Configuration is iterated, not regretted. One specimen: fix(ci): use .woodpecker.yml with local backend runner syntax, then 2.3 minutes later fix(ci): support manual trigger and array syntax for when conditions. Both touch .woodpecker.yml, both carry corrective verbs, and branch: main plus event: push appear as added-then-removed. The second commit is not repairing the first; it extends a schema the first had no way to fully specify, because the pipeline's shape was discovered by running it.
Multi-purpose and harness commits revert their own context. A 2,801-addition commit titled fix: close ten open issues across updater, daemon, translator, dashboard shares lines with the commit thirty seconds before it. A commit adding live e2e tests, then one seeding an in-memory database for those tests, shares the pool-setup lines verbatim. Both follow-ups replaced lines because the work unit reached an unplanned state, not because the earlier version was wrong in a way worth remembering.
Every case above is honest engineering history, and each passes the advertised filter exactly as written. The specification has no term whose job is to distinguish wrong from incomplete, which is why the reversal gate has to supply one.
Why a synthetic scar is a compression problem, not a writing problem
A scar is described as a four-vector — trap, wound, reflex, dialect. Strip the framing and it is a lossy compression of an incident, and lossy compression has a measurable budget. The wrong instinct is to write it as narrative: the incident's real cost was a failing CI run and forty minutes of an engineer's afternoon, and encoding that as prose compresses a diff into an anecdote.
- Trap is a code shape, not a mistake: the plausible-looking happy path that passed local checks.
- Wound is a signal, not a story: the exact failing assertion, the panic site, the 500 with its stack trace.
- Reflex is a predicate: the guard that must hold at the boundary, expressed so a linter or test can check it.
- Dialect is placement: which file the reflex lands in so it loads before the model writes the trap, not after.
The research on why CLAUDE.md grows without bound sharpens this. Once an instruction's rationale is gone, deleting it costs O(2^|D|) in a prompt of |D| instructions — you cannot tell which remaining rules depended on the one you removed, so nobody removes any. The measured cure is to keep the rationale attached as a comment: prompts carrying latent reasoning shed 99.3% of their excess instructions and improve instruction-following by up to 23.1%.
A scar without its wound is a rule nobody can safely delete. Carry the failing assertion, not a summary of it.
Ship the precision number with the corpus, not in a blog post
A miner that emits scars without emitting its own hit rate is untestable. The corpus is a prompt artifact, so the miner needs a fixture the way a parser needs one: a hand-labelled set of pairs where you have decided, once, whether the pair is a scar.
Twenty pairs is enough. Label them, pin the rate, and fail the build when a filter change moves it. This is the same discipline as pinning ToQueryString() output in a golden file, applied to a maintenance oracle rather than a query builder.
import json
from pathlib import Path
GOLDEN = Path("regret/golden_pairs.jsonl") # {"old": sha, "new": sha, "is_scar": bool}
MIN_PRECISION = 0.75
def calibrate(repo: str, miner: Miner) -> float:
labelled = [json.loads(line) for line in GOLDEN.read_text().splitlines() if line.strip()]
if not labelled:
raise RuntimeError("no golden pairs: precision is unmeasured, refuse to emit scars")
hits = 0
for entry in labelled:
pair = miner.lookup(entry["old"], entry["new"])
if pair is None:
continue # filtered out entirely, not a false positive
if entry["is_scar"]:
hits += 1
else:
# A surfaced non-scar is the expensive error: it enters the prompt.
hits -= 1
precision = hits / len(labelled)
if precision < MIN_PRECISION:
raise SystemExit(f"precision {precision:.3f} below gate {MIN_PRECISION}")
return precision
Penalising false positives twice is deliberate. A missed scar costs one lesson the agent learns the hard way; an injected false scar costs context budget on every turn of every session and teaches a rule that was never true. A conservative miner with 30% recall beats an eager one with 46% precision.
The deeper filter needs the AST the proposal already specifies, and it is the one place the AST genuinely pays: comparing normalized function hashes across the two revisions separates "the same function changed twice" from "the same file changed twice", because formatting and edits outside the function body produce identical hashes. File overlap cannot make that distinction, which is why 94 candidates contained so many multi-commit work units.
The right to refuse a scar is the part that keeps the corpus alive
The synthetic-scars frame argues that agents need somatic pain and the authority to say no. The no is more important than the pain, and it has a concrete implementation: a scar must be refusable by the code it constrains.
If a scar is a rule, a test that encodes the same invariant makes the scar redundant. That is not a loss, it is a graduation path — mine the pattern from history, express it as an assertion, and once the assertion is in CI, delete the scar from the prompt. The mined corpus should shrink over time. A scar file that only grows is following the exact growth curve the research measures at +226%, and it is failing the same way.
The healthiest scar corpus is one where every entry has a deletion date, because the rule graduated into a test.
Which gives the miner an exit criterion worth wiring in: count how many scars are covered by an existing check. Run the reflex's predicate as a test, or grep for the invariant in the suite. Covered entries are candidates for removal; uncovered ones are earning their context budget. That ratio tells you whether the corpus is an artifact or an accumulating liability. None of the numbers here argue against mining history — they argue against shipping the miner's unfiltered output into a prompt.