Loops and Graphs in Practice: An Agent Team Builds a Post-Quantum Mitigation Register

By | December 6, 2026

In part 3 of Loops and Graphs I turned a set of parallel workers into an agent team: each agent has a contract, a score from deterministic checks, labelled handoffs, a red-route triage agent, and one human approval gate before anything irreversible. The examples there were small. This post is the first real job: a five-agent Claude Code team that finished a piece of post-quantum security work my other agent had started and could not finish.

The short version: the first run failed, and failed well. Nothing was written outside the sandbox, two agents asked instead of guessing, and the triage agent named the exact cause. One configuration change later, all four working agents went green on their first turn, 16 of 16 checks passed, and I approved a single install step.


The job: a register that the audit actually reads

My homelab tracks cryptography that cannot yet meet the NSA’s post-quantum guidance (CNSA 2.0, and the advisory PP-26-4956): routers whose vendor firmware has no post-quantum SSH key exchange, an identity provider whose TLS stack is not there yet, and so on. Antigravity (agy, my other local agent) had already done most of the work:

  • a PQC Mitigation Register note in Obsidian, with a table of seven exceptions, their interim mitigations and target paths, plus two pending host actions;
  • a daily audit script (pqc_crypto_audit.py) that probes TLS and SSH endpoints for classical-only key exchange and weak ciphers, and sends new regressions to Signal.

The weak spot: the audit’s waivers were a hard-coded Python dictionary, copied by hand from the note. The note said one thing, the code another, and a waiver never expired. agy had planned to fix that and stopped when its Gemini model quota ran out.

So the goal for the team was:

  1. Turn the note’s table into a machine-readable register (JSON), with a review-by date on every open exception.
  2. Make the audit load its waivers from that JSON, and stop honouring a waiver once its review date has passed.
  3. Generate the note’s tables from the JSON, so the two can never drift.
  4. Ship all of it with one install script that a human approves.

Tests first, and every check must fail before any work

Before writing a single agent prompt, I wrote acceptance tests in a small git repository: four test files with four sections each, plus three register fixtures (a valid one, one with an expired waiver, one waiving a host the audit does not know). The baseline folder holds agy’s original audit and note, untouched.

Every done_well check is a shell command that exits 0 only when the work is right:

python3 -B ../tests/test_audit.py expiry && git diff --quiet HEAD -- ../tests ../baseline

The second half matters as much as the first. “Do not edit the tests” is not a polite request in the prompt; it is a git diff guard in every check, so an agent that weakens a test fails. The integrator’s checks add one more guard: a sha256sum -c over the live audit script and note, so a worker that touches the real files before approval also fails.

Then I ran all 16 checks once against the empty sandbox and confirmed that every one failed. A check that passes before the work is done is not checking anything.


The team

Agent Job Works in
register Turn the note’s table into pqc_register.json, wording taken from the note register/
coder Make the audit load waivers from the register, add expiry and --check-register audit/
renderer Generate the note’s tables from the JSON between BEGIN/END markers, with --check for drift render/
integrator Write install.sh: validate, back up, install, re-render, verify integration/
triage Runs only if the coder goes red: explain the failure, fix nothing audit/ (read only)

The first three have no dependencies, so they run in parallel. Each edits only its own folder. The integrator needs all three, and every edge carries a label saying what it hands over:

start (parallel): register, coder, renderer
register --[pqc_register.json: exception ids, waivers and review dates]--> integrator
coder    --[the audit's register API and --check-register behaviour]--> integrator
renderer --[render_register.py usage and its block format]--> integrator
coder ..[when RED: its failing checks and last answer]..> triage
integrator ==[4 checks GREEN]==> GATE
GATE --[human --approve, re-checks all]--> bash integration/install.sh

Each contract also has a never list and an ask_first list. Some examples from the spec:

  • register: never “add, drop or widen a waiver compared with the note’s Audit Waiver column”; ask first about “any fact the note does not state”.
  • coder: never “change a probe, a target list or a pass/fail rule”, and never “run the audit against the real fleet”.
  • integrator: never “deploy to the live scripts folder or vault (only the approved final step does that)”.

The never items that matter are also checks. The coder’s fourth check compares every probe function and target list, by source, with agy’s original.

Limits: Opus, at most 3 turns per agent, a $15 budget for the whole run.


Run 1: a clean, honest failure ($2.67)

? ASK renderer (score 0/4, 1 turn, $0.226)
? ASK register (score 0/4, 1 turn, $0.250)
✘ RED coder    (score 1/4, 3 turns, $1.821)
✎ DONE triage  (1 turn, $0.375): diagnosis written to ESCALATION.md
· SKIPPED integrator: runs only when register, coder, renderer are GREEN
GATE CLOSED: an agent is RED, ASKed or was skipped. Nothing irreversible was run.

The cause was mine. A headless claude -p worker can only reach its own working directory. My checks and prompts pointed the agents at ../tests and ../baseline, and every read of those folders was denied.

What I like is how each agent handled that:

  • register refused to invent data. Its ASK: “Without those files I can’t copy the note’s rows, waivers or dates, and I won’t guess them. Can you re-run me with ../baseline and ../tests added as extra directories?”
  • renderer asked the same thing, naming the exact folders and commands it needed.
  • coder did not ask. It spent three turns guessing the register format blind and reached 1 of 4.
  • triage read the coder’s failure and wrote the real diagnosis: “Three more blind guesses at the field name won’t converge.” It ended with a decision for me: grant read access to the tests, or paste a sample register entry into the coder’s contract.

Nothing outside the sandbox changed, and the team memory file now held those lessons for the next run.

The coder’s three blind turns cost more than the other three agents together. That is the case for the ASK protocol: an agent that asks on turn one is cheaper than one that guesses for three.


The fix: read access, with protection

I added a per-agent read_dirs field to the runner. Each entry becomes an --add-dir for that worker. The same folders also go into protect, so the runner hashes them before and after each agent and fails the agent if anything inside changed:

"read_dirs": ["../tests", "../baseline"],
"protect":   ["../tests/**", "../baseline/**"]

The integrator also gets read access to the other three agents’ folders, again protected. I checked that --add-dir worked with a half-cent Haiku probe before spending Opus money, and reset the coder’s folder to agy’s original so its blind attempt would not carry over.


Run 2: 16 out of 16 ($1.91)

✔ GREEN coder      (score 4/4, 1 turn, $0.481)
✔ GREEN register   (score 4/4, 1 turn, $0.466)
✔ GREEN renderer   (score 4/4, 1 turn, $0.461)
✔ GREEN integrator (score 4/4, 1 turn, $0.503)
· SKIPPED triage: nothing went red
Total spent: $1.912 of $15.00
ALL GREEN. GATE PENDING: the final step has NOT run.

Every agent finished in one turn. The runner’s report shows the change from version 1 of the spec to version 2:

ver  agent        runs  first-pass  green  mean turns  mean $
v1   coder           1          0%     0%         3.0   1.821
v1   register        1          0%     0%         1.0   0.250
v1   renderer        1          0%     0%         1.0   0.226
v2   coder           1        100%   100%         1.0   0.481
v2   integrator      1        100%   100%         1.0   0.503
v2   register        1        100%   100%         1.0   0.466
v2   renderer        1        100%   100%         1.0   0.461

What the team produced:

  • The register: agy’s seven exceptions and two pending actions, word for word from the note, three waivers, each open exception due for review in six months.
  • The audit: the hard-coded waivers are gone. load_waivers() reads open, unexpired waivers from the register. A missing register waives nothing, and a date it cannot parse counts as expired, so both mistakes fail closed. --check-register exits 1 and names the exception for any expired waiver, unknown host or missing file. The probes are byte for byte agy’s.
  • The renderer: replaces the hand-written tables with a generated block between markers, adds a Review-by column, keeps everything outside the block untouched, and --check reports drift without writing.
  • install.sh: validates the register with the new audit first and refuses, writing nothing, if it fails. It stages the rendered note in a temp folder, backs up only the files that will change, replaces them atomically, re-renders and verifies. --dry-run lists every destination; a second run changes nothing.

Four lessons from the team memory

Every agent can leave REMEMBER: lines, and the runner keeps them in a team memory file that the next run reads. Some lines from this one:

  • All four workers reported the same thing: the full check commands were denied in their sandboxes because of the git diff part. They ran the test half themselves and left the git guard to the runner. The runner does check both halves, so the score is still right, but next time I will give workers the test command and keep the guards for the runner only.
  • The register agent found that the content check takes the first word of each algorithm cell, and a backtick followed by punctuation broke it on one row. It fixed its own output, not the test.
  • The integrator wrote down that install.sh only backs up files whose content changes, which is why a second run creates no new backups.
  • From run 1, triage: matching values against known host names “can never detect an unknown target”. The register needs an explicit target field, which is what the fixtures had all along.

The gate

The run ends with the gate closed until a person opens it. Before approving I did what the gate is for:

  • read install.sh;
  • ran install.sh --dry-run against the real destinations (one script replaced with a backup, one JSON created, one note replaced with a backup);
  • rendered my live note in a temp copy and read the diff. agy’s text was kept, apart from two cells that lost a little wording: “Pass (pq_kex_accepted)” became “N/A” on a row with no waiver, and “N/A (overlay)” became “N/A”.

Then I approved. --approve runs no agent. It re-runs all 16 checks right then, and only if every one still passes does it run the final command. A Claude Code hook also asks me to confirm, so no agent can approve its own work.

APPROVED. Running final_cmd: bash integration/install.sh
register ok: 3 active waiver(s)
  replace    audit   : ~/scripts/pqc_crypto_audit.py  (backup: .bak-20261206-103911)
  create     register: ~/Vault/.../PQC Mitigation Register.json
  replace    note    : ~/Vault/.../PQC Mitigation Register.md  (backup: .bak-20261206-103911)
ok: PQC Mitigation Register.md matches PQC Mitigation Register.json
final_cmd exit 0

From the next nightly run, agy’s audit takes its waivers from the register. When a review date passes, that waiver stops counting, the host shows as FAIL, and Signal tells me about the new failure. To change an exception, I edit the JSON and re-render the note.


What I take from it

  • Write the tests, and watch them fail, before the agents start. This was the most useful step of the whole job. Sixteen commands said exactly what “done” meant, and an empty sandbox scored 0.
  • Put every important “never” into a check. The git diff guards and the live-file hashes meant I did not have to trust any agent to keep its hands off.
  • A failed run is fine if it fails closed. Run 1 cost $2.67, changed nothing real, and produced a precise diagnosis. Without the gate, the blind coder’s guess would have been the shipped version.
  • Asking is cheaper than guessing. The two agents that asked cost about a quarter each. The one that guessed cost $1.82.
  • Agents can finish each other’s work. agy designed the register and wrote the audit; a Claude Code team finished it while agy’s quota was spent. The shared vault made the handoff simple: the team’s baseline was agy’s own note and script.

Total for the job: $4.58 across both runs, and one approval from me.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.