mixle.inference.receipt module

Receipt – bind an answer’s ledger, trace, calibration state, and provenance into one artifact that a third party can re-verify offline, without re-running the teacher or touching the substrate.

A receipt makes four claims, each independently checkable from data the receipt itself carries:

  • ledger – an Explanation; is_exact() re-checks the additive identity (sum(parts) + correction == total) that is the evidence, not a summary of it.

  • trace – an ExecutionTrace; replaying it against the same tool registry must reproduce every step bit-for-bit (mixle.task.replay.is_bit_identical_replay()).

  • calibration – the alpha/qhat (or density-gate) state the answer was served under; a receipt with unknown calibration is flagged, never assumed calibrated.

  • provenance – where the evidence came from: {"sources": [{"id": ..., "digest": ..., "content": ...}, ...]}, each source’s digest the canonical_digest() of its content (content may be omitted and supplied to verify_receipt() as evidence={id: content}). A source without content to check against is "unobserved".

A receipt that carries a trace must also carry executables: {tool name: :func:`~mixle.inference.integrity.implementation_digest`(tool)} for every tool the trace calls, so a verifier can tell the registry it replays against is the one the answer was produced with.

Any of the four may be absent (a thin-shell System answer has no ledger yet); verify_receipt() marks missing claims "absent" but does not promote an evidence-free receipt. A declared trace without its exact executable registry, a calibration claim without observations, or a provenance source without matching content is "unobserved" and cannot pass.

class Receipt(answer, produced_by='', ledger=None, trace=None, calibration=None, provenance=<factory>, policy=<factory>, executables=<factory>, bindings=<factory>, receipt_digest='', schema_version='mixle-answer-receipt-v1')[source]

Bases: object

The bound artifact: an answer plus everything needed to re-verify it offline.

Parameters:
  • answer (Any)

  • produced_by (str)

  • ledger (Explanation | None)

  • trace (ExecutionTrace | None)

  • calibration (dict[str, Any] | None)

  • provenance (dict[str, Any])

  • policy (dict[str, Any])

  • executables (dict[str, str])

  • bindings (dict[str, str])

  • receipt_digest (str)

  • schema_version (str)

to_json()[source]

Return the answer receipt as JSON-compatible data.

Return type:

dict[str, Any]

to_knowledge_dict(*, id, project_id, task)[source]

A plain dict shaped like mixle_knowledge.contracts.AnswerReceipt (id/project_id/task/ produced_by/answer/ledger/trace/calibration/provenance), aligned with the mixle-knowledge receipt contracts. Distinct from mixle_knowledge.contracts.ArtifactReceipt, which certifies a trained model/artifact, not one served answer – this is the per-answer evidence trail an offline consumer re-verifies (recompute the ledger, replay the trace, resolve the citations).

Stays a plain dict on purpose: mixle core carries no dependency on mixle-knowledge (platform contract packages depend on core, never the other way); constructing the validated pydantic object (AnswerReceipt(**receipt.to_knowledge_dict(...))) is the receiving side’s job.

Parameters:
Return type:

dict[str, Any]

class VerificationReport(checks=<factory>, required=())[source]

Bases: object

Which claims were observed and which required observations determine the verdict.

Parameters:
property passed: bool

Whether at least one evidence claim was observed and every required check passed.

summary()[source]

Return a compact comma-separated verification summary.

Return type:

str

verify_receipt(receipt, *, tools=None, evidence=None, tol=1e-9)[source]

Re-check every claim the receipt actually makes, using only the receipt’s own bound data (plus the tools registry needed to re-execute a trace – the one piece that cannot be inlined into the receipt itself, since a tool is a function, not data).

Parameters:
Return type:

VerificationReport