heartwood-memory 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 (56) hide show
  1. heartwood_memory-0.1.0/LICENSE +21 -0
  2. heartwood_memory-0.1.0/PKG-INFO +326 -0
  3. heartwood_memory-0.1.0/README.md +285 -0
  4. heartwood_memory-0.1.0/heartwood/__init__.py +42 -0
  5. heartwood_memory-0.1.0/heartwood/adapters/__init__.py +30 -0
  6. heartwood_memory-0.1.0/heartwood/adapters/hermes.py +214 -0
  7. heartwood_memory-0.1.0/heartwood/adapters/mcp_server.py +387 -0
  8. heartwood_memory-0.1.0/heartwood/adapters/memory_tool.py +215 -0
  9. heartwood_memory-0.1.0/heartwood/adapters/openclaw.py +139 -0
  10. heartwood_memory-0.1.0/heartwood/audit.py +43 -0
  11. heartwood_memory-0.1.0/heartwood/chunking.py +166 -0
  12. heartwood_memory-0.1.0/heartwood/cli.py +431 -0
  13. heartwood_memory-0.1.0/heartwood/client.py +693 -0
  14. heartwood_memory-0.1.0/heartwood/consolidation.py +356 -0
  15. heartwood_memory-0.1.0/heartwood/contextual_ingest.py +349 -0
  16. heartwood_memory-0.1.0/heartwood/egress.py +264 -0
  17. heartwood_memory-0.1.0/heartwood/envelope.py +149 -0
  18. heartwood_memory-0.1.0/heartwood/erasure.py +94 -0
  19. heartwood_memory-0.1.0/heartwood/ergonomics.py +335 -0
  20. heartwood_memory-0.1.0/heartwood/faithfulness.py +268 -0
  21. heartwood_memory-0.1.0/heartwood/importers/__init__.py +5 -0
  22. heartwood_memory-0.1.0/heartwood/importers/markdown.py +651 -0
  23. heartwood_memory-0.1.0/heartwood/index.py +134 -0
  24. heartwood_memory-0.1.0/heartwood/key_custody.py +126 -0
  25. heartwood_memory-0.1.0/heartwood/models.py +56 -0
  26. heartwood_memory-0.1.0/heartwood/policy.py +67 -0
  27. heartwood_memory-0.1.0/heartwood/provenance.py +253 -0
  28. heartwood_memory-0.1.0/heartwood/recall_service.py +354 -0
  29. heartwood_memory-0.1.0/heartwood/retrieval.py +153 -0
  30. heartwood_memory-0.1.0/heartwood/review.py +68 -0
  31. heartwood_memory-0.1.0/heartwood/store.py +434 -0
  32. heartwood_memory-0.1.0/heartwood/typed_ranking.py +168 -0
  33. heartwood_memory-0.1.0/heartwood_memory.egg-info/PKG-INFO +326 -0
  34. heartwood_memory-0.1.0/heartwood_memory.egg-info/SOURCES.txt +54 -0
  35. heartwood_memory-0.1.0/heartwood_memory.egg-info/dependency_links.txt +1 -0
  36. heartwood_memory-0.1.0/heartwood_memory.egg-info/entry_points.txt +2 -0
  37. heartwood_memory-0.1.0/heartwood_memory.egg-info/requires.txt +28 -0
  38. heartwood_memory-0.1.0/heartwood_memory.egg-info/top_level.txt +1 -0
  39. heartwood_memory-0.1.0/pyproject.toml +70 -0
  40. heartwood_memory-0.1.0/setup.cfg +4 -0
  41. heartwood_memory-0.1.0/tests/test_bulk_api.py +163 -0
  42. heartwood_memory-0.1.0/tests/test_chunking.py +40 -0
  43. heartwood_memory-0.1.0/tests/test_consolidation.py +338 -0
  44. heartwood_memory-0.1.0/tests/test_contextual_ingest.py +239 -0
  45. heartwood_memory-0.1.0/tests/test_index.py +63 -0
  46. heartwood_memory-0.1.0/tests/test_inheritance.py +60 -0
  47. heartwood_memory-0.1.0/tests/test_key_custody.py +78 -0
  48. heartwood_memory-0.1.0/tests/test_markdown_import_classification.py +77 -0
  49. heartwood_memory-0.1.0/tests/test_markdown_importer.py +333 -0
  50. heartwood_memory-0.1.0/tests/test_mcp_hardening.py +155 -0
  51. heartwood_memory-0.1.0/tests/test_memory_tool.py +104 -0
  52. heartwood_memory-0.1.0/tests/test_provenance.py +162 -0
  53. heartwood_memory-0.1.0/tests/test_review_workflow.py +371 -0
  54. heartwood_memory-0.1.0/tests/test_trust_controls.py +169 -0
  55. heartwood_memory-0.1.0/tests/test_typed_ranking.py +125 -0
  56. heartwood_memory-0.1.0/tests/test_warm_recall.py +476 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Heartwood Memory
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,326 @@
1
+ Metadata-Version: 2.4
2
+ Name: heartwood-memory
3
+ Version: 0.1.0
4
+ Summary: Governed, provenance-first agent memory for AI systems.
5
+ Author: Heartwood Memory
6
+ License-Expression: MIT
7
+ Keywords: agent-memory,ai-agents,governance,provenance,retrieval,database
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Topic :: Database
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: cryptography>=42
20
+ Requires-Dist: numpy>=1.26
21
+ Provides-Extra: crypto
22
+ Requires-Dist: cryptography>=42; extra == "crypto"
23
+ Provides-Extra: sqlite
24
+ Requires-Dist: sqlite-vec>=0.1.6; extra == "sqlite"
25
+ Provides-Extra: models
26
+ Requires-Dist: sentence-transformers>=3; extra == "models"
27
+ Provides-Extra: recall
28
+ Requires-Dist: sentence-transformers>=3; extra == "recall"
29
+ Requires-Dist: sqlite-vec>=0.1.6; extra == "recall"
30
+ Provides-Extra: mcp
31
+ Requires-Dist: mcp>=1; extra == "mcp"
32
+ Provides-Extra: postgres
33
+ Requires-Dist: psycopg[binary]>=3.2; extra == "postgres"
34
+ Provides-Extra: dev
35
+ Requires-Dist: build>=1.2; extra == "dev"
36
+ Requires-Dist: cryptography>=42; extra == "dev"
37
+ Requires-Dist: mcp>=1; extra == "dev"
38
+ Requires-Dist: psycopg[binary]>=3.2; extra == "dev"
39
+ Requires-Dist: sqlite-vec>=0.1.6; extra == "dev"
40
+ Dynamic: license-file
41
+
42
+ # Heartwood Memory Codex Workspace
43
+
44
+ This workspace contains the early product and proof artifacts for Heartwood, an agent-native memory/database product.
45
+
46
+ The current direction is de-risked:
47
+
48
+ - V1 is **Heartwood Memory**, a derived, rebuildable, provenance-first memory layer beside existing systems of record.
49
+ - The native standalone database remains the north star, not the first implementation target.
50
+ - Phase 0 focuses on proving retrieval quality, generated-memory faithfulness, and deletion lineage before engine work.
51
+
52
+ Evidence boundary: the shipped package is `heartwood/` plus its SDK and adapter surfaces. Product-facing enterprise retrieval evidence now comes from `experiments/product-retrieval/`, which ingests the enterprise trace through `Heartwood.remember()` and evaluates `Heartwood.recall()`. The older `experiments/typed-memory/` retrieval numbers remain research/proof-core evidence, useful for design exploration and adapter validation but not a substitute for product API gates.
53
+
54
+ ## Key Docs
55
+
56
+ - `docs/README.md` - current documentation map and historical-doc boundary
57
+ - `docs/heartwood-memory-v1-prd.md` - de-risked V1 PRD
58
+ - `docs/heartwood-cohesive-solution.md` - merged product architecture and release gates
59
+ - `docs/heartwood-embedded-library-spec.md` - embedded SDK/product shell spec
60
+ - `docs/platform-support.md` - macOS, Linux, Windows, Docker, and dataset-location support notes
61
+ - `docs/integrations/onboarding-guide.md` - Phase 1 onboarding guide
62
+ - `docs/integrations/mcp-quickstart.md` - governed MCP quickstart
63
+ - `docs/phase-0-prove-plan.md` - Phase 0 hypotheses, pass/fail criteria, and deliverables
64
+ - `docs/integrations/api-ergonomics.md` - Phase 1 tenant/bulk API quickstart
65
+ - `docs/security/key-custody.md` - key-custody pattern
66
+ - `docs/api/python-api.md` and `docs/api/typescript-api.md` - generated API references
67
+ - `docs/migration/postgres-sqlite-migration-guide.md` - migration/projection guidance
68
+ - `docs/deployment/docker-usage.md` - Docker runtime and verification usage
69
+ - `docs/release/python-package-release.md` - signed Python wheel and manifest flow
70
+ - `docs/results/phase-1-completion-report.md` - Phase 1 evidence and live-adoption boundary
71
+ - `docs/typed-memory-plane-design.md` - executable typed-memory architecture
72
+ - `docs/outreach/heartwood-memory-2-minute-demo-script.md` - production-ready 2-minute demo script
73
+ - `docs/outreach/heartwood-memory-one-pager.md` - outreach one-pager grounded in the working demo
74
+ - `docs/pre-registered-thresholds.md` - locked Phase 0 realistic-trace recall thresholds
75
+ - `docs/results/phase-0-threshold-results.md` - realistic-trace threshold gate results
76
+ - `docs/results/phase-0-trust-suite-results.md` - latest end-to-end Phase 0 suite result
77
+ - `docs/results/phase-0-product-retrieval-results.md` - product API enterprise retrieval result
78
+ - `docs/results/phase-0-typed-memory-results.md` - typed-memory enterprise result
79
+ - `docs/results/phase-0-filtered-search-results.md` - filtered-search policy result
80
+ - `docs/results/phase-0-temporal-conflict-results.md` - temporal conflict result
81
+ - `docs/results/phase-0-context-ablation-results.md` - query-bias/context ablation result
82
+ - `docs/results/phase-0-storage-adapter-results.md` - SQLite storage adapter result
83
+ - `docs/results/phase-0-snapshot-import-results.md` - SQLite snapshot importer result
84
+ - `docs/results/phase-0-confidence-interval-results.md` - bootstrap confidence interval result
85
+ - `docs/deletion-lineage-design.md` - derived-artifact deletion architecture
86
+ - `docs/faithfulness-gate-design.md` - generated-memory faithfulness gate
87
+ - `docs/egress-policy-gate-design.md` - external-model egress policy gate
88
+
89
+ ## Product Shell
90
+
91
+ Heartwood Memory now has a developer-facing shell layered on top of the proof harnesses:
92
+
93
+ - `heartwood/` - Python embedded memory library with `remember`, `recall`, `explain_recall`, `approve`, `forget`, `evaluate_egress`, `assess_faithfulness`, and `remember_generated`
94
+ - `heartwood/adapters/` - Anthropic Memory Tool and MCP adapter surfaces
95
+ - `sdk/typescript/` - TypeScript SDK helpers for governed memory and memory-tool workflows; governed recall parity is not shipped yet
96
+ - `examples/regulated-support/` - regulated-support demo with a generated compliance report
97
+ - `tests/` - product-shell smoke, provenance, policy, index, and memory-tool tests
98
+
99
+ Run the Python product shell:
100
+
101
+ ```bash
102
+ python -m pip install -e ".[recall,mcp]"
103
+ heartwood --help
104
+ heartwood import-markdown ./memory ./team-memory --db ./heartwood.db --tenant-map-json '{"acme":"tenant:acme-payments"}' --output ./heartwood-import-report.json
105
+ python ./tests/smoke_test.py
106
+ python ./tests/test_memory_tool.py
107
+ python ./tests/test_provenance.py
108
+ python ./tests/test_trust_controls.py
109
+ python ./tests/test_index.py
110
+ python ./tests/test_inheritance.py
111
+ ```
112
+
113
+ The `heartwood` console script is equivalent to `python -m heartwood.cli` after
114
+ installation. Use the module form only when you are running directly from a
115
+ checkout before installing the package.
116
+
117
+ Run the TypeScript SDK tests:
118
+
119
+ ```bash
120
+ npm --prefix ./sdk/typescript test
121
+ ```
122
+
123
+ Run the regulated-support demo:
124
+
125
+ ```bash
126
+ python ./examples/regulated-support/run_demo.py
127
+ ```
128
+
129
+ Import Markdown memory:
130
+
131
+ ```bash
132
+ heartwood import-markdown ./memory ./team-memory --db ./heartwood.db --tenant-map-json '{"acme":"tenant:acme-payments"}' --output ./heartwood-import-report.json
133
+ ```
134
+
135
+ Run warm recall for hook/agent integration:
136
+
137
+ ```bash
138
+ export HEARTWOOD_RECALL_TOKEN="$(openssl rand -hex 24)"
139
+ heartwood serve-recall --db ./heartwood.db --tenant tenant:ops --host 127.0.0.1 --port 8765
140
+ heartwood recall --url http://127.0.0.1:8765 --tenant tenant:ops --query "what memory applies here?" --k 5 --json
141
+ heartwood bench-recall --url http://127.0.0.1:8765 --tenant tenant:ops --query "what memory applies here?" --repeat 10 --max-p95-ms 500 --require-pass
142
+ ```
143
+
144
+ Bulk-write JSON/JSONL records through the public tenant-aware API:
145
+
146
+ ```bash
147
+ heartwood bulk-remember --input ./records.jsonl --db ./heartwood.db --tenant tenant:ops --output ./heartwood-bulk-report.json
148
+ python ./tests/test_bulk_api.py
149
+ ```
150
+
151
+ ## Experiments
152
+
153
+ Run the Phase 0 end-to-end suite:
154
+
155
+ ```bash
156
+ python ./experiments/phase0-trust-suite/src/phase0_trust_suite.py
157
+ ```
158
+
159
+ Run the portable suite for fresh clones, manual verification, or containers without local LongMemEval fixtures:
160
+
161
+ ```bash
162
+ python ./experiments/phase0-trust-suite/src/phase0_trust_suite.py --skip-longmemeval
163
+ ```
164
+
165
+ Run the suite with the live Postgres adapter gate:
166
+
167
+ ```bash
168
+ python ./experiments/phase0-trust-suite/src/phase0_trust_suite.py --include-postgres
169
+ ```
170
+
171
+ Run typed-memory enterprise and LongMemEval benchmarks:
172
+
173
+ ```bash
174
+ python ./experiments/typed-memory/src/typed_memory_benchmark.py --dataset enterprise --require-pass
175
+ python ./experiments/typed-memory/src/typed_memory_benchmark.py --dataset longmemeval-s-session-100 --require-pass
176
+ ```
177
+
178
+ Run the product API enterprise retrieval benchmark:
179
+
180
+ ```bash
181
+ python ./experiments/product-retrieval/src/heartwood_product_benchmark.py --require-pass
182
+ python ./experiments/product-retrieval/src/heartwood_product_benchmark.py --phase1-scale --require-pass
183
+ ```
184
+
185
+ Run the SQLite-backed local memory-plane path:
186
+
187
+ ```bash
188
+ python ./experiments/typed-memory/src/memory_plane_cli.py ingest --db ./experiments/typed-memory/results/heartwood_memory_plane.sqlite
189
+ python ./experiments/typed-memory/src/memory_plane_cli.py recall --db ./experiments/typed-memory/results/heartwood_memory_plane.sqlite --query-id q_customer42_refund_eligibility
190
+ python ./experiments/typed-memory/src/memory_plane_cli.py inspect --db ./experiments/typed-memory/results/heartwood_memory_plane.sqlite
191
+ python ./experiments/typed-memory/src/memory_plane_cli.py export-eval --db ./experiments/typed-memory/results/heartwood_memory_plane.sqlite --jsonl-output ./experiments/typed-memory/results/recall_eval_export.jsonl
192
+ python ./experiments/typed-memory/src/storage_adapter_smoke.py --require-pass
193
+ ```
194
+
195
+ Run snapshot import and statistical reporting:
196
+
197
+ ```bash
198
+ python ./experiments/typed-memory/src/snapshot_import_smoke.py --require-pass
199
+ python ./experiments/typed-memory/src/confidence_interval_report.py --result ./experiments/typed-memory/results/enterprise_latest.json --require-pass
200
+ ```
201
+
202
+ Run the live Postgres adapter directly:
203
+
204
+ ```bash
205
+ python ./experiments/typed-memory/src/postgres_adapter_smoke.py --require-pass
206
+ ```
207
+
208
+ Run database/search-specific Phase 0 harnesses:
209
+
210
+ ```bash
211
+ python ./experiments/filtered-search/src/filtered_search_benchmark.py --require-pass
212
+ python ./experiments/temporal-conflict/src/temporal_conflict_benchmark.py --require-pass
213
+ python ./experiments/context-ablation/src/context_ablation_benchmark.py --require-pass
214
+ ```
215
+
216
+ Run the recall benchmark:
217
+
218
+ ```bash
219
+ python ./experiments/recall-benchmark/src/benchmark.py
220
+ ```
221
+
222
+ Run the realistic-trace threshold gate after benchmark result files exist:
223
+
224
+ ```bash
225
+ python ./experiments/recall-benchmark/src/evaluate_thresholds.py ./experiments/recall-benchmark/results/longmemeval_s_session_100.json ./experiments/recall-benchmark/results/longmemeval_s_turn_100.json ./experiments/recall-benchmark/results/longmemeval_m_session_25.json ./experiments/recall-benchmark/results/longmemeval_m_turn_25.json ./experiments/recall-benchmark/results/longmemeval_s_session_50_dense.json ./experiments/recall-benchmark/results/longmemeval_s_turn_50_dense.json --output ./experiments/recall-benchmark/results/phase0_threshold_results.json --markdown-output ./docs/results/phase-0-threshold-results.md
226
+ ```
227
+
228
+ Run deletion-lineage smoke test:
229
+
230
+ ```bash
231
+ python ./experiments/deletion-lineage/src/deletion_smoke.py --subject customer_42
232
+ ```
233
+
234
+ Run realistic deletion-lineage retrieval-path test:
235
+
236
+ ```bash
237
+ python ./experiments/deletion-lineage/src/deletion_realistic.py --subject customer_42
238
+ ```
239
+
240
+ Run negative missing-lineage deletion test:
241
+
242
+ ```bash
243
+ python ./experiments/deletion-lineage/src/deletion_negative.py --subject customer_42
244
+ ```
245
+
246
+ Run faithfulness-gate smoke test:
247
+
248
+ ```bash
249
+ python ./experiments/faithfulness-gate/src/faithfulness_smoke.py
250
+ ```
251
+
252
+ Run realistic and negative faithfulness-gate tests:
253
+
254
+ ```bash
255
+ python ./experiments/faithfulness-gate/src/faithfulness_realistic.py
256
+ python ./experiments/faithfulness-gate/src/faithfulness_negative.py
257
+ ```
258
+
259
+ Run egress-policy gate tests:
260
+
261
+ ```bash
262
+ python ./experiments/egress-policy/src/egress_policy_gate.py
263
+ python ./experiments/egress-policy/src/egress_policy_gate.py --requests ./experiments/egress-policy/data/negative_requests.jsonl --output ./experiments/egress-policy/results/negative_latest.json --expect-no-unsafe-external
264
+ python ./experiments/egress-policy/src/provider_registry_gate.py
265
+ ```
266
+
267
+ Run resilience gates for adversarial tenancy, local concurrency, and deletion chaos:
268
+
269
+ ```bash
270
+ python ./experiments/resilience/src/adversarial_multitenant.py
271
+ python ./experiments/resilience/src/scale_concurrency_soak.py
272
+ python ./experiments/resilience/src/deletion_chaos.py
273
+ ```
274
+
275
+ Run example framework adapter contract tests for Hermes/OpenClaw-style memory surfaces:
276
+
277
+ ```bash
278
+ python ./experiments/adapter-contracts/src/framework_adapter_contracts.py
279
+ ```
280
+
281
+ Build the local container image:
282
+
283
+ ```bash
284
+ docker build -t heartwood-memory:local .
285
+ ```
286
+
287
+ Run the Heartwood MCP server with a persistent local volume:
288
+
289
+ ```bash
290
+ docker run --rm -it -v heartwood-data:/data -e HEARTWOOD_TENANT=tenant:local heartwood-memory:local
291
+ ```
292
+
293
+ Run the local Compose stack with Heartwood MCP plus Postgres:
294
+
295
+ ```bash
296
+ docker compose up --build
297
+ ```
298
+
299
+ Build and run the verification image instead of the runtime image:
300
+
301
+ ```bash
302
+ docker build --target verify -t heartwood-memory-verify .
303
+ docker run --rm heartwood-memory-verify
304
+ ```
305
+
306
+ The verification image runs the portable trust suite. Run the local suite from the repo when the generated LongMemEval fixtures are available.
307
+
308
+ ## License
309
+
310
+ The core package in this repository is MIT licensed; see `LICENSE`. Commercial
311
+ support, signed release distribution, managed key custody, and hosted services
312
+ may be offered separately from the MIT core.
313
+
314
+ ## Current Bias
315
+
316
+ Prove boring trust before building ambitious cognition:
317
+
318
+ - provenance
319
+ - typed memory routing
320
+ - policy-aware recall
321
+ - temporal state
322
+ - deletion completeness
323
+ - generated-memory faithfulness
324
+ - repeatable evals
325
+
326
+ The cognitive database vision should be earned by evidence from these loops.
@@ -0,0 +1,285 @@
1
+ # Heartwood Memory Codex Workspace
2
+
3
+ This workspace contains the early product and proof artifacts for Heartwood, an agent-native memory/database product.
4
+
5
+ The current direction is de-risked:
6
+
7
+ - V1 is **Heartwood Memory**, a derived, rebuildable, provenance-first memory layer beside existing systems of record.
8
+ - The native standalone database remains the north star, not the first implementation target.
9
+ - Phase 0 focuses on proving retrieval quality, generated-memory faithfulness, and deletion lineage before engine work.
10
+
11
+ Evidence boundary: the shipped package is `heartwood/` plus its SDK and adapter surfaces. Product-facing enterprise retrieval evidence now comes from `experiments/product-retrieval/`, which ingests the enterprise trace through `Heartwood.remember()` and evaluates `Heartwood.recall()`. The older `experiments/typed-memory/` retrieval numbers remain research/proof-core evidence, useful for design exploration and adapter validation but not a substitute for product API gates.
12
+
13
+ ## Key Docs
14
+
15
+ - `docs/README.md` - current documentation map and historical-doc boundary
16
+ - `docs/heartwood-memory-v1-prd.md` - de-risked V1 PRD
17
+ - `docs/heartwood-cohesive-solution.md` - merged product architecture and release gates
18
+ - `docs/heartwood-embedded-library-spec.md` - embedded SDK/product shell spec
19
+ - `docs/platform-support.md` - macOS, Linux, Windows, Docker, and dataset-location support notes
20
+ - `docs/integrations/onboarding-guide.md` - Phase 1 onboarding guide
21
+ - `docs/integrations/mcp-quickstart.md` - governed MCP quickstart
22
+ - `docs/phase-0-prove-plan.md` - Phase 0 hypotheses, pass/fail criteria, and deliverables
23
+ - `docs/integrations/api-ergonomics.md` - Phase 1 tenant/bulk API quickstart
24
+ - `docs/security/key-custody.md` - key-custody pattern
25
+ - `docs/api/python-api.md` and `docs/api/typescript-api.md` - generated API references
26
+ - `docs/migration/postgres-sqlite-migration-guide.md` - migration/projection guidance
27
+ - `docs/deployment/docker-usage.md` - Docker runtime and verification usage
28
+ - `docs/release/python-package-release.md` - signed Python wheel and manifest flow
29
+ - `docs/results/phase-1-completion-report.md` - Phase 1 evidence and live-adoption boundary
30
+ - `docs/typed-memory-plane-design.md` - executable typed-memory architecture
31
+ - `docs/outreach/heartwood-memory-2-minute-demo-script.md` - production-ready 2-minute demo script
32
+ - `docs/outreach/heartwood-memory-one-pager.md` - outreach one-pager grounded in the working demo
33
+ - `docs/pre-registered-thresholds.md` - locked Phase 0 realistic-trace recall thresholds
34
+ - `docs/results/phase-0-threshold-results.md` - realistic-trace threshold gate results
35
+ - `docs/results/phase-0-trust-suite-results.md` - latest end-to-end Phase 0 suite result
36
+ - `docs/results/phase-0-product-retrieval-results.md` - product API enterprise retrieval result
37
+ - `docs/results/phase-0-typed-memory-results.md` - typed-memory enterprise result
38
+ - `docs/results/phase-0-filtered-search-results.md` - filtered-search policy result
39
+ - `docs/results/phase-0-temporal-conflict-results.md` - temporal conflict result
40
+ - `docs/results/phase-0-context-ablation-results.md` - query-bias/context ablation result
41
+ - `docs/results/phase-0-storage-adapter-results.md` - SQLite storage adapter result
42
+ - `docs/results/phase-0-snapshot-import-results.md` - SQLite snapshot importer result
43
+ - `docs/results/phase-0-confidence-interval-results.md` - bootstrap confidence interval result
44
+ - `docs/deletion-lineage-design.md` - derived-artifact deletion architecture
45
+ - `docs/faithfulness-gate-design.md` - generated-memory faithfulness gate
46
+ - `docs/egress-policy-gate-design.md` - external-model egress policy gate
47
+
48
+ ## Product Shell
49
+
50
+ Heartwood Memory now has a developer-facing shell layered on top of the proof harnesses:
51
+
52
+ - `heartwood/` - Python embedded memory library with `remember`, `recall`, `explain_recall`, `approve`, `forget`, `evaluate_egress`, `assess_faithfulness`, and `remember_generated`
53
+ - `heartwood/adapters/` - Anthropic Memory Tool and MCP adapter surfaces
54
+ - `sdk/typescript/` - TypeScript SDK helpers for governed memory and memory-tool workflows; governed recall parity is not shipped yet
55
+ - `examples/regulated-support/` - regulated-support demo with a generated compliance report
56
+ - `tests/` - product-shell smoke, provenance, policy, index, and memory-tool tests
57
+
58
+ Run the Python product shell:
59
+
60
+ ```bash
61
+ python -m pip install -e ".[recall,mcp]"
62
+ heartwood --help
63
+ heartwood import-markdown ./memory ./team-memory --db ./heartwood.db --tenant-map-json '{"acme":"tenant:acme-payments"}' --output ./heartwood-import-report.json
64
+ python ./tests/smoke_test.py
65
+ python ./tests/test_memory_tool.py
66
+ python ./tests/test_provenance.py
67
+ python ./tests/test_trust_controls.py
68
+ python ./tests/test_index.py
69
+ python ./tests/test_inheritance.py
70
+ ```
71
+
72
+ The `heartwood` console script is equivalent to `python -m heartwood.cli` after
73
+ installation. Use the module form only when you are running directly from a
74
+ checkout before installing the package.
75
+
76
+ Run the TypeScript SDK tests:
77
+
78
+ ```bash
79
+ npm --prefix ./sdk/typescript test
80
+ ```
81
+
82
+ Run the regulated-support demo:
83
+
84
+ ```bash
85
+ python ./examples/regulated-support/run_demo.py
86
+ ```
87
+
88
+ Import Markdown memory:
89
+
90
+ ```bash
91
+ heartwood import-markdown ./memory ./team-memory --db ./heartwood.db --tenant-map-json '{"acme":"tenant:acme-payments"}' --output ./heartwood-import-report.json
92
+ ```
93
+
94
+ Run warm recall for hook/agent integration:
95
+
96
+ ```bash
97
+ export HEARTWOOD_RECALL_TOKEN="$(openssl rand -hex 24)"
98
+ heartwood serve-recall --db ./heartwood.db --tenant tenant:ops --host 127.0.0.1 --port 8765
99
+ heartwood recall --url http://127.0.0.1:8765 --tenant tenant:ops --query "what memory applies here?" --k 5 --json
100
+ heartwood bench-recall --url http://127.0.0.1:8765 --tenant tenant:ops --query "what memory applies here?" --repeat 10 --max-p95-ms 500 --require-pass
101
+ ```
102
+
103
+ Bulk-write JSON/JSONL records through the public tenant-aware API:
104
+
105
+ ```bash
106
+ heartwood bulk-remember --input ./records.jsonl --db ./heartwood.db --tenant tenant:ops --output ./heartwood-bulk-report.json
107
+ python ./tests/test_bulk_api.py
108
+ ```
109
+
110
+ ## Experiments
111
+
112
+ Run the Phase 0 end-to-end suite:
113
+
114
+ ```bash
115
+ python ./experiments/phase0-trust-suite/src/phase0_trust_suite.py
116
+ ```
117
+
118
+ Run the portable suite for fresh clones, manual verification, or containers without local LongMemEval fixtures:
119
+
120
+ ```bash
121
+ python ./experiments/phase0-trust-suite/src/phase0_trust_suite.py --skip-longmemeval
122
+ ```
123
+
124
+ Run the suite with the live Postgres adapter gate:
125
+
126
+ ```bash
127
+ python ./experiments/phase0-trust-suite/src/phase0_trust_suite.py --include-postgres
128
+ ```
129
+
130
+ Run typed-memory enterprise and LongMemEval benchmarks:
131
+
132
+ ```bash
133
+ python ./experiments/typed-memory/src/typed_memory_benchmark.py --dataset enterprise --require-pass
134
+ python ./experiments/typed-memory/src/typed_memory_benchmark.py --dataset longmemeval-s-session-100 --require-pass
135
+ ```
136
+
137
+ Run the product API enterprise retrieval benchmark:
138
+
139
+ ```bash
140
+ python ./experiments/product-retrieval/src/heartwood_product_benchmark.py --require-pass
141
+ python ./experiments/product-retrieval/src/heartwood_product_benchmark.py --phase1-scale --require-pass
142
+ ```
143
+
144
+ Run the SQLite-backed local memory-plane path:
145
+
146
+ ```bash
147
+ python ./experiments/typed-memory/src/memory_plane_cli.py ingest --db ./experiments/typed-memory/results/heartwood_memory_plane.sqlite
148
+ python ./experiments/typed-memory/src/memory_plane_cli.py recall --db ./experiments/typed-memory/results/heartwood_memory_plane.sqlite --query-id q_customer42_refund_eligibility
149
+ python ./experiments/typed-memory/src/memory_plane_cli.py inspect --db ./experiments/typed-memory/results/heartwood_memory_plane.sqlite
150
+ python ./experiments/typed-memory/src/memory_plane_cli.py export-eval --db ./experiments/typed-memory/results/heartwood_memory_plane.sqlite --jsonl-output ./experiments/typed-memory/results/recall_eval_export.jsonl
151
+ python ./experiments/typed-memory/src/storage_adapter_smoke.py --require-pass
152
+ ```
153
+
154
+ Run snapshot import and statistical reporting:
155
+
156
+ ```bash
157
+ python ./experiments/typed-memory/src/snapshot_import_smoke.py --require-pass
158
+ python ./experiments/typed-memory/src/confidence_interval_report.py --result ./experiments/typed-memory/results/enterprise_latest.json --require-pass
159
+ ```
160
+
161
+ Run the live Postgres adapter directly:
162
+
163
+ ```bash
164
+ python ./experiments/typed-memory/src/postgres_adapter_smoke.py --require-pass
165
+ ```
166
+
167
+ Run database/search-specific Phase 0 harnesses:
168
+
169
+ ```bash
170
+ python ./experiments/filtered-search/src/filtered_search_benchmark.py --require-pass
171
+ python ./experiments/temporal-conflict/src/temporal_conflict_benchmark.py --require-pass
172
+ python ./experiments/context-ablation/src/context_ablation_benchmark.py --require-pass
173
+ ```
174
+
175
+ Run the recall benchmark:
176
+
177
+ ```bash
178
+ python ./experiments/recall-benchmark/src/benchmark.py
179
+ ```
180
+
181
+ Run the realistic-trace threshold gate after benchmark result files exist:
182
+
183
+ ```bash
184
+ python ./experiments/recall-benchmark/src/evaluate_thresholds.py ./experiments/recall-benchmark/results/longmemeval_s_session_100.json ./experiments/recall-benchmark/results/longmemeval_s_turn_100.json ./experiments/recall-benchmark/results/longmemeval_m_session_25.json ./experiments/recall-benchmark/results/longmemeval_m_turn_25.json ./experiments/recall-benchmark/results/longmemeval_s_session_50_dense.json ./experiments/recall-benchmark/results/longmemeval_s_turn_50_dense.json --output ./experiments/recall-benchmark/results/phase0_threshold_results.json --markdown-output ./docs/results/phase-0-threshold-results.md
185
+ ```
186
+
187
+ Run deletion-lineage smoke test:
188
+
189
+ ```bash
190
+ python ./experiments/deletion-lineage/src/deletion_smoke.py --subject customer_42
191
+ ```
192
+
193
+ Run realistic deletion-lineage retrieval-path test:
194
+
195
+ ```bash
196
+ python ./experiments/deletion-lineage/src/deletion_realistic.py --subject customer_42
197
+ ```
198
+
199
+ Run negative missing-lineage deletion test:
200
+
201
+ ```bash
202
+ python ./experiments/deletion-lineage/src/deletion_negative.py --subject customer_42
203
+ ```
204
+
205
+ Run faithfulness-gate smoke test:
206
+
207
+ ```bash
208
+ python ./experiments/faithfulness-gate/src/faithfulness_smoke.py
209
+ ```
210
+
211
+ Run realistic and negative faithfulness-gate tests:
212
+
213
+ ```bash
214
+ python ./experiments/faithfulness-gate/src/faithfulness_realistic.py
215
+ python ./experiments/faithfulness-gate/src/faithfulness_negative.py
216
+ ```
217
+
218
+ Run egress-policy gate tests:
219
+
220
+ ```bash
221
+ python ./experiments/egress-policy/src/egress_policy_gate.py
222
+ python ./experiments/egress-policy/src/egress_policy_gate.py --requests ./experiments/egress-policy/data/negative_requests.jsonl --output ./experiments/egress-policy/results/negative_latest.json --expect-no-unsafe-external
223
+ python ./experiments/egress-policy/src/provider_registry_gate.py
224
+ ```
225
+
226
+ Run resilience gates for adversarial tenancy, local concurrency, and deletion chaos:
227
+
228
+ ```bash
229
+ python ./experiments/resilience/src/adversarial_multitenant.py
230
+ python ./experiments/resilience/src/scale_concurrency_soak.py
231
+ python ./experiments/resilience/src/deletion_chaos.py
232
+ ```
233
+
234
+ Run example framework adapter contract tests for Hermes/OpenClaw-style memory surfaces:
235
+
236
+ ```bash
237
+ python ./experiments/adapter-contracts/src/framework_adapter_contracts.py
238
+ ```
239
+
240
+ Build the local container image:
241
+
242
+ ```bash
243
+ docker build -t heartwood-memory:local .
244
+ ```
245
+
246
+ Run the Heartwood MCP server with a persistent local volume:
247
+
248
+ ```bash
249
+ docker run --rm -it -v heartwood-data:/data -e HEARTWOOD_TENANT=tenant:local heartwood-memory:local
250
+ ```
251
+
252
+ Run the local Compose stack with Heartwood MCP plus Postgres:
253
+
254
+ ```bash
255
+ docker compose up --build
256
+ ```
257
+
258
+ Build and run the verification image instead of the runtime image:
259
+
260
+ ```bash
261
+ docker build --target verify -t heartwood-memory-verify .
262
+ docker run --rm heartwood-memory-verify
263
+ ```
264
+
265
+ The verification image runs the portable trust suite. Run the local suite from the repo when the generated LongMemEval fixtures are available.
266
+
267
+ ## License
268
+
269
+ The core package in this repository is MIT licensed; see `LICENSE`. Commercial
270
+ support, signed release distribution, managed key custody, and hosted services
271
+ may be offered separately from the MIT core.
272
+
273
+ ## Current Bias
274
+
275
+ Prove boring trust before building ambitious cognition:
276
+
277
+ - provenance
278
+ - typed memory routing
279
+ - policy-aware recall
280
+ - temporal state
281
+ - deletion completeness
282
+ - generated-memory faithfulness
283
+ - repeatable evals
284
+
285
+ The cognitive database vision should be earned by evidence from these loops.
@@ -0,0 +1,42 @@
1
+ """Heartwood — provenance-first, embedded agent-memory library (Phase 0).
2
+
3
+ The differentiation is governance — tamper-evident provenance + policy-enforced
4
+ recall + crypto-shred erasure — over benchmark-validated hybrid retrieval. NOT a
5
+ novel retrieval mechanism (spreading activation was CUT; see
6
+ experiments/recall-benchmark/RESULTS.md).
7
+
8
+ from heartwood import Heartwood, Principal, Policy
9
+ db = Heartwood(path="mem.db", tenant="tenant:acme")
10
+ mid = db.remember("User prefers concise answers.", subject="user:1",
11
+ created_by="agent:asst", kind="semantic", epistemic="user-stated")
12
+ out = db.recall("how should I talk to this user?",
13
+ principal=Principal(id="agent:asst", tenant="tenant:acme"))
14
+ """
15
+ from .client import Heartwood
16
+ from .egress import DENIED, EXTERNAL_ALLOWED, EXTERNAL_REDACTED, HUMAN_REVIEW, LOCAL_ONLY
17
+ from .envelope import Epistemic, Kind, Memory, Policy, TruthStatus
18
+ from .ergonomics import normalize_tenant, policy_from, principal_from, tenant_slug
19
+ from .key_custody import LocalKmsCustodian, RawKeyCustodian
20
+ from .policy import Principal
21
+
22
+ __all__ = [
23
+ "Heartwood",
24
+ "Principal",
25
+ "Policy",
26
+ "Memory",
27
+ "Kind",
28
+ "Epistemic",
29
+ "TruthStatus",
30
+ "normalize_tenant",
31
+ "tenant_slug",
32
+ "policy_from",
33
+ "principal_from",
34
+ "LocalKmsCustodian",
35
+ "RawKeyCustodian",
36
+ "EXTERNAL_ALLOWED",
37
+ "EXTERNAL_REDACTED",
38
+ "LOCAL_ONLY",
39
+ "HUMAN_REVIEW",
40
+ "DENIED",
41
+ ]
42
+ __version__ = "0.1.0"