Skip to content

steward

The independent checker: fixed policies, then a model audit.

coalitionkit_steward

The Steward: policies, model audit and signed verdicts.

StewardContext dataclass

Facts the host knows and the message does not carry.

Subject dataclass

What the Steward looks at: an envelope, or an artifact minted from events.

Artifact

Bases: BaseModel

Something minted from events that the Steward must audit before it is shown.

ModelVerdict

Bases: BaseModel

The strict schema of the model's answer.

Steward

audit_reason
audit_reason(
    coalition_id: str, event_id: str, revision: int = 1
) -> str | None

Host-only review detail; never include this value in a delivery or error.

review async
review(
    envelope: Envelope,
    *,
    context: StewardContext | None = None,
    flagged: bool = False,
    revision: int = 1,
) -> SignedVerdict

Judge one message. The verdict binds the envelope's event_id and revision.

review_artifact async
review_artifact(
    artifact: Artifact,
    *,
    context: StewardContext | None = None,
) -> SignedVerdict

Judge a minted artifact. Always audited by the model.

PolicyError

Bases: ValueError

A policy file is invalid. The message says which rule it broke.

PolicySet

Bases: tuple[Policy, ...]

Policies with unique ids, in a stable order.

SelfTestError

Bases: RuntimeError

A core policy gave the wrong answer on a known example.

VerdictError

Bases: Exception

The verdict does not verify, or is about a different subject or revision.

parse_model_verdict

parse_model_verdict(text: str) -> ModelVerdict | None

The verdict, or None when the answer is not strict JSON in the schema.

core_policies

core_policies() -> PolicySet

The core policies bundled with this package.

parse_policy

parse_policy(
    text: str, *, source: Literal["core", "pack"]
) -> Policy

Validate one policy document. source="pack" forbids quarantine.

run_selftest

run_selftest(
    policies: PolicySet,
    examples: tuple[Example, ...] = EXAMPLES,
) -> None

Raise SelfTestError unless every example gets its expected action and policy.

verify_verdict

verify_verdict(
    signed: SignedVerdict,
    public_key: Ed25519PublicKey,
    *,
    event_id: str,
    revision: int,
    expected_kid: str | None = None,
) -> VerdictBody

Check the signature and that it covers this event and revision. Raises VerdictError.