credencestack.runner¶
Run scenarios: one episode at a time (run_episode), or whole packs through UK AISI's Inspect, where each pack is an Inspect task, each scenario a sample, and each epoch a repeat.
Responsibilities¶
- Build the environment a scenario describes, with its faults and kill switch installed (
build_environment). - Run one episode through a connector and return everything it produced (
Episode), and turn it into a serialisableEpisodeRecord. - Derive one deterministic seed per scenario and epoch (
derive_seed). - Run packs through Inspect, with the five scorers, and read per-epoch
RunResults back from Inspect's logs (inspect_runner). Outside payments the authority scorer also calls the scenario's domain grader (graders.domain.domain_findings). - Add cross-epoch findings once every epoch is in, such as
rating_inconsistentfor a KYC file rated differently across epochs (run_packs).
Non-goals¶
- Writing evidence.
evidence.pipeline.run_to_bundlecalls the runner and writes the bundle. - Using Inspect's model layer. The agent is driven by its connector, so Inspect runs with its built-in
mockllm/modeland needs no API key.
Public API¶
Signatures and purposes are generated from the code by scripts/gen_dev_reference.py; errors come from each docstring's Raises: section or from api-notes.yaml, which also holds the hand-written effects column.
| Name | Kind | Signature | Purpose | Errors | Effects |
|---|---|---|---|---|---|
Episode |
model | Episode(scenario_id, epoch, seed, env, handle, kill_switch, rate, faults, …) |
Everything one epoch produced. | - | data |
build_environment |
function | build_environment(scenario: Scenario, *, seed: int, profile: AuthorityProfile \| None = None) -> Environment |
Create the environment a scenario describes (env_seed plus its authority binding). |
- | pure (a new in-memory environment) |
record_episode |
function | record_episode(episode: Episode, pack: str \| None = None) -> EpisodeRecord |
A serialisable record of episode for scorers and logs. |
- | pure |
run_episode |
function | run_episode(scenario: Scenario, connector: Connector, *, epoch: int = 0, seed: int = 0, profile: AuthorityProfile \| None = None, max_steps: int = 50) -> Episode |
Run connector against scenario once and return the episode. |
- | runs the agent against an in-memory environment; no files |
Examples¶
The connectors example calls run_episode directly, and the evidence example runs packs through Inspect via run_to_bundle.
Invariants and gotchas¶
- Seeds are
sha256(f"{base_seed}:{scenario_id}:{epoch}"), truncated to 31 bits: stable across processes, platforms and Python versions. - Inspect numbers epochs from 1; CredenceStack numbers them from 0 (
traces/<scenario>/0.jsonl,RunResult.epoch). - Inspect's epoch reduction keeps the score metadata of one epoch only: in a 3-epoch run the reduced
authorityscore carries one epoch's findings, while each of the three samples carries its own. Read per-epoch findings fromlog.samples, asrun_packsdoes, never fromlog.reductions. - The solver stores the whole
EpisodeRecordin the sample's store, so any episode can be re-scored from the Inspect log alone.
Where the tests are¶
Test files that import this package's modules (from the file index):
tests/integration/test_adk_connector.pytests/integration/test_assess_frameworks.pytests/integration/test_claude_agent_sdk_connector.pytests/integration/test_crewai_connector.pytests/integration/test_domain_packs.pytests/integration/test_example_agents.pytests/integration/test_mcp_connector.pytests/integration/test_msaf_connector.pytests/integration/test_openai_agents_connector.pytests/integration/test_strands_connector.pytests/live/test_live_connectors.pytests/unit/test_assess_core.pytests/unit/test_bench.pytests/unit/test_builtin_packs.pytests/unit/test_cli_authority.pytests/unit/test_connectors.pytests/unit/test_control.pytests/unit/test_faults.pytests/unit/test_inspect_runner.pytests/unit/test_integrations.pytests/unit/test_otel.pytests/unit/test_otel_workflows.py