omp-memory 0.2.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 (77) hide show
  1. omp_memory-0.2.0/LICENSE.md +19 -0
  2. omp_memory-0.2.0/PKG-INFO +506 -0
  3. omp_memory-0.2.0/README.md +459 -0
  4. omp_memory-0.2.0/pyproject.toml +58 -0
  5. omp_memory-0.2.0/setup.cfg +4 -0
  6. omp_memory-0.2.0/src/omp_memory/__init__.py +188 -0
  7. omp_memory-0.2.0/src/omp_memory/__main__.py +8 -0
  8. omp_memory-0.2.0/src/omp_memory/capture.py +658 -0
  9. omp_memory-0.2.0/src/omp_memory/cli.py +1045 -0
  10. omp_memory-0.2.0/src/omp_memory/context.py +187 -0
  11. omp_memory-0.2.0/src/omp_memory/db.py +4638 -0
  12. omp_memory-0.2.0/src/omp_memory/experience.py +309 -0
  13. omp_memory-0.2.0/src/omp_memory/handoff.py +468 -0
  14. omp_memory-0.2.0/src/omp_memory/hooks.py +162 -0
  15. omp_memory-0.2.0/src/omp_memory/mcp.py +1046 -0
  16. omp_memory-0.2.0/src/omp_memory/md_ingest.py +268 -0
  17. omp_memory-0.2.0/src/omp_memory/outcomes.py +58 -0
  18. omp_memory-0.2.0/src/omp_memory/provider.py +129 -0
  19. omp_memory-0.2.0/src/omp_memory/watch.py +163 -0
  20. omp_memory-0.2.0/src/omp_memory/web/dist/assets/index-BMXPmOzw.js +216 -0
  21. omp_memory-0.2.0/src/omp_memory/web/dist/assets/index-qca123ar.css +1 -0
  22. omp_memory-0.2.0/src/omp_memory/web/dist/index.html +13 -0
  23. omp_memory-0.2.0/src/omp_memory/web.py +879 -0
  24. omp_memory-0.2.0/src/omp_memory.egg-info/PKG-INFO +506 -0
  25. omp_memory-0.2.0/src/omp_memory.egg-info/SOURCES.txt +75 -0
  26. omp_memory-0.2.0/src/omp_memory.egg-info/dependency_links.txt +1 -0
  27. omp_memory-0.2.0/src/omp_memory.egg-info/entry_points.txt +3 -0
  28. omp_memory-0.2.0/src/omp_memory.egg-info/requires.txt +3 -0
  29. omp_memory-0.2.0/src/omp_memory.egg-info/top_level.txt +1 -0
  30. omp_memory-0.2.0/tests/test_auto_recall.py +84 -0
  31. omp_memory-0.2.0/tests/test_bench.py +253 -0
  32. omp_memory-0.2.0/tests/test_cli.py +434 -0
  33. omp_memory-0.2.0/tests/test_concurrency.py +43 -0
  34. omp_memory-0.2.0/tests/test_context.py +11 -0
  35. omp_memory-0.2.0/tests/test_docs_and_atomicity.py +70 -0
  36. omp_memory-0.2.0/tests/test_evidence_and_calibration.py +178 -0
  37. omp_memory-0.2.0/tests/test_external_bench.py +62 -0
  38. omp_memory-0.2.0/tests/test_handoff.py +194 -0
  39. omp_memory-0.2.0/tests/test_handoff_logic.py +85 -0
  40. omp_memory-0.2.0/tests/test_heat.py +341 -0
  41. omp_memory-0.2.0/tests/test_hooks.py +167 -0
  42. omp_memory-0.2.0/tests/test_identity.py +165 -0
  43. omp_memory-0.2.0/tests/test_mcp.py +281 -0
  44. omp_memory-0.2.0/tests/test_md_ingest.py +226 -0
  45. omp_memory-0.2.0/tests/test_memory_context.py +94 -0
  46. omp_memory-0.2.0/tests/test_memory_db.py +496 -0
  47. omp_memory-0.2.0/tests/test_mirror.py +285 -0
  48. omp_memory-0.2.0/tests/test_peer.py +44 -0
  49. omp_memory-0.2.0/tests/test_policy_constants.py +52 -0
  50. omp_memory-0.2.0/tests/test_provider.py +75 -0
  51. omp_memory-0.2.0/tests/test_recall.py +332 -0
  52. omp_memory-0.2.0/tests/test_similarity.py +189 -0
  53. omp_memory-0.2.0/tests/test_sleep.py +135 -0
  54. omp_memory-0.2.0/tests/test_staging.py +85 -0
  55. omp_memory-0.2.0/tests/test_taxonomy.py +58 -0
  56. omp_memory-0.2.0/tests/test_tfidf.py +50 -0
  57. omp_memory-0.2.0/tests/test_trust.py +142 -0
  58. omp_memory-0.2.0/tests/test_watch.py +108 -0
  59. omp_memory-0.2.0/tests/test_wave1.py +178 -0
  60. omp_memory-0.2.0/tests/test_wave10.py +107 -0
  61. omp_memory-0.2.0/tests/test_wave11.py +247 -0
  62. omp_memory-0.2.0/tests/test_wave12.py +207 -0
  63. omp_memory-0.2.0/tests/test_wave13.py +308 -0
  64. omp_memory-0.2.0/tests/test_wave14.py +61 -0
  65. omp_memory-0.2.0/tests/test_wave15.py +71 -0
  66. omp_memory-0.2.0/tests/test_wave16.py +63 -0
  67. omp_memory-0.2.0/tests/test_wave17.py +69 -0
  68. omp_memory-0.2.0/tests/test_wave18.py +682 -0
  69. omp_memory-0.2.0/tests/test_wave2.py +287 -0
  70. omp_memory-0.2.0/tests/test_wave3.py +323 -0
  71. omp_memory-0.2.0/tests/test_wave5.py +446 -0
  72. omp_memory-0.2.0/tests/test_wave6.py +182 -0
  73. omp_memory-0.2.0/tests/test_wave7.py +124 -0
  74. omp_memory-0.2.0/tests/test_wave8.py +119 -0
  75. omp_memory-0.2.0/tests/test_wave9.py +122 -0
  76. omp_memory-0.2.0/tests/test_web.py +517 -0
  77. omp_memory-0.2.0/web/dist/index.html +13 -0
@@ -0,0 +1,19 @@
1
+ # MIT License
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,506 @@
1
+ Metadata-Version: 2.4
2
+ Name: omp-memory
3
+ Version: 0.2.0
4
+ Summary: Local-first SQLite memory for coding agents: capture, search, reinforce, recap.
5
+ Author-email: alfar1zi <f.alfarizii10@gmail.com>
6
+ License: # MIT License
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
25
+ Project-URL: Homepage, https://github.com/alfar1zi/honcho-pi
26
+ Project-URL: Repository, https://github.com/alfar1zi/honcho-pi
27
+ Project-URL: Issues, https://github.com/alfar1zi/honcho-pi/issues
28
+ Keywords: agent,memory,sqlite,fts5,llm,context,opencode,claude-code
29
+ Classifier: Development Status :: 4 - Beta
30
+ Classifier: Environment :: Console
31
+ Classifier: Intended Audience :: Developers
32
+ Classifier: License :: OSI Approved :: MIT License
33
+ Classifier: Operating System :: OS Independent
34
+ Classifier: Programming Language :: Python :: 3
35
+ Classifier: Programming Language :: Python :: 3.10
36
+ Classifier: Programming Language :: Python :: 3.11
37
+ Classifier: Programming Language :: Python :: 3.12
38
+ Classifier: Programming Language :: Python :: 3.13
39
+ Classifier: Topic :: Database :: Database Engines/Servers
40
+ Classifier: Topic :: Software Development :: Quality Assurance
41
+ Requires-Python: >=3.10
42
+ Description-Content-Type: text/markdown
43
+ License-File: LICENSE.md
44
+ Provides-Extra: dev
45
+ Requires-Dist: pytest>=8; extra == "dev"
46
+ Dynamic: license-file
47
+
48
+ <div align="center">
49
+
50
+ <img
51
+ src="assets/logo.png"
52
+ alt="honcho-pi logo"
53
+ width="240"
54
+ />
55
+
56
+ # honcho-pi
57
+
58
+ ### Your coding agent forgets everything. This fixes that.
59
+
60
+ One SQLite file that remembers what worked, what failed, and why.
61
+ Local-first. No server, no API key, no embeddings. Nothing leaves your machine.
62
+
63
+ [Quick start](#quick-start) | [Memory universe](#the-memory-universe)
64
+ [How it works](#how-it-works) | [MCP](#connect-your-agent)
65
+
66
+ <p>
67
+ <a href="LICENSE.md"><img alt="License: MIT" height="20"
68
+ src="https://img.shields.io/badge/license-MIT-9b7bff.svg?style=flat-square&labelColor=0d0d10"></a>
69
+ <img alt="Python 3.10+" height="20"
70
+ src="https://img.shields.io/badge/python-3.10+-3a3a45.svg?style=flat-square&labelColor=0d0d10">
71
+ <img alt="stdlib only" height="20"
72
+ src="https://img.shields.io/badge/dependencies-stdlib_only-3a3a45.svg?style=flat-square&labelColor=0d0d10">
73
+ <img alt="local first" height="20"
74
+ src="https://img.shields.io/badge/data-local--first-3a3a45.svg?style=flat-square&labelColor=0d0d10">
75
+ </p>
76
+
77
+ </div>
78
+
79
+ ---
80
+
81
+ <div align="center">
82
+ <img
83
+ src="assets/screenshots/universe-hero.webp"
84
+ alt="The memory universe: typed records orbit a core of project knowledge,
85
+ skill families form satellite systems, threads connect related lessons"
86
+ width="100%"
87
+ />
88
+ </div>
89
+
90
+ <p align="center"><i>The memory universe: every lesson, decision, and skill your agent has learned, connected.</i></p>
91
+
92
+ ## The problem
93
+
94
+ Every session, your agent starts from zero. It re-learns the same build command, repeats the same wrong
95
+ assumption, and rediscovers the same fix it found last week. You end up being the memory.
96
+
97
+ honcho-pi gives the agent a memory that behaves like memory: lessons that hold get stronger, lessons that
98
+ fail fade, and everything carries the evidence behind it.
99
+
100
+ ## Quick start
101
+
102
+ ```bash
103
+ npx honcho-pi@latest setup
104
+ ```
105
+
106
+ That is the whole install. Python 3.10+ and Node 18+ are the only prerequisites. Then connect your agent:
107
+
108
+ ```json
109
+ {
110
+ "mcpServers": {
111
+ "memory": { "command": "omp-memory-mcp" }
112
+ }
113
+ }
114
+ ```
115
+
116
+ Works with Claude Code, Codex, Cursor, and any MCP client. The agent gets eight tools: `recall`,
117
+ `remember`, `reinforce`, `forget`, `stats`, `maintenance`, `digest`, `handoff`. It uses them on its
118
+ own; you never file anything.
119
+
120
+ ### Extensions live here
121
+
122
+ The omp extensions (`extensions/omp-handoff.ts`, `extensions/omp-auto-recall.ts`)
123
+ are versioned in this repo. The profile directory holds symlinks to them, and
124
+ omp follows those symlinks -- verified by loading the host and reading the
125
+ resolved `import.meta.url`, which points back into the repo:
126
+
127
+ ```bash
128
+ bin/link-extensions.sh # create/refresh the links (idempotent)
129
+ bin/link-extensions.sh --force # replace a real file, keeping a .bak copy
130
+ ```
131
+
132
+ A rebuilt profile only needs that script run once. Setting `OMP_EXT_TRACE` to a
133
+ file makes each extension append a line when it loads, which is the only
134
+ reliable way to tell "loaded" from "silently skipped".
135
+
136
+ ### Agent support
137
+
138
+ | Agent | Push (memory reaches the model) | Capture (lessons leave the session) | Status |
139
+ |---|---|---|---|
140
+ | omp | auto-recall extension injects 3 records per prompt | watch timer + `learn` ingest | automatic |
141
+ | Claude Code | `SessionStart` hook prints the digest into context | `SessionEnd` hook captures from `transcript_path` | `omp-memory install-hooks` |
142
+ | Codex | pull-only: the agent must call `recall` itself | not implemented | no claim |
143
+
144
+ ```bash
145
+ omp-memory install-hooks --dry-run # show the settings diff, write nothing
146
+ omp-memory install-hooks # merge both hooks into ~/.claude/settings.json
147
+ omp-memory install-hooks --uninstall # restore the file byte-for-byte
148
+ ```
149
+
150
+ Claude Code documents its transcript JSONL as internal and version-dependent,
151
+ so the reader recognises only the two shapes that have stayed stable and
152
+ ignores anything else. The supported contract is the hook payload, not the file
153
+ format.
154
+
155
+ ### Who may set what
156
+
157
+ An agent writes **claims**; only you can **attest**. That split is the trust boundary.
158
+
159
+ | Field | Agent (MCP, capture, web editor) | You (CLI) |
160
+ |---|---|---|
161
+ | `content`, `evidence`, `tags` | yes | yes |
162
+ | `confidence` | capped at 0.65 | any value |
163
+ | `verified` | forced to 0 | via `attest` only |
164
+ | `trust` | always `claimed` | `attested` via `attest` |
165
+ | `source` | the server's own id | any |
166
+ | promotion to FACT | blocked, reason logged | allowed once attested |
167
+
168
+ `verified=True` needs evidence on every write path, because a flag with nothing
169
+ behind it is an assertion rather than a check. A RULE or PROCEDURAL record whose
170
+ content runs commands or disables a guard is quarantined as a pending write
171
+ instead of stored, and any such record is kept out of the always-injected digest.
172
+
173
+ ```bash
174
+ omp-memory attest <id> --evidence "checked against the runbook" # claim -> attested
175
+ omp-memory verify # re-check structured evidence, demote what changed
176
+ omp-memory outcome test_pass --session sess-1 # objective result, credits what recall showed
177
+ omp-memory calibrate # Brier and ECE: does 0.8 mean 80%?
178
+ omp-memory doctor # versions, DB mode, FTS sync, hook state
179
+ omp-memory maintenance pending # what is quarantined
180
+ ```
181
+
182
+ ## The memory universe
183
+
184
+ ```bash
185
+ omp-memory overview
186
+ ```
187
+
188
+ <div align="center">
189
+ <img
190
+ src="assets/screenshots/universe-hover.webp"
191
+ alt="Hovering a node lights up its threads and dims everything unrelated"
192
+ width="100%"
193
+ />
194
+ </div>
195
+
196
+ Everything the agent remembers, on one canvas. Each color is a record type, each thread is a relationship.
197
+ Hover a node and its connections light up. Double-click to zoom into its neighborhood. Drag nodes to
198
+ arrange your own map; the layout is saved.
199
+
200
+ **Click any node to open it:**
201
+
202
+ <div align="center">
203
+ <img
204
+ src="assets/screenshots/detail-image.webp"
205
+ alt="Record detail: full content, evidence, provenance, connected nodes,
206
+ and an attached image rendered as the node thumbnail"
207
+ width="100%"
208
+ />
209
+ </div>
210
+
211
+ - **Read the full record**: content, evidence, confidence, where it came from.
212
+ - **Edit it**: fix a wrong lesson right there. The edit writes to the store as a logged correction,
213
+ with evidence required. The agent sees the corrected version on its next recall.
214
+ - **Attach images**: screenshots, diagrams, terminal output. The node becomes a thumbnail.
215
+ Agents can attach images too, through the same API.
216
+
217
+ **And a dashboard that answers one question: is the memory healthy?**
218
+
219
+ <div align="center">
220
+ <img
221
+ src="assets/screenshots/dashboard.webp"
222
+ alt="Dashboard: records by type, confidence buckets, capture activity per day, unlinked count, most connected nodes"
223
+ width="100%"
224
+ />
225
+ </div>
226
+
227
+ Cold records decay toward forgetting; hot ones survive. If the cold bucket dominates, the store needs
228
+ reinforcement, not more capture. The most-connected list shows the hubs your agent actually leans on.
229
+
230
+ The screenshots above use generated demo data (`python3 web/scripts/demo-universe.py`), not anyone's
231
+ real memory.
232
+
233
+ ## How it works
234
+
235
+ ```mermaid
236
+ flowchart LR
237
+ A[Agent works] -->|lesson| B[remember]
238
+ B --> C[(SQLite + FTS5)]
239
+ A -->|next session| D[recall]
240
+ C -->|ranked hits| D
241
+ D --> A
242
+ A -->|it worked / it failed| E[reinforce]
243
+ E -->|confidence up / down| C
244
+ C -->|stale, unverified| F[decay]
245
+ F -->|cold + old| G[forget]
246
+ ```
247
+
248
+ Three rules make it more than a notes file:
249
+
250
+ 1. **Every record carries evidence.** A type (FACT, RULE, DECISION, CORRECTION, ...), a confidence score,
251
+ a verified flag, and the proof behind it. A note written once never gets to masquerade as truth.
252
+ 2. **Reality adjusts confidence.** When a lesson works, the agent reinforces it and it ranks higher.
253
+ When it fails, it loses ground. Unused confidence decays with a 30-day half-life. Verified lessons
254
+ and rules are exempt.
255
+ 3. **The same lesson merges.** Content-addressed identity means "use uv, not pip" written by two sessions
256
+ is one record with two sources, not duplicates fighting in search.
257
+
258
+ Recall is lexical (SQLite FTS5), reranked by confidence, recency, and past success. No embedding model,
259
+ no vector database, no network call. The whole store is one file you can `cp`, inspect with `sqlite3`,
260
+ and back up on your own schedule.
261
+
262
+ ## CLI
263
+
264
+ The agent uses MCP; you can use the CLI:
265
+
266
+ ```bash
267
+ omp-memory search "wal corruption" # ranked search
268
+ omp-memory search "what broke" --explain # why each hit ranked where it did
269
+ omp-memory search "what broke" --expand 5 # each hit plus its temporal neighbours
270
+ omp-memory search "old fact" --as-of 2025-06-01 # what was true then
271
+ omp-memory search "wal corruption" --session sess-20261126 # one capture session
272
+ omp-memory search "wal corruption" --brief # id + first line + token estimate
273
+ omp-memory digest # always-in-context block for session start
274
+ omp-memory capture --task "fix WAL" --outcome "set busy_timeout" --verified
275
+ omp-memory pack team.pack # sync the store via a git-committable file
276
+ omp-memory unpack team.pack # merge on another machine (no server)
277
+ omp-memory skill-export <id> ./skills # procedural memory -> installable SKILL.md
278
+ omp-memory stats # counts by type
279
+ omp-memory health # integrity + backup status
280
+ omp-memory overview # the universe, in your browser
281
+ ```
282
+
283
+ Maintenance and recovery:
284
+
285
+ ```bash
286
+ omp-memory maintenance decay # age confidence toward the floor
287
+ omp-memory maintenance sleep --apply # full consolidation pass
288
+ omp-memory maintenance forget_cold --apply # delete cold records (report first)
289
+ omp-memory maintenance promote # hot inferences -> FACT
290
+ omp-memory maintenance reflect --apply # abstract patterns across sessions
291
+ omp-memory maintenance capture --apply # extract lessons from the session log
292
+ omp-memory maintenance ingest_md --apply # import omp's builtin memories/**/*.md
293
+ omp-memory maintenance review # candidates + the rules to judge them by
294
+ omp-memory maintenance pending # staged writes awaiting review
295
+ omp-memory maintenance approve --pending-id 3 # accept one staged write
296
+ omp-memory maintenance reject --pending-id 3 # refuse it
297
+ omp-memory maintenance not_conflict --a <id> --b <id> # these two do not contradict
298
+ omp-memory backup # consistent snapshot (VACUUM INTO)
299
+ omp-memory repair # restore the newest usable snapshot
300
+ omp-memory disk # free space + store size
301
+ omp-memory checkpoint --session <id> # snapshot evidence before compaction
302
+ omp-memory restore <checkpoint-id> # rebuild from a checkpoint
303
+ ```
304
+
305
+ Inspection and export:
306
+
307
+ ```bash
308
+ omp-memory recap # summarise a session or project
309
+ omp-memory context "wal corruption" # fenced memory block for a prompt
310
+ omp-memory scan "text" # secret scan, same rules as capture
311
+ omp-memory mirror ~/memory-mirror --init # export records to a git repo
312
+ omp-memory reinforce <id> success # record an outcome
313
+ omp-memory promote <id> # verified record -> RULE
314
+ omp-memory analyze # derive INFERENCE rows from logs
315
+ ```
316
+
317
+ ## What the bench shows
318
+
319
+ Measured, not claimed. Two tiers, kept separate because their metrics are not comparable:
320
+
321
+ **External, labeled** (`bench/EXTERNAL.md`, two datasets, SHA-pinned). LongMemEval
322
+ oracle, 428 scored questions: evidence retrieval R@5 **0.9556**, hit@1 **0.6285**,
323
+ every category >= 0.93 R@5. `--expand 5` lifts R@5 to **0.9836** (hit@1 unchanged,
324
+ cost unchanged) because the gold turn is often adjacent to a hit rather than the
325
+ hit itself. LoCoMo (1,977 QA, per-turn gold), measured through
326
+ `recall()` which is what the MCP server serves: hit@1 **0.2934**, R@10
327
+ **0.5878**; the same probe run through `search()` (lexical only) gives **0.3647**
328
+ and 0.5190. The gap is real and open: `search()` orders by bm25 while `recall()`
329
+ scores a matched-term fraction, so they disagree about which single row is best.
330
+ Forcing `recall()` to lead with the bm25 row was measured at 0.3060 and then
331
+ rejected, because it returned `limit+1` rows and put a superseded, stale,
332
+ unverified record above its attested replacement. This measures **evidence
333
+ retrieval**, not QA accuracy or F1; no vendor comparison is implied.
334
+
335
+ **Internal, self-referential** (`bench/RESULTS.md`, pinned synthetic corpus):
336
+ update-correctness 4/4, freshness ~8ms, R@5=1.0 saturated -- useful for
337
+ regression and latency, NOT a quality claim. Five ranking arms raced on
338
+ partial-evidence probes; incumbent wins, PPR earns +0.01 hit@1 over no-PPR.
339
+ No weight changes without a run that beats the incumbent.
340
+
341
+ Published numbers (Zep freshness 162.7s / 8-of-24 updates; mem0 v3 ADD-only)
342
+ come from vendor reports and are **not** directly comparable to our metrics.
343
+ Mem0's current code does implement update and delete with history events;
344
+ the "never invalidates" phrasing described an older published snapshot.
345
+
346
+ ## Surviving a model switch
347
+
348
+ The MCP `handoff` tool is pull-only: a fresh model has to *know* to call it,
349
+ and after a real switch it does not. omp emits no `model_change` event to
350
+ extensions, so the working mechanism is the `context`/`before_agent_start`
351
+ extension API, not a hook on the switch itself.
352
+
353
+ Two things make it automatic:
354
+
355
+ 1. **A brief built from evidence** (`handoff.py`): the operator's verbatim
356
+ requests, decisions and corrections from memory, observed failures, files
357
+ touched. No model paraphrase. Role-filtered so retry-fallback hops
358
+ (`role != "default"`) are not counted as switches - omp's own
359
+ `lastModelChangeRole(skipEphemeral)` skips the same rows.
360
+ 2. **An extension that delivers it** (`extensions/omp-handoff.ts` in this
361
+ repo, symlinked into the profile) on `before_agent_start`, by comparing
362
+ `ctx.model` with the last model that session wrote to a state file.
363
+ Verified API shape: `BeforeAgentStartEventResult` has exactly `message`
364
+ and `systemPrompt`; `additionalContext` is **not** a field and is silently
365
+ ignored.
366
+
367
+ Guards learned from the real transcript: a 20 s debounce (one observed
368
+ flip-flop was 0.3 minutes apart), one brief per switch key and session, and
369
+ a 400-char minimum so an almost-empty session does not inject noise. The injected text
370
+ is wrapped in `BEGIN/END HANDOFF EVIDENCE` markers and labelled data, because
371
+ a model given an unmarked block will happily invent its contents.
372
+
373
+ ## Connect your agent
374
+
375
+ **MCP client** (Claude Code, Codex, Cursor, ...): the JSON block from [Quick start](#quick-start).
376
+
377
+ **Any agent with a shell**: paste this into its instructions:
378
+
379
+ ```text
380
+ Set up the honcho-pi memory: run `npx honcho-pi@latest setup`, then follow its README.
381
+ ```
382
+
383
+ **Python**:
384
+
385
+ ```python
386
+ import omp_memory as m
387
+
388
+ conn = m.connect() # honours OMP_MEMORY_DB, else ~/.omp/memory
389
+ m.init_db(conn) # creates or migrates the schema; connect() alone does not
390
+ m.remember(conn, "FACT", "Install dependencies with uv, not pip",
391
+ verified=1, evidence="agreed in the 2026-10 review", source="s1")
392
+ hits = m.recall(conn, "install dependencies", limit=3)
393
+ ```
394
+
395
+ ## Evidence you can check
396
+
397
+ Free-text evidence is a note. Structured evidence is a claim a machine can
398
+ re-check, and only re-checkable evidence keeps an attestation alive:
399
+
400
+ ```json
401
+ {"file": "src/app.py", "sha256": "<hex>"}
402
+ {"commit": "<sha>"}
403
+ {"test_result": 12}
404
+ ```
405
+
406
+ `omp-memory verify` re-reads the file (or asks git, with an argument list and
407
+ no shell), and on a mismatch demotes the record to `claimed`, lowers its
408
+ confidence and, if the target is gone, flags it stale. An attestation also
409
+ ages: after 90 days recall reports `trust=claimed` again.
410
+
411
+ Calibration is the honest scoreboard for confidence. `omp-memory calibrate`
412
+ bins the confidence the engine claimed at recall time against what actually
413
+ happened afterwards, and prints Brier and ECE plus the sample count per bin;
414
+ below 30 labelled samples it says "insufficient data" instead of a number.
415
+
416
+ ## Reliability
417
+
418
+ | Concern | Behavior |
419
+ | --- | --- |
420
+ | Concurrent writers | WAL mode, 30 s lock wait |
421
+ | Backup | `VACUUM INTO` snapshot, rotated |
422
+ | Corrupt database | raises and keeps the file; `repair` restores from the newest usable backup |
423
+ | Secret leakage | capture, MCP writes, and the web editor scan for secrets before storing |
424
+ | Disk exhaustion | CLI capture refuses below 100 MB free |
425
+ | Unreviewed writes | `capture --staging` parks candidates in `pending_writes` with a content hash; `approve` is the only path that writes them, and a payload changed after staging raises instead of approving |
426
+ | Stale evidence | an anchor file whose checksum changed marks the record `stale`, and `recall` scores it 0.20 lower |
427
+ | Pruning safety | `sleep` only merges records that clear the same three guards a write does: score >= 0.85, identical numbers, no rare-token veto |
428
+
429
+ `omp-memory health` also reports what is decaying, not just whether the file is
430
+ sound: `never_retrieved` (share of records recall has never returned),
431
+ `duplicate_groups`, `stale_anchors`, `superseded`, `low_confidence`.
432
+
433
+ ## Why a hit ranked where it did
434
+
435
+ `recall(explain=True)` (or `search --explain`) attaches the score
436
+ decomposition per hit:
437
+
438
+ ```json
439
+ {"terms": {"lexical": 0.44, "heat": 0.04585, "type_prior": 0.05, "ppr": 0.05,
440
+ "cue": 0.0, "boost": 0.0, "penalty": -0.0},
441
+ "total": 0.58585,
442
+ "heat_parts": {"confidence": 0.9, "recency": 1.0, "reinforcement": 0.0,
443
+ "successes": 0, "age_days": 0.0}}
444
+ ```
445
+
446
+ The terms are the weighted values the ranker summed, so they add up to the
447
+ score exactly. There is no approximation to disagree with the ranking.
448
+
449
+ ## Feature inventory
450
+
451
+ Measured from the running code, not from this file.
452
+
453
+ **MCP tools (8):** `recall` (query, limit, type, project, session,
454
+ verified_only, min_confidence, brief, as_of, expand, explain), `remember`,
455
+ `reinforce`, `forget`, `stats`, `maintenance` (11 ops), `digest`, `handoff`.
456
+
457
+ **CLI (22 commands):** capture, search, recap, context, reinforce, promote,
458
+ analyze, health, stats, digest, maintenance, backup, repair, mirror,
459
+ skill-export, pack, unpack, disk, scan, overview, checkpoint, restore.
460
+
461
+ **Engine:** FTS5 bm25 with per-type divisor and column weights; synonym
462
+ concept groups; vocabulary gate; typo repair; PPR association graph with hub
463
+ penalty and weakest-link bonus; MMR; bi-temporal `as_of`; `not_conflict`
464
+ adjudication; power-law decay (30-day half-life); reinforcement signals;
465
+ consolidation; spacing effect; retrieval-induced forgetting; reconsolidation
466
+ gate; staging with hash pinning; checksum anchors; provenance penalty; budgeted
467
+ digest; markdown / SKILL.md / sync-pack export; web graph UI; session capture;
468
+ builtin-markdown ingestion; handoff brief + omp extension.
469
+
470
+ ## Configuration
471
+
472
+ | Variable | Default | Meaning |
473
+ | --- | --- | --- |
474
+ | `OMP_MEMORY_DB` | `~/.omp/memory/memory.db` | database file |
475
+ | `OMP_MEMORY_BACKUP_DIR` | `~/.omp/memory/backups` | snapshot directory |
476
+ | `OMP_MEMORY_MAX_BACKUPS` | `10` | snapshots kept (newest win) |
477
+ | `OMP_MEMORY_BUSY_TIMEOUT_MS` | `30000` | SQLite lock wait |
478
+ | `OMP_MEMORY_WEB_DIR` | bundled assets | UI root for `overview` |
479
+ | `OMP_MEMORY_IDLE_SECONDS` | `600` | watch: idle before a sleep pass |
480
+ | `OMP_MEMORY_POLL_SECONDS` | `60` | watch: poll interval |
481
+ | `OMP_MEMORY_SLEEP_INTERVAL` | `3600` | watch: seconds between sleep passes |
482
+ | `OMP_MEMORY_SESSIONS` | agent sessions dir | where `capture` reads logs from |
483
+ | `OMP_PROFILE` | `default` | profile name under `~/.omp/profiles` |
484
+ | `HONCHO_HOME` | `~/.omp/profiles/<p>/agent/honcho` | MCP data root |
485
+ | `HONCHO_MAX_RECALL` | `8` | default recall limit |
486
+ | `HONCHO_TRANSPORT` | `stdio` | `stdio` or `http` |
487
+ | `HONCHO_PORT` | `8765` | HTTP port when `HONCHO_TRANSPORT=http` |
488
+ | `HONCHO_TOKENS` | unset | comma list of bearer tokens for HTTP mode |
489
+ | `HONCHO_EXTRA_TOOLS` | unset | `os.pathsep` list of extra tool directories |
490
+
491
+ Every value is parsed tolerantly: a malformed number falls back to its default
492
+ instead of stopping the server from starting.
493
+
494
+ Updates: `npx honcho-pi@latest update` (keeps the database). Status: `npx honcho-pi@latest status`.
495
+
496
+ ## Development
497
+
498
+ ```bash
499
+ python -m pytest # 577 tests, no network
500
+ bash bin/clean-code.sh # quality gate
501
+ bash bin/web-deploy.sh # build + deploy the web UI
502
+ ```
503
+
504
+ ## License
505
+
506
+ MIT. See [LICENSE.md](LICENSE.md).