Skip to content

CredenceStack maintainer guide

This guide is for the person who looks after CredenceStack with nobody else to ask. It explains what the project is for, how it is put together, the rules each part keeps, and how to change things without breaking the guarantees reviewers rely on.

Related docs:

1. Purpose

Banks and fintechs want AI agents that act: pay invoices, onboard suppliers, serve partner agents. Every such firm already has delegated-authority rules. CredenceStack lets a team write those rules once (an authority profile), run its agent many times in a simulated finance back office against scenarios designed to tempt it past them, and hand reviewers a signed, tamper-evident evidence bundle organised around the six pillars of OCC Bulletin 2026-54. It produces test evidence; it never certifies compliance.

2. How a run works

credencestack run --pack payments --agent mymod:agent --epochs 5
  packs.load_pack            YAML -> validated Scenario objects (+ profile, environment checks)
  runner.inspect_runner      one Inspect task per pack, one sample per scenario, N epochs
    episode_solver           per epoch: runner.episode.run_episode
      build_environment      env.Environment from env_seed + authority binding
      install_faults         faults.* wrappers on the environment's tools
      KillSwitch, RateObserver   control.* hooks
      connector.start / run_until_done   the agent works through env.call(...)
      record_episode         graders.record.EpisodeRecord into the Inspect sample store
    scorers                  graders.scorers (authority, resilience, injection, third party)
                             + graders.outcome (expected outcomes) [+ advisory judge]
  run_statistics, oversight_metrics
  integrations.reconcile     with --runtime-log: three-way reconciliation
  evidence.bundle            results.json, traces, authority/, mappings.json, report.html,
                             manifest.json (hashes + Merkle root)
credencestack report --sign / evidence verify   evidence.signing / evidence.verify

3. Design principles (keep these)

  • Determinism first. The environment's clock, ids and randomness are simulated and seeded; the grader, the scorers and canonical JSON are pure. The scripted agents give the same results every run. Randomness lives only in real models.
  • One source of truth for authority. Limits live in the profile. The authority scorer, reconciliation, the scripted safe agent and authority explain all call the same decide(). Never duplicate a limit anywhere else.
  • The harness executes the tools. Every connector routes tool calls through Environment.call, so the trace and the ledger are complete whatever the agent is built with. Faults and the kill switch act there too.
  • Framework code behind interfaces. Only connectors/ and agents/ import agent frameworks, lazily. The core needs none of them.
  • Fail loudly on bad input, never on bad agents. Invalid packs or profiles raise with every error listed. Agent exceptions and connector bugs are recorded as results.
  • Evidence is append-only once signed. Anything that changes a bundle after signing invalidates the signature visibly; report --force removes it.
  • Offline by default. No test, and no run of the scripted agents, touches the network. Real model calls happen only behind explicit flags (the advisory judge; the benchmark).
  • Stealth and privacy. No personal names, emails or employer references anywhere. The author is "CredenceStack contributors" and the contact is hello@credencestack.ai. scripts/stealth_check.sh runs before every commit.

4. Repository layout

src/credencestack/
  core/          Scenario, Pack, Pillar, Finding, TraceEvent, RunResult (mypy strict)
  authority/     profiles, the grader decide(), step classification, profile resolution
  domains/       DomainGrader interface, registry, policy loading; payments, fincrime/,
                 docintegrity/, kyc/ (each a policy model and an grader)
  matching/      name matching: normalisation, transliteration, homoglyphs, distances
  packs/         loader, schema export, builtin/ (the seven packs, profiles, policies)
  env/           the simulated back office: clock, ledger, vendors, invoices, reviewer,
                 inbound agents, tool families (42 tools), injections; fincrime/, kyc/,
                 documents and registry worlds for the other domains
  faults/        fault wrappers (timeout, stale, partial failure, 429, outage, malformed,
                 clock jump)
  control/       kill switch and rate observer
  connectors/      the Connector protocol; Python, HTTP and LangChain connectors
  agents/        scripted naive and safe agents, naive_lc / safe_lc, offline test doubles
  runner/        run_episode, the Inspect runner, seeds
  graders/       episode record, scorers, expected-outcome check, statistics, advisory judge
  metrics/       oversight metrics
  integrations/  runtime-log import (Atryum), reconciliation, AP2 mandates
  evidence/      bundle, manifest, framework mappings, the report template, run_to_bundle
  bench/         benchmark config, cost cap, runner, charts and benchmark.md
  verifiable/    canonical JSON, hash chains, Merkle root, signing, verify, anchor/zk
  telemetry/     OpenTelemetry (the [otel] extra): config, span names, spans from trace
                 events, exporters, redaction, span-tree checks
  cli*.py        the Typer CLI
schemas/         exported JSON Schemas (scenario, authority profile)
profiles/        an example profile (identical to the packaged one)
fixtures/        external sample data (the Atryum log)
examples/        end_to_end.sh
bench/           sample_bench.yaml (offline), bench.example.yaml (the real run)
scripts/         stealth_check.sh

The import layering runs from core and authority at the bottom, through packs, env and graders, then faults, control, connectors and agents, to runner, evidence and the CLI at the top. The few imports that go upward (for example packs.loader checking fault parameters) are lazy.

5. Testing and quality

