Harness thesis

An agent's reliability is decided mostly by what surrounds it. Every rule in ai-wow started as a real failure in a real session, and the work is moving each rule out of prose, which a model can ignore, into a check that runs whether the model cooperates or not.

  • Harness engineering
  • Guardrails
  • Agent reliability
  • Continuous improvement
What it is
The argument for how ai-wow is built, written for a skeptic: a method (log the failure, route the rule to the strongest place that can hold it), a ladder of places a rule can live, and a casebook of failures paired with the check that now refuses them.
What it isn't
Proof that the harness makes anyone faster or safer. It has one operator. There is no lead-time data, no escaped-defect rate and no second team. The honest numbers says what is measured and what isn't.
Why it exists
"I practise harness engineering" can't be checked in an interview. A list of failures, each with the check that catches it and a command that makes the check fire, can.

The claim

The model changes every few months. The failures don't. An agent will still read $? after a pipe, still amend the wrong commit in a shared checkout, and still type a test count from memory instead of copying it from the run. A harness is the accumulated set of answers to those failures, written so they hold for the next model too: checks the agent can't skip, records that outlive the chat, and the order work moves in.

The method fits in one sentence. When an agent fails, write down the rule, then move the rule as far down the enforcement ladder as it will go.

Why prose rules fail

The harness started with the obvious design, a lessons file whose rules get promoted into the global prompt, and watched it fail three separate ways.

Promotion by recurrence never fired. The first lessons file held a rule until it had been seen three times, then proposed promoting it into the global instructions. Across 26 rules that happened zero times. Promotion needed the rule to recur; noticing a recurrence needed the rule to be loaded; and the rule was only loaded after promotion. The loop had no way in. The file now routes a rule on first sighting, and its header says why.

A loaded rule still recurred. One rule said: commit a landed change in the same command that applies it, because a peer session's end-of-session sync commits any dirty managed file. The rule was loaded, and the failure happened again anyway. It stopped only when the landing script started committing the landed paths itself. A second rule, "diff a lane against its own base", sat in the orchestration skill's text while a wave was landed with a diff against main's HEAD instead. That diff carried the reversal of a peer's commit, and git apply deleted eight of the peer's files. Nobody noticed for two and a half hours.

Even the rule about rules needed a script. One lesson states that a prose rule which recurs has proved prose can't hold it. Lessons kept landing in the global prompt anyway, justified with "no hook can see it", without anyone asking whether a test could. That question now lives in log_lesson.py, which refuses to route a lesson to prose unless the stated reason rules out a test. On the first case it caught, a test held the rule within about fifteen minutes.

Prose is where a rule starts. It is a poor place for a rule to stay.

The enforcement ladder

There are six places a rule can live. Each rung costs more to build than the one above it and is harder to skip.

Failure in a session caught by a human or a diff Lesson with an id failure · rule · L-number Global prompt line global/CLAUDE.md verification habits Skill or command text skills/mow, commands/fix-bug Printed context hooks/env-snapshot.py at session start Gate script land_wave.py, check_tracker.py Tool-call hook guard-shell-status, peer-session-guard Test in pre-push or CI bin/tests/test_ui_bans.py, githooks/pre-push wrap-up logs it route first sighting prose rule recurs model can skip runs regardless
A recurrence is a routing failure. A rule that comes back after it was written down has shown that its rung can't hold it, so the fix is to move it down a rung in the same pass.
RungRuns whenCan the model skip it?
Global prompt lineEvery session, as textYes, by not following it
Skill or command textWhen that workflow is invokedYes, same as above
Printed contextEvery session startIt can ignore it, but it can't miss it
Gate scriptAt a workflow stepOnly by not running the step
Tool-call hookBefore every matching tool callNo: the call is denied or the operator is asked
Test in pre-push or CIBefore code leaves the machineNo, short of --no-verify

Two rules of thumb came out of using it. A hook sees one command; a test sees every file, so "no hook can see it" is not the same as "nothing can check it". And a guard is proven only by making it fire on the input shape the tool actually sends. Cursor sends a different payload shape from Claude Code, so four guards now carry tests that feed them each tool's real payload.

The casebook

Six of the enforced lessons, picked because an engineer who has run agents will recognise the failure.

Failure that happenedRuleHeld by
Three times in one session, cmd | sed || echo absent printed nothing and the silence was reported as "inconclusive". sed succeeds on empty input, so the fallback can never run.Test the condition before any pipe, or read the pipe-status arrayhooks/guard-shell-status.py denies the command
git commit --amend in a shared checkout rewrote a peer's commit that had landed seconds earlier, absorbing 84 of their lines and dropping the agent's own two files.Never amend in a shared checkout; add a follow-up commithooks/peer-session-guard.py asks before --amend while a peer is live
An exported GIT_INDEX_FILE leaked into every child process, including the pre-push hook's test suite.Scope it per command, never export ithooks/guard-shell-status.py denies the export
A wave landed with git diff <main HEAD> <integrate> deleted eight files from a peer's commit.Diff from the merge-base; refuse paths outside the wave's owned filestaskman/taskman/mow/land_wave.py
A landed change sat uncommitted and a peer's end-of-session sync committed it under someone else's message, after the written rule existed.Commit in the same invocation as the applyland_wave.py, which now commits the landed paths itself
Test counts in run records were typed from memory rather than copied from the run.A count is copied from the output of the run that produced itcheck_tracker.py refuses a count the lane's verification record doesn't contain

