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,350 @@
1
+ # `adapters/cli/` — INTERFACE-GAPS
2
+
3
+ *What the console needed from `store/` and worked around instead of editing.
4
+ Written 2026-08-25 alongside `test/cli.test.ts`; §§1–3 CLOSED the same evening,
5
+ when BUILD-STATUS gaps 3 and 4 came due.*
6
+
7
+ ---
8
+
9
+ ## 1. `store/` has no chase surface for box-2 rows — **CLOSED 2026-08-25**
10
+
11
+ **What shipped:** `chaseRemoved(store, id): ChaseReport` on
12
+ `store/owner-op-seam.ts` — the honest fix below, built as named. One transaction,
13
+ which also appends the `chased` stage, so the rows and the record land together
14
+ or not at all. It refuses unless the id is already dark (`REMOVAL_NOT_DARK`: the
15
+ record comes first, always), and it crosses the store's own stance check, so an
16
+ instrument cannot chase (`OBSERVER_REFUSED`, site `chaseRemoved`).
17
+
18
+ **What dies:** the edges touching the id **in both directions** — the conducting
19
+ problem this entry named (§16 G14) — its prospective windows, the gate rows that
20
+ name it, and every content pointer it had (`prose_path`, `content_hash`, and the
21
+ same pair on each of its version rows).
22
+
23
+ **What survives, and why:** the removal record and the deny-list; a
24
+ `removal_tombstone` row saying what the memory WAS, in flags and counts only
25
+ (never a title, a body, or a hash — §16 G9), which is what lets `self.enumerate`
26
+ show a removed protected element as `[removed]` instead of losing it (§2.19); and
27
+ the memory's own row and version rows, STRIPPED — because box 2's foreign keys
28
+ make them the lineage. A survivor whose `superseded_by` or `successor_id` names
29
+ the removed id must land on a named removal rather than a dangling pointer, so
30
+ `Store.resolve` stops at a denied id and `Store.read` refuses it by name, and the
31
+ skeleton renders as `[removed by the owner]` wherever an id is rendered and as
32
+ nothing at all everywhere else.
33
+
34
+ `RemovalPlan.unchasable` is empty now, and the field STAYS: a chase that
35
+ half-works at run time still has to say so (§16 G15).
36
+
37
+ **The original entry, kept because the reasoning is the record:**
38
+
39
+ **What exists.** The owner-op seam's plan (`owner-op-seam.ts` step 5) says
40
+ "copies are chased — prose, versions, edges, prospective rows, box 3". The store
41
+ exports `appendRemovalRecord` and `deniedIds`, and `rebuildCache` skips denied
42
+ ids. It exports nothing that can remove a `memories`, `edges` or `prospective`
43
+ row, by design: "the store's public surface carrying a way to destroy a memory"
44
+ is the thing §5 G2 forbids.
45
+
46
+ **What the CLI does.** Chases what it can reach — the prose file, the version
47
+ files, and the cache (via a rebuild that skips and logs the denied id) — and
48
+ REPORTS the rest in `unchased`, printed to the owner by name. No silent partial
49
+ success (§16 G15). The rows survive as dark state that every consumer skips:
50
+ `recall/activate`, `sleep/{decay,prune,consolidate,dedup}`, `associate/` and
51
+ `prospective/` all consult `deniedIds()`.
52
+
53
+ **Why "dark" is not "chased".** An erased id left in the learned graph keeps
54
+ CONDUCTING activation between its former neighbours (§16 G14). Today the edges
55
+ survive; the deny-list stops the endpoints from being fetched, which blunts the
56
+ effect but does not remove the edge.
57
+
58
+ **The honest fix.** A single `Store.chaseRemoved(id): ChaseReport` on the owner-op
59
+ seam — importable only from here, the way `OwnerRemovalPort` already is — that
60
+ deletes the row, its edges and its prospective windows inside one transaction and
61
+ returns what it touched. The port type exists; only the store's half is missing.
62
+
63
+ ## 2. `Store.read`/`row` do not consult the deny-list — **CLOSED 2026-08-25**
64
+
65
+ The refusal is at the seam now, so every module inherits it instead of having to
66
+ remember it: `read`, `readProse`, `physicsOf` and `readVersion` raise
67
+ `REMOVED` with `detail: { id, by: "owner" }`, and `resolve` stops AT a removed id
68
+ rather than walking past it into `ID_DANGLING`. `put` consults it too — a removed
69
+ id is taken forever, so a stray copy cannot be reborn at the same address.
70
+
71
+ **`row()` is the deliberate exception**, and it is not an oversight: it is the raw
72
+ box-2 accessor, and the dashboard's browse list reads it over `list()` precisely
73
+ so that a removed memory keeps a LINE in the owner's inventory carrying
74
+ `[removed by the owner]`. A `row()` that threw would turn the instrument that
75
+ shows the absence into one that cannot render it (constitution 16).
76
+
77
+ **On the spelling:** the code is `REMOVED`, not `REMOVED_BY_OWNER`. The actor
78
+ rides in `detail`, where telemetry can read it; the CODE is the wire shape
79
+ consumers switch on, `adapters/dashboard/resolve.ts` switches on `"REMOVED"` to
80
+ choose its `[removed by the owner]` label, and renaming it would have bought a
81
+ longer string at the price of the one rendering path that depends on it.
82
+
83
+ ## 3. `OwnerRemovalOutcome` is not re-exported — **CLOSED 2026-08-25**
84
+
85
+ `store/index.ts` re-exports `ChaseReport`, `OwnerRemovalOutcome`,
86
+ `OwnerRemovalPort` and `OwnerRemovalRequest`. The seam's TYPES travel as one unit;
87
+ the chase itself does not — `chaseRemoved` is importable only from
88
+ `owner-op-seam.js`, by the one directory the caller-universality test allows.
89
+
90
+ ## 4. There is no writer's lock to take
91
+
92
+ CONTRACT §5 G2: "take the writer's lock only AFTER the confirmation, then reload
93
+ and re-plan under it." `store/` has no lock API — `remember/`'s `SpanBuffer` has
94
+ claim files, and box 2 relies on SQLite's own `BEGIN IMMEDIATE` per transaction.
95
+ So `remove` implements the half it can: it plans against a store opened in
96
+ observer stance, holds nothing across the human prompt (scar E5), then opens a
97
+ writing store and RE-PLANS before executing. Between the re-plan and the first
98
+ record append there is a window a concurrent writer could use. Fix: a data-dir
99
+ lock file the console takes and the background worker respects — which is
100
+ E5's own seam, and is the thing that would make the guarantee whole.
101
+
102
+ ## 5. `VACUUM INTO` needs a raw connection, so the CLI reaches past `store/index.ts`
103
+
104
+ `snapshot.ts` and `export.ts` import `openDb` from `../../core/store/db.js` — a
105
+ deep import into a core module's internals — because `Store` exposes no way to
106
+ execute the database's own snapshot operation, and a file copy is exactly what
107
+ scar §2.11 forbids. Fix: `Store.snapshotTo(path): SnapshotResult` on the store
108
+ itself, which is also where the WAL/journal knowledge belongs. Until then the
109
+ deep import is the honest version of the dependency: the CLI genuinely needs the
110
+ database, not the store's abstraction of it.
111
+
112
+ ## 6. The CLI CONTRACT §5 G6 and the store's LAYOUT disagree about `versions/`
113
+
114
+ **G6:** "the archive tree is deliberately excluded from snapshots — archive-on-
115
+ overwrite history is itself the redundancy layer, and snapshotting it copies an
116
+ unbounded, already-redundant tree into every snapshot."
117
+
118
+ **`store/paths.ts` LAYOUT:** `versions` is classified `backup: true`.
119
+
120
+ **What shipped:** the store's classification, because (a) rescope 3 replaced the
121
+ forever-archive with bounded versioning — superseded rows retain ~90 lived days,
122
+ which defuses G6's "unbounded" premise — and (b) G5's totality rule says the
123
+ backup set IS the layout, asserted by a test; maintaining a second, contradictory
124
+ list here would re-create the v1 bug G5 exists to prevent. Recorded as a real
125
+ contradiction for the owner to close in one direction or the other, not as a
126
+ silent choice.
127
+
128
+ ## 7. An instrument still MINTS an absent store at open — CLOSED 2026-08-26
129
+
130
+ **Filed 2026-08-25**, alongside the fix for the live "database is locked" failure
131
+ (`docs/live-verify-2026-08-25.md`). `Store`'s constructor no longer writes at open
132
+ when the store is current — that was the lock the backup lost — and a store a
133
+ schema BEHIND now refuses under observer (`STORE_UNINITIALIZED`) rather than
134
+ migrating itself out from under whoever owns it.
135
+
136
+ **Closed 2026-08-26** exactly as filed: an observer opening a data directory
137
+ with no store now refuses with the same `STORE_UNINITIALIZED` — thrown BEFORE
138
+ the first `mkdirSync`, so the refusal deposits nothing, not even the cache
139
+ container (`store.test.ts` pins "leaves NOTHING behind"). To a reader, "not
140
+ created yet" and "not migrated yet" are one condition. The seven test files
141
+ that opened observers on virgin temp dirs now create the store they read (an
142
+ owner open, closed immediately). Callers squared with the refusal: the
143
+ dashboard bin catches it and prints `statusCommand`'s sentence instead of a
144
+ stack trace; the hook bin still exits 0 but now names its stand-down on stderr
145
+ (a CORRUPT config fails toward observer, and on a machine with no store that
146
+ path used to be the silent mint — an ABSENT config keeps owner defaults, so
147
+ cold start still mints normally); the CLI's `storeExists` guards already
148
+ answered before opening.
149
+
150
+ ## 8. Entity birth (`schemas.mention`) has no adapter path at all
151
+
152
+ **Filed 2026-08-25** from the live-verification run, for the coordinator. Neither
153
+ `adapters/mcp/` nor `adapters/cli/` calls `Schemas.mention()`; grep finds it only
154
+ in `src/core/` and `test/`. Birth-by-mention is a core primitive whose only live
155
+ caller is the composition itself.
156
+
157
+ **Checked, not assumed** — and the answer is worse than the live note implies.
158
+ `grep -rn "\.mention(" src/` returns NOTHING: not an adapter, and **not the mint
159
+ path either**. `counterpart.ts` never calls it while placing a deposit, so birth
160
+ is not ambient-by-another-name; the live run's `{ ok: true, reason: "born" }`
161
+ happened because the seeding script called the composition's `schemas.mention()`
162
+ by hand. As shipped, an entity is born only if the embedding host reaches into
163
+ `Counterpart.schemas` itself.
164
+
165
+ That makes it the same shape BUILD-STATUS gap 2 names for `physics.symmetryCheck`
166
+ — enforced in one place, consumed by nobody — and it lands on a rule the module
167
+ states as doctrine: "birth is by mention, death is by decay". Death runs on the
168
+ clock; birth has no caller. For the coordinator to route: either the mint path
169
+ mentions the entities a deposit names (ambient, constitution 8) or the console
170
+ grows an owner-facing verb, but a birth rule with no live caller cannot be
171
+ claimed as working.
172
+
173
+ ## 9. `remember/` has no door to strike a span — **CLOSED 2026-09-05**
174
+
175
+ **What shipped:** `strikeSpans(buffer, request)` on
176
+ `src/core/remember/owner-strike-seam.ts` — the seam this entry proposed, built
177
+ as named and gated the way `store/owner-op-seam.ts` is: `SpanBuffer`'s
178
+ constructor hands it a capability through a WeakMap, `"strike"` joins
179
+ `WRITE_SITES` so the stand-down totality test covers it, and a
180
+ caller-universality test pins the two files in `src/` that may import it
181
+ (`remember/spans.ts`, which grants and never calls; this directory's
182
+ `removal.ts`). Holding a `SpanBuffer` — which every `Counterpart`, and so the
183
+ MCP server, does — reaches nothing.
184
+
185
+ **What dies:** the matching lines in the five files under a scope that carry
186
+ `text` — `buffer.jsonl`, `jots.jsonl`, `assistant.jsonl`, `quarantine.jsonl`,
187
+ and every `claims/*.jsonl` — rewritten per file by rename-aside plus
188
+ append-the-survivors-back, `claim()`'s own choreography, because `mutate()` is a
189
+ stance check and not a lock. `removal.ts` calls it between `dark` and the box-2
190
+ chase, so the addressing still exists when it runs.
191
+
192
+ **What survives, and why:** the hash, in `consumed.jsonl`. That is the terminal
193
+ ledger `seenHashes()`, `restore()` and `mergeOrphans()` all filter against, so
194
+ keeping it is what stops the words being re-captured, restored by a worker
195
+ mid-arc, or merged back from a crashed run's orphan. The strike ledgers FIRST,
196
+ before a byte moves. `coverage.jsonl` and `failures.jsonl` keep their hashes for
197
+ the same reason.
198
+
199
+ **On the persistence question this entry raised.** `Proposal.ownSpanHash` is
200
+ persisted now — in the PROSE META as `origin.spanHash`, not as a `memories`
201
+ column. Two reasons. §16 G9: a hash of low-entropy content is brute-forceable,
202
+ and `chaseRemoved` blanks `content_hash`/`prose_path` on the skeleton precisely
203
+ so no pointer to removed content outlives the removal; in the prose meta the
204
+ pointer dies with the document, in a column it would not. And the mechanical
205
+ one: `openOperational` returns early when the schema version matches, so a new
206
+ column needs `SCHEMA_VERSION` 4 → 5, after which a REVERT leaves the owner's
207
+ live store unopenable by the previous build (`SCHEMA_AHEAD`) — a one-way door
208
+ bought for a field the prose already carries. The chase also works
209
+ RETROACTIVELY, with no migration at all: every accepted proposal has always
210
+ written `{spanHash, proposalId, own}` into the scope's `coverage.jsonl` and the
211
+ mint has always stored the proposal id in `origin_ref`, so a memory minted long
212
+ before this branch is addressable by its `own: true` marks. The content
213
+ predicate stays as the third fallback, for a row with neither.
214
+
215
+ **The content fallback is FENCED, after the adversarial review (F4).** It is
216
+ full-text equality on a jot, never a substring, and only inside the memory's
217
+ recorded `origin_scope`. A row with no scope — which is every row
218
+ `tools/migrate/apply.ts` imported, since it writes `origin: { ref }` alone — is
219
+ NOT chased by content; the console lists the jot lines that would have matched,
220
+ by file and count, and stops. `--strike-by-content-across-scopes` performs it on
221
+ the owner's explicit say-so, and even then takes only an exact line.
222
+
223
+ **Still open, and deliberately:** the second, smaller ask below — a durable box-2
224
+ event for the removal's counts — is not taken. And one window is named rather
225
+ than closed: a worker that has already read `claim.spans` into memory finishes
226
+ its arc, so a NEW memory can be minted from a span struck a millisecond later.
227
+ The deny-list stops the removed id from returning; it does not stop that. Closing
228
+ it means a lock `remember/` does not have. `remember/NOTES.md` §14 says so.
229
+
230
+ **The original entry, kept because the reasoning is the record:**
231
+
232
+ **Filed 2026-09-04**, with the adapter half of LAUNCH-STATUS §I2 (owner ruling:
233
+ option A — report it now, chase it later).
234
+
235
+ A note is CAPTURED before it is minted: `captureJot` appends the verbatim text to
236
+ `spans/<keyFor(scope)>/jots.jsonl`, and `submitJot` mints from it. Nothing prunes
237
+ that file, so a removed note's words stay on disk — and `backup` copies them
238
+ (measured; `export` does not, §C1). `removal.ts` now reports the surface in all
239
+ three states, and `ownerRemoval` counts it into the `cli.removal.complete` EVENT
240
+ — which the console binds to `io.out`, so the count is printed and never stored.
241
+ The durable `removal_record` holds the removal's four stages and no count.
242
+ Reporting is all it can do.
243
+
244
+ **A second, smaller ask, filed with it.** If the unchased count should be
245
+ durable, the write is `store.appendEvent` on the completion payload, plus a
246
+ `cli.removal.*` name in `dashboard/registries.ts` so `activity` can render it.
247
+ Not taken tonight: the destruction path is the last place to add a write on a
248
+ launch eve, and the printed line is honest as long as the documents say printed.
249
+
250
+ **What is missing.** `SpanBuffer` exposes `claim`/`consume`/`restore` — the
251
+ lifecycle of a buffer being drained forward — and nothing that removes ONE span
252
+ from wherever it currently sits (live stream, `claims/*.jsonl` aside, consumed
253
+ ledger). The destruction path cannot be given a `rmSync` over `spans/`: that file
254
+ is `remember/`'s state machine, spec §2 G6 forbids a span being in neither claim
255
+ nor buffer, and a claim renaming underneath a chase is exactly the race that
256
+ guarantee exists to prevent.
257
+
258
+ **Fix, for the coordinator to route:** `SpanBuffer.strike(scope, predicate |
259
+ spanHash): StrikeReport` — one seam, inside `remember/`'s own `mutate()`, that
260
+ rewrites each stream file without the matching records and reports counts per
261
+ file. The removal path then calls it between `dark` and `chased` and moves the
262
+ surface from `unchasable` into `surfaces`. The hash to strike is already minted:
263
+ `Proposal.ownSpanHash` — but it is NOT persisted (the store keeps
264
+ `origin_session` / `origin_scope` / `origin_ref` and drops the span hash), so
265
+ either that column joins `memories`, or `strike` takes the content predicate the
266
+ adapter already uses to detect the residue.
267
+
268
+ **Until then**, `spanResidue()` in `removal.ts` decides by LOOKING: it searches
269
+ the scope's buffer files for the doomed words and reports `held` on a hit,
270
+ `not-applicable` on a checked miss, and `unknown` for its two blind spots (the
271
+ prose already gone; provenance never recorded). Evidence first, provenance
272
+ second — `source = 'authored'` turns a miss into `unknown` rather than an
273
+ all-clear, because "I did not find it" is not "it was never there".
274
+
275
+ *(Since the close: identity first, evidence second, provenance third.
276
+ `spanResidue()` matches the recorded span hash before it matches the body, which
277
+ is what lets a memory whose prose is already gone still be chased. Only ONE
278
+ blind spot is left — prose gone AND no hash — and it is still `unknown`, still
279
+ counted `unchased: 1`.)*
280
+
281
+ ## 10. `Store.eventLog` orders ASCENDING, so "the newest row of this name" is not a query
282
+
283
+ `doctor` (2026-09-14) asks the store one question over and over: what is the
284
+ NEWEST `sleep.cycle` / `sweep.gate` / `adapter.embed.backfill` /
285
+ `adapter.spawn.refused` row. `eventLog({ name, sinceDay, limit })` answers
286
+ `ORDER BY seq ASC LIMIT ?`, which is the OLDEST N — so a name with more rows than
287
+ the limit returns a window that does not contain the newest, and a caller that
288
+ took `rows.at(-1)` would report last week's reading as today's, silently.
289
+
290
+ `claude-code/doctor.ts#newestRows` closes it EXACTLY rather than approximately: a
291
+ ladder of lived-day windows, narrowest first (today, 2, 7, 30, everything), and a
292
+ window whose result is shorter than the limit was not truncated, so its last row
293
+ is provably the newest in it. A full window is discarded rather than trusted.
294
+ Cost: up to five queries where one `ORDER BY seq DESC LIMIT 1` would do, on a hot
295
+ path bounded at 150 ms.
296
+
297
+ **The ask**: `eventLog` takes an `order: "asc" | "desc"` (or a `newest: n`), and
298
+ `newestRows` collapses to one call per name. Box 2's own business, it changes no
299
+ behaviour, and it is the only reason that ladder exists.
300
+
301
+ ---
302
+
303
+ ## 11. `Store` has no GROUP BY, so the what-fired view counts rows in JavaScript
304
+
305
+ `adapters/fired.ts` (2026-09-17) asks two questions of every mechanism: how many
306
+ rows of this name landed in each of two seven-day windows, and when did the
307
+ newest one land. Both are one `GROUP BY` in SQL and neither is a call the store
308
+ offers, so the view reads the whole log through `eventLog({ limit })` — one
309
+ query, not one per name per day — and tallies it here. A read that comes back
310
+ FULL is handled rather than trusted (the same trap §10 names): it is the oldest
311
+ rows, so a second day-bounded read covers the windows, the two are joined on
312
+ `seq`, and every total is reported as a floor.
313
+
314
+ Four TABLE reads have the same shape and no aggregate at all. `edges`,
315
+ `prospective` and `versions` are keyed by memory id and reachable only as
316
+ `edgesFrom(id)` / `prospectiveFor(id)` / `versions(id)`, and `MemoryFilter` has
317
+ no `protected` field, so the five probes the view needs — newest `edges.last_day`,
318
+ the prospective count and newest fired day, the protected count, the removal
319
+ record, `versions` by reason — cost a few queries per memory. Only
320
+ `removalRecord()` is one query. `web/views.ts:1360` already pays the same price
321
+ for its edge count. The view bounds the scan, reports a truncated one as a floor,
322
+ and the one caller on a hook's hot path turns the probes off and NAMES the
323
+ mechanisms it therefore did not read.
324
+
325
+ **The ask**, in the order it would pay: (a) `eventCounts({ sinceDay })` returning
326
+ `name → { rows, newestAt }`, which collapses the whole first half; (b)
327
+ `MemoryFilter.protected`; (c) `edgeCensus()` / `prospectiveCensus()` /
328
+ `versionCensus()` returning a count and a newest day per key. All of it is box
329
+ 2's own business and none of it changes behaviour.
330
+
331
+ ## 12. `export --markdown` holds the whole tree in memory — OPEN 2026-09-20 (F7)
332
+
333
+ `collectMarkdown` builds a `Map<path, Buffer>` of every live row's rendered
334
+ markdown before one byte is written. That is what makes `--markdown
335
+ --passphrase` safe — nothing plaintext ever reaches the disk on that path — and
336
+ it is also a peak whose size is the store's bodies plus their frontmatter, and
337
+ twice that briefly during `encryptBundle`'s base64 manifest. On the measured
338
+ store shapes (a few thousand rows, ~10 MB of bodies) this is nothing. On a store
339
+ an order of magnitude larger it is the first thing that would hurt.
340
+
341
+ **The ask**, if it ever hurts: a streaming bundle — `store.forEachDoc(fn)` and a
342
+ sink the plaintext arm writes straight through, with the encrypted arm keeping
343
+ the buffered path because sealing needs the whole thing anyway. **Not built**:
344
+ constitution line 15 says wait for the named problem, and `--markdown` is a
345
+ deliberate owner action nobody runs in a loop.
346
+ Recorded against the store, where it would be declared: `store/CONTRACT.md` §7 question 6
347
+ (that module keeps no `INTERFACE-GAPS.md` of its own, so its open asks live in its §7).
348
+
349
+ **What is already bounded:** the DATABASE export streams through `VACUUM INTO`
350
+ and holds one file, so the ordinary export is unaffected by any of this.