Skip to content

Design principles

The binding design of CredenceStack 1.0. Every command, file, report, span and Python name follows it; a change to it is a change to this page first. Each decision lists the alternatives that were considered. The checks that enforce a rule are named with it.

P2-1. Vocabulary

One term per concept. The glossary defines each; scripts/docs_audit.py enforces them in the docs, CLI help, report templates and error messages, and fails on the banned synonyms and old names listed in scripts/docs_audit.py (BANNED_TERMS).

Concept Term Banned or old
a task, its world and its expected outcome scenario case, test case
a directory of scenarios with pack.yaml pack suite
the delegated-authority YAML profile (authority profile in prose when needed) mandate (except the environment tool lookup_mandate), authority config
a domain's rules YAML (fincrime, docintegrity, kyc) domain policy policy file
the deterministic rules that decide what should happen and classify what did grader oracle
Inspect's scoring hooks scorer (Inspect's own word, internal only)
a graded failure with a severity finding violation, issue
one invocation of run run
one repeat of a scenario epoch; one scenario × epoch is an episode sample (except when quoting Inspect), trial
the signed output directory evidence bundle bundle alone is acceptable after first use
a rendered result page report
the code that drives a framework's agent connector adapter (except third-party adapters, e.g. the Gymnasium adapter)
a scenario Forge starts from seed scenario base scenario, template (except a scenario template file)
a scenario transformation mutator perturbation, variant generator
the 1–5 dial difficulty level (as a noun alone), hardness
Forge output generated scenario synthetic scenario, variant
the simulated back office as an API environment world (internal only), sandbox
one environment run episode rollout (except when describing RL use)
the environment's score reward
a comparison of agents benchmark; one fresh-seed publication is a benchmark round leaderboard, held-back set
content visibility public (everything CredenceStack ships) and confidential (content a user loads) held-back, heldout, premium, private (for content)

Alternatives: keep "oracle" (the term of art in testing) — rejected, because risk reviewers read "grader" without explanation and two words for one engine confused the docs; keep "adapter" — rejected, "connector" was already the docs' word in 426 places and avoids the clash with third-party adapters.

"grader" already named the graders/ package of Inspect scorers. Resolution: the rule engines become credencestack.graders (authority and domain graders); Inspect's hooks are "scorers" in credencestack._internal.scoring, never shown to users.

P2-2. Command grammar

credencestack <command> [subcommand] [flags]. Help groups and the full tree:

Group Commands
Test test, run, demo, generate, bench run, bench brittleness
Evidence report, evidence verify, evidence export, evidence inspect, evidence keygen
Build agents and worlds packs list, packs show, packs validate, packs init, packs schema, profiles init, profiles validate, profiles explain, profiles import, mutators list, mutators show, connectors list, connectors check, env episode, env export, env serve
Operate otel check, otel print, config show, config init, doctor, version

Removed with no alias: gate (→ run --fail-on, evidence inspect --fail-on), validate (→ packs validate), init (→ packs init), schema and policy schema (→ packs schema), authority * and policy * (→ profiles *), adapters * (→ connectors *), evidence sign (→ --sign), keys generate (→ evidence keygen), mcp serve (→ env serve), bench report (→ bench run writes its report; report <dir> regenerates), judge calibrate (→ scripts/calibrate_judge.py, a maintainer tool that calls a model).

Alternatives: a flat list of verbs at the top level — rejected, nouns group 25 commands into four readable groups; keeping evidence sign — rejected, signing at creation means an unsigned bundle is never the default path when a key is set.

Enforced by tests/unit/test_cli_grammar.py.

P2-3. Shared flags

Defined once in credencestack/cli/options.py and reused; same name, type, default and help text everywhere they apply.