uv sync --all-groups --extra langchain --extra anthropic --extra bench
uv run pytest -q                       # everything offline: unit, property, integration
uv run ruff check . && uv run ruff format --check .
uv run pyright                         # strict, over src, tests and examples
uv run mypy                            # strict, on src/credencestack/core
scripts/stealth_check.sh
examples/end_to_end.sh                 # the whole flow, offline, ending with the sample benchmark
  • tests/unit: one file per module. Hypothesis property tests cover the grader, canonical JSON and statistics. test_builtin_packs.py runs both scripted agents through every built-in scenario and pins which ones each passes.
  • tests/integration: the evidence bundle and report, the stealth check, the end-to-end script.
  • tests/conftest.py builds one naive and one safe bundle per session; tests that change a bundle copy it.

Pre-commit runs ruff, pyright, mypy, gitleaks and the stealth check. If gitleaks fails with an SSL error on macOS, run it with SSL_CERT_FILE=$(.venv/bin/python -c "import certifi;print(certifi.where())").

6. Common maintenance tasks

  • Add a scenario. Copy a scenario in the pack, give it a new id, its pillars and risks, and its expected block. Run credencestack packs validate, then run both scripted agents and update NAIVE_PASSES in tests/unit/test_builtin_packs.py if needed. Then regenerate the pack reference: uv run python scripts/gen_docs_reference.py (a test and the docs workflow fail while it is stale).
  • Add a pack. Create pack.yaml and scenarios/. Add a packs: entry in evidence/mappings/frameworks.yaml if the pack evidences framework items as a whole.
  • Change a limit. Edit the packaged profile and copy it to profiles/ (a test keeps them identical). Scenario descriptions that quote amounts may need updating.
  • Add a finding type. Add it to FindingType and FINDING_PILLARS (core/findings.py), emit it from a scorer, map it in frameworks.yaml, and document it in docs/running.md.
  • Add a runtime source. Implement a RuntimeDecisionSource and register it. Keep its field names in a mapping file and add a fixture under fixtures/external/ marked TODO-verify until it has been checked against the vendor's spec.
  • Change the scenario or profile models. Regenerate the schemas: uv run credencestack packs schema scenario > schemas/scenario.schema.json and uv run credencestack packs schema profile > schemas/profile.schema.json.
  • Change the documentation. Pages are in docs/, the navigation in mkdocs.yml. docs/reference/packs/ and docs/frameworks.md are generated from the packs and frameworks.yaml: edit those, then run scripts/gen_docs_reference.py. Code on the integration pages is included from examples/agents/, which the tests run. Build with uv sync --group docs && uv run mkdocs build --strict; .github/workflows/docs.yml builds every pull request and deploys main to docs.credencestack.ai.
  • Rotate the signing key. Generate a new key and publish the new public key. Old bundles stay verifiable with the old public key, so keep it.

  • Confidential content. Every shipped pack is public. When you change what a bundle shows about confidential scenarios, keep evidence/privacy.py the single place that decides it, and extend tests/integration/test_confidential_bundles.py, which plants marker strings and checks that no shareable file contains them. The fixture pack under tests/fixtures/confidential/ never ships.

  • Run the benchmark. Copy bench/bench.example.yaml to bench/bench.yaml (git-ignored), fill in the models, prices and max_usd, try a scenarios: subset first, then run bench run --confirm-spend and bench run (which writes the report) (details). Never commit prices you have not checked, and never put API keys in the file.

  • Before a release. Run scripts/release_check.sh. It installs the wheel in fresh environments, runs the README quickstart word for word and every connector's offline conformance, builds the docs strictly, and checks versions, that the confidential test fixtures stay out of what ships, and secrets. Rebuild the sample report when the report format changes: uv run python scripts/build_sample_report.py --key <demo key>. The demo private key lives outside the repository; only examples/sample-report/demo-signing.pub is committed.

  • Release. The version lives only in pyproject.toml (credencestack --version reads the installed metadata). Add the release to CHANGELOG.md under ## [X.Y.Z] - date, then check everything agrees: python scripts/release_version.py --tag vX.Y.Z. Pushing the tag runs .github/workflows/release.yml: build, twine check, a smoke test of the wheel, build-provenance attestations, PyPI publishing through trusted publishing (OIDC, no token), and a GitHub release with the CHANGELOG section as notes. A pre-release tag (vX.Y.Z-rcN) needs the version X.Y.ZrcN in pyproject.toml; the workflow refuses a mismatch. One-time setup: on PyPI, add a trusted publisher for this repository with workflow release.yml and environment pypi; on GitHub, create the pypi environment with required reviewers. After a final release, move the floating action tag users pin (for example v1) if you publish one.

7. Things that are deliberately not done yet

See ROADMAP.md: more connectors, the AP2 mandate scenarios (they need a shopping environment), real anchoring and zero-knowledge proofs (interfaces only), and upstream verification of the Atryum export format and parts of the AP2 mapping.

8. Troubleshooting

Symptom Likely cause
test_committed_schema_is_current fails Models changed; regenerate both schemas (section 6)
verify says "file is not listed" Something wrote into the bundle after the manifest (an editor, a stray file)
verify passes but you expected a different signer You did not pass --public-key
keys generate refuses --out is inside a git working tree, or already holds a key (--force); use ~/.credencestack/keys
run says the output directory is not empty Use a new --out; bundles are never written over
A safe-agent scenario fails after a profile edit The scenario's expectations assume the old limits
An unexpected reconciliation coverage gap The runtime record's agent id, tool name, object or amount does not match the call
ProfileError loading a mandate Unknown top-level keys: only the mandate keys, their ap2.mandates.* aliases, constraints and _comment are allowed