Skip to content

credencestack.core

The shared models every other package uses: scenarios and packs, domains and tool families, trace events, findings, per-epoch results, pillars and visibility. It has no behaviour of its own. Apart from core itself it imports only the authority models (AuthorityProfile, Outcome, PriorAction), so it sits just above authority.profile and authority.grader at the bottom of the import graph.

Responsibilities

  • Define Scenario, Pack, FaultSpec, ControlEvent and AgentActor (the scenario file format, validated by pydantic), including the domain fields domain, domain_policy and tools.
  • Define the domains (Domain, DOMAINS: payments, fincrime, docintegrity, kyc) and tool families (ToolFamily), and the pack manifest's synthetic flag.
  • Define TraceEvent and its kinds: the one record every episode is made of.
  • Define Finding, the finding types, and which pillars each type counts against (FINDING_PILLARS).
  • Define RunResult, the outcome of one epoch of one scenario.
  • Define the visibility levels and the scenario-id convention for each (id_problem).

Non-goals

  • Loading files (that is packs), running anything (runner) or scoring (graders).

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
FINDING_PILLARS constant FINDING_PILLARS: dict of 44 Finding type -> the pillars it counts against. - -
PASSING_FINDINGS constant PASSING_FINDINGS: frozenset of 2 Finding types that do not fail an epoch. - -
VISIBILITIES constant VISIBILITIES: tuple of 2 Every scenario visibility level. - -
AgentActor model AgentActor(id, role, connector, target, agent_id, under_test) One agent taking part in a multi-agent scenario (interface only). - data
AuthorityProfile model AuthorityProfile(id, version, description, currency, agents, controls) A versioned delegated-authority profile. - data
ControlEvent model ControlEvent(kind, at_step, during_tool, reason) A control signal sent to the agent (e.g. the kill switch). - data
FaultSpec model FaultSpec(kind, tool, service, params) A fault applied to a tool (or a whole service) while the scenario runs. - data
Finding model Finding(scenario_id, epoch, type, step_ref, rule_ids, pillars, message, severity, …) One conclusion about one step (or the whole run) of a scenario epoch. - data
FindingType type FindingType = Literal["compliant", "overreach", "over_cautious", "missed_escalation", "duplicate_execution", "fail_open", "ignored_suspension", "slow_halt", …] Every finding type a scorer can emit. - -
Pack model Pack(name, version, description, visibility, root, digest, scenarios) A loaded, validated pack. - data
PackManifest model PackManifest(name, version, description, visibility, synthetic) Contents of an optional pack.yaml at the root of a pack directory. - data
Pillar enum Pillar: PURPOSE, RISK, CONTROL, OVERSIGHT, RESILIENCE, ASSURANCE A pillar of the supervisory framework, used to group scenarios and findings. - data
RunResult model RunResult(scenario_id, pack, visibility, epoch, seed, passed, findings, unmet_expectations, …) The outcome of one epoch of one scenario. - data
Scenario model Scenario(id, pack, visibility, generic_description, actors, title, description, pillars, …) One test: a task, its simulated environment and the expected outcome. - data
Severity type Severity = Literal["low", "medium", "high", "critical"] Scenario and finding severity. - -
TraceEvent model TraceEvent(seq, ts, kind, tool, args, result, meta) One event in an epoch, timestamped by the simulated clock. - data
TraceEventKind type TraceEventKind = Literal["model_call", "tool_call", "tool_result", "approval_request", "approval_decision", "control_signal", "fault", "handoff", …] Every kind of trace event. - -
Visibility type Visibility = Literal["public", "confidential"] Whether a scenario's content may appear in shared outputs: public or confidential. - -
confidential_ref function confidential_ref(identifier: str) -> str How a confidential id appears in shared outputs: confidential:<8 hex>. - pure
default_pillars function default_pillars(finding_type: str, extra: tuple[Pillar, ...] = ()) -> tuple[Pillar, ...] Pillars for finding_type plus extra, without duplicates, in a stable order. - pure
is_confidential function is_confidential(visibility: str) -> bool True for confidential. - pure
shown_id function shown_id(identifier: str, visibility: str) -> str identifier itself when public, its confidential_ref when confidential. - pure

Examples

core has no runnable example of its own; every example on the other module pages prints these models. The graders example shows Findings, and the faults example shows TraceEvents.

Invariants and gotchas

  • mypy --strict runs on this package ([tool.mypy] files in pyproject.toml). Keep it free of Any leaks.
  • Trace timestamps come from the simulated clock, never the wall clock, so the same seed gives the same events.
  • A scenario loaded on its own has visibility: null; it takes its pack's visibility when the pack loads it. Read Scenario.effective_visibility, not visibility.
  • A scenario outside payments must name a domain_policy; a payments scenario that declares no tools gets the original eleven tools, so earlier bundles still reproduce.
  • PASSING_FINDINGS (compliant, runtime_stricter) are recorded but do not fail an epoch. Every other finding type does.
  • Confidential ids appear in shared outputs only as confidential:<8 hex of SHA-256> (shown_id).

Where the tests are

Test files that import this package's modules (from the file index):

  • tests/integration/test_domain_packs.py
  • tests/integration/test_example_agents.py
  • tests/unit/test_assess_core.py
  • tests/unit/test_builtin_packs.py
  • tests/unit/test_connectors.py
  • tests/unit/test_control.py
  • tests/unit/test_core.py
  • tests/unit/test_env_rl.py
  • tests/unit/test_env_v1.py
  • tests/unit/test_faults.py
  • tests/unit/test_forge_mutators.py
  • tests/unit/test_inspect_runner.py
  • tests/unit/test_kyc_grader.py
  • tests/unit/test_otel.py
  • tests/unit/test_otel_workflows.py
  • tests/unit/test_visibility.py