Extending CredenceStack¶
Six common extensions, each with the files to touch and a checklist. The tests named in the
checklists fail if a step is missed, so run uv run pytest -q -m "not guides" before you
open a pull request.
A scenario¶
A scenario is one YAML file: the task, the simulated environment (env_seed), the
authority binding, optional injections, faults and control events, and the expected
outcomes. The format is documented in Writing your own scenarios and
validated by schemas/scenario.schema.json.
- Start from
credencestack packs init <dir>(a pack with one example scenario and a copy of the demo profile), or copy a built-in scenario from the pack reference. - Set
id,title,user_task,inputs,pillars,risks(finding types the scenario is about),severityandauthority_profile(relative to the file, orbuiltin:<file>). - Seed only what the task needs in
env_seed, and addfaults:,injections:orcontrol_events:for the behaviour under test. - Write
expected:so a correct agent passes and the failure you care about fails:decision_in,must_call,must_not_call,ledger,max_payments,max_tool_calls,halt. - Run it against both scripted agents and read the findings:
credencestack run -p <dir> -s <ID> --agent credencestack.agents:scripted_naive.
Checklist:
-
credencestack packs validate <dir>passes (schema, environment, references, profiles and graders). -
scripted_safepasses andscripted_naivefails it, for the reason in the description (or the scenario is documented as testing something they both handle). - The id is unique across the shipped packs and continues its pack's sequence (the next free number in that pack).
A pack¶
A pack is a directory with a pack.yaml (name, version, visibility, description)
and a scenarios/ folder. Use one from anywhere with --pack-path <parent dir> or
CREDENCESTACK_PACKS_PATH.
Checklist for a new built-in (public) pack under src/credencestack/packs/builtin/:
- Every scenario passes
credencestack packs validate, and every id is unique across all packs (load_packsrejects duplicates). -
tests/unit/test_builtin_packs.pypasses: it checks the planned scenario counts, and that for every built-in scenarioscripted_safemeets the expectations andscripted_naiveis caught. Update the planned counts. - Add the pack's framework references under
packs:insrc/credencestack/evidence/mappings/frameworks.yaml(every one indicative). - Add it to
PACK_ORDERinscripts/gen_docs_reference.py, run the script, and add the newdocs/reference/packs/<pack>.mdto thenavinmkdocs.yml. The script refuses to document a pack that is not public.
A fault type¶
Faults are frozen dataclasses in src/credencestack/env/faults.py.
- Add the kind to
FaultKindinsrc/credencestack/core/scenario.py. - Subclass
Fault: its parameters are dataclass fields, and its wrapper calls the handler it wraps, counts calls, and records afaultevent when it fires. - Register it in
FAULT_TYPES. - Teach
ResilienceScorer(src/credencestack/graders/scoring.py) what a wrong reaction looks like, using an existing finding type or a new one (next section). - Regenerate the scenario schema:
uv run credencestack packs schema scenario > schemas/scenario.schema.json.
Checklist:
-
tests/unit/test_faults.pypasses; it assertsFAULT_TYPESandFaultKindmatch. -
tests/unit/test_schema.pypasses (the committed schema is current). - A test in
tests/unit/test_faults.pyfor the new wrapper: when it fires, what the agent sees, the ledger, and thefaultevent'smeta. - A scenario that uses it, and its row in Writing your own scenarios.
A grader or a finding type¶
A finding type is a value of FindingType in src/credencestack/core/findings.py.
- Add the type to
FindingType, and its pillars toFINDING_PILLARS. If it should not fail an epoch, add it toPASSING_FINDINGStoo. - Emit it from a scorer in
src/credencestack/graders/scoring.py(or a new scorer class added toall_findingsand to the Inspect task inrunner/inspect_runner.py). Give every finding astep_ref,rule_idswhere an grader rule or check is behind it, and a message a reviewer can act on. - Map it under
findings:insrc/credencestack/evidence/mappings/frameworks.yaml.
Checklist:
-
tests/unit/test_core.pypasses; it assertsFindingTypeandFINDING_PILLARSlist the same types. - Unit tests for the scorer on a trace that should and one that should not produce it.
-
uv run python scripts/gen_docs_reference.pyregenerates the framework-mapping page, anddocs/running.md#findingsdescribes the new type.
A framework mapping¶
All mappings live in src/credencestack/evidence/mappings/frameworks.yaml: the primary
grouping by the six pillars, then frameworks (title, version, url), references (an id
per item, with its framework and theme), and which references each finding type and pack
bears on.
- Add the framework under
frameworks:withstatus: indicative, and its items underreferences:. Mark anything not confirmed against a primary sourcetodo_verify: trueand list it in the TODO-verify register. - Point finding types and packs at the new reference ids.
Checklist:
-
load_framework_map()loads it:evidence/frameworks.pyrejects reference ids that are not defined and references to unknown frameworks. - Every new entry says
indicative; nothing is worded as a compliance claim. -
uv run python scripts/gen_docs_reference.pyregenerates Framework mappings, and a sample run'smappings.jsonand report show it.
A connector¶
Follow Write and check a connector: the
Connector contract, the patterns the built-in connectors use (tools through
env.call, model_call events, approvals, suspension, a scripted offline model), the
ConnectorSpec in src/credencestack/connectors/registry.py, and the conformance kit.
Checklist:
- An optional extra in
pyproject.toml; the framework is imported only inside the connector module (the core install must not need it). -
credencestack connectors check --connector <name> --model credencestack:scriptedis conformant, and its report is committed undersrc/credencestack/connectors/conformance/reports/. - Connector tests in
tests/integration/test_<name>_connector.py, skipped when the extra is missing. - A connector note in
docs/dev/connectors/, an integration page indocs/integrate/, and a framework guide indocs/guides/with tutorial code inexamples/guides/<name>/. - A row in the CI connector matrix (
.github/workflows/ci.yml) and aGuideinscripts/gen_doc_examples.py; run it for the new group. -
uv run python scripts/gen_docs_reference.pyregenerates the connector table and conformance summaries.
A new domain¶
A domain is a scenario family judged by its own grader (see decision 0002). Checklist:
- Add the name to
DomainandDOMAINSincore/scenario.py. - A policy model in
domains/<domain>/policy.py(subclassPolicyBase, narrowdomainto a literal, add aview()forlookup_policy), registered indomains/policy.py(_models,POLICY_DOMAINS); regenerate each schema withuv run credencestack packs schema policy-<domain> > schemas/<domain>_policy.schema.json. - Seed models under
env/<domain>/(strict pydantic), added toEnvSeed. - Tool specs in
env/families.py(unique names;consequential,kind,action), a family name inToolFamily, the domain's default families inDEFAULT_FAMILIES, and outage services inSERVICE_FAMILY_TOOLS. - A world (
handlers(),snapshot()) registered inenv/environment.py(WORLD_OF_FAMILY,WORLDS). - An grader with
expectedandjudgeindomains/<domain>/grader.py, registered indomains/__init__.py(GRADERS). Put the decision in a pure function the safe reference agent can share. - Finding types in
core/findings.pywith pillars (FINDING_PILLARS) and fixed severities (FINDING_SEVERITY), mapped inevidence/mappings/frameworks.yaml(indicative), documented indocs/running.md#findings. - Naive and safe reference agents in
agents/, registered inagents/scripted.py(DOMAIN_AGENTS). - A synthetic pack under
packs/builtin/<pack>/withsynthetic: trueand a README, the name inDOMAIN_PACKS, a pack page indocs/packs/, andMIN_NAIVE_FAILURESintests/integration/test_domain_packs.py. - Unit tests for the grader and the world;
scripts/check_synthetic.pypasses.
A domain policy¶
Policies are data: a user writes their own and runs with --policy. To change what a
policy can say:
- Add the field to the domain's policy model with a default that keeps existing
policies valid, a
description, and validation (ranges, cross-field checks). - Use it in the grader and, if the agent should see it, it appears in
view(). - Update the shipped example (
packs/builtin/policies/<domain>_policy.yaml), keepsynthetic_examples: true, and mark any regulatory value indicative (and indocs/dev/todo-verify.mdif it is unverified). - Regenerate the policy schemas and the docs (
scripts/gen_docs_reference.py). - Test the new behaviour with
parse_policyandcredencestack profiles explain.