Skip to content

Herd 0.15.0

Choose a tag to compare

@Beovulfo Beovulfo released this 29 Nov 10:31
988fb50

The designer's hand-solved cases bind the builder: herd verify runs the program on each case and compares the whole output, so a coarser or narrower reading fails a check the builder cannot rewrite (issue #190).

  • Added: owned/cases in the task folder: <name>.in and <name>.out pairs, written by the designer before any code. herd note --tried --attack other-reading --example "prog {in}" --cases <folder> runs the program once per case, by name, and compares the whole stdout line by line (trailing blank lines and line ends aside). The first failing case is the fault, with its input and both outputs.
  • Added: the owned folder and the other-reading note are frozen at the first herd verify (owned.json). A change fails the attack, the guard denies writes to the folder, and a line added since the start that names the owned cases fails verify. herd note --owned-changed "<reason>" re-freezes at the next full verify, and the report shows the reason first under "Changed after red". At high risk the human's own message must state the reason before herd done passes.
  • Changed: on the standard route, tasks at medium and high risk need --cases for the other-reading attack; --expect stays for low risk and for tasks started before this version. --cases and --expect cannot be logged together.
  • Changed: the skills (adversarial, run, designer) say to write the cases before any code. No TestBudgets word budget changed.
  • Known limits: the reach check reads text lines only (not .md, .rst, .txt, or binary files), so an encoded path is not seen. The guard sees only the writes it detects. Generated cases from a reference (issue #191) are not built. The hand answers are the designer's claim, shown in the report. At high risk the confirmation is read from the session logs herd init and herd reopen recorded: an agent that reopens the task from its own claude -p session could state the reason itself. Not tried in a live session.

Also in this release: 0.14.14 (never released on its own)

A check, attack command, --refuses or --example that was only printf ... counted as evidence, while the same command with echo was refused as running no project code (issue #173).

  • Fixed: printf is vacuous like echo for herd check, herd verify, herd note and herd done. As with echo, a --refuses or --example command that pipes into a program (printf 'milk\n' | python3 prog.py) still counts.
  • Changed: the test fixtures that used printf as a passing attack command now run expr and ls.
  • Fixed: a check made of echo or printf followed by real code (printf x && python3 -m unittest, echo start; pytest, echo a || make test) counted as running no project code, because the shape list matched everything after echo. Now every command of a chain (split on &&, ||, ;, |, & and newlines outside quotes) must be true, :, exit N, echo, printf or test -f/-e PATH, and a $(...) or backtick outside single quotes always runs a command. exit N joins exit 0 so echo no >&2; exit 1 stays vacuous. The --refuses/--example pipe exception is unchanged.
  • Known limits: the rule is a short list of command shapes: sh -c 'printf ok' or cat file runs no project code and is not refused. Not tried in a live session.
  • Known limits: an escaped \$( is still read as a substitution; sh -c '...' and scripts are not looked into. Not tried in a live session.

The attack lines in herd verify and evidence.md joined an attack's check and its --refuses or --example command into one string, python3 -m unittest t.BadInput --refuses python3 -m textutil, so a reader could not copy either command on its own (issue #142).

  • Changed: each part of an attack is a labelled field. herd verify prints attack bad-input failing: check python3 -m unittest t.BadInput; refuses python3 -m textutil: exit 0, needs 1 to 125, with why a part failed after that part. evidence.md and the PR body print bad-input passing (check `python3 -m unittest t.BadInput`, refuses `python3 -m textutil`), each command in its own backticks. --example and --expect show as example and expect fields the same way.
  • Changed: a --covered-by attack shows covered by C1, plain text, since a criterion id is not a command. A collision --refuses "n/a: <reason>" shows its reason without backticks.
  • Known limits: output format only; no benchmark leg was run. The wiki page Example.md still shows the old format: refreshing it needs a new paid run.

Red first, the herd verify before any code, exited 1 when it went as planned: every check failing is the expected result, but the agent and the demo GIF (#116) saw "Error: Exit code 1" (issue #118).

  • Added: herd verify --red exits 0 and prints "N of N criteria failing, as expected before the build" when every criterion with a check fails. It exits 1 with "red first not met: C1 already passes" (or "C1 ran zero tests", or "no criterion has a check") otherwise. Attack results do not change its exit code: attacks may fail before the code too. Without --red, herd verify exits as before.
  • Changed: the run skill (step 4), the quick route and herd-designer run herd verify --red and drop the "checks must fail, tighten it" text, which the exit code now enforces.
  • Fixed: herd verify --red exited 0 with "N of N criteria failing, as expected before the build" even when code existed before the first verify. It now exits 1 with "red first not met: code already existed before the first verify: ".
  • Fixed: herd verify --only <id> --red ignored --red, and herd verify --red --only <id> took --red as the slug. Both orders are now refused with one line and exit 1.
  • Known limits: for a failing check, "ran zero tests" is read from the stored output tail only. Not tried in a live session.

The guard allowed (cd sub); git push, x=$(date); git push --force, x="$(echo ")"; git push)", git clean --f, git clean --fo and chmod -w .herd/active during a task. Mutation testing found it (issue #178, part of #157).

  • Fixed: an operator glued to a parenthesis ();, )&&, )|) splits the command, as ; alone did: shlex returns it as one token. <( and >( (process substitution) start a new command too.
  • Fixed: the body of a $(...) is found by a scan that skips quotes and nested parentheses, so a quoted ) no longer ends it. An unclosed $( is checked to the end of the line.
  • Fixed: a long flag of 3 or more characters counts as a prefix, so --f and --fo match --force, as git takes them. An ambiguous prefix is denied too; git refuses it anyway.
  • Fixed: chmod's mode is the first word after chmod's own options (-R, -f, -v, ...), so a mode such as -w or a-w no longer hides the path. With --reference=FILE every other word is a path.
  • Known limits: the guard still reads command text only: bash -c, eval, scripts and aliases pass (a Non-Goal of the guardrails design). A $(...) inside single quotes is checked as if it ran, so it can over-deny. A case pattern's unmatched ) inside $(...) ends the body early. Not tried in a live session.

After herd cancel, herd init recorded the cancelled task's unpushed branch as the PR base, and trusted a base that no longer existed (issue #184).

  • Fixed: herd init after herd cancel recorded the cancelled task's unpushed branch herd/<slug> as the PR base, so herd pr failed with "Base ref must be a branch" (issue #184). A task cut from an unpushed herd/<slug> branch now takes the base that task recorded (main, or the upstream name of the #148 case); a pushed herd/<slug> branch stays the base.
  • Fixed: herd init trusted the base a cancelled task recorded even when that branch no longer existed, and crashed on an unreadable base file. A base that is neither a local nor a remote-tracking branch, or that cannot be read, is ignored and the upstream rule decides.

A /herd:run handed to a subagent: a report said the guard denied a foreground herd:herd-designer call (issue #181).

  • Fixed: a /herd:run handed to a subagent is now recorded and its denial says what it received. Spike S6 (Claude Code 2.1.332, docs/spikes/s6-subagent-agent-call.md) recorded the PreToolUse input of a foreground herd:herd-designer call from a subagent: it carries run_in_background: false plus agent_id and agent_type, and the guard allows it. The denial reported in #181 did not reproduce, so the guard's decision is unchanged. A denial now says what it received (received \run_in_background: true`orreceived no `run_in_background`), and the run skill and docs/how-it-works.mdname the proven route for an orchestrating agent: a headlessclaude -p "/herd:run ..."session in the project. Not proven: a nested/herd:runending in a passingherd done`.

Mutation testing of the rule-enforcing code (issue #157). A green suite shows the tests pass, not that they would fail on a bug.

  • Added: tests/mutate.py GROUP (gate, guard, done, verify, triage) runs mutmut 3.9.0 through uvx, so nothing is added to the project and the standard-library rule holds. It mutates one group's functions in a copy of the repository and prints each surviving mutant at its source line. Not in CI: a group takes 1 to 30 minutes, and verify takes longer, so it is sampled. How to run it and the scope: docs/how-it-works.md, "Mutation testing".
  • Added: tests for the survivors in gate (tests/test_gate_mutants.py), guard (tests/test_guard_mutants.py), done (tests/test_done_mutants.py) and triage (tests/test_herd_triage.py). Before, no test covered the guard's session-log rule, and most of the Stop gate's and herd done's messages were not checked word for word.
  • Found: the guard allows (cd sub); git push, x=$(date); git push --force, a git push inside a $(...) with a quoted ), git clean --f and --fo (git reads both as --force), and chmod -w .herd/active. Listed under #178, fixed in this release.
  • Known limits: mutmut picks, per mutant, only the tests that called the function in the same process, so a test that reaches it only through a herd.py subprocess is not picked. The verify group was sampled (285 of 1174 mutants) to keep the run under about 2 hours. Survivors marked equivalent are listed with a reason in the pull request that closes #157.

A 2026-11-29 benchmark of 0.14.14 (Haiku builds, Sonnet designs, 6 runs per leg) showed loosely read requests. One run lost every case: the request said the output goes "step by step", the criteria never said what one step is, so the builder chose a coarser step and its own checks passed. One run covered only some of the cases the request named. Two runs got a check that required every one of N items to meet a threshold when only the average did, so the check never passed and the run ended at the Stop gate. A builder also stored the herd command in a shell variable and its calls failed with exit 127.

  • Changed: the second-look brief (herd design-brief) has one more sentence: when the request describes output in steps, events, lines, records or state, say in a criterion text, not only in coverage, what one of them is, and name every case or input that must produce it. The brief's earlier text is unchanged; the design eval that measured it predates this sentence, so the sentence itself is not measured.
  • Changed: the criteria skill says the same in one line under "Outcomes, not steps", and warns to check the real spread of values before requiring all N items to meet a threshold. To stay in its word budget the skill drops the list of vacuous commands in rule 9 and two clauses that herd done and herd verify already enforce. The run skill says to write each herd command out in full every time, never stored in a shell variable.
  • Added: tests/test_design_units.py checks the new text is present and has no word from the benchmark's domain.
  • Known limits: the new sentences are advice to a model: no code can decide whether a criterion names its unit. Not tried in a live session.

Benchmark (supermarket-route, claude-haiku-5-5, tiers S/M/L, 6 runs)

KPI 0.15.0 0.14.14 RC 2925bcf v0.14.13
Valid stores of 40 40.0 ± 0.0 39.0 ± 1.5 26.7 ± 20.7
Fully valid runs 6 of 6 4 of 6 4 of 6
Bad inputs handled of 6 6.0 6.0 5.8
$ per run 0.48 0.59 0.42
Active minutes 9.3 11.0 8.1

Details: #193 (comment)