counterparts 0.1.0

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 (195) hide show
  1. package/CONSTITUTION.md +68 -0
  2. package/LICENSE +21 -0
  3. package/README.md +348 -0
  4. package/docs/ELI5.md +84 -0
  5. package/docs/QUICKSTART.md +1258 -0
  6. package/docs/module-map.md +81 -0
  7. package/package.json +63 -0
  8. package/src/adapters/claude-code/CONTRACT.md +606 -0
  9. package/src/adapters/claude-code/INTERFACE-GAPS.md +655 -0
  10. package/src/adapters/claude-code/NOTES.md +1055 -0
  11. package/src/adapters/claude-code/bin/hook.ts +820 -0
  12. package/src/adapters/claude-code/bin/runner.ts +522 -0
  13. package/src/adapters/claude-code/config.ts +778 -0
  14. package/src/adapters/claude-code/credentials.ts +199 -0
  15. package/src/adapters/claude-code/doctor.ts +2557 -0
  16. package/src/adapters/claude-code/embed-client.ts +617 -0
  17. package/src/adapters/claude-code/hooks.ts +2240 -0
  18. package/src/adapters/claude-code/index.ts +224 -0
  19. package/src/adapters/claude-code/interpret-client.ts +395 -0
  20. package/src/adapters/claude-code/page-writer.ts +462 -0
  21. package/src/adapters/claude-code/primacy.ts +162 -0
  22. package/src/adapters/claude-code/spawn.ts +241 -0
  23. package/src/adapters/claude-code/standdown.ts +536 -0
  24. package/src/adapters/claude-code/transcript.ts +661 -0
  25. package/src/adapters/claude-code/vectors.ts +415 -0
  26. package/src/adapters/cli/CONTRACT.md +255 -0
  27. package/src/adapters/cli/INTERFACE-GAPS.md +350 -0
  28. package/src/adapters/cli/NOTES.md +936 -0
  29. package/src/adapters/cli/bin/counterparts.ts +74 -0
  30. package/src/adapters/cli/commands.ts +6095 -0
  31. package/src/adapters/cli/export.ts +766 -0
  32. package/src/adapters/cli/index.ts +103 -0
  33. package/src/adapters/cli/install.ts +670 -0
  34. package/src/adapters/cli/removal.ts +1186 -0
  35. package/src/adapters/cli/repair-dates.ts +659 -0
  36. package/src/adapters/cli/self-page.ts +229 -0
  37. package/src/adapters/cli/snapshot.ts +279 -0
  38. package/src/adapters/cli/start-fresh.ts +1228 -0
  39. package/src/adapters/config-path.ts +342 -0
  40. package/src/adapters/dashboard/CONTRACT.md +67 -0
  41. package/src/adapters/dashboard/INTERFACE-GAPS.md +139 -0
  42. package/src/adapters/dashboard/NOTES.md +474 -0
  43. package/src/adapters/dashboard/activity.ts +121 -0
  44. package/src/adapters/dashboard/ansi.ts +82 -0
  45. package/src/adapters/dashboard/bin/dashboard.ts +479 -0
  46. package/src/adapters/dashboard/browse.ts +298 -0
  47. package/src/adapters/dashboard/identity.ts +182 -0
  48. package/src/adapters/dashboard/index.ts +183 -0
  49. package/src/adapters/dashboard/layout.ts +149 -0
  50. package/src/adapters/dashboard/registries.ts +291 -0
  51. package/src/adapters/dashboard/resolve.ts +206 -0
  52. package/src/adapters/dashboard/source.ts +48 -0
  53. package/src/adapters/dashboard/status.ts +327 -0
  54. package/src/adapters/dashboard/stories.ts +194 -0
  55. package/src/adapters/dashboard/web/app.html +1731 -0
  56. package/src/adapters/dashboard/web/brain.html +463 -0
  57. package/src/adapters/dashboard/web/fired.ts +31 -0
  58. package/src/adapters/dashboard/web/flow.ts +457 -0
  59. package/src/adapters/dashboard/web/narrate.ts +1042 -0
  60. package/src/adapters/dashboard/web/reveal.ts +135 -0
  61. package/src/adapters/dashboard/web/server.ts +287 -0
  62. package/src/adapters/dashboard/web/views.ts +1744 -0
  63. package/src/adapters/expansions.ts +569 -0
  64. package/src/adapters/fired.ts +1580 -0
  65. package/src/adapters/mcp/CONTRACT.md +240 -0
  66. package/src/adapters/mcp/INTERFACE-GAPS.md +271 -0
  67. package/src/adapters/mcp/NOTES.md +205 -0
  68. package/src/adapters/mcp/bin/serve.ts +349 -0
  69. package/src/adapters/mcp/deliberate.ts +619 -0
  70. package/src/adapters/mcp/index.ts +101 -0
  71. package/src/adapters/mcp/protocol.ts +170 -0
  72. package/src/adapters/mcp/server.ts +1740 -0
  73. package/src/adapters/mcp/stdio.ts +56 -0
  74. package/src/adapters/mcp/tools.ts +779 -0
  75. package/src/adapters/scopes.ts +657 -0
  76. package/src/adapters/sessions.ts +402 -0
  77. package/src/adapters/snapshots.ts +1069 -0
  78. package/src/adapters/stance-env.ts +137 -0
  79. package/src/core/associate/CONTRACT.md +118 -0
  80. package/src/core/associate/INTERFACE-GAPS.md +173 -0
  81. package/src/core/associate/NOTES.md +194 -0
  82. package/src/core/associate/buffer.ts +66 -0
  83. package/src/core/associate/edges.ts +188 -0
  84. package/src/core/associate/index.ts +570 -0
  85. package/src/core/associate/pending.ts +383 -0
  86. package/src/core/associate/spread.ts +149 -0
  87. package/src/core/associate/tunables.ts +123 -0
  88. package/src/core/bridge.ts +272 -0
  89. package/src/core/briefing.ts +67 -0
  90. package/src/core/counterpart.ts +3855 -0
  91. package/src/core/encode/CONTRACT.md +151 -0
  92. package/src/core/encode/INTERFACE-GAPS.md +135 -0
  93. package/src/core/encode/NOTES.md +146 -0
  94. package/src/core/encode/aliases.ts +71 -0
  95. package/src/core/encode/battery.ts +284 -0
  96. package/src/core/encode/chunk.ts +265 -0
  97. package/src/core/encode/emotion.ts +119 -0
  98. package/src/core/encode/floor.ts +76 -0
  99. package/src/core/encode/index.ts +100 -0
  100. package/src/core/encode/precision.ts +162 -0
  101. package/src/core/encode/preselect.ts +269 -0
  102. package/src/core/encode/salience.ts +108 -0
  103. package/src/core/encode/secrets.ts +265 -0
  104. package/src/core/encode/tunables.ts +99 -0
  105. package/src/core/encode/types.ts +286 -0
  106. package/src/core/encode/words.ts +75 -0
  107. package/src/core/handoff/CONTRACT.md +199 -0
  108. package/src/core/handoff/INTERFACE-GAPS.md +166 -0
  109. package/src/core/handoff/NOTES.md +206 -0
  110. package/src/core/handoff/index.ts +957 -0
  111. package/src/core/mint.ts +279 -0
  112. package/src/core/observer.ts +28 -0
  113. package/src/core/physics/CONTRACT.md +341 -0
  114. package/src/core/physics/NOTES.md +155 -0
  115. package/src/core/physics/clock.ts +51 -0
  116. package/src/core/physics/index.ts +1054 -0
  117. package/src/core/prospective/CONTRACT.md +137 -0
  118. package/src/core/prospective/INTERFACE-GAPS.md +112 -0
  119. package/src/core/prospective/NOTES.md +160 -0
  120. package/src/core/prospective/derive.ts +188 -0
  121. package/src/core/prospective/index.ts +1030 -0
  122. package/src/core/prospective/tunables.ts +72 -0
  123. package/src/core/prospective/windows.ts +187 -0
  124. package/src/core/recall/CONTRACT.md +326 -0
  125. package/src/core/recall/INTERFACE-GAPS.md +163 -0
  126. package/src/core/recall/NOTES.md +472 -0
  127. package/src/core/recall/activate.ts +521 -0
  128. package/src/core/recall/cues.ts +275 -0
  129. package/src/core/recall/gate.ts +441 -0
  130. package/src/core/recall/index.ts +692 -0
  131. package/src/core/recall/probe.ts +239 -0
  132. package/src/core/recall/reference.ts +201 -0
  133. package/src/core/recall/render.ts +285 -0
  134. package/src/core/recall/session.ts +403 -0
  135. package/src/core/recall/tunables.ts +329 -0
  136. package/src/core/remember/CONTRACT.md +293 -0
  137. package/src/core/remember/INTERFACE-GAPS.md +189 -0
  138. package/src/core/remember/NOTES.md +373 -0
  139. package/src/core/remember/fallback.ts +452 -0
  140. package/src/core/remember/index.ts +103 -0
  141. package/src/core/remember/owner-strike-seam.ts +479 -0
  142. package/src/core/remember/proposals.ts +609 -0
  143. package/src/core/remember/spans.ts +1310 -0
  144. package/src/core/remember/tunables.ts +111 -0
  145. package/src/core/remember/updates.ts +198 -0
  146. package/src/core/retrieval.ts +96 -0
  147. package/src/core/revision.ts +441 -0
  148. package/src/core/schemas/CONTRACT.md +190 -0
  149. package/src/core/schemas/INTERFACE-GAPS.md +172 -0
  150. package/src/core/schemas/NOTES.md +260 -0
  151. package/src/core/schemas/aliases.ts +160 -0
  152. package/src/core/schemas/index.ts +1459 -0
  153. package/src/core/schemas/tunables.ts +44 -0
  154. package/src/core/schemas/types.ts +387 -0
  155. package/src/core/self/CONTRACT.md +459 -0
  156. package/src/core/self/INTERFACE-GAPS.md +284 -0
  157. package/src/core/self/NOTES.md +1057 -0
  158. package/src/core/self/briefing.ts +980 -0
  159. package/src/core/self/episodes.ts +483 -0
  160. package/src/core/self/freeze.ts +103 -0
  161. package/src/core/self/identity.ts +604 -0
  162. package/src/core/self/index.ts +2130 -0
  163. package/src/core/self/journal-file.ts +760 -0
  164. package/src/core/self/page.ts +404 -0
  165. package/src/core/self/tunables.ts +244 -0
  166. package/src/core/self/writer.ts +714 -0
  167. package/src/core/sleep/CONTRACT.md +298 -0
  168. package/src/core/sleep/INTERFACE-GAPS.md +262 -0
  169. package/src/core/sleep/NOTES.md +770 -0
  170. package/src/core/sleep/briefing.ts +86 -0
  171. package/src/core/sleep/consolidate.ts +241 -0
  172. package/src/core/sleep/cycle.ts +598 -0
  173. package/src/core/sleep/decay.ts +237 -0
  174. package/src/core/sleep/dedup.ts +373 -0
  175. package/src/core/sleep/index.ts +112 -0
  176. package/src/core/sleep/log.ts +116 -0
  177. package/src/core/sleep/markers.ts +164 -0
  178. package/src/core/sleep/prune.ts +170 -0
  179. package/src/core/sleep/strength-cache.ts +176 -0
  180. package/src/core/sleep/tunables.ts +135 -0
  181. package/src/core/sleep/types.ts +542 -0
  182. package/src/core/store/CONTRACT.md +446 -0
  183. package/src/core/store/NOTES.md +1068 -0
  184. package/src/core/store/cache.ts +709 -0
  185. package/src/core/store/db.ts +275 -0
  186. package/src/core/store/errors.ts +134 -0
  187. package/src/core/store/index.ts +2450 -0
  188. package/src/core/store/operational.ts +610 -0
  189. package/src/core/store/owner-op-seam.ts +428 -0
  190. package/src/core/store/paths.ts +494 -0
  191. package/src/core/store/prose.ts +165 -0
  192. package/src/core/store/render.ts +87 -0
  193. package/src/core/store/walk-seam.ts +78 -0
  194. package/src/core/types.ts +68 -0
  195. package/tools/install-loop/run.sh +1063 -0
