Testing¶
The whole suite runs offline: no network, no API keys, no spend. Agents are scripted, the
framework connectors use the scripted model credencestack:scripted, and every episode is
seeded, so a test that passes once passes everywhere.
Layout¶
| Folder | What it holds |
|---|---|
tests/unit/ |
One file per area (test_authority_grader.py, test_env.py, test_faults.py, test_stats.py, test_verify.py, ...): fast, in-process tests of the packages |
tests/integration/ |
End to end through the CLI and real files: evidence bundles, private bundles, each framework connector (test_<framework>_connector.py), the GitHub workflows, the stealth and private-content checks |
tests/golden/otel/ |
Normalised OpenTelemetry span trees, one per connector (scripts/gen_otel_golden.py; tests/unit/test_otel_golden.py) |
tests/docs/ |
The documentation's own examples: test_guides.py re-runs every framework guide; test_dev_reference.py checks the developer reference |
tests/live/ |
Real-model smoke tests for the connectors, skipped by default |
tests/fixtures/ |
Test inputs (AP2 mandates); shared external samples such as the Atryum log live in fixtures/external/ |
tests/conftest.py |
Session fixtures: a naive and a safe evidence bundle built once per run |
The file index lists, for every source file, the test files that import it.
Running the tests¶
uv run pytest -q -m "not guides" # everything except the guide runs (about 2 minutes)
uv run pytest -q tests/docs/test_guides.py -k langgraph # one framework guide, end to end
uv run pytest -q -m "not integration" # unit tests only
Markers (pyproject.toml; --strict-markers is on):
integration: end-to-end tests that use the CLI and real files.guides: a developer guide's commands, end to end. Each guide runs 150 or more episodes, so CI runs one guide per connector job rather than all of them in one job.docker: needs a local Docker daemon (the OpenTelemetry Collector test); skips with a clear message without one, and CI runs it in theotel-integrationjob.
Tests for a connector whose extra is not installed are skipped, so uv sync --group dev
alone gives a passing suite (the CI job "Core install (no extras)" checks this).
Offline and live¶
Live tests call real, paid models and read API keys from the environment only:
CREDENCESTACK_LIVE=1 uv run pytest tests/live -q
Each connector needs its own variables (for example OPENAI_API_KEY and
CREDENCESTACK_LIVE_OPENAI_AGENTS_MODEL); the docstring of
tests/live/test_live_connectors.py lists them all. A live test runs one compliant
scenario once and checks only that the connector delivered a final decision without an
connector error, because model behaviour varies. The guides' live paths
(test_guide_live_path) follow the same rule with CREDENCESTACK_LIVE_<FRAMEWORK>_MODEL.
Unit tests never use the network. A test that needs a model uses the scripted one.
Golden examples: generated, committed, checked¶
Every command, output and code example in the guides and the developer reference is produced by running the real code, committed, and checked in CI. Two generators:
| Generator | Writes | Check |
|---|---|---|
scripts/gen_doc_examples.py |
docs/_generated/core/ (profiles, the report tour, troubleshooting errors), docs/_generated/dev/ (the module reference examples: the output of each examples/dev/*.py), docs/_generated/guides/<framework>/ (each guide's runs, diff, trace, comparison, signing and report extract) |
--check; tests/docs/test_guides.py and tests/docs/test_dev_reference.py |
scripts/gen_dev_reference.py |
docs/dev/file-index.md, docs/_generated/reference/ (the API tables, test lists and the CLI table) |
--check; tests/docs/test_dev_reference.py |
scripts/gen_otel_golden.py |
tests/golden/otel/<connector>.json (normalised span trees) |
--check; tests/unit/test_otel_golden.py |
scripts/gen_docs_reference.py |
the pack reference, framework mappings, connector table and conformance summaries | --check; tests/unit/test_docs_reference.py |
The generators run commands in a scratch directory with a fake home, a fixed terminal width and no colour, and replace machine-specific paths, hashes, key ids, run ids and wall times with placeholders, so output is identical on every machine.
To regenerate after a change:
uv run python scripts/gen_doc_examples.py --only core dev # seconds
uv run python scripts/gen_doc_examples.py --only langgraph # one guide: about 1 to 2 minutes
uv run python scripts/gen_dev_reference.py
uv run python scripts/gen_docs_reference.py
The CrewAI guide needs an environment with only the crewai extra (it conflicts with the
mcp and openai-agents extras): run the generator with that environment's Python and
--only crewai.
A guide group whose framework is not installed is skipped, not deleted.
Determinism and synthetic data¶
- Determinism. Every scenario must give the same trace for the same seed. The
conformance kit runs everything twice per connector;
tests/integration/test_domain_packs.pyruns every domain scenario twice per episode, and the three domain packs through Inspect twice with a fixed seed, and requires identical results. - The naive-fails, safe-passes property. For each domain pack, the safe reference agent
passes every scenario and the naive one fails at least the checkpoint's minimum
(
MIN_NAIVE_FAILURES). - Synthetic data.
scripts/check_synthetic.py(alsotests/unit/test_synthetic_data.pyand the release check) requiressynthetic: trueon domain packs and watch-lists,synthetic_examples: trueon policies, fictional country codes, vessel numbers that fail the IMO check digit, and no name from your local.synthetic-denylist.
Continuous integration¶
.github/workflows/ci.yml, on every push and pull request:
| Job | What it runs |
|---|---|
| Python 3.12 and 3.13 | ruff check and format, pyright, mypy (strict, core), pytest -q -m "not guides" with the langchain, anthropic, bench and otel extras |
| Core install (no extras) | the suite without any optional extra; connectors list and the python connector's conformance |
| Connector (one job per framework) | that extra only: its connector tests, the conformance kit's tests, its developer guide end to end (offline), and its conformance run with the scripted model; CrewAI also runs pyright on its own files |
| OpenTelemetry Collector (HTTP and gRPC) | the [otel] extra; a Collector in Docker; one scenario over each protocol (-m docker), then the telemetry unit and golden tests |
| Docs examples are current | gen_doc_examples.py --check --only core dev otel, gen_dev_reference.py --check, gen_docs_reference.py --check, mkdocs build --strict |
| Offline end-to-end example | examples/end_to_end.sh (run, sign, verify, tamper, sample benchmark) and the distribution check |
| GitHub Action self-test | the composite action on the safe agent (must pass the gate) and the naive agent (must fail it) |
.github/workflows/docs.yml builds the site on pull requests and deploys it on pushes to
main. tests/integration/test_github_workflows.py asserts the jobs above exist and run
what this page says.
Before committing, the pre-commit hooks run ruff, pyright, mypy, secret detection, the stealth check and the private-content check.