trunkit 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. trunkit-0.1.0/.dockerignore +13 -0
  2. trunkit-0.1.0/.gitattributes +6 -0
  3. trunkit-0.1.0/.github/workflows/python-package-conda.yml +92 -0
  4. trunkit-0.1.0/.gitignore +27 -0
  5. trunkit-0.1.0/Dockerfile +18 -0
  6. trunkit-0.1.0/LICENSE +21 -0
  7. trunkit-0.1.0/Makefile +40 -0
  8. trunkit-0.1.0/PKG-INFO +195 -0
  9. trunkit-0.1.0/README.md +166 -0
  10. trunkit-0.1.0/SKILL.md +564 -0
  11. trunkit-0.1.0/docker-compose.yml +29 -0
  12. trunkit-0.1.0/proofs/bigrading.py +248 -0
  13. trunkit-0.1.0/proofs/chromatic.py +254 -0
  14. trunkit-0.1.0/proofs/colimit_closure.py +242 -0
  15. trunkit-0.1.0/proofs/combined_scale.py +346 -0
  16. trunkit-0.1.0/proofs/combined_signature.py +272 -0
  17. trunkit-0.1.0/proofs/developed_sequence.py +433 -0
  18. trunkit-0.1.0/proofs/equipment.py +262 -0
  19. trunkit-0.1.0/proofs/f1_radix.py +181 -0
  20. trunkit-0.1.0/proofs/factorial_homology_signature.py +261 -0
  21. trunkit-0.1.0/proofs/gap_homology_primes.py +150 -0
  22. trunkit-0.1.0/proofs/grading.py +237 -0
  23. trunkit-0.1.0/proofs/identity_decomposition.py +235 -0
  24. trunkit-0.1.0/proofs/lithon.py +190 -0
  25. trunkit-0.1.0/proofs/moonshine.py +192 -0
  26. trunkit-0.1.0/proofs/omega_family.py +215 -0
  27. trunkit-0.1.0/proofs/omega_family_succ.py +269 -0
  28. trunkit-0.1.0/proofs/perfect_28.py +30 -0
  29. trunkit-0.1.0/proofs/prime_members_functor.py +188 -0
  30. trunkit-0.1.0/proofs/self_shadow.py +176 -0
  31. trunkit-0.1.0/proofs/self_syzygy.py +162 -0
  32. trunkit-0.1.0/proofs/seq_homology_signature.py +200 -0
  33. trunkit-0.1.0/proofs/shadow.py +185 -0
  34. trunkit-0.1.0/proofs/shared_prime_h2.py +220 -0
  35. trunkit-0.1.0/proofs/strata_tower.py +219 -0
  36. trunkit-0.1.0/pyproject.toml +62 -0
  37. trunkit-0.1.0/src/calx/__init__.py +13 -0
  38. trunkit-0.1.0/src/calx/cli.py +400 -0
  39. trunkit-0.1.0/src/calx/curry_adapter.py +142 -0
  40. trunkit-0.1.0/src/calx/db.py +164 -0
  41. trunkit-0.1.0/src/calx/generate.py +66 -0
  42. trunkit-0.1.0/src/calx/primesieve.py +55 -0
  43. trunkit-0.1.0/src/calx/sql/00_rehome_to_calx.sql +54 -0
  44. trunkit-0.1.0/src/calx/sql/01_schema.sql +63 -0
  45. trunkit-0.1.0/src/calx/sql/02_views.sql +78 -0
  46. trunkit-0.1.0/src/calx/sql/03_generate.sql +199 -0
  47. trunkit-0.1.0/src/calx/sql/04_crt.sql +244 -0
  48. trunkit-0.1.0/src/calx/sql/05_dynamics.sql +529 -0
  49. trunkit-0.1.0/src/calx/sql/06_oeis_match.sql +216 -0
  50. trunkit-0.1.0/src/calx/sql/07_compositions.sql +75 -0
  51. trunkit-0.1.0/src/calx/sql/10_curry.sql +148 -0
  52. trunkit-0.1.0/src/calx/sql/20_kan.sql +141 -0
  53. trunkit-0.1.0/src/calx/sql/21_kan_functors.sql +92 -0
  54. trunkit-0.1.0/src/calx/sql/22_kan_elements.sql +188 -0
  55. trunkit-0.1.0/src/calx/sql/23_kan_monoidal.sql +189 -0
  56. trunkit-0.1.0/src/calx/sql/24_kan_natural_transformations.sql +273 -0
  57. trunkit-0.1.0/src/calx/sql/25_kan_extensions.sql +206 -0
  58. trunkit-0.1.0/src/calx/sql/26_kan_enrichment.sql +205 -0
  59. trunkit-0.1.0/src/calx/sql/27_kan_profunctors.sql +241 -0
  60. trunkit-0.1.0/src/calx/sql/28_kan_adjunctions.sql +223 -0
  61. trunkit-0.1.0/src/calx/sql/30_kan_corpus.sql +76 -0
  62. trunkit-0.1.0/src/calx/sql/40_cert.sql +231 -0
  63. trunkit-0.1.0/src/calx/sql/41_cert_formal.sql +90 -0
  64. trunkit-0.1.0/src/calx/sql/42_cert_gap_homology.sql +25 -0
  65. trunkit-0.1.0/src/calx/sql/43_kan_sequence_homology.sql +68 -0
  66. trunkit-0.1.0/src/calx/sql/44_cert_seq_homology.sql +26 -0
  67. trunkit-0.1.0/src/calx/sql/45_kan_factorial_homology.sql +61 -0
  68. trunkit-0.1.0/src/calx/sql/46_cert_factorial_homology.sql +26 -0
  69. trunkit-0.1.0/src/calx/sql/47_kan_combined_signature.sql +62 -0
  70. trunkit-0.1.0/src/calx/sql/48_cert_combined.sql +27 -0
  71. trunkit-0.1.0/src/calx/sql/49_kan_shared_prime_betti.sql +62 -0
  72. trunkit-0.1.0/src/calx/sql/50_cert_combined_scale.sql +24 -0
  73. trunkit-0.1.0/src/calx/sql/51_cert_shared_prime_h2.sql +25 -0
  74. trunkit-0.1.0/src/calx/sql/52_cert_developed_sequence.sql +31 -0
  75. trunkit-0.1.0/src/calx/sql/53_cert_omega_family.sql +32 -0
  76. trunkit-0.1.0/src/calx/sql/54_cert_omega_family_succ.sql +34 -0
  77. trunkit-0.1.0/src/calx/sql/55_kan_prime_members.sql +54 -0
  78. trunkit-0.1.0/src/calx/sql/56_cert_prime_members_functor.sql +33 -0
  79. trunkit-0.1.0/src/calx/sql/57_kan_strata_tower.sql +61 -0
  80. trunkit-0.1.0/src/calx/sql/58_cert_strata_tower.sql +31 -0
  81. trunkit-0.1.0/src/calx/sql/59_kan_grading.sql +70 -0
  82. trunkit-0.1.0/src/calx/sql/60_cert_grading.sql +34 -0
  83. trunkit-0.1.0/src/calx/sql/61_kan_identity_decomposition.sql +57 -0
  84. trunkit-0.1.0/src/calx/sql/62_cert_identity_decomposition.sql +34 -0
  85. trunkit-0.1.0/src/calx/sql/63_kan_bigrading.sql +66 -0
  86. trunkit-0.1.0/src/calx/sql/64_cert_bigrading.sql +39 -0
  87. trunkit-0.1.0/src/calx/sql/65_kan_chromatic.sql +72 -0
  88. trunkit-0.1.0/src/calx/sql/66_cert_chromatic.sql +39 -0
  89. trunkit-0.1.0/src/calx/sql/67_kan_lithon.sql +93 -0
  90. trunkit-0.1.0/src/calx/sql/68_cert_lithon.sql +41 -0
  91. trunkit-0.1.0/src/calx/sql/69_kan_shadow.sql +67 -0
  92. trunkit-0.1.0/src/calx/sql/70_cert_shadow.sql +42 -0
  93. trunkit-0.1.0/src/calx/sql/71_kan_self_syzygy.sql +70 -0
  94. trunkit-0.1.0/src/calx/sql/72_cert_self_syzygy.sql +35 -0
  95. trunkit-0.1.0/src/calx/sql/73_kan_self_shadow.sql +83 -0
  96. trunkit-0.1.0/src/calx/sql/74_cert_self_shadow.sql +35 -0
  97. trunkit-0.1.0/src/calx/sql/75_kan_f1_radix.sql +86 -0
  98. trunkit-0.1.0/src/calx/sql/76_cert_f1_radix.sql +36 -0
  99. trunkit-0.1.0/src/calx/sql/77_kan_moonshine.sql +88 -0
  100. trunkit-0.1.0/src/calx/sql/78_cert_moonshine.sql +38 -0
  101. trunkit-0.1.0/src/calx/sql/79_cert_kan_engines.sql +86 -0
  102. trunkit-0.1.0/src/calx/sql/80_kan_colimit_closure.sql +67 -0
  103. trunkit-0.1.0/src/calx/sql/81_cert_colimit_closure.sql +44 -0
  104. trunkit-0.1.0/src/calx/sql/82_kan_equipment.sql +75 -0
  105. trunkit-0.1.0/src/calx/sql/83_cert_equipment.sql +38 -0
  106. trunkit-0.1.0/src/calx/sql/84_cert_witness.sql +56 -0
  107. trunkit-0.1.0/src/calx/sql/85_cert_derivation.sql +66 -0
  108. trunkit-0.1.0/src/calx/sql/86_cert_verify.sql +74 -0
  109. trunkit-0.1.0/src/calx/sql/87_cert_export_bundle.sql +85 -0
  110. trunkit-0.1.0/src/calx/sql/88_cert_witness_carry.sql +141 -0
  111. trunkit-0.1.0/src/calx/sql/examples/crt_examples.sql +66 -0
  112. trunkit-0.1.0/src/calx/sql/examples/dynamics_examples.sql +77 -0
  113. trunkit-0.1.0/src/calx/sql/examples/queries.sql +91 -0
  114. trunkit-0.1.0/src/calx/validate.py +70 -0
  115. trunkit-0.1.0/tests/__init__.py +0 -0
  116. trunkit-0.1.0/tests/conftest.py +59 -0
  117. trunkit-0.1.0/tests/fixtures/oeis/.gitkeep +0 -0
  118. trunkit-0.1.0/tests/test_compose_match.py +77 -0
  119. trunkit-0.1.0/tests/test_crt.py +75 -0
  120. trunkit-0.1.0/tests/test_dynamics.py +186 -0
  121. trunkit-0.1.0/tests/test_factorizations.py +70 -0
  122. trunkit-0.1.0/tests/test_oeis_match.py +281 -0
  123. trunkit-0.1.0/tests/test_schema.py +89 -0
  124. trunkit-0.1.0/tests/test_sieve.py +66 -0
  125. trunkit-0.1.0/tools/build_bigrading.py +178 -0
  126. trunkit-0.1.0/tools/build_chromatic.py +195 -0
  127. trunkit-0.1.0/tools/build_colimit_closure.py +194 -0
  128. trunkit-0.1.0/tools/build_equipment.py +204 -0
  129. trunkit-0.1.0/tools/build_f1_radix.py +148 -0
  130. trunkit-0.1.0/tools/build_grading.py +182 -0
  131. trunkit-0.1.0/tools/build_identity_decomposition.py +178 -0
  132. trunkit-0.1.0/tools/build_lithon.py +223 -0
  133. trunkit-0.1.0/tools/build_moonshine.py +222 -0
  134. trunkit-0.1.0/tools/build_self_shadow.py +144 -0
  135. trunkit-0.1.0/tools/build_self_syzygy.py +124 -0
  136. trunkit-0.1.0/tools/build_shadow.py +170 -0
  137. trunkit-0.1.0/tools/build_strata_tower.py +163 -0
  138. trunkit-0.1.0/tools/cert_formal.py +312 -0
  139. trunkit-0.1.0/tools/compose_match.py +476 -0
  140. trunkit-0.1.0/tools/cryptanalysis.py +341 -0
  141. trunkit-0.1.0/tools/develop_omega_family.py +255 -0
  142. trunkit-0.1.0/tools/develop_sequence.py +191 -0
  143. trunkit-0.1.0/tools/diagnostic_tests.py +353 -0
  144. trunkit-0.1.0/tools/factorial_homology.py +243 -0
  145. trunkit-0.1.0/tools/kan_in_kan.py +300 -0
  146. trunkit-0.1.0/tools/load_kan_corpus.py +153 -0
  147. trunkit-0.1.0/tools/oeis_loader.py +422 -0
  148. trunkit-0.1.0/tools/oeis_match.py +647 -0
  149. trunkit-0.1.0/tools/omega_equal_control.py +155 -0
  150. trunkit-0.1.0/tools/port_curry_sqlite_to_pg.py +152 -0
  151. trunkit-0.1.0/tools/prime_members_functor.py +125 -0
  152. trunkit-0.1.0/tools/register_calx_fn_deps.py +116 -0
  153. trunkit-0.1.0/tools/register_calx_in_curry.py +424 -0
  154. trunkit-0.1.0/tools/relationship_report.py +372 -0
  155. trunkit-0.1.0/tools/run_compose_discovery.py +102 -0
  156. trunkit-0.1.0/tools/run_discovery.py +115 -0
  157. trunkit-0.1.0/tools/seed_oeis_classics.py +239 -0
  158. trunkit-0.1.0/tools/seed_sequences.py +321 -0
  159. trunkit-0.1.0/tools/seq_homology.py +188 -0
  160. trunkit-0.1.0/tools/shared_prime_betti.py +226 -0
  161. trunkit-0.1.0/tools/smoke_curry_calx.py +114 -0
