chronomemory 0.1.2__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.
- chronomemory-0.1.2/COMMERCIAL-LICENSE.md +55 -0
- chronomemory-0.1.2/LICENSE +56 -0
- chronomemory-0.1.2/PKG-INFO +395 -0
- chronomemory-0.1.2/README.md +353 -0
- chronomemory-0.1.2/pyproject.toml +132 -0
- chronomemory-0.1.2/setup.cfg +4 -0
- chronomemory-0.1.2/src/chronomemory/__init__.py +94 -0
- chronomemory-0.1.2/src/chronomemory/bridge.py +249 -0
- chronomemory-0.1.2/src/chronomemory/context_pack.py +214 -0
- chronomemory-0.1.2/src/chronomemory/deps.py +272 -0
- chronomemory-0.1.2/src/chronomemory/metrics.py +170 -0
- chronomemory-0.1.2/src/chronomemory/py.typed +1 -0
- chronomemory-0.1.2/src/chronomemory/query.py +306 -0
- chronomemory-0.1.2/src/chronomemory/rollback.py +171 -0
- chronomemory-0.1.2/src/chronomemory/store.py +706 -0
- chronomemory-0.1.2/src/chronomemory.egg-info/PKG-INFO +395 -0
- chronomemory-0.1.2/src/chronomemory.egg-info/SOURCES.txt +30 -0
- chronomemory-0.1.2/src/chronomemory.egg-info/dependency_links.txt +1 -0
- chronomemory-0.1.2/src/chronomemory.egg-info/requires.txt +15 -0
- chronomemory-0.1.2/src/chronomemory.egg-info/top_level.txt +1 -0
- chronomemory-0.1.2/tests/test_bridge.py +303 -0
- chronomemory-0.1.2/tests/test_context_pack.py +105 -0
- chronomemory-0.1.2/tests/test_cross_compat.py +244 -0
- chronomemory-0.1.2/tests/test_deps.py +169 -0
- chronomemory-0.1.2/tests/test_metrics.py +155 -0
- chronomemory-0.1.2/tests/test_oea.py +121 -0
- chronomemory-0.1.2/tests/test_query.py +105 -0
- chronomemory-0.1.2/tests/test_query_ext.py +385 -0
- chronomemory-0.1.2/tests/test_robustness.py +1007 -0
- chronomemory-0.1.2/tests/test_rollback.py +149 -0
- chronomemory-0.1.2/tests/test_store.py +186 -0
- chronomemory-0.1.2/tests/test_wal_chain.py +175 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# chronomemory — Commercial License Summary
|
|
2
|
+
|
|
3
|
+
**chronomemory** is the Epistemic State Database (ESDB) engine for agentic AI
|
|
4
|
+
workflows. It is **proprietary software** — see [LICENSE](LICENSE) for the
|
|
5
|
+
full legal terms.
|
|
6
|
+
|
|
7
|
+
## Who needs a license?
|
|
8
|
+
|
|
9
|
+
Anyone who installs or uses chronomemory in any context, including:
|
|
10
|
+
|
|
11
|
+
- Installing via `pip install specsmith[esdb]`
|
|
12
|
+
- Importing `chronomemory` or `specsmith.esdb` (ChronoStore backend) in code
|
|
13
|
+
- Running `specsmith esdb migrate` or `specsmith esdb status` while ChronoStore is active
|
|
14
|
+
|
|
15
|
+
The **free SQLite backend** bundled in specsmith does **not** require a license.
|
|
16
|
+
|
|
17
|
+
## What the license covers
|
|
18
|
+
|
|
19
|
+
A standard commercial license grants:
|
|
20
|
+
|
|
21
|
+
- Use of the Software within your organisation (single tenant)
|
|
22
|
+
- Integration with specsmith via the `specsmith[esdb]` extra
|
|
23
|
+
- Access to patch and minor version updates for the licensed version series
|
|
24
|
+
- Email support from Layer1Labs
|
|
25
|
+
|
|
26
|
+
## What requires a separate negotiated agreement
|
|
27
|
+
|
|
28
|
+
- Multi-tenant SaaS or cloud service deployments
|
|
29
|
+
- OEM / redistribution inside another product
|
|
30
|
+
- White-label or source-code access agreements
|
|
31
|
+
|
|
32
|
+
## How to obtain a license
|
|
33
|
+
|
|
34
|
+
1. Email **licensing@layer1labs.com** with your organisation name and intended use.
|
|
35
|
+
2. We will send a signed `.esdb.key` license file.
|
|
36
|
+
3. Activate it: `specsmith esdb enable --key-file /path/to/your.esdb.key`
|
|
37
|
+
|
|
38
|
+
## Activation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Install the ESDB backend (requires accepted license)
|
|
42
|
+
pip install specsmith[esdb]
|
|
43
|
+
|
|
44
|
+
# Activate your license
|
|
45
|
+
specsmith esdb enable --key-file /path/to/your.esdb.key
|
|
46
|
+
|
|
47
|
+
# Confirm ChronoStore is active
|
|
48
|
+
specsmith esdb status
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Contact
|
|
52
|
+
|
|
53
|
+
- **Licensing**: licensing@layer1labs.com
|
|
54
|
+
- **Support**: support@layer1labs.com
|
|
55
|
+
- **Website**: https://layer1labs.com/esdb-licensing
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
PROPRIETARY SOFTWARE LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Layer1Labs Silicon, Inc. and BitConcepts, LLC.
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
This software and all associated files (the "Software") are the proprietary
|
|
7
|
+
and confidential information of Layer1Labs Silicon, Inc. and BitConcepts, LLC.
|
|
8
|
+
|
|
9
|
+
LICENSE GRANT
|
|
10
|
+
|
|
11
|
+
A limited, non-exclusive, non-transferable license to use the Software is
|
|
12
|
+
granted ONLY to parties who have received written permission from Layer1Labs
|
|
13
|
+
Silicon, Inc. or BitConcepts, LLC. (collectively, the "Licensor").
|
|
14
|
+
|
|
15
|
+
PROHIBITED ACTIONS
|
|
16
|
+
|
|
17
|
+
Without prior written permission from the Licensor, you may NOT:
|
|
18
|
+
|
|
19
|
+
1. Copy, reproduce, or distribute the Software or any portion thereof.
|
|
20
|
+
2. Modify, adapt, translate, or create derivative works of the Software.
|
|
21
|
+
3. Reverse engineer, disassemble, or decompile the Software.
|
|
22
|
+
4. Sublicense, rent, lease, or lend the Software to any third party.
|
|
23
|
+
5. Use the Software in any product or service offered commercially without
|
|
24
|
+
a separate commercial license agreement with the Licensor.
|
|
25
|
+
6. Upload or publish the Software to any public package registry (including
|
|
26
|
+
PyPI, crates.io, npm, or equivalent) without explicit written consent.
|
|
27
|
+
|
|
28
|
+
LICENSE ACQUISITION
|
|
29
|
+
|
|
30
|
+
To obtain a license to use the Software, contact:
|
|
31
|
+
|
|
32
|
+
licensing@layer1labs.com
|
|
33
|
+
https://layer1labs.com/esdb-licensing
|
|
34
|
+
|
|
35
|
+
COMPATIBILITY WITH specsmith
|
|
36
|
+
|
|
37
|
+
The specsmith CLI (https://github.com/layer1labs/specsmith, MIT License)
|
|
38
|
+
may reference this Software as an optional commercial dependency under the
|
|
39
|
+
"specsmith[esdb]" extra. Installing specsmith[esdb] requires acceptance of
|
|
40
|
+
this license in addition to the specsmith MIT license. The specsmith CLI
|
|
41
|
+
installs and integrates this Software only after a valid license key has been
|
|
42
|
+
activated via "specsmith esdb enable".
|
|
43
|
+
|
|
44
|
+
DISCLAIMER
|
|
45
|
+
|
|
46
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
47
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
48
|
+
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
|
49
|
+
THE LICENSOR BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER
|
|
50
|
+
IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN
|
|
51
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
52
|
+
|
|
53
|
+
GOVERNING LAW
|
|
54
|
+
|
|
55
|
+
This license shall be governed by the laws of the State of Delaware, United
|
|
56
|
+
States, without regard to conflict-of-law principles.
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: chronomemory
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Epistemic State Database — tamper-evident WAL-based persistence for agentic AI workflows.
|
|
5
|
+
Author: Layer1Labs Silicon, Inc., BitConcepts, LLC.
|
|
6
|
+
License-Expression: LicenseRef-Proprietary
|
|
7
|
+
Project-URL: Homepage, https://github.com/layer1labs/chronomemory
|
|
8
|
+
Project-URL: Repository, https://github.com/layer1labs/chronomemory
|
|
9
|
+
Project-URL: Issues, https://github.com/layer1labs/chronomemory/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/layer1labs/chronomemory/blob/main/CHANGELOG.md
|
|
11
|
+
Project-URL: Licensing, https://layer1labs.com/esdb-licensing
|
|
12
|
+
Keywords: esdb,epistemic-ai,agent-memory,wal,cpsc,constraint-topology,agentic-ai,chronomemory,anti-hallucination,oea,epistemic-state-database,layer1labs
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Classifier: Topic :: Database
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
License-File: COMMERCIAL-LICENSE.md
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
31
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
32
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
33
|
+
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
34
|
+
Requires-Dist: pre-commit>=3.0; extra == "dev"
|
|
35
|
+
Provides-Extra: rust
|
|
36
|
+
Requires-Dist: maturin>=1.4; extra == "rust"
|
|
37
|
+
Provides-Extra: docs
|
|
38
|
+
Requires-Dist: mkdocs>=1.6; extra == "docs"
|
|
39
|
+
Requires-Dist: mkdocs-material>=9.5; extra == "docs"
|
|
40
|
+
Requires-Dist: pymdown-extensions>=10.0; extra == "docs"
|
|
41
|
+
Dynamic: license-file
|
|
42
|
+
|
|
43
|
+
# chronomemory
|
|
44
|
+
|
|
45
|
+
**Epistemic State Database (ESDB) for agentic AI workflows.**
|
|
46
|
+
|
|
47
|
+
[](https://github.com/layer1labs/chronomemory)
|
|
48
|
+
[](https://www.python.org)
|
|
49
|
+
[](LICENSE)
|
|
50
|
+
[](https://pypi.org/project/chronomemory/)
|
|
51
|
+
[](pyproject.toml)
|
|
52
|
+
[](tests/)
|
|
53
|
+
[](https://chronomemory.readthedocs.io)
|
|
54
|
+
[](https://specsmith.readthedocs.io/esdb)
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Why chronomemory?
|
|
59
|
+
|
|
60
|
+
Traditional databases store **facts**. Agentic AI systems produce **beliefs** — and beliefs have properties that facts do not:
|
|
61
|
+
|
|
62
|
+
- **Provenance** — was this observed by a sensor, inferred by logic, or hallucinated by an LLM?
|
|
63
|
+
- **Confidence** — how strongly is this held? Is it safe to inject into RAG context?
|
|
64
|
+
- **Recursion depth** — was this produced by an agent acting on another agent's output?
|
|
65
|
+
- **Tamper-evidence** — if someone edits a past belief to hide a mistake, will you know?
|
|
66
|
+
|
|
67
|
+
chronomemory makes these properties **mandatory on every record** and uses a SHA-256 hash chain to make every past write tamper-evident.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 30-second example
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from chronomemory import ChronoStore, ChronoRecord
|
|
75
|
+
|
|
76
|
+
with ChronoStore("/path/to/project") as store:
|
|
77
|
+
|
|
78
|
+
# Write a benchmark result with full epistemic provenance
|
|
79
|
+
store.upsert(ChronoRecord(
|
|
80
|
+
id="bench-A-seed42",
|
|
81
|
+
kind="fact",
|
|
82
|
+
label="CTT achieves 0% invalid rollout rate on DoorKey-5x5",
|
|
83
|
+
source_type="observed", # H19 — was this measured or inferred?
|
|
84
|
+
confidence=1.0, # H17 — degree of belief (0.0–1.0)
|
|
85
|
+
evidence=["seed=42", "epoch=50", "model=CTTStateNet"], # H20
|
|
86
|
+
epistemic_boundary=["model:CTTStateNet-v1", "dataset:DoorKey-5x5"], # H15
|
|
87
|
+
data={"invalid_rate": 0.0, "nll_bits": 0.312},
|
|
88
|
+
))
|
|
89
|
+
|
|
90
|
+
# Confidence-filtered RAG query — H18 enforced
|
|
91
|
+
context = store.query(rag_filter=True) # confidence >= 0.6 only
|
|
92
|
+
|
|
93
|
+
# Tamper detection
|
|
94
|
+
assert store.chain_valid() # False if any past event was modified
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Installation
|
|
100
|
+
|
|
101
|
+
> **License:** chronomemory is **proprietary software** requiring a commercial license.
|
|
102
|
+
> Contact [licensing@layer1labs.com](mailto:licensing@layer1labs.com) or visit
|
|
103
|
+
> [layer1labs.com/esdb-licensing](https://layer1labs.com/esdb-licensing).
|
|
104
|
+
> If you are a specsmith user, install via `specsmith[esdb]` — see
|
|
105
|
+
> [specsmith ESDB docs](https://specsmith.readthedocs.io/esdb).
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# From PyPI
|
|
109
|
+
pip install chronomemory
|
|
110
|
+
|
|
111
|
+
# Or editable from source
|
|
112
|
+
git clone https://github.com/layer1labs/chronomemory.git
|
|
113
|
+
pip install -e chronomemory
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Add to `pyproject.toml`:
|
|
117
|
+
```toml
|
|
118
|
+
dependencies = [
|
|
119
|
+
"chronomemory>=0.1.2",
|
|
120
|
+
]
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Zero runtime dependencies** — pure Python stdlib (`hashlib`, `json`, `os`, `shutil`, `pathlib`).
|
|
124
|
+
|
|
125
|
+
### Using with specsmith
|
|
126
|
+
|
|
127
|
+
specsmith users get chronomemory via the `[esdb]` extra:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
pip install "specsmith[esdb]" # installs chronomemory from PyPI
|
|
131
|
+
specsmith esdb enable --key-file your.esdb.key
|
|
132
|
+
specsmith esdb status # confirms ChronoStore is active
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Full walkthrough: [specsmith ESDB documentation](https://specsmith.readthedocs.io/esdb)
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## OEA anti-hallucination fields
|
|
140
|
+
|
|
141
|
+
Every `ChronoRecord` carries 7 mandatory OEA (Ontological Epistemic Anchoring) fields. Safe defaults apply when omitted.
|
|
142
|
+
|
|
143
|
+
| Field | Rule | Default | Description |
|
|
144
|
+
|-------|------|---------|-------------|
|
|
145
|
+
| `source_type` | H19 | `"observed"` | `observed` \| `inferred` \| `hypothesis` \| `synthetic` |
|
|
146
|
+
| `confidence` | H17 | `0.7` | Float 0.0–1.0. RAG threshold: `>= 0.6` |
|
|
147
|
+
| `evidence` | H20 | `[]` | Source references (doc IDs, URLs, experiment IDs) |
|
|
148
|
+
| `epistemic_boundary` | H15 | `[]` | Scope constraints on validity |
|
|
149
|
+
| `is_hypothesis` | H20 | `False` | True = tentative, untested belief |
|
|
150
|
+
| `model_assumptions` | H21 | `{}` | `{provider, model, temperature, context_window}` |
|
|
151
|
+
| `recursion_depth` | H16 | `0` | 0 = human; N = agent chain depth |
|
|
152
|
+
|
|
153
|
+
`query(rag_filter=True)` returns only records with `confidence >= 0.6` AND `status == "active"` (H18).
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Core API
|
|
158
|
+
|
|
159
|
+
### ChronoStore
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
from chronomemory import ChronoStore, ChronoRecord
|
|
163
|
+
|
|
164
|
+
# Context manager (recommended)
|
|
165
|
+
with ChronoStore("/path/to/project", recursion_depth=0) as store:
|
|
166
|
+
...
|
|
167
|
+
|
|
168
|
+
# Manual lifecycle
|
|
169
|
+
store = ChronoStore(project)
|
|
170
|
+
store.open()
|
|
171
|
+
store.upsert(record) # write to WAL
|
|
172
|
+
records = store.query() # read from memory
|
|
173
|
+
store.delete("FACT-001") # tombstone (never physical deletion)
|
|
174
|
+
assert store.chain_valid() # verify SHA-256 chain
|
|
175
|
+
store.compact() # truncate WAL → snapshot + 1 sentinel
|
|
176
|
+
store.close()
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**All query parameters:**
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
store.query(
|
|
183
|
+
kind="fact", # filter by kind (None = all)
|
|
184
|
+
status="active", # "active" | "deprecated" | "tombstone" | "" (all)
|
|
185
|
+
rag_filter=True, # H18: confidence >= 0.6 only
|
|
186
|
+
min_confidence=0.9, # custom threshold (takes max with rag_filter)
|
|
187
|
+
)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### ChronoRecord kinds
|
|
191
|
+
|
|
192
|
+
`fact` · `hypothesis` · `requirement` · `testcase` · `decision` · `risk`
|
|
193
|
+
|
|
194
|
+
### EsdbBridge
|
|
195
|
+
|
|
196
|
+
Unified adapter: delegates to `ChronoStore` when `.chronomemory/events.wal` exists; falls back to `.specsmith/*.json` for uninitialized projects.
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
from chronomemory import EsdbBridge
|
|
200
|
+
|
|
201
|
+
bridge = EsdbBridge(project_dir=".")
|
|
202
|
+
print(bridge.status().to_dict()) # backend, record_count, chain_valid, wal_seq
|
|
203
|
+
reqs = bridge.requirements() # list[EsdbRecord]
|
|
204
|
+
tests = bridge.testcases() # list[EsdbRecord]
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Where data lives
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
<project_root>/
|
|
213
|
+
.chronomemory/
|
|
214
|
+
events.wal ← append-only NDJSON, SHA-256 chained
|
|
215
|
+
snapshot.json ← materialized state (every 50 events)
|
|
216
|
+
backup/
|
|
217
|
+
20260518T170000/ ← timestamped backup
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
The WAL is NDJSON — human-readable, grep-able, diff-able, no special tooling needed:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
cat .chronomemory/events.wal | python -m json.tool
|
|
224
|
+
grep '"op": "upsert"' .chronomemory/events.wal | wc -l
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Migration from .specsmith/ JSON
|
|
230
|
+
|
|
231
|
+
Projects using specsmith store requirements and test cases as flat JSON. Migrate to ESDB to gain OEA fields and tamper-evidence:
|
|
232
|
+
|
|
233
|
+
```python
|
|
234
|
+
from chronomemory import ChronoStore
|
|
235
|
+
from pathlib import Path
|
|
236
|
+
|
|
237
|
+
with ChronoStore("." ) as store:
|
|
238
|
+
counts = store.migrate_from_json(Path(".specsmith"))
|
|
239
|
+
print(counts) # {'requirements': 12, 'testcases': 10, 'skipped': 0}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Or: `specsmith esdb migrate` (requires specsmith ≥ 0.11.3)
|
|
243
|
+
|
|
244
|
+
**Import map:**
|
|
245
|
+
```
|
|
246
|
+
# Before (specsmith vendored)
|
|
247
|
+
from specsmith.esdb.store import ChronoStore, ChronoRecord
|
|
248
|
+
from specsmith.esdb.bridge import EsdbBridge
|
|
249
|
+
|
|
250
|
+
# After (standalone)
|
|
251
|
+
from chronomemory import ChronoStore, ChronoRecord, EsdbBridge
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
WAL format is identical — existing `.chronomemory/events.wal` files are fully compatible.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Integration
|
|
259
|
+
|
|
260
|
+
### chronoagent — memory write gate + RAG source
|
|
261
|
+
|
|
262
|
+
```python
|
|
263
|
+
# chronoagent/memory/store.py
|
|
264
|
+
from chronomemory import ChronoStore, ChronoRecord
|
|
265
|
+
|
|
266
|
+
class AgentMemoryStore:
|
|
267
|
+
def __init__(self, project_root: str, agent_depth: int = 1):
|
|
268
|
+
self._store = ChronoStore(project_root, recursion_depth=agent_depth)
|
|
269
|
+
self._store.open()
|
|
270
|
+
|
|
271
|
+
def write_belief(self, content: str, confidence: float = 0.7, evidence=None) -> str:
|
|
272
|
+
"""Called by memory_write_gate after gate passes."""
|
|
273
|
+
import uuid
|
|
274
|
+
rid = str(uuid.uuid4())
|
|
275
|
+
self._store.upsert(ChronoRecord(
|
|
276
|
+
id=rid, kind="fact", label=content,
|
|
277
|
+
source_type="inferred", confidence=confidence,
|
|
278
|
+
evidence=evidence or [],
|
|
279
|
+
))
|
|
280
|
+
return rid
|
|
281
|
+
|
|
282
|
+
def rag_context(self) -> list[dict]:
|
|
283
|
+
"""Confidence-filtered beliefs for CPR retrieval gate."""
|
|
284
|
+
return [
|
|
285
|
+
{"chunk_id": r.id, "content": r.label,
|
|
286
|
+
"authority_score": r.confidence, "source_type": r.source_type}
|
|
287
|
+
for r in self._store.query(rag_filter=True)
|
|
288
|
+
]
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### ctt-neural — benchmark results + hypothesis tracking
|
|
292
|
+
|
|
293
|
+
```python
|
|
294
|
+
# Persist benchmark result with patent-quality provenance
|
|
295
|
+
from chronomemory import ChronoStore, ChronoRecord
|
|
296
|
+
|
|
297
|
+
with ChronoStore(project_root, recursion_depth=0) as store:
|
|
298
|
+
store.upsert(ChronoRecord(
|
|
299
|
+
id=f"bench-{scenario}-seed{seed}",
|
|
300
|
+
kind="fact",
|
|
301
|
+
label=f"CTT on {scenario}: invalid_rate={result['invalid_rate']}",
|
|
302
|
+
source_type="observed",
|
|
303
|
+
confidence=1.0,
|
|
304
|
+
evidence=[f"seed={seed}", f"model={model_id}", f"epoch={epoch}"],
|
|
305
|
+
data=result,
|
|
306
|
+
))
|
|
307
|
+
assert store.chain_valid() # tamper-evident proof for patent filing
|
|
308
|
+
|
|
309
|
+
# Track hypotheses through lifecycle
|
|
310
|
+
store.upsert(ChronoRecord(
|
|
311
|
+
id="HYP-001", kind="hypothesis",
|
|
312
|
+
label="CTT R=4 NLL within 2% of Bayes-optimal on scenario B",
|
|
313
|
+
is_hypothesis=True, confidence=0.75,
|
|
314
|
+
source_type="inferred",
|
|
315
|
+
evidence=["REQ-NN-006", "CTT-Paper §4.2"],
|
|
316
|
+
))
|
|
317
|
+
# After experiment: rec.is_hypothesis=False, rec.confidence=1.0, store.upsert(rec)
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### specsmith — governance store
|
|
321
|
+
|
|
322
|
+
```python
|
|
323
|
+
# specsmith reads requirements/testcases via EsdbBridge
|
|
324
|
+
from chronomemory import EsdbBridge
|
|
325
|
+
|
|
326
|
+
bridge = EsdbBridge(project_dir=".")
|
|
327
|
+
reqs = bridge.requirements() # ESDB WAL or .specsmith/ JSON fallback
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## Python vs Rust
|
|
333
|
+
|
|
334
|
+
| | Python (`src/chronomemory/`) | Rust (`crates/chronomemory/`) |
|
|
335
|
+
|---|---|---|
|
|
336
|
+
| **Status** | ✅ Production-ready | 🔧 Phase 2 (bindings pending) |
|
|
337
|
+
| **WAL format** | NDJSON (canonical) | Binary bincode (needs migration) |
|
|
338
|
+
| **Deps** | stdlib only | serde, sha2, uuid, chrono |
|
|
339
|
+
| **Dep graph** | ❌ | ✅ typed edges |
|
|
340
|
+
| **Projection engine** | ❌ | ✅ CPSC Accept/Reject/Downgrade |
|
|
341
|
+
| **Rollback cascade** | ❌ | ✅ transitive invalidation |
|
|
342
|
+
| **Context pack** | ❌ | ✅ token-budget assembly |
|
|
343
|
+
| **PyO3 bindings** | — | Phase 2 |
|
|
344
|
+
|
|
345
|
+
**Phase 2**: migrate Rust WAL to NDJSON → add PyO3 bindings → `from chronomemory import ChronoStore` transparently uses Rust with Python fallback.
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## Test suite
|
|
350
|
+
|
|
351
|
+
113 tests, all passing on Python 3.10–3.13 (Linux + Windows):
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
pip install -e ".[dev]"
|
|
355
|
+
pytest tests/ -v
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Test categories:
|
|
359
|
+
- **test_store.py** — snapshot replay, tombstone, migration, zero-deps
|
|
360
|
+
- **test_wal_chain.py** — hash chain integrity, NDJSON format, atomic writes, cross-project compat
|
|
361
|
+
- **test_oea.py** — all 7 OEA fields, WAL round-trip, recursion depth stamping
|
|
362
|
+
- **test_query.py** — confidence filtering, RAG threshold, kind/status filters
|
|
363
|
+
- **test_robustness.py** — 60+ tests: WAL corruption at multiple offsets, hash tampering, binary garbage, snapshot gaps, write failure simulation, crash recovery, CRLF, Unicode, Arabic RTL, 100KB payloads, compact/backup/lifecycle
|
|
364
|
+
- **test_bridge.py** — EsdbBridge delegation, JSON fallback, write operations
|
|
365
|
+
|
|
366
|
+
---
|
|
367
|
+
|
|
368
|
+
## Docs
|
|
369
|
+
|
|
370
|
+
Full documentation at **[chronomemory.readthedocs.io](https://chronomemory.readthedocs.io)**:
|
|
371
|
+
|
|
372
|
+
- [Installation](https://chronomemory.readthedocs.io/installation)
|
|
373
|
+
- [Quick start](https://chronomemory.readthedocs.io/quickstart)
|
|
374
|
+
- [Concepts: OEA fields](https://chronomemory.readthedocs.io/concepts/oea)
|
|
375
|
+
- [Concepts: WAL and hash chain](https://chronomemory.readthedocs.io/concepts/wal)
|
|
376
|
+
- [API: ChronoStore](https://chronomemory.readthedocs.io/api/store)
|
|
377
|
+
- [API: ChronoRecord](https://chronomemory.readthedocs.io/api/record)
|
|
378
|
+
- [API: EsdbBridge](https://chronomemory.readthedocs.io/api/bridge)
|
|
379
|
+
- [Integration: chronoagent](https://chronomemory.readthedocs.io/integration/chronoagent)
|
|
380
|
+
- [Integration: ctt-neural](https://chronomemory.readthedocs.io/integration/ctt-neural)
|
|
381
|
+
- [Integration: specsmith](https://chronomemory.readthedocs.io/integration/specsmith)
|
|
382
|
+
- [Migration guide](https://chronomemory.readthedocs.io/migration)
|
|
383
|
+
- [Rust core (Phase 2)](https://chronomemory.readthedocs.io/rust-core)
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## Spec
|
|
388
|
+
|
|
389
|
+
Implements **ESDB-Specification.md v1.0** (Layer1Labs / BitConcepts, proprietary).
|
|
390
|
+
|
|
391
|
+
Part of the Layer1Labs IP stack: CPSC · CAS-YAML · CPSC-RAG · CTT · ChronoFabric Gen 2.
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
© 2026 Layer1Labs Silicon, Inc. / BitConcepts, LLC. — MIT License.
|