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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c5bfc0d43ba5a7a9486145aa66ff6eb45de571fc381fb8cf90aaed6479dcdc5
|
|
| MD5 |
0ba68ac572ee90cb8e7810b9b968a6a7
|
|
| BLAKE2b-256 |
08881a425f17b3cbbb267225e5369925571173b2b7526b5c65632d6a93cd1a8c
|
Provenance
The following attestation bundles were made for receipt_kernel-0.1.0.tar.gz:
Publisher:
publish.yml on unpingable/receipt_kernel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
receipt_kernel-0.1.0.tar.gz -
Subject digest:
1c5bfc0d43ba5a7a9486145aa66ff6eb45de571fc381fb8cf90aaed6479dcdc5 - Sigstore transparency entry: 1107151327
- Sigstore integration time:
-
Permalink:
unpingable/receipt_kernel@0e0a5f5f2728d791ac2951069ef35833f4bd12e9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/unpingable
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0e0a5f5f2728d791ac2951069ef35833f4bd12e9 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3ab9b176dc598ccb08bc4ea015d15eed39475dd147fa485828e453feaa02c09
|
|
| MD5 |
3a29b35fd781783ee28c03728216aec5
|
|
| BLAKE2b-256 |
09a4ddf07a0ac5aa669fe6a269f693473d83d2755ef55b5c3eb48cadf99a16b5
|
Provenance
The following attestation bundles were made for receipt_kernel-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on unpingable/receipt_kernel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
receipt_kernel-0.1.0-py3-none-any.whl -
Subject digest:
e3ab9b176dc598ccb08bc4ea015d15eed39475dd147fa485828e453feaa02c09 - Sigstore transparency entry: 1107151329
- Sigstore integration time:
-
Permalink:
unpingable/receipt_kernel@0e0a5f5f2728d791ac2951069ef35833f4bd12e9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/unpingable
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0e0a5f5f2728d791ac2951069ef35833f4bd12e9 -
Trigger Event:
release
-
Statement type: