Trunkit — low-cost proof-carrying code middleware on PostgreSQL
Project description
Trunkit
The smallest elephant in the room that's not too Coq-y and doesn't Lean too heavily on your system.
Proof-carrying code middleware on PostgreSQL. Trunkit is a self-contained schema stack that attaches verifiable claims to mathematical objects, chains proofs compositionally, and lets consumers re-verify results without trusting the producer — all inside a database you already operate, with no specialist toolchain required.
No 3 GB compiler. No gigabytes of cached proof objects. No new runtime to learn. Just PostgreSQL, Python, and ~1 MB of schemas that describe, attest, and verify themselves.
Schemas
┌──────────────────────────────────────────────────────────┐
│ cert — proof-carrying attestation │
│ witness · derivation · verify() · export_bundle() │
├──────────────┬───────────────────────────────────────────┤
│ kan │ curry │
│ category │ versioned provenance │
│ theory │ + immutable constants │
├──────────────┴───────────────────────────────────────────┤
│ calx — integer arithmetic bedrock │
│ primes · factorizations · dynamics · CRT · OEIS │
└──────────────────────────────────────────────────────────┘
PostgreSQL 16 · Python 3.11+
| Schema | Role |
|---|---|
| calx | Dense prime factorisation of ℤ[1..N]; aliquot/derivative dynamics; CRT; OEIS sequence matching |
| curry | Immutable versioned constants and functions; append-only computational provenance |
| kan | Category-theory meta-layer: base categories → monoidal → NTs → Kan extensions → enrichment → profunctors → adjunctions; reflexively describes itself |
| cert | Proof-carrying attestation: five method tiers, structured witness storage, proof composition DAG, portable bundle export, side-effect-free consumer re-verification |
Quick start
# 1. Start PostgreSQL
docker compose up -d db
# 2. Apply schemas (idempotent — safe to re-run)
make apply
# 3. Populate integers and compute reflexive closure
trunkit generate --limit 10000
trunkit close --write
# 4. Check all claims
trunkit standing
# Install
pip install trunkit
pip install -e ".[dev]" # local development
Environment variable: CALX_DSN=postgresql://trunk:trunk@localhost:5434/trunk
CLI
Trunkit ships a dual-surface CLI. Consumer commands are read-only and safe for LLM use.
Prover commands require --write to record; they dry-run without it.
Consumer — read-only
trunkit verify <claim_id>
# Re-verifies a claim without inserting. Replays the stored witness or
# re-runs the probe SQL in a subtransaction. Exits 0 if valid.
trunkit standing [--method M] [--status S]
# Lists all claims with their latest attestation status.
# Filter by method (comp_sql, struct_kan, formal_external,
# empirical_corpus, witness_carry) or status (valid, refuted, unverified).
trunkit export <id> [<id> ...]
# Emits a self-contained JSONB bundle to stdout:
# claims + certificates + witnesses + derivations.
# Portable — consumers can re-verify without a Trunkit install.
Prover — require --write
trunkit check <claim_id> [--write]
# Dry-run: shows what the claim would attest as (via cert.verify).
# With --write: runs cert.check() and records a certificate.
trunkit attest [--write]
# Dry-run: reports formal-tier claims that would be attested.
# With --write: runs cert_formal.py and records all formal-tier certificates.
trunkit close [--write]
# Dry-run: reports intent without side effects.
# With --write: computes reflexive closure — curry fixed points
# (primitive eigenforms) + kan Perron-Frobenius attractor — and
# records eigenform claims.
trunkit witness <claim_id> --kind KIND --body JSON [--write]
# Attach a structured proof witness to a claim.
# KIND: term | trace | counterexample | hash_chain | kan_diagram
calx data
trunkit init # apply schema DDL
trunkit generate --limit N # populate integers 1..N
trunkit validate [--limit N] # compare ω/Ω against OEIS
trunkit reset # drop all calx tables
trunkit oeis-load [--family F] # fetch curated OEIS b-files
trunkit oeis-match [--orbit-id ID | --all]
trunkit compose-match
cert method tiers
| Method | Trust root | Use |
|---|---|---|
comp_sql |
In-DB probe | Computational facts about integers or categorical counts |
struct_kan |
Existing kan invariant | Naturality, triangle identities, faithfulness checks |
formal_external |
SHA256-pinned external artifact | Python/Lean/Agda proof scripts |
empirical_corpus |
Provenance only | Corpus document assertions |
witness_carry |
In-DB witness term | Structured proof terms stored alongside certificates; consumer-replayable |
PCC properties
| Property | Mechanism |
|---|---|
| Proof travels with code | cert.witness stores structured proof terms alongside every certificate |
| Proofs compose | cert.derivation encodes a DAG of premises → conclusion under named rules |
| Consumer re-verifies | cert.verify(claim_id) replays without INSERTing — safe for untrusted callers |
| Bundle is portable | cert.export_bundle(ids[]) emits self-contained JSONB: claims + certs + witnesses + derivations |
Bundle size
| Component | Files | Size |
|---|---|---|
| SQL (89 files, 00–88) | 89 | ~290 KB |
| Python tools | 37 | ~323 KB |
| Proof scripts | 24 | ~172 KB |
| Src + tests + config | ~30 | ~130 KB |
| Total (no virtualenv) | ~183 | ~1.1 MB |
Compare: Lean 4 toolchain ≈ 2.9 GB per version; Mathlib compiled ≈ 4–10 GB per project.
License
MIT
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 trunkit-0.1.0.tar.gz.
File metadata
- Download URL: trunkit-0.1.0.tar.gz
- Upload date:
- Size: 229.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1212ef6c6e1bb40df547e23efd66b259a21903a468597d90284411e1d5890b5
|
|
| MD5 |
5d4093adedcac7f2376e272db9a8a923
|
|
| BLAKE2b-256 |
748acfc93cfaaac288788b810a585034ccc7bc7593fc22f973f931c746009070
|
Provenance
The following attestation bundles were made for trunkit-0.1.0.tar.gz:
Publisher:
python-package-conda.yml on Athena-Pro/Trunkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trunkit-0.1.0.tar.gz -
Subject digest:
d1212ef6c6e1bb40df547e23efd66b259a21903a468597d90284411e1d5890b5 - Sigstore transparency entry: 1565338298
- Sigstore integration time:
-
Permalink:
Athena-Pro/Trunkit@3601a0839f78e3ec7d25506b4e4b957fefd7e54f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Athena-Pro
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-package-conda.yml@3601a0839f78e3ec7d25506b4e4b957fefd7e54f -
Trigger Event:
push
-
Statement type:
File details
Details for the file trunkit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: trunkit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 315.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
214692d6055acd0a4301ceeb47a43c88aff66c2c57bb2a97f6e623a45dfbfdd2
|
|
| MD5 |
002450e41e37500ab83186aa21541c39
|
|
| BLAKE2b-256 |
14acdc7ba59a2f589b0fcc2492ee6c33210481b5074f20105860e3e3cf203fd1
|
Provenance
The following attestation bundles were made for trunkit-0.1.0-py3-none-any.whl:
Publisher:
python-package-conda.yml on Athena-Pro/Trunkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trunkit-0.1.0-py3-none-any.whl -
Subject digest:
214692d6055acd0a4301ceeb47a43c88aff66c2c57bb2a97f6e623a45dfbfdd2 - Sigstore transparency entry: 1565338342
- Sigstore integration time:
-
Permalink:
Athena-Pro/Trunkit@3601a0839f78e3ec7d25506b4e4b957fefd7e54f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Athena-Pro
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-package-conda.yml@3601a0839f78e3ec7d25506b4e4b957fefd7e54f -
Trigger Event:
push
-
Statement type: