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 (source ids / citations), following the same dict shape mixle.substrate.core.SubstrateItem.provenance and mixle.substrate.context.ContextPacket citations already use.

Any of the four may be absent (a thin-shell System answer has no ledger yet); verify_receipt() only checks what is present and marks the rest "absent" – it never invents a pass for a claim the receipt does not make.

class Receipt(answer, produced_by='', ledger=None, trace=None, calibration=None, provenance=<factory>)[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])

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>)[source]

Bases: object

Which of the receipt’s claims hold. passed is True only if every present claim checks out – an absent claim never counts as a pass or a failure, it is just not a claim this receipt makes.

Parameters:

checks (dict[str, str])

property passed: bool

Whether no recorded verification check failed.

summary()[source]

Return a compact comma-separated verification summary.

Return type:

str

verify_receipt(receipt, *, tools=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