Skip to main content

Append-only, hash-chained run ledger with invariant evaluation

Project description

receipt-kernel

Append-only, hash-chained run ledger with invariant evaluation.

Zero dependencies. Stdlib only. Python 3.10+.

What it does

  • Run ledger: append-only, hash-chained event store (SQLite, WAL mode)
  • Stage machine: explicit stage graph with hard-fail on illegal transitions
  • Evidence store: content-addressed blobs with pre-write redaction and retention policies
  • Invariant evaluation: PASS / WARN / FAIL / UNKNOWN — no silent downgrade

What it doesn't do

No daemons, schedulers, reconciliation loops, plugins, auth, tenancy, or LLM abstractions. It records what happened, proves the chain is intact, and evaluates invariants. That's it.

Install

pip install receipt-kernel

Quick start

from receipt_kernel import Verdict
from receipt_kernel.store_sqlite import SqliteReceiptStore
from receipt_kernel.envelope import make_envelope

# Create a store
store = SqliteReceiptStore(":memory:")
store.initialize_schema()

# Start a run
run_id = "run-001"
store.ensure_run(run_id, policy_id="default", policy_version="1.0", stage_graph_id="default")

# Append an event (store fills run_id, seq, prev_hash, event_hash)
env = make_envelope(
    event_type="RUN_START",
    stage="START",
    actor_kind="system",
    actor_id="test",
    policy_id="default",
    policy_version="1.0",
    stage_graph_id="default",
    payload={"task": "example"},
)
store.append_event(run_id, env)

events = store.get_events(run_id)
print(f"Events: {len(events)}, chain intact: {events[0]['event_hash'] is not None}")

Invariants

Six constitutional invariants ship with the kernel:

Invariant What it checks
ledger_chain_valid Hash chain integrity (seq contiguity, prev_hash, event_hash)
receipt_completeness Required evidence keys present, blobs retrievable
evaluation_completeness Attested evaluation, no silent downgrade
finalization_completeness Clean endings, decision ref, last event
run_shape.single_finalize Exactly one RUN_FINALIZE per run
run_shape.stage_required_path Required stages appear in order

All invariants return InvariantResult with a Verdict. Any UNKNOWN or FAIL in required invariants poisons overall success.

Verdicts

from receipt_kernel import Verdict

Verdict.PASS     # verified and satisfied
Verdict.WARN     # verified but degraded
Verdict.FAIL     # verified and violated
Verdict.UNKNOWN  # cannot verify (missing evidence, read failure)

UNKNOWN is a failure, not a shrug.

Evidence

Evidence is stored as content-addressed blobs (blob://sha256:<hex>).

Two evidence classes:

  • public: retained longer, safe for logging
  • sealed: aggressively expired, encrypted-at-rest when applicable

An optional redaction hook runs before persistence (13 built-in secret patterns).

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

receipt_kernel-0.1.0.tar.gz (43.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

receipt_kernel-0.1.0-py3-none-any.whl (41.8 kB view details)

Uploaded Python 3

File details

Details for the file receipt_kernel-0.1.0.tar.gz.

File metadata

  • Download URL: receipt_kernel-0.1.0.tar.gz
  • Upload date:
  • Size: 43.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for receipt_kernel-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1c5bfc0d43ba5a7a9486145aa66ff6eb45de571fc381fb8cf90aaed6479dcdc5
MD5 0ba68ac572ee90cb8e7810b9b968a6a7
BLAKE2b-256 08881a425f17b3cbbb267225e5369925571173b2b7526b5c65632d6a93cd1a8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for receipt_kernel-0.1.0.tar.gz:

Publisher: publish.yml on unpingable/receipt_kernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file receipt_kernel-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: receipt_kernel-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 41.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for receipt_kernel-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e3ab9b176dc598ccb08bc4ea015d15eed39475dd147fa485828e453feaa02c09
MD5 3a29b35fd781783ee28c03728216aec5
BLAKE2b-256 09a4ddf07a0ac5aa669fe6a269f693473d83d2755ef55b5c3eb48cadf99a16b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for receipt_kernel-0.1.0-py3-none-any.whl:

Publisher: publish.yml on unpingable/receipt_kernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page