@@ -0,0 +1,446 @@
1
+ # `store/` — CONTRACT
2
+
3
+ ## 1. Purpose
4
+
5
+ The substrate: **two** boxes — one small canonical transactional database
6
+ (`counterparts.sqlite`), one rebuildable search cache (`cache/`) — and the single seam
7
+ every write crosses. Since the floor (schema v6, 2026-09-20) **a memory IS a row**: its
8
+ title, its words, its metadata and its archived versions are columns. Markdown is an
9
+ export (`render.ts`), written one direction only; nothing reads it back.
10
+
11
+ ## 2. Brain analog
12
+
13
+ None, deliberately. This is the engineering floor the brain does not have: **exactness
14
+ where the brain is reconstructive** (constitution line 9 — "biology's rules without
15
+ biology's limits"). Human memory has no separable substrate; conflating the two is how v1
16
+ ended up with canonical state spread across a prose store plus half a dozen sidecars
17
+ (Appendix A #14).
18
+
19
+ ## 3. Keeps
20
+
21
+ - **The owner can VIEW every memory.** Constitution line 6, in the owner's own words
22
+ (2026-09-16): "going forward by 'readable' we mean if someone can view them" — in a file
23
+ or in the database. The dashboard, `counterparts recall`, the console and asking the
24
+ counterpart all show the words; `counterparts export` writes markdown. What is not
25
+ claimed is that every memory IS a markdown file.
26
+ - **Round-trip fidelity extends to metadata** — unrecognized fields survive untouched.
27
+ [v1] §4.2 G6 (v1 incident: a parser silently dropped tier, frequency, provenance and
28
+ aliases on rewrite). *Free since the floor: `meta` is one TEXT column holding the JSON
29
+ verbatim, and a value JSON would drop or transform is refused before the row is written
30
+ (`assertJsonSafe`, `PROSE_META_UNSERIALIZABLE`) rather than truncated — the one guard
31
+ that outlived the markdown parser.*
32
+ - **Ids are immutable, never reused, type-prefixed; resolution follows lineage; a cycle,
33
+ a dangling id, or an over-deep chain is a hard error.** [v1] §4.2 G2, test-triage P1
34
+ `ids.test.ts`.
35
+ - **Every mutable sub-item carries a stable handle. The body is the content; the handle is
36
+ the identity.** [v1] §4.2 G1.
37
+ - **Archive-on-overwrite, in one transaction.** [v1] §16 G4. *Since the floor the prior
38
+ version is a ROW written beside the update — body, title, meta, hash and both provenance
39
+ dates — so "atomic and collision-proof" is a property of the transaction: no `wx` loop,
40
+ no temp-file naming ceremony, and no crash-leaked stage that could be loaded as a
41
+ duplicate, because there is no stage.*
42
+ - **Destruction enforced by absence**, with a caller-universality test. [v1] §16 G1–G2,
43
+ earned-mechanism #14: "the shape — enforced by absence, verified mechanically — is worth
44
+ more than the specific mechanism."
45
+ - **Removal is recorded, the record is canonical and append-only, and carries no body and
46
+ no content hash.** [v1] §16 G7–G9, scar §2.20.
47
+ - **A removed memory cannot be silently resurrected** — a deny-list at load and rebuild;
48
+ the stray copy is skipped and logged, never deleted. [v1] §16 G12.
49
+ - **Per-item persistence isolation** — one item that fails to serialize is logged and
50
+ skipped; the rest persist. [v1] §16 G6.
51
+ - **Three dates, deliberately distinct**: when it happened (at stated precision, never
52
+ rounded), when it was learned, which lived day it was born on. [v1] §4.2. The first two
53
+ come from the session's INJECTED clock (`StoreOptions.now`), the third from the physics
54
+ clock (`advanceClock` / `livedDay`) — two clocks, never one (`NOTES.md` 2026-09-05).
55
+ - **One content-address function**, so a raw span, a run record and a rejected proposal
56
+ join on the same key. [v1] §17.1. *Since the floor it is `hashText(body)`, one definition
57
+ across `memories` and `versions`, where it used to address the whole serialized document:
58
+ a title-only revision no longer moves it, and two memories differing only in title share
59
+ it. `NOTES.md` 2026-09-20 traces where the column travels and why the weaker preimage is
60
+ acceptable.*
61
+ - **A store directory is self-contained.** A copy, a move or a restored backup reads and
62
+ removes its OWN memories and never another store's (finding I22, 2026-09-05).
63
+ Constitution line 6 — local-first, portable — and line 7's "backups catch catastrophe"
64
+ both rest on it: a backup that still pointed at the live store was not a backup. *G15
65
+ below: structural since the floor rather than enforced.*
66
+
67
+ ## 4. Drops / simplifies
68
+
69
+ - **The three boxes are two** (owner decision 2026-08-25, settled; revised by the same
70
+ owner 2026-09-16/17 — `docs/storage-spec-2026-09-16.md` §15 item 9, "everything lives in
71
+ the database for now; markdown is an export"):
72
+ 1. ~~**Canonical prose** — one markdown file per memory.~~ **GONE at the floor.** About
73
+ 16,000 files sat beside a 7 MB database and the two could disagree. With them went
74
+ `prose/`, `versions/`, `tmp/`, `memories.prose_path`, `versions.path`, the placement
75
+ rules, the census and ~1,000 lines of path-juggling. The MARKDOWN survives as
76
+ `render.ts#renderMarkdown`, the export renderer, which keeps the format's one testable
77
+ property — a section never used renders byte-identically to a document that predates
78
+ the section ([v1] §4.2 G8, `test/store.test.ts`). The journal ALSO keeps a file copy,
79
+ as a copy, because plain files outlive the system that wrote them (§15 item 9): one
80
+ `journal/<YYYY>/<YYYY-MM-DD>-<id>.md` per episode, written by the worker as each
81
+ chapter lands, never read back, derived and regenerated if deleted.
82
+ 2. **One small canonical transactional SQLite** — the memories themselves (`title`,
83
+ `body`, `meta`, `confidential`, `content_hash`), their archived versions, and the
84
+ structured state around them: ids, kinds, salience, `uses`, day stamps, lineage rows,
85
+ entity/belief rows, prospective windows, the removal record, per-session gate state.
86
+ **Transactional**: every multi-step change commits or does not.
87
+ 3. **A separate rebuildable cache** — embeddings and full-text index. **Never backed
88
+ up**, always reconstructible, and its loss is a re-index, never a memory. Vectors are
89
+ float32 BLOBs (`dim` little-endian singles, cache schema v4, 2026-09-05) — the
90
+ embedder's own precision, 2.8× smaller and ~11× faster to scan than v3's JSON text
91
+ (measured; `NOTES.md`). "Reconstructible" is honest for the text index and partly
92
+ dishonest for the vectors: those cost a paid network call each, which is why
93
+ `rebuildCache({ keepVectors })` and `counterparts migrate-cache` exist rather than a
94
+ rebuild.
95
+ - **The markdown parser is gone, and with it the "refuses ambiguity" guarantee it carried**
96
+ ([v1] §4.2 G7): the frontmatter reader, the authoritative `payload:` line that existed so
97
+ a lossy YAML reading could never become the truth, and the six refusal codes around them
98
+ (`PROSE_FRONTMATTER_MISSING`, `PROSE_PAYLOAD_MISSING/MALFORMED`, `PROSE_FILE_MISSING`,
99
+ `ARCHIVE_COLLISION`, `STORED_PATH_ESCAPES`). Nothing parses markdown back, so there is no
100
+ ambiguity to refuse. What replaced `PROSE_FILE_MISSING` is `MEMORY_BODY_MISSING`, which
101
+ says the same thing about a row and is told apart from a tombstone by the hash beside it.
102
+ - **The strength-only exemption to archive-on-overwrite is gone** ([v1] §16 G5) — a
103
+ conservative line-level diff with a flag as permission. Structural since physics moved to
104
+ columns: `updatePhysics` names the columns it sets and none of them is the body, the
105
+ title, the meta or the hash.
106
+ - **The universal "the DB is a cache" rebuild contract is released** (owner rescope 1,
107
+ settled) — it covers box 3 only. Box 2 is canonical and is backed up as a database.
108
+ *One box-2 table is telemetry rather than memory and has bounded retention: the durable
109
+ event log (SEAMS item K). `pruneEvents({ limit })` deletes UNLATCHED rows older than
110
+ `retentionDays` lived days, oldest first, capped per call, and reports what went and what
111
+ is left; rows carrying a `dedup_key` — the replay latch — are kept at any age.
112
+ `eventLogCensus()` is the read-only count of the same. The caller is sleep's `log` phase
113
+ (`sleep/` §5 G16, 2026-09-05).*
114
+ - **Hand-serialized JSON sidecars are gone** (owner rescope 1, settled). All seven bugs in
115
+ v1's 2026-08-18 verified-bug batch were structured-sidecar bugs, and the class refired
116
+ 2026-08-23 (scar §2.1).
117
+ - **The staged quarantine → cooling-off → chase-every-copy erase ceremony is released**
118
+ (owner rescope 3, settled): 871 lines, never production-fired. The kernel survives —
119
+ owner-initiated removal, loud, recorded, unreachable from any model path. One property
120
+ from inside the released ceremony is kept as a note for `cli/`: the cooling-off was
121
+ deliberately **wall-clock**, not active days.
122
+ - **Forever-archive becomes bounded versioning** (owner rescope 3, settled) — superseded
123
+ rows retained ~90 lived days, on by default (owner ruling 1, 2026-09-18). *The prune's
124
+ cost changed at the floor and the ruling was taken knowing it: a version row now holds
125
+ the owner's earlier WORDS, where it used to hold a note about a file that was never
126
+ deleted. His steer: simple working-memory mechanics over keeping everything.*
127
+ - **Local-only absolutism is released**; the property is **no silent egress** (owner
128
+ rescope 2, settled).
129
+ - **The v1 → v2 import is gone** (owner ruling 6, 2026-09-18, and F8): `tools/migrate/**`
130
+ and its tests are deleted, the cut-over carries nothing, and the owner starts as a new
131
+ user. If an import is ever built it traverses G1's seam like everything else, and for the
132
+ named reason: scar §2.7's worst incident was v1's migration path bypassing the secrets
133
+ gate and putting three live API keys into the store.
134
+
135
+ ## 5. Contract
136
+
137
+ **Inputs** — write requests (create, revise, supersede, archive, prune), reads by id, by
138
+ cue, by kind, by scope; rebuild requests for box 3.
139
+ **Outputs** — durable state; resolved references; ids; the removal record; telemetry by
140
+ reference only.
141
+
142
+ *Numbering is stable across the floor on purpose: G1–G17 are the numbers other modules,
143
+ tests and `docs/` already cite, and none of them is retired. G5, G11 and G15 are restated
144
+ for rows; G16 and G17 arrived with the floor; **G18 and G19 are new here**, and they are
145
+ not new PROMISES — they are two things the code has kept since 2026-09-18 and 2026-08-25
146
+ that lived only in `NOTES.md`, written down so a citation can reach them. The
147
+ implementation plan's §5 outline numbered the tail differently — its G15 is this page's
148
+ G16 and its G16 is this page's G18 — and its G17, "a snapshot is a VACUUM INTO of the
149
+ classified backup set, rotated by an adapter", is not a store guarantee at all: rotation
150
+ DELETES, so it lives in `adapters/snapshots.ts` and may never live here (G2). What is a
151
+ store property is the `VACUUM INTO`, and that is G19. The code's numbering wins.*
152
+
153
+ **Guarantees** — **[M]** mechanized, **[A]** advisory:
154
+
155
+ 1. **[M] One seam.** Every path by which text becomes canonical — steady state, jot,
156
+ crash fallback, import, repair, replay harness, adapter — traverses one write function,
157
+ and a totality test enumerates entrances and asserts each one does (scar §2.7).
158
+ 2. **[M] The store exports no delete/remove/unlink function of any kind**, and a test
159
+ asserts that over every export name. Removal lives in exactly one module, and a
160
+ caller-universality test pins who may import it — **no model-reachable path may**
161
+ (scar §2.6, earned-mechanism #14).
162
+ *Correction (2026-08-25, when the box-2 chase landed — BUILD-STATUS gap 3): the ban is
163
+ total over the module EXCEPT `owner-op-seam.ts`, whose export list is pinned by name in
164
+ `test/store.test.ts`. The seam had to become the place removal actually happens, because
165
+ a removal that could not reach the `memories`/`edges`/`prospective` rows was "anything
166
+ can be removed loudly" with a footnote. Nothing weakened: `Store` itself still carries no
167
+ such method (the prototype test is unchanged and total), the chase reaches its capability
168
+ through a WeakMap the constructor grants and no caller can read, it crosses the same
169
+ observer stance check every write crosses, and a second caller-universality test pins who
170
+ may VALUE-import the seam — `adapters/cli/` and nobody else.*
171
+ *Second correction (2026-09-05, the probe-H repair — `sleep/NOTES.md` §12): the seam
172
+ gained `unarchiveMerged` (with `MERGED_ARCHIVE_REASON` and `UNMERGE_EVENT`), the one
173
+ REPAIR on this path. It is here rather than on `Store` for the same reason the chase is:
174
+ a general `unarchive` would reverse the prune, the revision and the removal along with
175
+ the merge, and every one of those is archived for a reason a repair tool has no business
176
+ undoing. This door undoes exactly `archived_reason: "merged"` and refuses every other
177
+ reason, a superseded row, a removed id and an unknown id, each by its own error code. It
178
+ crosses the same stance check, appends a latched `memory.unmerged` record in the same
179
+ transaction, and erases nothing (constitution 7). It is also the one owner-op that
180
+ touches box 3 — `OwnerOpAccess.reindexLexical`, the LEXICAL half only, so a restored row
181
+ is findable again while its embedding is neither recomputed at cost nor dropped.*
182
+ 3. **[M] No structured mutable state is hand-serialized by more than one writer** (scar
183
+ §2.1). Box 2 is transactional, and since the floor there is no non-transactional
184
+ canonical state left at all — the words moved inside the transaction with everything
185
+ else. **Partly mechanized, honestly:** `test/store.test.ts`'s layout totality enumerates
186
+ every top-level path and fails on an unclassified one, and this page names what each one
187
+ is; what NO test proves is single-writer-ness for the two mutable directories that are
188
+ not the database — `spans/` (`remember/`'s buffer, one writer per project key plus a
189
+ claim protocol) and `sessions/` (host state). Argued in `remember/` and
190
+ `adapters/sessions.ts`, not asserted. §7 question 4.
191
+ 4. **[M] Referential integrity is enforced by the store** — foreign keys, or one retarget
192
+ site every write path inherits — never by remembering at each call site. Supersession
193
+ leaves a forwarding address; a dangling reference is a hard error, not a silent drop
194
+ (scar §2.2; v1's cross-boundary dangling gap, §6.2 known gaps, is closed by this).
195
+ 5. **[M] An overwrite keeps the prior version, body included, in the same transaction.**
196
+ *(Restated at the floor: it was "archives the prior version first, atomically and
197
+ collision-proof", which described an ordering between a file copy and a file rename. The
198
+ version is a row now, written beside the update, so there is no first and no window. The
199
+ version row carries `learned_on` and `happened_on` as well as the words, because
200
+ `revise({learnedOn})` travels this same door precisely so a corrected date keeps its
201
+ prior version — taking the dates from the live row would silently rewrite every version
202
+ behind a correction.)*
203
+ 6. **[M] Removal is ordered so every crash point is safe**: at each moment a memory is
204
+ fully alive, or dark *and* recorded. A failed record append is never reported as
205
+ success — if the record cannot be written, nothing moves (§16 G10–G11).
206
+ 7. **[M] Everything that must read doomed content happens before any copy is chased**
207
+ (§16 G13), and every surface is chased including the derived index and the association
208
+ graph (§16 G14, scar §2.2's erase variant). The span buffer is chased FIRST, because the
209
+ chase blanks the row's body, hash and `origin_ref` — which are what address a span. The
210
+ journal's markdown copy is a named surface too, and it stands down rather than following
211
+ a symlink at or under `journal/` (`journal-symlink`), which is the one place this
212
+ guarantee answers "could not" instead of "did" — said in the report, never passed over.
213
+ Copies taken BEFORE a removal still hold the memory, and the report says so rather than
214
+ implying the machine is clean (G19's `VACUUM INTO` is why no copy taken AFTER one does).
215
+ 8. **[M] Box 3 is behaviorally rebuildable**: a test deletes it, rebuilds from canonical,
216
+ and asserts *the same recall for the same cues* — not merely that rebuild returned.
217
+ Anything rebuild cannot recompute is declared, with a named owner and a repair path,
218
+ and the count of un-recomputed items is logged at every rebuild (scar §2.12).
219
+ 9. **[M] Path guards resolve and realpath both sides before comparing**; no tool accepts a
220
+ pointer at a real store from an environment variable (scar §2.13). Since 2026-09-18 the
221
+ snapshot directory and its optional mirror go through the same guard, which also refuses
222
+ a destination inside the store it is copying and one that contains it.
223
+ 10. **[M] Telemetry is content-by-reference** — ids, hashes, scores, counts, kinds, tiers;
224
+ never body text, never user turn text; error messages included. Any surface that names
225
+ a memory resolves the id against the live store **at render time**, so the display dies
226
+ with the record (scar §2.20, earned-mechanism #16). *`content_hash` became a weaker
227
+ reference at the floor — a 16-hex SHA-256 prefix of a short, low-entropy body is
228
+ guessable — and it is acceptable because of where it goes, which `NOTES.md` 2026-09-20
229
+ traces rather than assumes: the removal record and the tombstone carry no hash at all,
230
+ the dashboard blanks it for confidential rows, and `store.put`'s emitted `hash` reaches
231
+ no durable row. If it ever starts riding telemetry that lands on disk, look again.*
232
+ 11. **[M] Every top-level path in the data directory is classified**: in the backup set, or
233
+ on an explicit documented exclusion list. Adding a directory breaks the build until it
234
+ is classified (scar §2.11 — v1 silently omitted the canonical episode journal from
235
+ snapshots for three weeks). Five entries, and the reason each one is where it is:
236
+ `counterparts.sqlite` (prefix, backed up — box 2), `cache` (excluded, rebuildable),
237
+ `spans` (backed up, not reconstructible), `journal` (**classified and EXCLUDED**),
238
+ `sessions` (excluded, host state).
239
+ **Classified is not the same question as backed up**, and `journal/` is what makes
240
+ that worth saying. It is a derived, write-only markdown COPY of episode rows the
241
+ database already holds, and it is excluded on purpose: a copy of it put removed
242
+ episodes' words into every rotating snapshot as plain greppable markdown, where a
243
+ database inside an old snapshot is a file somebody must know to open and a `.md`
244
+ inside one is a search result. Excluding it costs nothing, because a restored store
245
+ writes every file again at its next boundary. Scar §2.11 is not weakened by that —
246
+ the scar is about losing the CANONICAL journal from every backup, and the canonical
247
+ journal is rows. What the scar's other half still demands is met: the directory was
248
+ **classified BEFORE anything wrote it**, which is v1's incident said forwards.
249
+ *Note (2026-09-18, when the boxes went to WAL): the database entry classifies by
250
+ PREFIX, so `counterparts.sqlite-wal` and `-shm` are covered — but* **the database file
251
+ alone is no longer the database.** *Pages committed since the last checkpoint live in
252
+ the `-wal`, so a copy of the file alone opens and is silently short, and deleting a
253
+ `-wal` deletes what is inside it. The copies that are whole are `counterparts backup`,
254
+ `export` and the rotating snapshot — all `VACUUM INTO` (G19) — or a copy of the whole
255
+ directory, sidecars included. For the same reason `sqlite3 "file:…?immutable=1"` reads
256
+ the store as of the last checkpoint and says nothing; plain `-readonly` is right.*
257
+ 12. **[A] Raw conversational text is not the system of record.** The shipped default keeps
258
+ none; where a developer opts in, the window is as short as the retry path needs.
259
+ 13. **[M] Reads of archived, superseded, and removal-record content emit an event.** v1
260
+ could not answer "did the archival mechanisms ever pay for themselves" because nothing
261
+ logged a read-back (log-audit §3). This is a v2 instrumentation requirement, not a
262
+ preference. The exemption is `walk-seam.ts#readProseWalking`, for a caller WALKING rows
263
+ rather than answering for one — an index build, a repair plan. It is a look at the
264
+ address, so it fires no event and asks the deny-list nothing; the callers that need it
265
+ (`schemas/index.ts#load`, `cli/commands.ts`'s unmerge helpers) had exactly that by
266
+ reading the file behind the store's back until 2026-09-18, and this is the same
267
+ exemption said once, in one place, where it can be seen and one day closed. It is
268
+ **not** a `Store` method, for the reason `chaseRemoved` is not: §4's "unreachable from
269
+ any model path" has to stay true of the store's own surface, and `Counterpart.store` is
270
+ public. Two files may import it and `test/cli.test.ts` pins which.
271
+ `StoredMemory.confidential` rides on the ordinary read for the opposite reason: the
272
+ confidentiality class is a gate, and a gate that re-parses JSON at every call site is a
273
+ gate that will one day fail open (`confidentialByMeta`, the one truth table, which
274
+ `recall/activate.ts#isConfidential` is a door onto). It is a COLUMN since the floor and
275
+ the truth table is unchanged.
276
+ 14. **[M] The implicit default is refusable.** `dataDir()`'s fallback to
277
+ `~/.counterparts/store` is the one path a caller reaches by naming nothing, and on the
278
+ owner's machine it is his live memory; `.counterparts` cannot join the forbidden roots
279
+ (G9) because the store must open its own default. So the fallback is a door with a lock:
280
+ with `COUNTERPARTS_REQUIRE_EXPLICIT_DIR` armed (`1`, `true` or `on` — trimmed and
281
+ case-insensitive), every resolution that would have returned it throws
282
+ `IMPLICIT_DEFAULT_DIR_REFUSED` before anything is created, naming the guard, the
283
+ directory and the remedy — and a named `dir` or a `COUNTERPARTS_DATA_DIR` is unaffected.
284
+ Absent, blank, or `0` / `false` / `off` means OFF, behaviour unchanged; **the guard fails
285
+ closed on anything else**, throwing `EXPLICIT_DIR_GUARD_MALFORMED` at the same decision
286
+ point rather than reading a word it does not know as "off" (the #80 review measured
287
+ `=true`, `=yes`, `=on` and `= 1` all falling open under the first draft). Off means off
288
+ and junk is a question this will not answer; the variable is never set on an installed
289
+ host. The same guard covers the configuration default in `adapters/config-path.ts`,
290
+ because a default-sourced `~/.counterparts/claude-code.json` NAMES a store and `install`
291
+ writes under that base. **Not covered, by design:** a number read from the default config
292
+ for a store already named (`rebrief`'s ceiling), and the read-only instruments that carry
293
+ the live paths as defaults by their own rule (`claude-code/primacy.ts`,
294
+ `tools/parallel/bin/*`). Armed by `test/preload.ts` for the whole suite, so a forgetful
295
+ test is REFUSED rather than redirected (LAUNCH-STATUS I21, owner ruling 2026-09-05).
296
+ 15. **[M] A store directory is self-contained: copying or moving it never touches another
297
+ store's files.** **Structural since the floor rather than enforced.** A row IS its
298
+ memory, so there is nothing outside the database for a copy to reach, and there is no
299
+ pointer to resolve against the wrong root. The mechanism that defended this while rows
300
+ named files is deleted — `memories.prose_path`, `versions.path`, `paths.stored.*`,
301
+ `resolveStoredPath`, `relativizeStoredPath`, `isCanonicalRelativePath` and
302
+ `STORED_PATH_ESCAPES`, four review rounds of blank pointers, pre-v5 absolute rows and
303
+ `../ESCAPE/…` — and the two resolvers live on in `tools/parallel/legacy-paths.ts`, for
304
+ the read-only instruments that still read the owner's parked pre-rows store. **The
305
+ criterion is unchanged and still proved**: `test/store-portable.test.ts` copies a store,
306
+ destroys the source outright and reads through the copy; removes through the copy and
307
+ finds the source byte-identical; and opens a `backup` snapshot standalone after the
308
+ source is gone. *Added 2026-09-05 (schema v5) when finding I22 showed an absolute
309
+ `prose_path` made a copied store read and DELETE the source's prose.*
310
+ 16. **[M] A store written by an older floor is refused BY NAME, never migrated.**
311
+ A data directory holding `operational.sqlite`, `prose/` or `versions/` was written by a
312
+ build that kept its memories in files, and this one has no code that reads them.
313
+ `Store`'s constructor throws `STORE_PRE_ROWS` — carrying what it found, the version this
314
+ build writes, and `readableBy: "floor/v5-last"`, the tag whose build still opens it —
315
+ **before any transaction, before any directory is created, and without opening the old
316
+ database**. FILENAMES are the evidence deliberately: reading the schema version would
317
+ mean opening a WAL store whose `-wal` a close could checkpoint away, moving the bytes
318
+ the refusal exists to leave alone. All three names, because a store whose database was
319
+ moved by hand still holds every one of its words in files. `ADDED_COLUMNS` is empty and
320
+ may never name a v6 column, which is the second lock: `openOperational` migrates
321
+ anything below `SCHEMA_VERSION`, and `body` added that way would be NULL on every row
322
+ while the words sat in files, stamping the store v6 and unreadable by the build that can
323
+ read it. `OBSERVER_READ_FLOOR` is `SCHEMA_VERSION`: there is no floor below v6, because
324
+ a v6 instrument on a v5 store would report an empty store rather than an unreadable one.
325
+ There is no migration and there is not going to be one (owner ruling 6, 2026-09-18: the
326
+ cut-over carries nothing). `test/store-portable.test.ts` builds a real v5 store by hand
327
+ and proves the directory is byte-identical after a refused writer open, a refused
328
+ observer open and a refused session.
329
+ 17. **[M] A removal reclaims the pages that held the words — the log AND the free list —
330
+ on both databases.** Blanking a body is an `UPDATE`: in WAL mode the old page stays in
331
+ the `-wal` until a checkpoint, and a body long enough to take OVERFLOW pages leaves
332
+ whole pages on the FREELIST still holding the words (`secure_delete` is FAST by default
333
+ and zeroes only the slack of a page being rewritten). Measured 2026-09-20, deterministic
334
+ with marks at the start, middle and end of a ~40 KB body. So the console's removal ends
335
+ with `VACUUM` then `PRAGMA wal_checkpoint(TRUNCATE)` on each database, on its own
336
+ connection, reported as its own surface and never thrown (G7; scar §2.20). A contended
337
+ reclaim is REPORTED in words, with what is still true and the command that finishes it —
338
+ never `nothing`. Snapshots taken BEFORE a removal hold the memory properly and are not
339
+ reached; nothing that leaves the machine ever carried the residue (G19).
340
+ 18. **[M] Both boxes are WAL, every handle carries a busy timeout, the timeout is set
341
+ FIRST, and an opener that did not ask to convert sets no pragma that writes.** The
342
+ order is the fix (I38/I39, 2026-09-18):
343
+ `busy_timeout = 5000` before anything else, because every statement after it can contend
344
+ for a lock and without it SQLite fails them INSTANTLY — it used to be set LAST, so the
345
+ journal-mode statement ran with zero wait inside another writer's commit window. Then
346
+ `foreign_keys = ON`; then the journal mode is READ and set only when it differs from
347
+ `wal` **and the caller asked**, because setting is a write that takes the exclusive
348
+ lock and an opener that converted a file it had come to read would be writing at open;
349
+ then `synchronous = FULL` (WAL's usual pairing is `NORMAL`, and that is a durability
350
+ ruling for the owner, not a cleanup to make in passing — TUNABLE). A swallowed
351
+ conversion leaves the store in its old mode and says so through `verify` and `doctor`
352
+ rather than through a write from inside `openDb`. Only SQLITE_BUSY/LOCKED is swallowed.
353
+ *Why at all: several processes hold this one small database open at once — the session
354
+ hooks, a long-running MCP server, the nightly worker, the dashboard — and in WAL a
355
+ reader no longer blocks the writer. What it costs is in `NOTES.md`, including the three
356
+ things a WAL store cannot do that a DELETE store could.*
357
+ 19. **[M] A canonical database never leaves by file copy.** `backup`, `export` and the
358
+ rotating snapshot all go through `VACUUM INTO`, which copies live pages only and whose
359
+ output is a plain DELETE-mode database readable on any medium by any SQLite reader
360
+ (this build still refuses a database a NEWER one wrote — `SCHEMA_AHEAD` — which is a
361
+ different question from whether the file opens) — so a copy
362
+ is consistent even taken from a store another process is mid-write on, and even from a
363
+ store in G17's residue state. This is scar §2.11(b) said as a guarantee rather than left
364
+ in two notes; it is what makes the snapshot the real protection against a corrupt or
365
+ wiped database (owner ruling 3, 2026-09-18). Rotation, which DELETES, lives in an
366
+ adapter and never here (G2) — and it never deletes a folder holding pre-rows markers, so
367
+ the copies of the parked store survive cut-over.
368
+
369
+ ## 6. Scars honored
370
+
371
+ Each line: the scar, what carries it on this floor, and where it is pinned.
372
+
373
+ | scar | carried by | pinned by |
374
+ |---|---|---|
375
+ | **E5** / **§2.1** multi-writer structured state needs a transaction | G3 — strengthened: there is no non-transactional canonical state left | `test/seams.test.ts` "the interleaved load→mutate→save race that the meta row lost now loses nothing" |
376
+ | **§2.2** supersede retargets every inbound reference | G4 | `test/store.test.ts` "supersede leaves a forwarding address; the old id resolves forever"; "referential integrity is enforced by the store, not by the caller" |
377
+ | **§2.4** every discard says what and how much | G8's declaration; the two prunes; rotation | `test/store.test.ts` "version rows past H lived days are pruned; resolution is NOT"; "the event sweep is capped per call, takes the OLDEST rows first, and reports what it left"; `test/snapshots.test.ts` "keeps the newest N and reports every deletion, oldest first" |
378
+ | **§2.6 / §2.7** one seam; no model-reachable removal | G1, G2 | `test/store.test.ts` "no export name in the module is a deletion verb"; "no method on Store (public OR private) is a deletion verb"; "the owner-removal seam exports EXACTLY the destruction path, and nothing else does"; "the chase is not reachable from the store's own surface"; `test/cli.test.ts` "no core module, no other adapter, and no test but this one imports removal.ts" |
379
+ | **§2.11(a)** backup scope asserted against the layout | G11 — and `journal/` was classified before the code that writes it | `test/store.test.ts` "every top-level path is classified as backed-up or explicitly excluded (§5 G11)"; "an unclassified new directory fails loudly" |
380
+ | **§2.11(a)**, the other half — the canonical journal is never missing from a backup | G11: the canonical journal is ROWS, inside the database every copy carries. The markdown copy is derived and deliberately EXCLUDED, and its absence costs nothing | `test/cli.test.ts` "MAJOR-5: a snapshot does NOT carry the journal's copies, and a restore REGENERATES them"; `test/self.test.ts` "DELETING journal/ LOSES NOTHING: the next boundary writes it again" |
381
+ | **§2.11(b)** a canonical database is never file-copied | G19 | `test/store.test.ts` "the sidecars are classified, and `VACUUM INTO` still copies a consistent database"; `test/cli.test.ts` "`backup` survives a store another process is WRITING"; `test/snapshots.test.ts` "copies the WHOLE backup set, not just the database — and the words come with it" |
382
+ | **§2.12** the cache-rebuild contract is a test | G8 | `test/store.test.ts` "rebuild from canonical answers the same cues identically"; "what rebuild cannot recompute is declared, counted, and logged (§5 G8)" |
383
+ | **§2.13** path guards resolve before they compare | G9 | `test/store.test.ts` "refuses a pointer at a live v1 store — resolved before compared (scar §2.13)"; `test/snapshots.test.ts` "a SYMLINK is judged by its target, not by its name"; "refuses a directory inside the store"; "refuses a directory that CONTAINS the store"; and since `assertSafeTarget` began resolving both sides, `test/cli.test.ts` "MAJOR-4 — a destination reached THROUGH A SYMLINK into the store is refused too"; "MAJOR-4 — a DANGLING symlink target is refused by name, not by an mkdir errno"; "MAJOR-4 — a target symlinked into ~/.bansai or ~/.claude-engram refuses under a FAKE HOME" |
384
+ | **§2.19** permanence and the write bar: a removed protected element still shows as `[removed]` | G2 — the tombstone captures the row's band at chase time | `test/self.test.ts` "a removed element is a NAMED absence in BOTH halves, never a silent drop" |
385
+ | **§2.20** content-by-reference is only private if the reference cannot be inverted | G10, G17 | `test/cli.test.ts` "NEW-MAJOR-1: a removed body on OVERFLOW pages leaves no freed page holding it"; "review B, MAJOR-1: a CONTENDED cache checkpoint is reported, never claimed"; "the words a note rode in on are struck out of the buffer, and a later backup has none of them" |
386
+ | **§2.20**, the journal half — the markdown copy is body text on disk, so removal must reach it and nothing may carry it off | G7, G11 | `test/cli.test.ts` "F6: removing an episode takes its markdown copy, and the whole directory is clean"; "MAJOR-3: the journal echo is EXACT, not a ranked top-20 that goes silent on a big store"; "MAJOR-5: a snapshot does NOT carry the journal's copies…"; "--markdown OMITS confidential rows, and SAYS how many — on the terminal and in the tree"; and the four stand-downs that keep the copy and the chase inside the store — `test/self.test.ts` "MAJOR-1 — a symlinked YEAR directory does not carry a chapter out of the store"; "the removal arm never unlinks THROUGH a symlink"; "a DANGLING link under journal/ is refused too, not treated as absent"; "`journal` ITSELF being a symlink is refused, not followed" |
387
+ | **I22** the copied-store bug | G15 — criterion kept, mechanism deleted | `test/store-portable.test.ts` "(a) `cp -R` the store, DESTROY the source outright, and the copy still reads its own words"; "(b) an owner removal run in the COPY leaves the SOURCE byte-identical"; "(d) a `backup` snapshot opens standalone and HOLDS THE WORDS after the source is gone" |
388
+ | **I38 / I39** "database is locked" | G18 | `test/store.test.ts` "busy_timeout is set FIRST, before every other pragma (I39)"; "a second handle WAITS for a held write lock instead of failing instantly"; "a WRITER converts the file to WAL; an INSTRUMENT opening a DELETE store leaves it alone" |
389
+ | **the stage→commit→rename crash window** (`NOTES.md` §5, deleted): a crash never leaves a row whose words are missing | G5, G6 — structurally true: the words commit with the row | `test/store.test.ts` "SIGKILL mid-write leaves the store readable, every row's words intact" |
390
+ | **the floor's own hazard**: migrate-at-open would have destroyed the pre-rows store | G16 | `test/store-portable.test.ts` "a WRITER open throws STORE_PRE_ROWS and the directory is byte-identical afterwards"; "an OBSERVER open, and a whole session, meet the same refusal and write nothing"; "ADDED_COLUMNS is EMPTY at v6, and may never name a column the floor introduced" |
391
+
392
+ **Scars that no longer apply**, named so nobody re-ports them: temp-file naming (§16 G4's
393
+ "a crash-leaked stage must not load as a duplicate" — there is no stage), the
394
+ archive-collision `wx` loop, the absolute-vs-relative placement rule, "the loader reads
395
+ only `*.md` under `prose/`", and "`journal_mode = DELETE` because every top-level path must
396
+ be classified" (the database entry matched by prefix all along).
397
+
398
+ ## 7. Open questions
399
+
400
+ 1. **Is `PRAGMA secure_delete = ON` on the chase's connection the cheap answer to G17?**
401
+ It would, on paper, zero overflow pages as they are freed and cost nothing per removal,
402
+ where a `VACUUM` costs 23 ms on a 9.3 MB box 2 and 58 ms on a 16.6 MB box 3. It
403
+ measured clean on some body shapes and left the middle and end marks on others, because
404
+ it only zeroes what THAT transaction frees. F5's third review could not settle it either
405
+ — a bare-SQLite fixture did not reproduce the residue at all, so the real mechanism
406
+ involves more than the one statement. `VACUUM` is kept because it clears residue whatever
407
+ freed the page and whenever.
408
+ 2. **How often is a contended checkpoint met in practice?** G17 reports one honestly and a
409
+ test proves the report; nobody has seen one arise by itself. If it turns out to be common,
410
+ the reclaim wants a retry rather than a sentence.
411
+ 3. **Node is untested.** `db.ts` binds `node:sqlite` under Node (22.5+ flagged, 23.4+
412
+ default) and the branch is structurally present, but `node:sqlite` + WAL + `VACUUM INTO`
413
+ + bodies in rows has never been run. Verify at packaging (`NOTES.md` §9).
414
+ 4. **G3's totality is argued, not tested, for the two directories that are not the
415
+ database.** The layout test enumerates every top-level path; nothing asserts that
416
+ `spans/` and `sessions/` have one writer each. A test in the shape of G1's entrance
417
+ enumeration would close it.
418
+
419
+ *Two asks stand against this module from outside it. This module keeps no
420
+ `INTERFACE-GAPS.md` of its own (CLAUDE.md), so they are recorded here rather than
421
+ nowhere; neither is built, and both are waiting for a named problem (constitution 15).*
422
+
423
+ 5. **A store-owned seam that hands a module its own CLASSIFIED subdirectory** —
424
+ `store.ownedDir("journal")` — refusing at the seam what `assertLayout()` refuses at the
425
+ next open. Two core modules now hold a piece of layout knowledge beside their own work:
426
+ `remember/spans.ts` and, since F6, `self/journal-file.ts`, which reaches `Store.dir` by
427
+ the owner's decision 2 and says so in its header. Nothing enforces the pairing from
428
+ their side; a module writing to a directory `LAYOUT` does not know breaks the store's
429
+ next open, loudly, which is the safe direction but is a runtime answer to a
430
+ compile-time question. `self/INTERFACE-GAPS.md` asks it, and so does that file's #4 for
431
+ the briefing's render file — the two want one answer, not two.
432
+ 6. **A streaming read seam** — `store.forEachDoc(fn)` — so `export --markdown` need not
433
+ hold the whole rendered tree in memory before writing a byte. Buffering is what makes
434
+ `--markdown --passphrase` safe (nothing plaintext reaches the disk on that path) and it
435
+ is also a peak the size of every body plus its frontmatter, briefly doubled while
436
+ `encryptBundle` builds its base64 manifest. Nothing at the measured store shapes; the
437
+ first thing that would hurt an order of magnitude up. `cli/INTERFACE-GAPS.md` §12 asks
438
+ it, and notes that the DATABASE export is unaffected — it streams through `VACUUM INTO`
439
+ and holds one file.
440
+
441
+ *Closed since the last revision of this page: **is the embedding cache one box or two?**
442
+ Answered one file, two tables (`NOTES.md` §7) — the split that matters is rebuild cost, and
443
+ that is expressed by G8's declaration, not by a second file; re-open if vectors ever need a
444
+ different backup posture than the text index. **Does prose stay one file per memory?**
445
+ Answered no, 2026-09-20 — this whole page. **How does a v1→v2 import traverse the seam?**
446
+ Not a question any more: there is no import (§4).*