verify

A verification command for stateful programs, meaning programs whose next result depends on their stored state and incoming actions. It creates several formal behavior descriptions from source code and replays recorded traces, or checks previously saved descriptions.

In plain words
What is it for?
Use it to generate and test behavior descriptions from a contract, replay real execution traces, save findings, and optionally check the winning description with TLA+ model checking.
Why use it?
It separates mistakes in the generated descriptions from findings in the program itself. This makes it easier to tell whether a reported problem comes from the specification or the code.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/cognitive-fab/polygraph/verify
Clone the repo
git clone --depth 1 https://github.com/cognitive-fab/polygraph
Per session 31 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,160 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00031 $0.01160
Opus 5 $0.00015 $0.00580
Sonnet 5 $0.00006 $0.00232
Haiku 4.5 $0.00003 $0.00116

Measured yesterday against content hash 4193428c3c8a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

verify scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/verify.md · 81 lines

How it starts

The opening of the file, as written. The whole thing — 81 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Run the Polygraph verification loop over the arguments in $ARGUMENTS.

This drives ${CLAUDE_PLUGIN_ROOT}/scripts/verify.mjs. The generated artifact is a v2 SAM strict-profile module (named intents with schemas and finite domains, keyed acceptors, observable reject(reason), sealed model). The 1.x bare next(state, action, data) artifact was removed in 8.0.0. Two modes:

  • Generate + replay (needs ANTHROPIC_API_KEY and --model):
    node ${CLAUDE_PLUGIN_ROOT}/scripts/verify.mjs \
      --contract <c.json> --source <file> --traces <dir> \
      --model <id> --n 5 --out out/
    
  • Replay saved specs (no key):
    node ${CLAUDE_PLUGIN_ROOT}/scripts/verify.mjs \
      --contract <c.json> --traces <dir> --specs <dir> --out out/
    

Useful flags:

  • --tla — TLC escalation tier: after the verdict, the winning live spec (most windows passed; tie → first) is mechanically transpiled to TLA+ (out/tla/*.tla + .cfg) and model-checked with TLC; the outcome (states, per-invariant verdicts, counterexample steps, skipped invariants with reasons) lands in a "TLC escalation" subsection of findings.md Part 2. Toolchain discovery: POLYGRAPH_JAVA (or java on PATH) and POLYGRAPH_TLA_JAR (path to tla2tools.jar; no PATH fallback). A missing toolchain is reported as a note — the .tla/.cfg artifacts are still written. Optional: --tla-bound N, --tla-timeout <seconds>.
  • --invariants <inv.mjs> / --max-states N — the model-checking half (Part 2); runs automatically when invariants.mjs sits beside the contract.
  • --no-auto-regen — generation mode regenerates ONCE automatically when the first pass hits the reject-as-annotation signature uniformly (every live spec rejected ≥2 windows the code acted on); this flag disables that. Both spec sets are kept (out/specs/, out/specs_regen/) and findings.md names both passes.
  • --initial-states <states.json> — a JSON array of state objects seeded into every per-spec model check alongside init(). This is the remedy for a FROZEN STATE KEY warning in findings.md (a key no action changes leaves Part 2 structurally blind to behavior it gates — seed non-default values to unfreeze it).

Recommended model: opus-5 for spec derivation; if the API refuses on policy grounds, retry with opus-4.8 (per-step source of truth: RECOMMENDED_MODELS in scripts/models.mjs). No default — pass the exact Anthropic model id if you are not using a known alias.

Prerequisite: a REAL captured trace corpus. The corpus is the verification — if the code cannot be run and instrumented to capture traces, this tool does not apply (recommend hand-written modeling instead); never substitute synthetic traces derived from reading the source.

Steps to perform:

  1. If no contract.json exists yet, help the user build one from ${CLAUDE_PLUGIN_ROOT}/templates/contract.example.json (see the polygraph skill for the full method). In the v2 default pipeline every action with data fields MUST have a dataDomain entry — it is also the exploration and transpilation domain, and a gap blocks generation loudly.
  2. Validate the corpus first: node ${CLAUDE_PLUGIN_ROOT}/scripts/validate_corpus.mjs <c.json> <traces>. Every action appearing in the traces must be declared in the contract — the v2 strict artifact has no silent-unknown-action fallback.
  3. Run verify.mjs with the parsed arguments.
  4. Read out/findings.md and walk the user through each finding, classifying it as a code-finding, contract-error, or spec-error per the skill's Step 5. In the v2 default, each finding window also carries a step classification — rejected(reason) and identity-by-mutation are the two GOOD no-op classes; unhandled (the spec neither acted nor rejected) is itself a finding.

Always state that this is a consistency check, not a proof — exhaustive only over the declared finite (action, data) domains, not unbounded real data — and that findings are leads to investigate by hand.

Read the full file on GitHub · 81 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 81 lines · 31 tokens per session scan A 4193428c3c8a

Subscribe to this mod's changes

verify is a command published in the GitHub repository cognitive-fab/polygraph (11 stars, last pushed 5d ago), licensed Apache-2.0. It adds 31 tokens to every session and 1,160 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.