Flag Type, default Meaning
--profile path or builtin:<file> profile used for every scenario
--pack/-p repeatable pack name, path or all
--pack-path repeatable dir extra directories of packs
--mutator-path repeatable dir extra directories of mutators
--seed int or fresh, 0 master seed; fresh draws one and records it
--epochs int ≥ 1, 1 repeats per scenario
--difficulty N or N-M in 1–5, 1-5 Forge difficulty
--n int ≥ 1 how many to generate or export
--out dir, ./credencestack-out parent of <kind>-<id>/
--format per command file format of generated content
--json flag stdout carries one JSON document
--fail-on severity or none, high exit 1 if any finding is at or above it
--sign flag sign the output with the configured key
--redact flag replace confidential content with generic descriptions
--otel/--no-otel flag, settings emit OpenTelemetry
--otel-content flag include content (public scenarios only, redacted)
--otel-granularity scenario, run trace granularity
--otel-metrics flag emit metrics
--max-usd float spending cap for real models
--confirm-spend flag required for real models
--quiet, --verbose, --no-color global flags console behaviour

Other OTel exporter details (endpoint, protocol, headers, service name) are settings, not flags ([otel] in credencestack.toml, or the standard OTEL_* variables). --otel-headers is gone: secrets never travel as flags.

P2-4. Configuration

Precedence: flag > environment variable CREDENCESTACK_<SECTION>_<KEY> > project file credencestack.toml (found by walking up from the working directory) > defaults. One typed object, credencestack.settings.Settings, loads all of it. Nothing else reads environment variables except the OTel SDK's own OTEL_* variables (read only in credencestack.otel) and NO_COLOR. Enforced by tests/unit/test_settings.py (test_no_environ_reads_outside_settings).

Sections: [output] (dir), [packs] (path), [mutators] (path), [run] (epochs, seed, fail_on, max_samples), [evidence] (signing_key, sign), [otel] (enabled, content, granularity, metrics, exporter, endpoint, protocol, service_name, trace_url_template, agent_spans, sample_rate), [bench] (max_usd), [connectors] (http_token, secret).

Alternatives: YAML project file — rejected, TOML is Python's standard (tomllib) and reads unambiguously; pydantic-settings — rejected, one more dependency for 60 lines of code.

P2-5. Output layout and manifest

Every command that writes results writes <out>/<kind>-<id>/ (default ./credencestack-out/) and updates <out>/latest-<kind> (a symlink, or a LATEST-<kind> text file where symlinks fail). Kinds: run, generate, bench, brittleness, env-export, export.

manifest.json has one schema, schemas/manifest.schema.json (credencestack.manifest/v1): schema, kind, id, created_at (UTC ISO 8601), credencestack_version, settings (resolved, secrets removed), inputs (packs, profile hash, seed, seed_drawn for fresh), outputs (relative path → SHA-256 and size), otel (trace id and otel/ids.json, when on), visibility (confidential if any content inside is), plus one kind-specific section (run, generation, bench, …).