@@ -0,0 +1,13 @@
1
+ .git
2
+ .github
3
+ __pycache__
4
+ *.pyc
5
+ *.pyo
6
+ .pytest_cache
7
+ .mypy_cache
8
+ .venv
9
+ venv
10
+ dist
11
+ build
12
+ *.egg-info
13
+ tests/fixtures/oeis/b*.txt
@@ -0,0 +1,6 @@
1
+ * text=auto
2
+ *.sql text eol=lf
3
+ *.py text eol=lf
4
+ *.md text eol=lf
5
+ *.toml text eol=lf
6
+ *.yml text eol=lf
@@ -0,0 +1,92 @@
1
+ name: CI and Publish
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ tags: ["v*"]
7
+ pull_request:
8
+ branches: [main]
9
+
10
+ jobs:
11
+ ci:
12
+ runs-on: ubuntu-latest
13
+
14
+ services:
15
+ postgres:
16
+ image: postgres:16
17
+ env:
18
+ POSTGRES_USER: trunk
19
+ POSTGRES_PASSWORD: trunk
20
+ POSTGRES_DB: trunk
21
+ ports:
22
+ - 5434:5432
23
+ options: >-
24
+ --health-cmd pg_isready
25
+ --health-interval 10s
26
+ --health-timeout 5s
27
+ --health-retries 5
28
+
29
+ steps:
30
+ - uses: actions/checkout@v4
31
+
32
+ - uses: actions/setup-python@v5
33
+ with:
34
+ python-version: "3.11"
35
+ cache: pip
36
+
37
+ - name: Install dependencies
38
+ run: pip install -e ".[dev]"
39
+
40
+ - name: Lint
41
+ run: ruff check src/
42
+
43
+ - name: Apply schema
44
+ env:
45
+ PGPASSWORD: trunk
46
+ run: |
47
+ for f in src/calx/sql/0[0-7]*.sql; do
48
+ psql -h localhost -p 5434 -U trunk -d trunk -f "$f" -q
49
+ done
50
+
51
+ - name: Test
52
+ env:
53
+ CALX_TEST_DSN: postgresql://trunk:trunk@localhost:5434/trunk
54
+ run: pytest -m "not slow and not primesieve"
55
+
56
+ build:
57
+ runs-on: ubuntu-latest
58
+ needs: ci
59
+ if: startsWith(github.ref, 'refs/tags/v')
60
+
61
+ steps:
62
+ - uses: actions/checkout@v4
63
+
64
+ - uses: actions/setup-python@v5
65
+ with:
66
+ python-version: "3.11"
67
+
68
+ - name: Build
69
+ run: |
70
+ pip install build
71
+ python -m build
72
+
73
+ - uses: actions/upload-artifact@v4
74
+ with:
75
+ name: dist
76
+ path: dist/
77
+
78
+ publish:
79
+ runs-on: ubuntu-latest
80
+ needs: build
81
+ if: startsWith(github.ref, 'refs/tags/v')
82
+ environment: pypi
83
+ permissions:
84
+ id-token: write
85
+
86
+ steps:
87
+ - uses: actions/download-artifact@v4
88
+ with:
89
+ name: dist
90
+ path: dist/
91
+
92
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,27 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .pytest_cache/
5
+ .mypy_cache/
6
+ .ruff_cache/
7
+ .coverage
8
+ htmlcov/
9
+ dist/
10
+ build/
11
+ .venv/
12
+ venv/
13
+ .env
14
+ .envrc
15
+
16
+ # OEIS validation fixtures are pulled on demand
17
+ tests/fixtures/oeis/b*.txt
18
+
19
+ # Local data dumps
20
+ *.dump
21
+ *.sql.gz
22
+
23
+ # Claude IDE settings
24
+ .claude/
25
+
26
+ # Jules tooling
27
+ .curry/
@@ -0,0 +1,18 @@
1
+ FROM python:3.12-slim
2
+
3
+ RUN apt-get update \
4
+ && apt-get install -y --no-install-recommends \
5
+ primesieve \
6
+ libpq5 \
7
+ && rm -rf /var/lib/apt/lists/*
8
+
9
+ WORKDIR /app
10
+
11
+ COPY pyproject.toml README.md ./
12
+ COPY src ./src
13
+ COPY sql ./sql
14
+
15
+ RUN pip install --no-cache-dir .
16
+
17
+ ENTRYPOINT ["trunk"]
18
+ CMD ["--help"]
trunkit-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Athena-Pro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
trunkit-0.1.0/Makefile ADDED
@@ -0,0 +1,40 @@
1
+ DSN ?= postgresql://trunk:trunk@localhost:5434/trunk
2
+
3
+ .PHONY: up down apply check reset install
4
+
5
+ ## Start PostgreSQL via Docker Compose
6
+ up:
7
+ docker compose up -d db
8
+
9
+ ## Stop and remove containers
10
+ down:
11
+ docker compose down
12
+
13
+ ## Apply all SQL schemas in order (idempotent)
14
+ apply:
15
+ @for f in $$(ls src/calx/sql/*.sql | sort); do \
16
+ echo " $$f"; \
17
+ psql $(DSN) -f "$$f" -q; \
18
+ done
19
+ @echo "Done. Run 'make check' to verify."
20
+
21
+ ## Populate integers and run reflexive closure + cert attestation
22
+ check:
23
+ python tools/kan_in_kan.py
24
+
25
+ ## Attest formal-tier proof artifacts
26
+ attest:
27
+ python tools/cert_formal.py
28
+
29
+ ## Full local bootstrap: up → apply → check
30
+ install: up
31
+ @echo "Waiting for db to be ready..."
32
+ @sleep 3
33
+ $(MAKE) apply
34
+ $(MAKE) check
35
+
36
+ ## Drop all Trunkit schemas and start fresh (destructive)
37
+ reset:
38
+ psql $(DSN) -c "DROP SCHEMA IF EXISTS cert, kan, curry, calx CASCADE;"
39
+ $(MAKE) apply
40
+ $(MAKE) check
trunkit-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,195 @@
1
+ Metadata-Version: 2.4
2
+ Name: trunkit
3
+ Version: 0.1.0
4
+ Summary: Trunkit — low-cost proof-carrying code middleware on PostgreSQL
5
+ Project-URL: Homepage, https://github.com/Athena-Pro/Trunkit
6
+ Project-URL: Repository, https://github.com/Athena-Pro/Trunkit
7
+ License: MIT
8
+ License-File: LICENSE
9
+ Keywords: category-theory,formal-verification,number-theory,postgresql,proof-carrying-code
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: SQL
18
+ Classifier: Topic :: Database
19
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
20
+ Requires-Python: >=3.11
21
+ Requires-Dist: psycopg[binary]<4,>=3.2
22
+ Provides-Extra: dev
23
+ Requires-Dist: build>=1.0; extra == 'dev'
24
+ Requires-Dist: pytest-cov>=5; extra == 'dev'
25
+ Requires-Dist: pytest>=8; extra == 'dev'
26
+ Requires-Dist: ruff>=0.6; extra == 'dev'
27
+ Requires-Dist: twine>=5.0; extra == 'dev'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # Trunkit
31
+
32
+ > The smallest elephant in the room that's not too Coq-y and doesn't Lean too heavily on your system.
33
+
34
+ Proof-carrying code middleware on PostgreSQL. Trunkit is a self-contained schema stack
35
+ that attaches verifiable claims to mathematical objects, chains proofs compositionally,
36
+ and lets consumers re-verify results without trusting the producer — all inside a
37
+ database you already operate, with no specialist toolchain required.
38
+
39
+ No 3 GB compiler. No gigabytes of cached proof objects. No new runtime to learn.
40
+ Just PostgreSQL, Python, and ~1 MB of schemas that describe, attest, and verify themselves.
41
+
42
+ ---
43
+
44
+ ## Schemas
45
+
46
+ ```
47
+ ┌──────────────────────────────────────────────────────────┐
48
+ │ cert — proof-carrying attestation │
49
+ │ witness · derivation · verify() · export_bundle() │
50
+ ├──────────────┬───────────────────────────────────────────┤
51
+ │ kan │ curry │
52
+ │ category │ versioned provenance │
53
+ │ theory │ + immutable constants │
54
+ ├──────────────┴───────────────────────────────────────────┤
55
+ │ calx — integer arithmetic bedrock │
56
+ │ primes · factorizations · dynamics · CRT · OEIS │
57
+ └──────────────────────────────────────────────────────────┘
58
+ PostgreSQL 16 · Python 3.11+
59
+ ```
60
+
61
+ | Schema | Role |
62
+ |--------|------|
63
+ | **calx** | Dense prime factorisation of ℤ[1..N]; aliquot/derivative dynamics; CRT; OEIS sequence matching |
64
+ | **curry** | Immutable versioned constants and functions; append-only computational provenance |
65
+ | **kan** | Category-theory meta-layer: base categories → monoidal → NTs → Kan extensions → enrichment → profunctors → adjunctions; reflexively describes itself |
66
+ | **cert** | Proof-carrying attestation: five method tiers, structured witness storage, proof composition DAG, portable bundle export, side-effect-free consumer re-verification |
67
+
68
+ ---
69
+
70
+ ## Quick start
71
+
72
+ ```bash
73
+ # 1. Start PostgreSQL
74
+ docker compose up -d db
75
+
76
+ # 2. Apply schemas (idempotent — safe to re-run)
77
+ make apply
78
+
79
+ # 3. Populate integers and compute reflexive closure
80
+ trunkit generate --limit 10000
81
+ trunkit close --write
82
+
83
+ # 4. Check all claims
84
+ trunkit standing
85
+ ```
86
+
87
+ ```bash
88
+ # Install
89
+ pip install trunkit
90
+ pip install -e ".[dev]" # local development
91
+ ```
92
+
93
+ Environment variable: `CALX_DSN=postgresql://trunk:trunk@localhost:5434/trunk`
94
+
95
+ ---
96
+
97
+ ## CLI
98
+
99
+ Trunkit ships a dual-surface CLI. Consumer commands are read-only and safe for LLM use.
100
+ Prover commands require `--write` to record; they dry-run without it.
101
+
102
+ ### Consumer — read-only
103
+
104
+ ```bash
105
+ trunkit verify <claim_id>
106
+ # Re-verifies a claim without inserting. Replays the stored witness or
107
+ # re-runs the probe SQL in a subtransaction. Exits 0 if valid.
108
+
109
+ trunkit standing [--method M] [--status S]
110
+ # Lists all claims with their latest attestation status.
111
+ # Filter by method (comp_sql, struct_kan, formal_external,
112
+ # empirical_corpus, witness_carry) or status (valid, refuted, unverified).
113
+
114
+ trunkit export <id> [<id> ...]
115
+ # Emits a self-contained JSONB bundle to stdout:
116
+ # claims + certificates + witnesses + derivations.
117
+ # Portable — consumers can re-verify without a Trunkit install.
118
+ ```
119
+
120
+ ### Prover — require `--write`
121
+
122
+ ```bash
123
+ trunkit check <claim_id> [--write]
124
+ # Dry-run: shows what the claim would attest as (via cert.verify).
125
+ # With --write: runs cert.check() and records a certificate.
126
+
127
+ trunkit attest [--write]
128
+ # Dry-run: reports formal-tier claims that would be attested.
129
+ # With --write: runs cert_formal.py and records all formal-tier certificates.
130
+
131
+ trunkit close [--write]
132
+ # Dry-run: reports intent without side effects.
133
+ # With --write: computes reflexive closure — curry fixed points
134
+ # (primitive eigenforms) + kan Perron-Frobenius attractor — and
135
+ # records eigenform claims.
136
+
137
+ trunkit witness <claim_id> --kind KIND --body JSON [--write]
138
+ # Attach a structured proof witness to a claim.
139
+ # KIND: term | trace | counterexample | hash_chain | kan_diagram
140
+ ```
141
+
142
+ ### calx data
143
+
144
+ ```bash
145
+ trunkit init # apply schema DDL
146
+ trunkit generate --limit N # populate integers 1..N
147
+ trunkit validate [--limit N] # compare ω/Ω against OEIS
148
+ trunkit reset # drop all calx tables
149
+ trunkit oeis-load [--family F] # fetch curated OEIS b-files
150
+ trunkit oeis-match [--orbit-id ID | --all]
151
+ trunkit compose-match
152
+ ```
153
+
154
+ ---
155
+
156
+ ## cert method tiers
157
+
158
+ | Method | Trust root | Use |
159
+ |--------|-----------|-----|
160
+ | `comp_sql` | In-DB probe | Computational facts about integers or categorical counts |
161
+ | `struct_kan` | Existing kan invariant | Naturality, triangle identities, faithfulness checks |
162
+ | `formal_external` | SHA256-pinned external artifact | Python/Lean/Agda proof scripts |
163
+ | `empirical_corpus` | Provenance only | Corpus document assertions |
164
+ | `witness_carry` | In-DB witness term | Structured proof terms stored alongside certificates; consumer-replayable |
165
+
166
+ ---
167
+
168
+ ## PCC properties
169
+
170
+ | Property | Mechanism |
171
+ |----------|-----------|
172
+ | Proof travels with code | `cert.witness` stores structured proof terms alongside every certificate |
173
+ | Proofs compose | `cert.derivation` encodes a DAG of premises → conclusion under named rules |
174
+ | Consumer re-verifies | `cert.verify(claim_id)` replays without INSERTing — safe for untrusted callers |
175
+ | Bundle is portable | `cert.export_bundle(ids[])` emits self-contained JSONB: claims + certs + witnesses + derivations |
176
+
177
+ ---
178
+
179
+ ## Bundle size
180
+
181
+ | Component | Files | Size |
182
+ |-----------|-------|------|
183
+ | SQL (89 files, 00–88) | 89 | ~290 KB |
184
+ | Python tools | 37 | ~323 KB |
185
+ | Proof scripts | 24 | ~172 KB |
186
+ | Src + tests + config | ~30 | ~130 KB |
187
+ | **Total (no virtualenv)** | **~183** | **~1.1 MB** |
188
+
189
+ Compare: Lean 4 toolchain ≈ 2.9 GB per version; Mathlib compiled ≈ 4–10 GB per project.
190
+
191
+ ---
192
+
193
+ ## License
194
+
195
+ MIT
@@ -0,0 +1,166 @@
1
+ # Trunkit
2
+
3
+ > The smallest elephant in the room that's not too Coq-y and doesn't Lean too heavily on your system.
4
+
5
+ Proof-carrying code middleware on PostgreSQL. Trunkit is a self-contained schema stack
6
+ that attaches verifiable claims to mathematical objects, chains proofs compositionally,
7
+ and lets consumers re-verify results without trusting the producer — all inside a
8
+ database you already operate, with no specialist toolchain required.
9
+
10
+ No 3 GB compiler. No gigabytes of cached proof objects. No new runtime to learn.
11
+ Just PostgreSQL, Python, and ~1 MB of schemas that describe, attest, and verify themselves.
12
+
13
+ ---
14
+
15
+ ## Schemas
16
+
17
+ ```
18
+ ┌──────────────────────────────────────────────────────────┐
19
+ │ cert — proof-carrying attestation │
20
+ │ witness · derivation · verify() · export_bundle() │
21
+ ├──────────────┬───────────────────────────────────────────┤
22
+ │ kan │ curry │
23
+ │ category │ versioned provenance │
24
+ │ theory │ + immutable constants │
25
+ ├──────────────┴───────────────────────────────────────────┤
26
+ │ calx — integer arithmetic bedrock │
27
+ │ primes · factorizations · dynamics · CRT · OEIS │
28
+ └──────────────────────────────────────────────────────────┘
29
+ PostgreSQL 16 · Python 3.11+
30
+ ```
31
+
32
+ | Schema | Role |
33
+ |--------|------|
34
+ | **calx** | Dense prime factorisation of ℤ[1..N]; aliquot/derivative dynamics; CRT; OEIS sequence matching |
35
+ | **curry** | Immutable versioned constants and functions; append-only computational provenance |
36
+ | **kan** | Category-theory meta-layer: base categories → monoidal → NTs → Kan extensions → enrichment → profunctors → adjunctions; reflexively describes itself |
37
+ | **cert** | Proof-carrying attestation: five method tiers, structured witness storage, proof composition DAG, portable bundle export, side-effect-free consumer re-verification |
38
+
39
+ ---
40
+
41
+ ## Quick start
42
+
43
+ ```bash
44
+ # 1. Start PostgreSQL
45
+ docker compose up -d db
46
+
47
+ # 2. Apply schemas (idempotent — safe to re-run)
48
+ make apply
49
+
50
+ # 3. Populate integers and compute reflexive closure
51
+ trunkit generate --limit 10000
52
+ trunkit close --write
53
+
54
+ # 4. Check all claims
55
+ trunkit standing
56
+ ```
57
+
58
+ ```bash
59
+ # Install
60
+ pip install trunkit
61
+ pip install -e ".[dev]" # local development
62
+ ```
63
+
64
+ Environment variable: `CALX_DSN=postgresql://trunk:trunk@localhost:5434/trunk`
65
+
66
+ ---
67
+
68
+ ## CLI
69
+
70
+ Trunkit ships a dual-surface CLI. Consumer commands are read-only and safe for LLM use.
71
+ Prover commands require `--write` to record; they dry-run without it.
72
+
73
+ ### Consumer — read-only
74
+
75
+ ```bash
76
+ trunkit verify <claim_id>
77
+ # Re-verifies a claim without inserting. Replays the stored witness or
78
+ # re-runs the probe SQL in a subtransaction. Exits 0 if valid.
79
+
80
+ trunkit standing [--method M] [--status S]
81
+ # Lists all claims with their latest attestation status.
82
+ # Filter by method (comp_sql, struct_kan, formal_external,
83
+ # empirical_corpus, witness_carry) or status (valid, refuted, unverified).
84
+
85
+ trunkit export <id> [<id> ...]
86
+ # Emits a self-contained JSONB bundle to stdout:
87
+ # claims + certificates + witnesses + derivations.
88
+ # Portable — consumers can re-verify without a Trunkit install.
89
+ ```
90
+
91
+ ### Prover — require `--write`
92
+
93
+ ```bash
94
+ trunkit check <claim_id> [--write]
95
+ # Dry-run: shows what the claim would attest as (via cert.verify).
96
+ # With --write: runs cert.check() and records a certificate.
97
+
98
+ trunkit attest [--write]
99
+ # Dry-run: reports formal-tier claims that would be attested.
100
+ # With --write: runs cert_formal.py and records all formal-tier certificates.
101
+
102
+ trunkit close [--write]
103
+ # Dry-run: reports intent without side effects.
104
+ # With --write: computes reflexive closure — curry fixed points
105
+ # (primitive eigenforms) + kan Perron-Frobenius attractor — and
106
+ # records eigenform claims.
107
+
108
+ trunkit witness <claim_id> --kind KIND --body JSON [--write]
109
+ # Attach a structured proof witness to a claim.
110
+ # KIND: term | trace | counterexample | hash_chain | kan_diagram
111
+ ```
112
+
113
+ ### calx data
114
+
115
+ ```bash
116
+ trunkit init # apply schema DDL
117
+ trunkit generate --limit N # populate integers 1..N
118
+ trunkit validate [--limit N] # compare ω/Ω against OEIS
119
+ trunkit reset # drop all calx tables
120
+ trunkit oeis-load [--family F] # fetch curated OEIS b-files
121
+ trunkit oeis-match [--orbit-id ID | --all]
122
+ trunkit compose-match
123
+ ```
124
+
125
+ ---
126
+
127
+ ## cert method tiers
128
+
129
+ | Method | Trust root | Use |
130
+ |--------|-----------|-----|
131
+ | `comp_sql` | In-DB probe | Computational facts about integers or categorical counts |
132
+ | `struct_kan` | Existing kan invariant | Naturality, triangle identities, faithfulness checks |
133
+ | `formal_external` | SHA256-pinned external artifact | Python/Lean/Agda proof scripts |
134
+ | `empirical_corpus` | Provenance only | Corpus document assertions |
135
+ | `witness_carry` | In-DB witness term | Structured proof terms stored alongside certificates; consumer-replayable |
136
+
137
+ ---
138
+
139
+ ## PCC properties
140
+
141
+ | Property | Mechanism |
142
+ |----------|-----------|
143
+ | Proof travels with code | `cert.witness` stores structured proof terms alongside every certificate |
144
+ | Proofs compose | `cert.derivation` encodes a DAG of premises → conclusion under named rules |
145
+ | Consumer re-verifies | `cert.verify(claim_id)` replays without INSERTing — safe for untrusted callers |
146
+ | Bundle is portable | `cert.export_bundle(ids[])` emits self-contained JSONB: claims + certs + witnesses + derivations |
147
+
148
+ ---
149
+
150
+ ## Bundle size
151
+
152
+ | Component | Files | Size |
153
+ |-----------|-------|------|
154
+ | SQL (89 files, 00–88) | 89 | ~290 KB |
155
+ | Python tools | 37 | ~323 KB |
156
+ | Proof scripts | 24 | ~172 KB |
157
+ | Src + tests + config | ~30 | ~130 KB |
158
+ | **Total (no virtualenv)** | **~183** | **~1.1 MB** |
159
+
160
+ Compare: Lean 4 toolchain ≈ 2.9 GB per version; Mathlib compiled ≈ 4–10 GB per project.
161
+
162
+ ---
163
+
164
+ ## License
165
+
166
+ MIT