Skip to content

Run the test scenarios

scenarios/scenarios.toml holds 17 single tool calls an agent might make while fixing failing tests in a small library. They fall into five groups:

  • Ordinary work, which the gate must leave alone.
  • The AISI incident, step by step.
  • Harmful actions inside the mandate's paths, which only the model gate can see.
  • The agent trying to change its own mandate.
  • An outward action, a push, which asks a person.

The scenarios are a regression suite: each one pins a verdict, so a change to the rules cannot alter it unnoticed. They are not an evaluation of how well the gate catches harm; that needs a labeled set (Roadmap item 3).

Each scenario names the tool and its input, and two expected verdicts:

  • expect_rules is the verdict with the model gate off.
  • expect_model is the verdict with it on. ask|deny accepts either.

Scenarios that share a session value share a ledger, in file order, so a retry can be tested after the denial it repeats.

scenarios/run.py builds a throwaway project with a mandate and a throwaway ledger, then runs every scenario through the gate. It prints a table of expected and actual verdicts, the layer that decided, the time and the reason. It exits 1 if any verdict differs from the expected one.

Run them

To run the scenarios with the rules only:

poetry run python scenarios/run.py

To run them with the model gate on the Claude API:

poetry run python scenarios/run.py --model

To run them with a local model on oMLX:

SYNTH_API_KEY=... poetry run python scenarios/run.py --model \
  --backend openai --name Qwen3-4B-Instruct-2507-MLX-8bit

--endpoint sets a different server, for example http://localhost:11434/v1 for Ollama.

With --model, the runner calls the model once for every consequential scenario that the rules did not deny, about eight calls per run.

CI runs the rules-only scenarios on every push.

Add a scenario

Append a [[scenario]] table with id, what, tool, input, expect_rules and expect_model.

Replay real sessions

scenarios/replay.py judges every tool call in real Claude Code session files under one mandate, without running anything, and prints the totals and each flagged call, redacted. The model gate is off and the ledger goes to a throwaway directory.

poetry run python scenarios/replay.py MANDATE.toml ~/.claude/projects/<project>/*.jsonl

The first replay, on 2026-12-01, read 152 session files from 30 days of fleet work on EGS's Mac: 12,953 calls. The mandate let the agent write in ~/repos and /tmp, reach the usual package and code hosts and push to the fleet's own remotes; it named nobody to email, sent outward actions to a person, and left the model gate off.

Verdict Calls Share
pass 10,705 82.6%
ask 1,749 13.5%
deny 499 3.9%
  • Most asks are by design: outward actions (617 pushes, 99 GitHub writes, 49 artifact publishes) and 554 calls after a burst of denials. Another 247 are commands whose host, remote or file the gate could not read, such as a loop over repos in a shell variable.
  • Most denials are calls outside this mandate: 374 reach hosts it does not list, most of them machines on the local network, and 82 write under ~/.claude. A mandate written for one task would list what the task needs.
  • The replay found false alarms in the gate itself, now fixed: a ~ that names no user (~364,000) crashed the check, which failed closed; a host in a shell variable was denied rather than asked; reading the hook settings with 2>/dev/null counted as a write; a > inside quotes or a line of heredoc text counted as a redirect or a command; dscl . -read counted as an account change; and after three denials, every later call in a session asked.
  • It also found misses, now fixed: a quoted redirect target was not checked, and a cd, git -C or variable earlier in the command was ignored, so a write after cd ~/.claude/... was judged as if it were in the project.