The evidence format is credencestack.evidence/v1: the manifest plus signature.json (an Ed25519 DSSE-style envelope over the canonical manifest, which lists every output's hash; trace files keep their hash chains). One structure serves every kind.

Alternatives: one directory per command with its own manifest (today's state) — rejected; a database — rejected, evidence must be plain files a reviewer can read.

P2-6. Identifiers

<kind>-<YYYYMMDD>-<6 base32> (lowercase RFC 4648 alphabet, from secrets) for runs, benches, brittleness, generation batches, env exports and exports. Scenario ids stay PAY-001 style. Generated ids are G-<PACK>-<seed>-<index> (G-PAYMENTS-42-0007). Confidential mutator ids appear as confidential:<first 8 hex of SHA-256> in every shared output; confidential scenario ids do in telemetry and in generated scenarios. In an evidence bundle and its redacted export, a confidential scenario keeps its id and pack, with a generic description and no content (evidence/privacy.py): the export carries the run's own signature, so its files are the run's files. (Revised in phase 16; hashing scenario ids inside bundles is deferred, see the coherence audit.)

P2-7. Exit codes

Code Meaning
0 success
1 the agent failed the gate (a finding at or above --fail-on)
2 usage or configuration error
3 environment or dependency problem (missing extra, unreachable collector with --otel-required)
4 verification failure
5 internal error

P2-8. Console output

One module, credencestack/cli/console.py, used by every command:

  • header CredenceStack <version> · <command> · <id>;
  • one progress style (a single updating line on a TTY, nothing otherwise);
  • result tables with columns in this order: ID, title, result, finding, rate;
  • colour meaning: pass green, finding amber, error red, muted grey; always with a word or symbol (✓ pass, ! finding, ✗ error); off with --no-color, NO_COLOR or a non-TTY;
  • numbers: rates 83.3%, intervals [71.2–91.0], money 12,000.00 USD, durations 1.2s;
  • closing block: the files written and the next useful command.

With --json, stdout carries one JSON document shaped like the manifest and nothing else; progress goes to stderr.

P2-9. Errors

error: <what went wrong>, then hint: <what to do>, then docs: <url> when a page exists. No traceback unless --verbose. CredenceStackError with subclasses UsageError (2), ConfigError (2), DependencyError (3), VerificationError (4), GateFailed (1); anything else is an internal error (5).

P2-10. Reports

One engine (credencestack.reports) and one template set for every kind: evidence (with its six-pillar section), redacted export, bench, brittleness, and the generated-scenario section. Page structure: title block (kind, id, date, version, signature status), summary metric tiles, sections, methods, limitations, disclaimer. Shared components: metric tiles, finding chips, pillar rows, interval notation, charts. HTML and Markdown render from one data model. HTML is self-contained: no scripts and no external requests; the font stacks name the website's fonts (Space Grotesk, Inter, JetBrains Mono) first and fall back to system fonts, so nothing is downloaded or embedded.

Charts: series 1 #1E4FD8 solid with circles, series 2 #B5651D dashed with squares, then #1F6B45 dash-dot with triangles, #6B4FBB dotted with diamonds; every series has a distinct line style and marker, and every bar series its own hatch. Design tokens live in src/credencestack/reports/tokens.json (inside the package, because reports need them at run time): the one source shared with the docs theme and the website, which are generated from it.

P2-11. Python API

Public, with __all__, type hints and docstrings: credencestack (run, load packs, profiles, graders, findings, evidence verify), credencestack.connectors, credencestack.forge, credencestack.env, credencestack.otel. Every other subpackage is internal: its modules carry no __all__ promise, docs mark it internal, and shared utilities live in credencestack._internal (hashing and canonical JSON, statistics, seeding, IO, paths, ids, logging). The reference API docs are generated from the public packages only.

Alternative: move every internal module under _internal — rejected for the runner, packs and evidence packages, whose module paths appear in tracebacks and contributor docs; they are documented as internal instead.

P2-12. Package layout and extras

credencestack/
  __init__.py  settings.py  errors.py
  core/        scenario, finding, pillar, result and trace models; visibility
  packs/       loader, models, schema, builtin/ (packs, profiles, domain policies)
  profiles/    profile model, schema, steps
  graders/     authority grader, domain graders, outcome checks, oversight metrics, judge
  env/         the environment (worlds, tools, faults, kill switch), CredenceEnv, gym adapter
  forge/       generator, difficulty.yaml, mutators/
  connectors/  one module per framework, conformance kit
  agents/      scripted and reference agents
  runner/      episode runner, Inspect integration
  evidence/    bundle, manifest, signing, chains, export, verification
  reports/     engine, templates, charts
  bench/       benchmark and brittleness
  integrations/ runtime decision logs (AP2, Atryum, Tenuo)
  otel/        telemetry
  cli/         commands, options, console
  _internal/   shared utilities

Extras are named after what they enable: one per connector framework (langchain, openai-agents, msaf, strands, adk, claude-agent-sdk, crewai, mcp), plus otel, bench, env (Gymnasium), judge, tenuo; all installs every extra that can share one environment.