Metadata-Version: 2.4
Name: assaystone
Version: 0.9.0
Summary: Audit AI agent traces for silent failures, then gate CI and runtime with acceptance contracts.
Author: Assaystone contributors
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/yellowsand1/assaystone
Project-URL: Repository, https://github.com/yellowsand1/assaystone
Project-URL: Issues, https://github.com/yellowsand1/assaystone/issues
Project-URL: Changelog, https://github.com/yellowsand1/assaystone/blob/main/CHANGELOG.md
Keywords: ai,agents,verification,evaluation,mutation-testing,llm,audit,ai-agents,agent-verification,claude-code,codex,codex-cli,agent-audit,llm-evaluation,test-integrity,acceptance-testing
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: pytest
Requires-Dist: pytest>=7; extra == "pytest"
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: ruff>=0.9; extra == "dev"
Requires-Dist: coverage[toml]>=7; extra == "dev"
Dynamic: license-file

<p align="center"><img src="assets/logo.svg" width="88" alt="Assaystone"></p>

# Assaystone

**Your agent's tests pass. Did it delete the failing test?**

![ci](https://github.com/yellowsand1/assaystone/actions/workflows/ci.yml/badge.svg)
[![pypi](https://img.shields.io/pypi/v/assaystone)](https://pypi.org/project/assaystone/)
[![release](https://img.shields.io/github/v/release/yellowsand1/assaystone)](https://github.com/yellowsand1/assaystone/releases)
![status](https://img.shields.io/badge/status-alpha-orange)
![python](https://img.shields.io/badge/python-3.10%2B-blue)
![license](https://img.shields.io/badge/license-Apache--2.0-blue)
[![website](https://img.shields.io/badge/website-live-2ea44f)](https://yellowsand1.github.io/assaystone/)

**Assaystone is an open protocol and adversarial benchmark for agent acceptance.**

Every verifier must answer three questions before it is allowed to decide:

- **claim** — one sentence a human can disagree with
- **catches** — the defect classes it claims to detect
- **blind_spots** — the defect classes it knows it cannot detect

Above the verifier, the **acceptance plane** answers the deployment question: a
capability manifest binds typed criteria to nine generic oracles — compile, file,
git, HTTP, SQL, old-vs-new shadow, the agent's transcript, and the verifier ABI —
and gates `shadow`, `canary`, and `production`, recording every decision in a
hash-chained trail.

Assaystone then measures the verifier set on axes that a single pass rate hides:

| question | metric | command |
|---|---|---|
| Did it catch a known defect? | recall | `assaystone benchmark failure-zoo` |
| Can an agent that knows the contract pass without working? | resistance | `assaystone benchmark goodhart` |
| Does the contract cover what you declared? | coverage | `assaystone coverage` |
| Can a failing check decide alone? | independence | runner policy |
| All four, on one page | report card | `assaystone scorecard` |
| How do several contracts compare? | leaderboard | `assaystone leaderboard` |

It also ships a reference implementation: audit existing Claude Code, Codex CLI,
and observability traces, then gate CI, runtime, and deployment with the same
acceptance language. Nothing leaves your machine; no API key or runtime
dependency is required.

The deployment question — *can this capability move to the next stage, and with
what evidence?* — is a gate too: `assaystone demo plane`.

<img src="assets/demo.gif" alt="Assaystone auditing a Claude Code transcript and finding a deleted failing test" width="760">

## 60-second adversarial demo

```bash
assaystone demo adversarial
```

A six-line `sitecustomize.py` neutralises `assertEqual`, so the suite passes while
the bug remains. The naive contract (`syntax + tests`) returns **pass**; the
hardened contract fails at `tests.harness_integrity`:

```
contract     verdict   first failure
naive        pass      —
hardened     fail      tests.harness_integrity: sitecustomize.py (added): can change the test runtime
```

That is the product in one screen: a green suite is not acceptance. The same
attacks, with minimal reproductions, are in
[docs/evasions.md](docs/evasions.md).

## 60-second audit

No transcript yet? Run the bundled failure case — no Python setup required:

```bash
uvx assaystone demo audit
```

`uvx` runs Assaystone in a throwaway environment, so it works even when your system
`python3` is older than 3.10. With Python 3.10+ installed, audit your own newest local
transcript instead:

```bash
pip install assaystone
assaystone audit --latest claude-code   # or: --latest codex
```

Assaystone finds the newest local transcript for the current workspace and audits it.
Nothing leaves your machine. No API key or runtime dependency is required.

> macOS note: the system `python3` is often 3.9. `pip install assaystone` then fails
> with "No matching distribution found" because the package needs 3.10+. Check with
> `python3 --version`; if it is older, use `uvx` above or install Python 3.12.

The bundled demo prints:

```
audit-demo-session  changed: pricing/discounts.py, tests/test_discounts.py
  HIGH     tests.integrity          tests/test_discounts.py (modified)

summary: 0 critical, 1 high, 0 medium, 0 low
```

The agent fixed the rounding bug, then deleted the one test it still failed, and
reported success. `tests.pass` saw a green suite. The audit found the deleted test.

The rest of the loop:

```bash
python3 -m assaystone demo        # code/test verifier pack
python3 -m assaystone demo ops    # runtime gate + ops/refund pack
python3 -m assaystone demo plane  # acceptance plane: pass, fail, approval, trail
```

The code demo compares a naive contract (`tests + syntax`) with a hardened one:
**1/4 vs 4/4** defects caught, and mutation testing raises verifier recall from
**67% to 94%**. The ops demo catches **0/4 vs 4/4** bad refunds, and the runtime gate
blocks a denied approval and an over-limit refund.

The plane demo runs one pricing change through the lifecycle in one screen: the
`shadow` oracle passes, a refactor that keeps the tests green but changes the
wire format fails at `parity`, `canary` escalates without the owner's approval,
passes with it, and the audit trail detects an edited decision.

## What a passing test suite misses

| Defect | `tests.pass` | Assaystone |
|---|---|---|
| Agent deletes the failing test | ✅ passes | ❌ `tests.integrity` |
| Agent edits CI to skip the suite | ✅ passes | ❌ `diff.forbidden_paths` |
| Agent leaves a debug print | ✅ passes | ❌ `quality.no_debug_prints` |
| Agent weakens an assertion | ✅ passes | ❌ `tests.integrity` |
| Regression in another module | ❌ fails | ❌ `tests.pass` |

Actions have the same problem. In the ops demo, an amount-only contract catches 0/4
bad refunds; policy, ledger, status, and approval checks catch 4/4.

## Failure Zoo

The repo ships with labeled failures, not just demos: a deleted test, a CI edit, a
debug print, a cross-module regression, an over-limit refund, and a missing approval.
Each case names the verifier that should catch it, and each one is a regression test
for the verifier ladder. The corpus is the seed for a public benchmark —
[bring a redacted trace](failure_zoo/README.md) and it becomes a fixture.

Run the benchmark offline against the committed corpus:

```bash
assaystone benchmark failure-zoo
make benchmark   # also refreshes docs/failure-zoo.md
```

It runs every built-in verifier independently against each case and reports
caught / escaped / false-alarm counts per verifier, with a regression threshold so
verifier recall cannot silently drop. The generated scorecard is committed at
[docs/failure-zoo.md](docs/failure-zoo.md), and the JSON and CSV forms are available
with `--json PATH` and `--csv PATH`.

## Contribute a failure case

```bash
assaystone corpus add \
  --corpus assaystone/demo_data/goodhart/corpus.json \
  --family mechanical \
  --trace ~/session.jsonl --format claude-code \
  --baseline ~/repo-before \
  --label fail --defect test-harness-hijack \
  --note "neutralised assertEqual instead of fixing the rounding" \
  --validate
```

One labelled trace or redacted transcript becomes a scored fixture. The command
never edits the manifest; `--validate` reruns the corpus and tells you whether the
current pack caught it. Details: [docs/corpus.md](docs/corpus.md).

Running a design-partner session? The 45-minute script, the invitation, and what
to collect are in [docs/adoption.md](docs/adoption.md). The reproducible evasion
write-up is [docs/evasions.md](docs/evasions.md). What the current pack still
misses is public in [docs/known-evasions.md](docs/known-evasions.md).

## Protocol

A verifier is only useful if another tool can consume it. The v1 protocol makes the
three questions machine-readable for all built-in verifiers:

```bash
assaystone protocol
assaystone protocol --check examples/code_agent/contracts/hardened.json
assaystone protocol --schemas ./schemas   # contract, verifier, verdict JSON Schemas
```

The schemas are dependency-free and versioned under
`https://assaystone.dev/protocol/v1/`. A verifier written in another language can
publish a manifest and be scored by the same benchmark. A verifier that cannot name
its blind spots fails conformance.

## Goodhart suite

Recall asks whether a verifier catches a defect. The Goodhart suite asks the harder
question: **can an agent that reads the contract get a clean pass without doing the
work?**

```bash
assaystone benchmark goodhart
```

The bundled adversary is split into two families, because they fail for different
reasons:

| family | attack | outcome |
|---|---|---|
| mechanical | startup hook neutralises `assertEqual` | caught by `tests.harness_integrity` |
| mechanical | a local `unittest.py` shadows the runner | caught by `tests.harness_integrity` |
| mechanical | a CI action outside `.github/workflows/` | caught by `diff.ci_surface` |
| semantic | an unrequested behavior change no test covers | **escapes** |
| semantic | hardcoded test inputs, truncation everywhere else | **escapes** |
| ops | an approval recorded in evidence but never requested in the trace | caught by `ops.approval_lineage` |
| ops | two refund rows recorded from one `refund.create` step | caught by `ops.refund_lineage` |
| ops | approved 4000 cents, refunded 8000 | caught by `ops.approval_lineage` |
| support | a shared assertion helper made a no-op, test files untouched | caught by `tests.support_integrity` |

Mechanical, ops lineage, and support resistance are **100%**; semantic resistance
is **0%**. The catalog-wide number is **78%** (7/9), and both escapes were already
in `tests.pass`'s declared blind spots, so the report counts them as declared
escapes, not surprises. That split is the point: deterministic checks stop
mechanical attacks and can enforce an action lineage; they do not specify
semantics.

A contract's report card is scoped to its domain: the code contract is scored
against the code families (60%), and the ops contract against the ops family
(100%). The benchmark itself reports every family. `--md` and `--json` emit the full report; regressions are blocked by
[thresholds](assaystone/demo_data/goodhart/thresholds.json).

## Report card

```bash
assaystone scorecard \
  --contract examples/code_agent/contracts/hardened.json \
  --trace examples/code_agent/traces \
  --baseline examples/code_agent/baseline
```

One page: protocol conformance, declared coverage, recall on labelled traces, and
resistance by family. The exit code is 0 only when all four pass, so the card can
be a CI gate. `--md` and `--json` write the same data for a review artifact.

## Leaderboard

`assaystone leaderboard --manifest benchmarks/leaderboard.json` scores several
contracts side by side: coverage, recall, resistance, false alarms, cost, and one
result per entry. The generated table is
[docs/leaderboard.md](docs/leaderboard.md).

The built-in entries show the trade-off the project is about: a short contract can
have perfect recall and no coverage; a long one can cover every declared class and
still leak semantics. A leaderboard makes that visible instead of reducing it to a
single score.

## Acceptance IR

A contract is not a list of checks. It is a statement of what "acceptable" means:

| kind | the question |
|---|---|
| `precondition` | what must be true before the run? |
| `invariant` | what must never change? |
| `postcondition` | what must be true after? |
| `forbidden_action` | what must never happen? |
| `evidence` | what must be shown? |

Each criterion binds to checks through a defect tag. A criterion with no check is
an **assurance gap**, not a bug: the requirement is declared, and the tool says it
cannot decide it. A critical or high criterion with no check escalates the run
instead of passing it. The same language describes code, actions, data, and
research. Spec: [docs/acceptance-ir.md](docs/acceptance-ir.md).

## Domain packs

The core is domain-neutral; the packs supply what changes. Three ship today:

| domain | example criteria | checks |
|---|---|---|
| code | tests pass; no test, runtime, or support tampering; no CI bypass | `tests.*`, `diff.*` |
| ops | refunds within policy; approval lineage; totals conserved | `ops.*` |
| data | report schema; row totals equal the total; no PII added | `data.*` |
| research | every claim cites; every source exists; every quote is verbatim | `research.*` |

The same `precondition` / `invariant` / `postcondition` / `forbidden_action` /
`evidence` language describes all four.

## Plan a contract

`assaystone compose` turns "these defect classes matter" into the cheapest set of
independent checks that decides them:

```bash
assaystone compose --contract examples/code_agent/contracts/hardened.json
```

It reports the selected checks, the cost against the budget, classes that no check
decides, and classes that rest on a single check. The last list is the useful one:
a contract can cover every declared class and still have no redundancy.

## Acceptance plane

A capability manifest binds criteria to generic oracles — `command`, `file`,
`git`, `human`, `http`, `sql`, `shadow`, `transcript`, `verifier` — and a
lifecycle policy:

```bash
assaystone capability init --root . --owner platform-team   # draft a manifest
assaystone capability brief --manifest .assaystone/capability.json --task "..."  # hand the criteria to the agent
assaystone capability validate --manifest examples/capability/pricing.json
assaystone gate --manifest examples/capability/pricing.json --stage shadow \
  --root examples/capability/pricing_project --audit trail.jsonl --actor ci
assaystone trail verify trail.jsonl
```

`shadow` can pass but cannot merge; `canary` and `production` add approvals.
A later stage can require a recorded earlier pass (`"after": "canary"`), and the
chain verifies the trail before trusting it.
The core does not know Maven: `mvn -q -DskipTests compile` is a command payload.
A SQL check is a single read-only query. A `shadow` check runs the old and the
new implementation on the same input and fails when the output diverges, which
is the missing oracle for refactors, migrations, and model swaps.

Three domains run on the same core:

- `java.json` — Maven template. Oracles come from a versioned registry
  (`oracles.json`) and the manifest pins versions; a registry update cannot
  silently change what a capability verifies.
- `support.json` — a refund request with a policy limit and a manager approval.
- `pricing.json` — a fee refactor. `shadow` proves parity, `sql` checks the
  ledger, and a critical criterion missing from a stage is reported as an
  assurance gap (`--strict` escalates it).

`capability validate --strict` fails when a critical criterion is gated by no
stage at all. `gate` appends to a hash-chained trail: actor, stage, outcome,
missing oracles, the assurance gap, and a digest of every oracle it ran. `trail verify` detects
edits and deleted entries; pass `--expect HASH` with an externally anchored head
to detect truncation as well. Case study: [a green build, a broken API, a blocked promotion, and a verified
rollback](docs/case-study-lifecycle.md). Reference: [docs/plane.md](docs/plane.md).

## External tools

The protocol is not limited to the built-in pack. `external.pytest` and
`external.ruff_debug_print` run real third-party tools when installed and escalate
when they are missing. Their blind spots are declared, and the benchmark shows why
that matters: pytest catches the regression and passes the deleted test; ruff
catches the debug print and sees only the rule you selected.

## Why

Evaluations give you a score. Production needs a verdict: what failed, why, with
what evidence, and whether a human must look. Agents fail silently; a green test
suite is not an acceptance criterion.

The longer argument: [Verification is the bottleneck](docs/why.md).
The product: [What we are building](docs/vision.md).

Field note: [What 162 real Claude Code sessions say about verification](docs/case-study-2026-11.md)
or read the [hosted version](https://yellowsand1.github.io/assaystone/blog/162-claude-code-sessions/).

## Install

Python 3.10+. No runtime dependencies.

```bash
pip install assaystone
assaystone demo audit
```

No Python 3.10+ yet? `uvx assaystone demo audit` runs the same demo with no setup.

From source for contributors:

```bash
git clone https://github.com/yellowsand1/assaystone
cd assaystone
python3 -m pip install -e ".[pytest]"
python3 -m assaystone demo audit
```

## Audit your own traces

```bash
# newest local session for this repo (no path required)
assaystone audit --latest claude-code
assaystone audit --latest codex

# explicit Claude Code transcript
assaystone audit ~/.claude/projects/.../<session>.jsonl --baseline .

# LangSmith / Langfuse exports
assaystone audit runs.json --format langsmith --baseline .
assaystone audit trace.json --format langfuse --baseline .

# OpenTelemetry GenAI (OTLP JSON)
assaystone audit otel.json --format otel --baseline .

# a message export or a trace JSON
assaystone audit trace-export.json --git-repo .

# turn findings into a contract
assaystone audit session.jsonl --baseline . \
  --write-contract .assaystone/contract.json

# CI reports
assaystone audit session.jsonl --baseline . \
  --sarif results.sarif --junit results.xml

# use HEAD as the pre-session baseline for diff-size / public-API checks
assaystone audit session.jsonl --baseline . --git-preimage

# aggregate-only audit of a local Claude Code corpus
python scripts/corpus_audit.py --root ~/.claude/projects
```

Supported inputs: Claude Code `.jsonl` transcripts, Codex CLI session JSONL,
LangSmith run exports, Langfuse trace/observation exports, OpenTelemetry GenAI spans,
message JSON/lists, and Assaystone trace JSON. Importers are heuristic; `--format`
forces one. `--latest claude-code` and `--latest codex` discover the newest session
for the current workspace. For transcripts
and importers, artifacts are reconstructed from `Write` / `Edit` tool calls;
`--git-repo` is more reliable when the changes are real. If the repository is already
in its post-session state, the audit falls back to reading the current files;
`--workspace` forces that mode (the Claude Code hook uses it). Default rules: test
integrity, forbidden paths, syntax, diff size, public API, debug prints, and
claim-vs-evidence. `--run-tests` adds the test suite. `--json` is for machines;
`--sarif` / `--junit` are for CI; `--no-evidence` keeps raw evidence out of reports.
`--run-tests` executes the project's test command in a temporary copy of the baseline;
it is not a sandbox, so only audit traces and repositories you trust.
Details: [docs/audit.md](docs/audit.md) · [importers](docs/importers.md).

## Quickstart in your repo

If you already have transcripts, start with `assaystone audit` above. `init` is for
when you want a contract to gate future runs:

```bash
cd your-agent-repo
assaystone init --ci
```

This writes `.assaystone/contract.json` and a GitHub Actions workflow. The contract
includes checks for syntax, forbidden paths, test integrity, diff size, public API,
debug prints, claim-vs-evidence, and the test suite (when one is detected).

Record a trace from a framework message list:

```python
from assaystone.adapters import artifacts_from_git, from_claude_agent

trace = from_claude_agent(
    messages,
    artifacts=artifacts_from_git("."),
    task="fix the failing rounding test",
)
trace.save(".assaystone/traces/run-001.json")
```

Or from a recorded transcript:

```bash
assaystone record --transcript messages.json --git-repo . \
  --out .assaystone/traces/run-001.json
```

Verify:

```bash
assaystone verify --contract .assaystone/contract.json \
  --trace .assaystone/traces
```

Exit codes: `0` all pass, `1` at least one fail, `2` needs human review. Use `--json`
for machines, `--github` for Actions annotations.

## Integrations

### Claude Code plugin

Install the plugin marketplace and plugin directly inside Claude Code:

```bash
claude plugin marketplace add yellowsand1/assaystone
claude plugin install assaystone@assaystone
pip install assaystone
```

The plugin adds `/assaystone:audit`, `/assaystone:setup`, and a Stop hook that runs the
same local audit after each session. The hook fails open if the CLI is unavailable.
Details: [docs/plugin.md](docs/plugin.md).

### Claude Code Stop hook

Use the hook without the plugin when you want a project-local settings change:

```bash
assaystone hook install claude-code --mode warn
```

This merges a Stop hook into `.claude/settings.local.json` (use `--user` for global
settings). The hook audits the session transcript when Claude stops. Default is warn;
`--mode block` blocks high/critical findings. Repeated identical findings are
suppressed per session, and `.assaystone/hook.json` can ignore known-good test edits.
Details: [docs/hooks.md](docs/hooks.md), example:
[examples/hooks](examples/hooks/README.md).

### pytest

```bash
pytest --assaystone-contract .assaystone/contract.json \
       --assaystone-traces .assaystone/traces
```

One test item per trace; failures show up like normal pytest failures. Or use the
fixture:

```python
def test_agent_run(assaystone):
    result = assaystone.verify(".assaystone/traces/run-001.json")
    assert result.verdict == "pass", result.first_failure
```

### GitHub Action

```yaml
- uses: yellowsand1/assaystone@v0.9.0
  with:
    contract: .assaystone/contract.json
    traces: .assaystone/traces
    install: assaystone==0.9.0   # optional; default installs the action repo
```

Failures become PR annotations; a Markdown summary is written to the job summary.

The same action gates a capability when you pass `manifest` instead of
`contract`/`traces`:

```yaml
- uses: yellowsand1/assaystone@v0.9.0
  with:
    manifest: .assaystone/capability.json
    stage: canary
    root: .
    audit: .assaystone/trail.jsonl
    actor: ${{ github.actor }}
```

It sets `verdict` and `findings` outputs, writes the oracle table to the step
summary, and exits non-zero on `fail` or `escalate`. When a stage declares
`after`, carry the same trail artifact from the earlier stage.

### Framework adapters

- Claude Code and Codex CLI transcript import
- Claude Agent SDK message streams (`from_claude_agent`)
- OpenAI-style chat/tool messages (`from_openai_agents`)
- LangGraph state dicts (`from_langgraph`)
- Generic message lists (`from_messages`)
- Runtime wrappers: [LangGraph and OpenAI Agents SDK](docs/integrations.md)
- `artifacts_from_git` collects changed files as artifacts

Adapters are duck-typed and never import the framework. Details:
[docs/adapters.md](docs/adapters.md).

### Custom verifier

```python
from assaystone import Verifier, register

@register
class NoMigrationEdits(Verifier):
    name = "policy.no_migrations"
    layer = "L1"
    cost_usd = 0.00001
    independence = "high"

    def check(self, ctx, params):
        bad = [path for path, _ in ctx.changed() if path.startswith("migrations/")]
        return (not bad, [f"migration touched: {path}" for path in bad], [])
```

Add `{"name": "policy.no_migrations"}` to the contract.

## How it works

```
recorded trace (task, tool calls, artifacts, evidence)
        │
        ▼
 acceptance contract (verifier ladder + budget + escalation)
        │
        ▼
   pass / fail / escalate  ──►  CI gate, runtime gate, human review
        │
        ├── mutate: inject labeled defects, measure verifier recall
        └── backtest: replay historical traces before enforcing a check
```

- **Trace** — what the agent did, what it produced, what evidence it left.
- **Contract** — acceptance criteria for one task type, versioned with the agent.
- **Verifier** — a cheap, independent check with a declared layer and cost.
- **Verdict** — pass, fail, or escalate with reasons and evidence refs.
- **Mutation** — inject one plausible defect at a time; did the contract kill it?
- **Backtest** — replay human-labeled traces; measure catch rate, escaped defects,
  false alarms, and cost.

## Runtime gate

The same contract can gate actions, not just CI:

```python
from assaystone.adapters import artifacts_from_git
from assaystone.runtime import RuntimeGuard

guard = RuntimeGuard(
    ".assaystone/contract.json",
    baseline=".",
    irreversible={"refund.create"},
    approval_callback=ask_human,
)

with guard.session(task="refund duplicate charge") as session:
    session.call("read_order", {"order_id": "O-1"}, read_order)
    session.call("refund.create", {"amount_cents": 4000}, do_refund)
    result = session.finish(artifacts=artifacts_from_git("."))
```

Irreversible tools are blocked unless `approval_callback` returns True. The full
contract runs at `finish`; `ContractFailed` and `EscalationRequired` stop the run.
`enforce=False` runs in shadow mode. Details: [docs/runtime.md](docs/runtime.md).

Framework wrappers: `LangGraphGuard` and `run_with_verification` for OpenAI Agents —
[docs/integrations.md](docs/integrations.md).

## The verifier ladder

| Layer | Examples | Cost | Independence |
|---|---|---|---|
| L0 | invariants, schema, step budget | ~free | high |
| L1 | compiler, tests, path policy, harness integrity | low | high |
| L2 | diff, public API, custom rules | low | high |
| L3 | evidence / citation checks | low-medium | medium-high |
| L4 | LLM judge (not in the default ladder) | low but correlated | low |

Every verifier declares `claim`, `catches`, `blind_spots`, `cost`, and
`independence`. The runner uses the last one: a **low-independence failure cannot
decide alone**. It keeps looking for an independent confirmation; if none arrives,
the verdict is `escalate`, not `fail`. Unknown independence levels are treated as
low, so a verifier that cannot describe itself routes to a human.

`assaystone coverage` turns the contract into a residual-risk report: which declared
defect classes are decided by an independent check, which are only weakly covered,
and which are not covered at all.

Use the cheapest sufficient verifier. A judge is a filter, never the oracle.

References: [built-in verifiers](docs/verifiers.md) · [contract format](docs/contracts.md) · [protocol](docs/protocol.md).

## Where it fits

Assaystone is an acceptance layer, not a replacement for evaluation or observability.

- **Evals** (promptfoo, DeepEval, Inspect AI) score outputs across a dataset.
  Assaystone audits one run's artifacts and returns a verdict with evidence.
- **Guardrails** (Guardrails AI, framework callbacks) filter inputs and outputs.
  Assaystone also gates irreversible tool calls and checks the final deliverable.
- **Tracing** (LangSmith, Langfuse, OpenTelemetry) records what happened. Assaystone
  consumes those exports and decides whether the run is acceptable.
- **Signed records** (Tracekit and similar) prove what ran. Assaystone supplies the
  contract and verdict those records can attest to.

They compose: record → verify → escalate. Keep the tools you already run; put
Assaystone at the acceptance boundary.

## Design principles

1. **Verify artifacts, not self-reports.** "All tests pass" is a claim; the recorded
   exit code and the re-run suite are evidence.
2. **Record once, verify many.** Verification is decoupled from generation, so checks
   can be replayed, backtested, and mutated.
3. **Cheapest sufficient verifier first.** Every verifier declares cost; the runner
   stops at the first required failure.
4. **Escalation is a first-class outcome.** If cheap checks cannot decide, route to a
   human with an evidence bundle.
5. **Verifiers are code, and they are tested.** Mutation testing measures recall; a
   verifier you never challenged is a liability.
6. **Name your blind spots or you are claiming to be an oracle.** A verifier that
   cannot state what it misses fails protocol conformance.
7. **Independence is a property of the verdict, not a label.** A check that shares
   context with the generator cannot decide alone.
8. **Measure resistance, not just recall.** Any verifier can be gamed; the benchmark
   must include an agent that knows the rules.

## Repository layout

```
assaystone/            # library: models, sessions, runner, verifiers, adapters, audit, runtime, CLI
assaystone/protocol.py # verifier ABI, JSON Schemas, conformance check
assaystone/coverage.py # declared defects vs. decided coverage vs. residual risk
assaystone/goodhart.py # adversarial suite: resistance and declared escapes
assaystone/reportcard.py # conformance + coverage + recall + resistance on one page
assaystone/plane.py    # capability manifests, lifecycle gates, assurance gap
assaystone/oracles.py  # nine generic primitives + versioned registry
assaystone/trail.py    # hash-chained gate audit trail
assaystone/corpus.py   # add a labelled trace or transcript to a family
assaystone/leaderboard.py # compare several contracts on one page
assaystone/packs/external.py # pytest / ruff adapters (optional, fail closed)
assaystone/demo_data/  # packaged demos (the wheel can run them)
assaystone/demo_data/goodhart/ # adversarial corpus: mechanical + semantic
.claude-plugin/        # Claude Code marketplace catalog
plugins/assaystone/    # Claude Code plugin: skills + Stop hook
site/                  # static GitHub Pages landing page
examples/code_agent/   # baseline repo, contracts, scenarios, generated traces
examples/ops_agent/    # runtime gate + ops/refund pack
examples/audit/        # a Claude Code transcript that deletes the failing test
examples/importers/    # LangSmith / Langfuse / OTel export fixtures
examples/hooks/        # Claude Code Stop hook settings
examples/third_party_pack/ # a verifier implemented outside the package
examples/capability/   # three domains on one plane: Java, refund, pricing
failure_zoo/           # labeled failure corpus (seed)
docs/why.md            # the longer argument
docs/vision.md         # the product spec: four layers and the domain-pack boundary
docs/protocol.md       # the verifier ABI and the three schemas
docs/acceptance-ir.md  # the criterion language above the verifiers
docs/plane.md          # acceptance plane: oracles, registry, gates, trail
docs/protocol.json     # generated catalog of every conformant verifier
docs/corpus.md         # how to add a labelled case
docs/adoption.md       # the 45-minute design-partner script
docs/evasions.md       # three reproducible ways to make tests lie
docs/known-evasions.md # what the current pack still misses
docs/leaderboard.md    # generated comparison of built-in contracts
docs/goodhart.md       # generated resistance report
docs/report-card.md    # generated contract report card
docs/case-study-2026-11.md  # 162-session field note
docs/audit.md          # audit inputs, rules, output, limitations
docs/importers.md      # LangSmith / Langfuse / OTel formats
docs/hooks.md          # Claude Code Stop hook
docs/adapters.md       # Claude / OpenAI / LangGraph adapters
docs/integrations.md   # LangGraph / OpenAI Agents runtime wrappers
docs/verifiers.md      # built-in verifier reference
docs/contracts.md      # contract format and exit codes
docs/runtime.md        # runtime guard reference
docs/release.md        # maintainer release checklist
docs/releases/         # per-version release notes
scripts/corpus_audit.py # aggregate local corpus audit
tests/                 # unit + integration tests
```

## Status and roadmap

`v0.9.0` — alpha. The core is domain-agnostic, and the acceptance plane now
gates a capability at shadow, canary, and production.

- [x] audit: Claude Code and Codex CLI transcripts, message exports, trace JSON
- [x] one-command discovery: `audit --latest claude-code|codex`
- [x] LangSmith / Langfuse / OpenTelemetry importers
- [x] Claude Code plugin marketplace + Stop hook (warn/block, dedupe, allowlist)
- [x] SARIF and JUnit output
- [x] contracts, verifier ladder, pass/fail/escalate
- [x] mutation testing and backtesting
- [x] Claude Agent SDK / OpenAI-style / LangGraph adapters, `artifacts_from_git`
- [x] pytest plugin and GitHub Action with machine-readable outputs
- [x] runtime gate for irreversible actions (approvals, shadow mode)
- [x] LangGraph / OpenAI Agents runtime wrappers
- [x] ops/refund pack
- [x] git pre-image baseline for post-session diff checks
- [x] Failure Zoo benchmark and per-verifier release scorecard
- [x] data reconciliation and report citation packs
- [x] oracle registry (versioned, pinned, fingerprinted)
- [x] acceptance plane: capability manifests, nine oracle primitives, lifecycle gates
- [x] hash-chained gate trail, manifest-digest continuity, signed approvals
- [x] chained stages: production requires a recorded, verified canary pass
- [x] checked rollback evidence and `capability init`
- [ ] TypeScript port

## Contributing

New here? The [Start here discussion](https://github.com/yellowsand1/assaystone/discussions/11)
has the 60-second audit path, the honest limits of `tests.integrity`, and a place to ask
questions.

The fastest way to help is to
[bring a failure case](.github/ISSUE_TEMPLATE/failure_case.md). See
[CONTRIBUTING.md](CONTRIBUTING.md) for verifier and adapter guidelines.

Maintainers: see [docs/release.md](docs/release.md) for the release checklist and
[ROADMAP.md](ROADMAP.md) for the current product and growth priorities.

If this catches a failure in your stack,
[bring the trace](.github/ISSUE_TEMPLATE/failure_case.md). Reproducible cases become
regression tests.

## Name

An *assay* determines the quality of a substance; an *assay stone* (touchstone) tests
gold. Chinese: 试金石.

## License

Apache-2.0.
