pyboltzmann 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.
- pyboltzmann-0.1.0/.gitignore +54 -0
- pyboltzmann-0.1.0/LICENSE +21 -0
- pyboltzmann-0.1.0/PKG-INFO +185 -0
- pyboltzmann-0.1.0/README.md +153 -0
- pyboltzmann-0.1.0/pyproject.toml +344 -0
- pyboltzmann-0.1.0/src/boltzmann/__init__.py +160 -0
- pyboltzmann-0.1.0/src/boltzmann/blocks/__init__.py +50 -0
- pyboltzmann-0.1.0/src/boltzmann/blocks/base.py +215 -0
- pyboltzmann-0.1.0/src/boltzmann/blocks/canonical.py +76 -0
- pyboltzmann-0.1.0/src/boltzmann/blocks/episodic.py +52 -0
- pyboltzmann-0.1.0/src/boltzmann/blocks/memory_type.py +53 -0
- pyboltzmann-0.1.0/src/boltzmann/blocks/procedural.py +62 -0
- pyboltzmann-0.1.0/src/boltzmann/blocks/provenance.py +305 -0
- pyboltzmann-0.1.0/src/boltzmann/blocks/semantic.py +79 -0
- pyboltzmann-0.1.0/src/boltzmann/brain.py +1877 -0
- pyboltzmann-0.1.0/src/boltzmann/conformance/__init__.py +23 -0
- pyboltzmann-0.1.0/src/boltzmann/conformance/golden.py +48 -0
- pyboltzmann-0.1.0/src/boltzmann/conformance/suite.py +438 -0
- pyboltzmann-0.1.0/src/boltzmann/conformance/vectors/__init__.py +1 -0
- pyboltzmann-0.1.0/src/boltzmann/conformance/vectors/block_ids.json +185 -0
- pyboltzmann-0.1.0/src/boltzmann/conformance/vectors/inclusion_proofs.json +158 -0
- pyboltzmann-0.1.0/src/boltzmann/conformance/vectors/merkle_roots.json +156 -0
- pyboltzmann-0.1.0/src/boltzmann/conformance/vectors/serialization.json +72 -0
- pyboltzmann-0.1.0/src/boltzmann/constants.py +22 -0
- pyboltzmann-0.1.0/src/boltzmann/distribution/__init__.py +37 -0
- pyboltzmann-0.1.0/src/boltzmann/distribution/layers.py +203 -0
- pyboltzmann-0.1.0/src/boltzmann/distribution/local.py +164 -0
- pyboltzmann-0.1.0/src/boltzmann/distribution/manifest.py +391 -0
- pyboltzmann-0.1.0/src/boltzmann/distribution/media_types.py +112 -0
- pyboltzmann-0.1.0/src/boltzmann/distribution/oras_client.py +345 -0
- pyboltzmann-0.1.0/src/boltzmann/distribution/registry.py +111 -0
- pyboltzmann-0.1.0/src/boltzmann/exceptions.py +147 -0
- pyboltzmann-0.1.0/src/boltzmann/identity/__init__.py +32 -0
- pyboltzmann-0.1.0/src/boltzmann/identity/digest.py +185 -0
- pyboltzmann-0.1.0/src/boltzmann/identity/hashing.py +88 -0
- pyboltzmann-0.1.0/src/boltzmann/identity/serialization.py +154 -0
- pyboltzmann-0.1.0/src/boltzmann/identity/time.py +68 -0
- pyboltzmann-0.1.0/src/boltzmann/indices/__init__.py +10 -0
- pyboltzmann-0.1.0/src/boltzmann/indices/base.py +164 -0
- pyboltzmann-0.1.0/src/boltzmann/ingest/__init__.py +58 -0
- pyboltzmann-0.1.0/src/boltzmann/ingest/commit.py +49 -0
- pyboltzmann-0.1.0/src/boltzmann/ingest/pipelines.py +113 -0
- pyboltzmann-0.1.0/src/boltzmann/ingest/proposer.py +119 -0
- pyboltzmann-0.1.0/src/boltzmann/ingest/register.py +71 -0
- pyboltzmann-0.1.0/src/boltzmann/ingest/schema.py +195 -0
- pyboltzmann-0.1.0/src/boltzmann/ingest/task.py +90 -0
- pyboltzmann-0.1.0/src/boltzmann/ingest/validation.py +234 -0
- pyboltzmann-0.1.0/src/boltzmann/ingest/validators.py +472 -0
- pyboltzmann-0.1.0/src/boltzmann/merkle/__init__.py +28 -0
- pyboltzmann-0.1.0/src/boltzmann/merkle/diff.py +86 -0
- pyboltzmann-0.1.0/src/boltzmann/merkle/layout.py +60 -0
- pyboltzmann-0.1.0/src/boltzmann/merkle/proof.py +113 -0
- pyboltzmann-0.1.0/src/boltzmann/merkle/tree.py +227 -0
- pyboltzmann-0.1.0/src/boltzmann/module/__init__.py +16 -0
- pyboltzmann-0.1.0/src/boltzmann/module/composition.py +255 -0
- pyboltzmann-0.1.0/src/boltzmann/module/ledger.py +173 -0
- pyboltzmann-0.1.0/src/boltzmann/module/module.py +245 -0
- pyboltzmann-0.1.0/src/boltzmann/module/snapshot.py +219 -0
- pyboltzmann-0.1.0/src/boltzmann/protocol/__init__.py +27 -0
- pyboltzmann-0.1.0/src/boltzmann/protocol/operations.py +472 -0
- pyboltzmann-0.1.0/src/boltzmann/py.typed +0 -0
- pyboltzmann-0.1.0/src/boltzmann/query/__init__.py +26 -0
- pyboltzmann-0.1.0/src/boltzmann/query/evidence.py +133 -0
- pyboltzmann-0.1.0/src/boltzmann/query/planner.py +49 -0
- pyboltzmann-0.1.0/src/boltzmann/query/request.py +124 -0
- pyboltzmann-0.1.0/src/boltzmann/query/scan.py +325 -0
- pyboltzmann-0.1.0/src/boltzmann/retention/__init__.py +41 -0
- pyboltzmann-0.1.0/src/boltzmann/retention/cascade.py +192 -0
- pyboltzmann-0.1.0/src/boltzmann/retention/policy.py +122 -0
- pyboltzmann-0.1.0/src/boltzmann/retention/reachability.py +154 -0
- pyboltzmann-0.1.0/src/boltzmann/retention/requests.py +254 -0
- pyboltzmann-0.1.0/src/boltzmann/store/__init__.py +13 -0
- pyboltzmann-0.1.0/src/boltzmann/store/base.py +302 -0
- pyboltzmann-0.1.0/src/boltzmann/store/memory.py +138 -0
- pyboltzmann-0.1.0/src/boltzmann/store/oci_layout.py +294 -0
- pyboltzmann-0.1.0/src/boltzmann/utils/__init__.py +7 -0
- pyboltzmann-0.1.0/src/boltzmann/utils/logging.py +41 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
.DS_Store
|
|
2
|
+
|
|
3
|
+
# Virtual environments
|
|
4
|
+
venv/
|
|
5
|
+
.venv/
|
|
6
|
+
env/
|
|
7
|
+
ENV/
|
|
8
|
+
.env
|
|
9
|
+
|
|
10
|
+
# Build artifacts
|
|
11
|
+
dist/
|
|
12
|
+
build/
|
|
13
|
+
*.egg-info/
|
|
14
|
+
|
|
15
|
+
# Python cache
|
|
16
|
+
__pycache__/
|
|
17
|
+
*.pyc
|
|
18
|
+
*.pyo
|
|
19
|
+
*.pyd
|
|
20
|
+
.Python
|
|
21
|
+
|
|
22
|
+
# Distribution / packaging
|
|
23
|
+
*.gz
|
|
24
|
+
*.whl
|
|
25
|
+
|
|
26
|
+
# Logs
|
|
27
|
+
*.log
|
|
28
|
+
|
|
29
|
+
# Jupyter
|
|
30
|
+
.ipynb_checkpoints
|
|
31
|
+
*.ipynb_checkpoints/
|
|
32
|
+
|
|
33
|
+
# IDEs
|
|
34
|
+
.vscode/
|
|
35
|
+
.idea/
|
|
36
|
+
*.swp
|
|
37
|
+
*.swo
|
|
38
|
+
*~
|
|
39
|
+
|
|
40
|
+
# OS
|
|
41
|
+
Thumbs.db
|
|
42
|
+
|
|
43
|
+
# Coverage
|
|
44
|
+
.coverage
|
|
45
|
+
.coverage.*
|
|
46
|
+
htmlcov/
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
.pytest_cache/
|
|
50
|
+
.ruff_cache/
|
|
51
|
+
.mypy_cache/
|
|
52
|
+
|
|
53
|
+
# Hypothesis
|
|
54
|
+
.hypothesis/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Gaussia Labs
|
|
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.
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyboltzmann
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: An SDK for the Boltzmann Protocol: portable, verifiable, model-agnostic knowledge
|
|
5
|
+
Project-URL: Homepage, https://github.com/gaussia-labs/pyboltzmann
|
|
6
|
+
Project-URL: Repository, https://github.com/gaussia-labs/pyboltzmann.git
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/gaussia-labs/pyboltzmann/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/gaussia-labs/pyboltzmann/releases
|
|
9
|
+
Author: Gaussia Labs
|
|
10
|
+
Maintainer-email: Alex Fiorenza <alexfiorenza2012@gmail.com>
|
|
11
|
+
License: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: content-addressing,knowledge-representation,llm,memory-systems,merkle-dag,oci-artifacts,protocol,provenance,retrieval-augmented-generation
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.11
|
|
27
|
+
Requires-Dist: pydantic<3.0.0,>=2.0.0
|
|
28
|
+
Requires-Dist: rfc8785>=0.1.4
|
|
29
|
+
Provides-Extra: oci
|
|
30
|
+
Requires-Dist: oras>=0.2.42; extra == 'oci'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# pyboltzmann
|
|
34
|
+
|
|
35
|
+
An SDK for the **Boltzmann Protocol**: portable, verifiable, model-agnostic knowledge.
|
|
36
|
+
|
|
37
|
+
> *The brain conserves, validates, and retrieves knowledge. An external LLM
|
|
38
|
+
> processes, contextualizes, and uses it.*
|
|
39
|
+
|
|
40
|
+
Reference: [*Boltzmann Brain: A Versioned, Distributable, and Model-Agnostic
|
|
41
|
+
Knowledge Architecture*](https://github.com/gaussia-labs/papers) (Gaussia, 2026).
|
|
42
|
+
|
|
43
|
+
## What this is
|
|
44
|
+
|
|
45
|
+
A **client** for a Boltzmann brain. You open a directory, call methods, and they
|
|
46
|
+
work against an OCI artifact. `Brain` implements the whole protocol — 23 of 23
|
|
47
|
+
operations across the four contracts.
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
brain = Brain.open("./my-brain", actor=alex)
|
|
51
|
+
brain.ingest(pdf, request, my_llm) # register → delegate → validate → commit
|
|
52
|
+
brain.search(Query(text="Fourier")) # filter, resolve, verify
|
|
53
|
+
brain.drop(DropRequest(...)) # rebuild the Merkle DAG, cascade, record
|
|
54
|
+
await brain.push(client, "ghcr.io/org/brain", "v1")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The line it draws: **the SDK does whatever the protocol defines mechanically; the
|
|
58
|
+
implementer supplies whatever the paper assigns elsewhere.** So identity, the wire
|
|
59
|
+
formats, the four operation paths and a conformance suite are here; the model, the
|
|
60
|
+
ranking, the index engines and any CLI or MCP server are yours.
|
|
61
|
+
|
|
62
|
+
It embeds no language model. Interpretation enters through `CandidateProposer` and
|
|
63
|
+
nowhere else.
|
|
64
|
+
|
|
65
|
+
There are **no `NotImplementedError` stubs**, and a test enforces it. An
|
|
66
|
+
unimplemented function is worse than an interface: it looks callable and is not.
|
|
67
|
+
Nothing is declared and unreachable either — every type, enum member and constant
|
|
68
|
+
is produced by something, and a test enforces that too.
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pip install pyboltzmann # the distribution
|
|
74
|
+
pip install 'pyboltzmann[oci]' # plus the network registry transport
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
import boltzmann # the import package
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The two names differ because `boltzmann` on PyPI belongs to an unrelated package. It is the same split as
|
|
82
|
+
`pygaussia` providing `gaussia`.
|
|
83
|
+
|
|
84
|
+
The core needs **`pydantic` and `rfc8785`**. Everything else is optional: `[oci]`
|
|
85
|
+
adds a network registry transport, and moving a brain between OCI layouts on disk
|
|
86
|
+
needs nothing at all.
|
|
87
|
+
|
|
88
|
+
Python >= 3.11.
|
|
89
|
+
|
|
90
|
+
## Usage
|
|
91
|
+
|
|
92
|
+
The whole lifecycle of Section 11, against a real OCI layout:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from boltzmann import Actor, Brain, MemoryType, Producer, Query
|
|
96
|
+
from boltzmann.blocks import ActorKind, ProducerKind
|
|
97
|
+
from boltzmann.ingest import Candidate, CandidateSet, RegistrationRequest
|
|
98
|
+
|
|
99
|
+
alex = Actor(id="alex", kind=ActorKind.HUMAN)
|
|
100
|
+
brain = Brain.open("./my-brain", actor=alex)
|
|
101
|
+
|
|
102
|
+
# You supply the model. The SDK embeds none: what knowledge a source yields is its
|
|
103
|
+
# judgment, and what gets stored is the protocol's.
|
|
104
|
+
def my_llm(task, source):
|
|
105
|
+
# task.output_schema names the schema; brain.candidates_schema(task) *is* it, with the
|
|
106
|
+
# payload resolved per memory type. Hand it to the model as structured output.
|
|
107
|
+
return CandidateSet(
|
|
108
|
+
producer=Producer(kind=ProducerKind.MODEL, id="claude-opus-5", version="2026-07"),
|
|
109
|
+
candidates=[
|
|
110
|
+
Candidate(
|
|
111
|
+
memory_type=MemoryType.SEMANTIC,
|
|
112
|
+
evidence=[task.source],
|
|
113
|
+
locator="p.147",
|
|
114
|
+
payload={
|
|
115
|
+
"kind": "formula",
|
|
116
|
+
"label": "Fourier series",
|
|
117
|
+
"statement": "decomposes a periodic function into sines",
|
|
118
|
+
"subject": "signals",
|
|
119
|
+
},
|
|
120
|
+
)
|
|
121
|
+
],
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
request = RegistrationRequest(media_type="application/pdf", actor=alex, license="CC-BY-4.0")
|
|
125
|
+
pdf = b"%PDF-1.7 lecture 07: Fourier analysis"
|
|
126
|
+
|
|
127
|
+
# Register, delegate, validate, commit. Registering the same source twice is a no-op.
|
|
128
|
+
commit = brain.ingest(pdf, request, my_llm)
|
|
129
|
+
|
|
130
|
+
# Data with its provenance, never prose, every match verified against the snapshot.
|
|
131
|
+
bundle = brain.search(Query(text="periodic function"))
|
|
132
|
+
assert bundle.all_verified
|
|
133
|
+
assert bundle.matches[0].sources[0].locator == "p.147"
|
|
134
|
+
|
|
135
|
+
# Membership is provable in O(log n), without holding the rest of the module.
|
|
136
|
+
block_id = commit.committed[0]
|
|
137
|
+
assert brain.prove(block_id, MemoryType.SEMANTIC).verify(brain.root_of(MemoryType.SEMANTIC))
|
|
138
|
+
assert brain.verify()
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Removing knowledge cascades through provenance, publishing is a copy rather than a
|
|
142
|
+
conversion, and an implementation in any language can prove it conforms against the
|
|
143
|
+
golden vectors that ship in the wheel. Each of those has a guide.
|
|
144
|
+
|
|
145
|
+
## Documentation
|
|
146
|
+
|
|
147
|
+
The [`docs/`](https://github.com/gaussia-labs/pyboltzmann/tree/master/docs) directory
|
|
148
|
+
is the source of truth, and it is published as the Boltzmann SDK section of the
|
|
149
|
+
[Gaussia docs](https://github.com/gaussia-labs/docs).
|
|
150
|
+
|
|
151
|
+
<!-- Absolute URLs: this file is also the PyPI long description, where a relative link
|
|
152
|
+
resolves against pypi.org and 404s. -->
|
|
153
|
+
|
|
154
|
+
| | |
|
|
155
|
+
|---|---|
|
|
156
|
+
| [Quickstart](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/quickstart.mdx) | Ingest, query, prove, publish, remove — in one file |
|
|
157
|
+
| [Architecture](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/concepts/architecture.mdx) | Blocks, compositions, modules, snapshots |
|
|
158
|
+
| [Memory types](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/concepts/memory-types.mdx) | The five typed blocks and the rules each obeys |
|
|
159
|
+
| [Identity](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/concepts/identity.mdx) | JCS, the three levels of hashes, the values a payload refuses |
|
|
160
|
+
| [Merkle DAGs](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/concepts/merkle.mdx) | RFC 6962 over sorted leaves, and inclusion proofs |
|
|
161
|
+
| [Interfaces](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/concepts/interfaces.mdx) | The protocol surface, and the four things you plug in |
|
|
162
|
+
| [Ingestion](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/guides/ingestion.mdx) | Preserve the source, delegate the interpretation, validate |
|
|
163
|
+
| [Query](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/guides/query.mdx) | Evidence Bundles, filters, and supplying a planner |
|
|
164
|
+
| [Retention](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/guides/retention.mdx) | Drop, supersede, demote, prune, redact |
|
|
165
|
+
| [Distribution](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/guides/distribution.mdx) | Pack, push, pull, and selective installs |
|
|
166
|
+
| [Conformance](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/guides/conformance.mdx) | Golden vectors, and the suites you inherit |
|
|
167
|
+
|
|
168
|
+
## Development
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
uv sync
|
|
172
|
+
uv run pre-commit install && uv run pre-commit install --hook-type commit-msg
|
|
173
|
+
|
|
174
|
+
uv run ruff check . && uv run ruff format .
|
|
175
|
+
uv run mypy src
|
|
176
|
+
uv run pytest
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Commits follow [Conventional Commits](https://www.conventionalcommits.org/) — use
|
|
180
|
+
`uv run cz commit` for the interactive prompt. Releases are cut by
|
|
181
|
+
`python-semantic-release` from the commit history.
|
|
182
|
+
|
|
183
|
+
## License
|
|
184
|
+
|
|
185
|
+
MIT — see [LICENSE](https://github.com/gaussia-labs/pyboltzmann/blob/master/LICENSE).
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# pyboltzmann
|
|
2
|
+
|
|
3
|
+
An SDK for the **Boltzmann Protocol**: portable, verifiable, model-agnostic knowledge.
|
|
4
|
+
|
|
5
|
+
> *The brain conserves, validates, and retrieves knowledge. An external LLM
|
|
6
|
+
> processes, contextualizes, and uses it.*
|
|
7
|
+
|
|
8
|
+
Reference: [*Boltzmann Brain: A Versioned, Distributable, and Model-Agnostic
|
|
9
|
+
Knowledge Architecture*](https://github.com/gaussia-labs/papers) (Gaussia, 2026).
|
|
10
|
+
|
|
11
|
+
## What this is
|
|
12
|
+
|
|
13
|
+
A **client** for a Boltzmann brain. You open a directory, call methods, and they
|
|
14
|
+
work against an OCI artifact. `Brain` implements the whole protocol — 23 of 23
|
|
15
|
+
operations across the four contracts.
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
brain = Brain.open("./my-brain", actor=alex)
|
|
19
|
+
brain.ingest(pdf, request, my_llm) # register → delegate → validate → commit
|
|
20
|
+
brain.search(Query(text="Fourier")) # filter, resolve, verify
|
|
21
|
+
brain.drop(DropRequest(...)) # rebuild the Merkle DAG, cascade, record
|
|
22
|
+
await brain.push(client, "ghcr.io/org/brain", "v1")
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The line it draws: **the SDK does whatever the protocol defines mechanically; the
|
|
26
|
+
implementer supplies whatever the paper assigns elsewhere.** So identity, the wire
|
|
27
|
+
formats, the four operation paths and a conformance suite are here; the model, the
|
|
28
|
+
ranking, the index engines and any CLI or MCP server are yours.
|
|
29
|
+
|
|
30
|
+
It embeds no language model. Interpretation enters through `CandidateProposer` and
|
|
31
|
+
nowhere else.
|
|
32
|
+
|
|
33
|
+
There are **no `NotImplementedError` stubs**, and a test enforces it. An
|
|
34
|
+
unimplemented function is worse than an interface: it looks callable and is not.
|
|
35
|
+
Nothing is declared and unreachable either — every type, enum member and constant
|
|
36
|
+
is produced by something, and a test enforces that too.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install pyboltzmann # the distribution
|
|
42
|
+
pip install 'pyboltzmann[oci]' # plus the network registry transport
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
import boltzmann # the import package
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The two names differ because `boltzmann` on PyPI belongs to an unrelated package. It is the same split as
|
|
50
|
+
`pygaussia` providing `gaussia`.
|
|
51
|
+
|
|
52
|
+
The core needs **`pydantic` and `rfc8785`**. Everything else is optional: `[oci]`
|
|
53
|
+
adds a network registry transport, and moving a brain between OCI layouts on disk
|
|
54
|
+
needs nothing at all.
|
|
55
|
+
|
|
56
|
+
Python >= 3.11.
|
|
57
|
+
|
|
58
|
+
## Usage
|
|
59
|
+
|
|
60
|
+
The whole lifecycle of Section 11, against a real OCI layout:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from boltzmann import Actor, Brain, MemoryType, Producer, Query
|
|
64
|
+
from boltzmann.blocks import ActorKind, ProducerKind
|
|
65
|
+
from boltzmann.ingest import Candidate, CandidateSet, RegistrationRequest
|
|
66
|
+
|
|
67
|
+
alex = Actor(id="alex", kind=ActorKind.HUMAN)
|
|
68
|
+
brain = Brain.open("./my-brain", actor=alex)
|
|
69
|
+
|
|
70
|
+
# You supply the model. The SDK embeds none: what knowledge a source yields is its
|
|
71
|
+
# judgment, and what gets stored is the protocol's.
|
|
72
|
+
def my_llm(task, source):
|
|
73
|
+
# task.output_schema names the schema; brain.candidates_schema(task) *is* it, with the
|
|
74
|
+
# payload resolved per memory type. Hand it to the model as structured output.
|
|
75
|
+
return CandidateSet(
|
|
76
|
+
producer=Producer(kind=ProducerKind.MODEL, id="claude-opus-5", version="2026-07"),
|
|
77
|
+
candidates=[
|
|
78
|
+
Candidate(
|
|
79
|
+
memory_type=MemoryType.SEMANTIC,
|
|
80
|
+
evidence=[task.source],
|
|
81
|
+
locator="p.147",
|
|
82
|
+
payload={
|
|
83
|
+
"kind": "formula",
|
|
84
|
+
"label": "Fourier series",
|
|
85
|
+
"statement": "decomposes a periodic function into sines",
|
|
86
|
+
"subject": "signals",
|
|
87
|
+
},
|
|
88
|
+
)
|
|
89
|
+
],
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
request = RegistrationRequest(media_type="application/pdf", actor=alex, license="CC-BY-4.0")
|
|
93
|
+
pdf = b"%PDF-1.7 lecture 07: Fourier analysis"
|
|
94
|
+
|
|
95
|
+
# Register, delegate, validate, commit. Registering the same source twice is a no-op.
|
|
96
|
+
commit = brain.ingest(pdf, request, my_llm)
|
|
97
|
+
|
|
98
|
+
# Data with its provenance, never prose, every match verified against the snapshot.
|
|
99
|
+
bundle = brain.search(Query(text="periodic function"))
|
|
100
|
+
assert bundle.all_verified
|
|
101
|
+
assert bundle.matches[0].sources[0].locator == "p.147"
|
|
102
|
+
|
|
103
|
+
# Membership is provable in O(log n), without holding the rest of the module.
|
|
104
|
+
block_id = commit.committed[0]
|
|
105
|
+
assert brain.prove(block_id, MemoryType.SEMANTIC).verify(brain.root_of(MemoryType.SEMANTIC))
|
|
106
|
+
assert brain.verify()
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Removing knowledge cascades through provenance, publishing is a copy rather than a
|
|
110
|
+
conversion, and an implementation in any language can prove it conforms against the
|
|
111
|
+
golden vectors that ship in the wheel. Each of those has a guide.
|
|
112
|
+
|
|
113
|
+
## Documentation
|
|
114
|
+
|
|
115
|
+
The [`docs/`](https://github.com/gaussia-labs/pyboltzmann/tree/master/docs) directory
|
|
116
|
+
is the source of truth, and it is published as the Boltzmann SDK section of the
|
|
117
|
+
[Gaussia docs](https://github.com/gaussia-labs/docs).
|
|
118
|
+
|
|
119
|
+
<!-- Absolute URLs: this file is also the PyPI long description, where a relative link
|
|
120
|
+
resolves against pypi.org and 404s. -->
|
|
121
|
+
|
|
122
|
+
| | |
|
|
123
|
+
|---|---|
|
|
124
|
+
| [Quickstart](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/quickstart.mdx) | Ingest, query, prove, publish, remove — in one file |
|
|
125
|
+
| [Architecture](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/concepts/architecture.mdx) | Blocks, compositions, modules, snapshots |
|
|
126
|
+
| [Memory types](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/concepts/memory-types.mdx) | The five typed blocks and the rules each obeys |
|
|
127
|
+
| [Identity](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/concepts/identity.mdx) | JCS, the three levels of hashes, the values a payload refuses |
|
|
128
|
+
| [Merkle DAGs](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/concepts/merkle.mdx) | RFC 6962 over sorted leaves, and inclusion proofs |
|
|
129
|
+
| [Interfaces](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/concepts/interfaces.mdx) | The protocol surface, and the four things you plug in |
|
|
130
|
+
| [Ingestion](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/guides/ingestion.mdx) | Preserve the source, delegate the interpretation, validate |
|
|
131
|
+
| [Query](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/guides/query.mdx) | Evidence Bundles, filters, and supplying a planner |
|
|
132
|
+
| [Retention](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/guides/retention.mdx) | Drop, supersede, demote, prune, redact |
|
|
133
|
+
| [Distribution](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/guides/distribution.mdx) | Pack, push, pull, and selective installs |
|
|
134
|
+
| [Conformance](https://github.com/gaussia-labs/pyboltzmann/blob/master/docs/guides/conformance.mdx) | Golden vectors, and the suites you inherit |
|
|
135
|
+
|
|
136
|
+
## Development
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
uv sync
|
|
140
|
+
uv run pre-commit install && uv run pre-commit install --hook-type commit-msg
|
|
141
|
+
|
|
142
|
+
uv run ruff check . && uv run ruff format .
|
|
143
|
+
uv run mypy src
|
|
144
|
+
uv run pytest
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Commits follow [Conventional Commits](https://www.conventionalcommits.org/) — use
|
|
148
|
+
`uv run cz commit` for the interactive prompt. Releases are cut by
|
|
149
|
+
`python-semantic-release` from the commit history.
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
MIT — see [LICENSE](https://github.com/gaussia-labs/pyboltzmann/blob/master/LICENSE).
|