I made two of these fire on 2026-10-08 by feeding the hook the same JSON that Claude Code sends before a Bash call:

printf '%s' '{"tool_name":"Bash","tool_input":{"command":"ls /nope | sed s/a/b/ || echo absent"}}' \
  | python3 hooks/guard-shell-status.py

It replies "permissionDecision": "deny" and explains that the || can never run because sed succeeds on any input. Swapping in export GIT_INDEX_FILE=/tmp/i; git commit -m x also gets a deny, explaining that every later child process would run against the private index.

AI engineering practices it demonstrates

  • Guardrails as code. Tool-call hooks intercept the agent's action before it runs, rather than asking the model to remember.
  • Failure-driven design. Every rule cites the lesson id it came from, and docs/lessons-cases.md keeps the incident behind each id.
  • Measuring before building. bin/guard_score.py replays a candidate pattern or an existing hook over every past Bash call in the local transcripts, so a guard's hit rate is read rather than guessed (see Evals and guard scoring).
  • Tests that pin a guard to the real payload shape of each agent host, not just to the shape the author pictured.
  • A machine-readable ledger, docs/lessons-status.json, that records for every lesson where it lives and what, if anything, enforces it. CI checks it.

The honest numbers

Most rules are still prose. The ledger records each lesson and its enforcer, and the counts are derived from it rather than written down by hand:

python3 -c "import json; d=json.load(open('docs/lessons-status.json'))['lessons']; print(len(d), 'lessons,', sum(1 for x in d if x['enforced_by']), 'enforced')"
168lessons logged
34enforced by code
102still prose
5prose rules with a measuring probe

Of the 34, 15 are held by a gate script, 12 by a hook and 7 by a test, about one in five. Another 23 have a guard promised but not built, 6 are still being staged, and the rest are dropped or live outside the repo. Some of the rest can't be mechanised at all ("read the file before prescribing a fix for it"); others simply haven't been built.

Limits

Where it loses

There is no outcome data. The evidence is failures that stopped recurring, not throughput that rose or defects that fell, and every rule came from one operator running many parallel sessions in one checkout.

  • Transfer is unproven. Someone running one session at a time may find half the ceremony costs more than it saves.
  • Guards cost something nobody has totalled. guard_score.py can replay a hook over past commands, but its hits are read by hand, and there is no published false-positive rate. Several false positives and missed shapes are filed against guard-shell-status alone.
  • Most hooks fail open by design: a crashed hook never blocks a session, so a broken guard is silent.
  • Pattern-matching shell text is a running contest. Each guard has a list of known bypass shapes (absolute-path git, unusual option orders, nested subshells), and some are slow on pathological input: one quadratic case times out at 15 s on a hook that runs before every Bash call.
  • Prose rules still dominate the global prompt. 47 unenforced lessons live in global/CLAUDE.md, where the model can ignore them.

Starting your own

The method doesn't need this repo. It needs four habits, in this order:

  1. Keep a lessons buffer that is meant to empty. Each entry is a failure that happened, the rule it implies, and an id you can cite.
  2. Route each lesson on first sighting to the lowest rung that can hold it. Don't wait for a third occurrence.
  3. Treat a recurrence as a routing failure, and build the gate, hook or test in the same pass.
  4. Prove each guard by breaking what it protects and watching it refuse, using the input your tool actually sends.

Roadmap

ItemWhy it mattersStatus
Refuse prose routing for any recurring lessonToday the routing refusal applies only when the caller flags the recurrence; deriving it from the lesson's own tag closes the opt-inbacklog · high
Rule on the "| filter && next" guardA masked check printed one hit and a commit went through anyway; the open question is whether to deny every case or only commit and push targetsawaiting decision
Decoy-repo pre-push checkTurns a prevention (unsetting git variables) into a refusal for a lesson that currently reads only "promised"backlog · high
Make the hot guards linear-timeTwo guards that run before every shell call have quadratic casesperformance
Classify the first 24 routed rulesThey were routed as one batch and never sorted into prose versus guardbacklog
A/B evals of prose rulesRun the full prompt against a one-line control to find which rules are dead weightrevisit

Sources

  • docs/workflow/harness-thesis.md: the argument, ladder and casebook this page restates.
  • LESSONS.md: the routing design and the 26-rule promotion failure. docs/lessons-cases.md: the full story behind each lesson id.
  • docs/lessons-status.json: per-lesson home and enforced_by; the 168 / 34 / 102 reading comes from bin/lessons_status.py run on 2026-10-08, and the kind split from the status file.
  • hooks/guard-shell-status.py, hooks/peer-session-guard.py: both denials above were run on 2026-10-08.
  • taskman/taskman/mow/land_wave.py, check_tracker.py, skills/wrap-up/scripts/log_lesson.py: the gate scripts.
  • bin/guard_score.py and docs/workflow/guard-scoring.md: measuring a guard or a prose rule against past sessions.
  • Task board: open items for recurrence routing, the pass-through guard decision, the decoy pre-push check, guard performance and prose-rule evals.

Facts as of 2026-10-08. Lesson counts derived from docs/lessons-status.json on that date.