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,936 @@
1
+ # `adapters/cli/` — NOTES
2
+
3
+ *Decisions taken while building, and the ones deliberately left open. Working
4
+ defaults, revisable without ceremony (constitution 13).*
5
+
6
+ ## Built — six commands
7
+
8
+ `status` · `init` · `export` · `backup` · `remove <id>` · `verify`
9
+
10
+ `commands.ts` holds the dispatcher and the three simple commands; `snapshot.ts`
11
+ owns the copy rules; `export.ts` owns egress and its crypto; `removal.ts` is the
12
+ destruction path and is deliberately not re-exported from `index.ts` (a module
13
+ that is easy to import is a module somebody imports).
14
+
15
+ `run(argv, { io })` returns an exit code and never calls `process.exit`, so every
16
+ command is tested against a temp dir with a faked console rather than a
17
+ subprocess. `bin/counterparts.ts` binds the real stdio and a `node:readline`
18
+ prompt.
19
+
20
+ ## Not built, and named so it is not mistaken for missing-by-accident
21
+
22
+ The contract's input list also names `install`, `on`/`off`, `protected` (list)
23
+ and `restore`. This build was scoped to the six above.
24
+
25
+ - **`install`** — `init` PRINTS the steps instead. An installer that edits a
26
+ host's settings unasked is the same class of surprise as a memory layer that
27
+ writes unasked.
28
+ - **`on`/`off`** and the machine-readable pass record (§5 G10) — the gated
29
+ ambient channel they switch does not exist yet. A switch with nothing behind it
30
+ is machinery in anticipation of a failure (Amendment 15).
31
+ - **`protected` (list)** — `status` already enumerates everything permanent
32
+ (§14.1 G9), which is the guarantee. A dedicated subcommand is formatting.
33
+ - **`restore`** — CONTRACT §7 OQ3 asks whether it is a command or a documented
34
+ procedure, and it is unanswered. What shipped is the minimum the contract
35
+ demands: a test that OPENS a backup and reads a row written inside the pre-copy
36
+ write window. v1 never once logged a read-back of a backup; this one is read
37
+ back in CI on every run.
38
+
39
+ ## `package.json` needs a `bin` entry, and this build did not write one
40
+
41
+ Scope was `src/adapters/cli/`, `src/adapters/mcp/` and the two test files. The
42
+ line the package needs:
43
+
44
+ ```json
45
+ "bin": { "counterparts": "src/adapters/cli/bin/counterparts.ts" }
46
+ ```
47
+
48
+ Until then: `bun run src/adapters/cli/bin/counterparts.ts <command>`.
49
+
50
+ ## Export: the owner supplies the key, and nothing is minted
51
+
52
+ CONTRACT §7 OQ1 — "does export encrypt to a key the owner already has, or does it
53
+ mint one?" — is answered PROVISIONALLY as: the owner supplies a passphrase.
54
+ Minting is friendlier and is also how an owner ends up with a backup they cannot
55
+ open. There is **no default mode**: `--passphrase` encrypts, `--plaintext` is the
56
+ loud opt-out, and neither flag is a refusal rather than a guess. Format
57
+ (scrypt + AES-256-GCM + gzip'd manifest) is documented in the README written
58
+ beside every export, because an encrypted archive whose format is undocumented is
59
+ a different way of losing the data.
60
+
61
+ Still open for the owner: whether a local copy to another directory on the same
62
+ disk should count as egress at all. Today it does, which is why `--plaintext`
63
+ must be typed.
64
+
65
+ ## Removal has still never fired in anger
66
+
67
+ CONTRACT §7 OQ2 stands: v1's erase machinery was built, tested, and never run in
68
+ production, which by scar §2.17's own criterion makes it unproven rather than
69
+ sound. v2's version is smaller (no quarantine, no cooling-off staging — released
70
+ by rescope 3) and is exercised end-to-end in `test/cli.test.ts`, including the
71
+ read-back that proves the prose is gone and the deny-list holds. That is a test,
72
+ not a production fire. **The owner still has to say which this is: exercised
73
+ deliberately in bake-in, or carried as declared-dormant-by-design.**
74
+
75
+ ## Owner-in-the-loop is one item long
76
+
77
+ §5 G12: currently `remove`. `export --plaintext` requires an explicit flag but no
78
+ prompt; `backup`, `verify --rebuild` and `init` are autonomous — though
79
+ `--rebuild` now has a refusal of its own (below), which is a flag rather than a
80
+ human.
81
+
82
+ ## 2026-09-04 — removal names the span buffer: the seventh surface
83
+
84
+ **LAUNCH-STATUS §I2, owner ruling: option A.** `remove` reported `unchased:
85
+ nothing` while a removed note's verbatim words were still on disk. A note is
86
+ CAPTURED first — `captureJot` appends the raw text to
87
+ `spans/<keyFor(scope)>/jots.jsonl` — and minted second; the chase never reached
88
+ that file, `unchasable` was a hardcoded `[]`, and a `backup` taken afterwards
89
+ copied the words into the snapshot (`export` does not; spans are outside its
90
+ set). Against §16 G15, quoted in the comment sitting on that very `[]`, this was
91
+ a silent partial success.
92
+
93
+ What shipped, adapter-side:
94
+
95
+ - **`RemovalPlan.spans`** — a seventh surface, reported rather than chased, and
96
+ present in ALL THREE states. `not applicable` is printed too: a surface that
97
+ goes quiet when it is empty is what made the residue invisible.
98
+ - **`unchasable` carries it**, so `ownerRemoval` seeds `unchased` from it and the
99
+ `cli.removal.complete` EVENT counts it — an event the console binds to `io.out`,
100
+ so the count is a printed line and nothing else. The durable `removal_record`
101
+ is `(seq, memory_id, stage, at, actor, reason)`: four stage rows, no count.
102
+ Said here because three documents inherited the opposite claim from this
103
+ paragraph (claims audit, round 3). The dry run prints it ABOVE
104
+ `Dry run. Nothing has changed.` — a disclosure under the closing line is one
105
+ the reader has already stopped reading (cold-stranger round 3, C3).
106
+ - **Evidence first, provenance second.** `spanResidue()` searches the scope's
107
+ buffer files for the doomed words (during the plan, before anything is chased,
108
+ §16 G13) and reports `held` with the file named. Provenance only breaks a tie
109
+ when the search misses: `source = 'authored'` means the memory came through the
110
+ jot door, so a miss is `unknown`, never an all-clear. The two blind spots — the
111
+ prose already gone, provenance never recorded — are reported as `unknown`
112
+ rather than resolved in the comfortable direction. Paths are store-RELATIVE and
113
+ no line of what was read is ever printed (§16 G15).
114
+
115
+ **Why not chase it, that day.** Striking a span needs a door in `remember/` that
116
+ did not exist, and the buffer is a state machine whose spec (§2 G6) forbids a
117
+ span being in neither claim nor buffer — a `rmSync` from the destruction path
118
+ would race a concurrent claim. Filed as INTERFACE-GAPS §9 with the proposed seam
119
+ (`SpanBuffer.strike`), including the detail that `Proposal.ownSpanHash` is minted
120
+ but never persisted, which is why the adapter detected by content rather than by
121
+ hash.
122
+
123
+ **Still true after this change:** the words are still on disk. This makes the
124
+ report honest; it does not make the removal complete. Closed the next day — see
125
+ below.
126
+
127
+ ## 2026-09-05 — the seventh surface is CHASED (option B; INTERFACE-GAPS §9 closed)
128
+
129
+ The chase landed as `src/core/remember/owner-strike-seam.ts`, called from
130
+ `ownerRemoval` between `dark` and the box-2 chase. What the console owns:
131
+
132
+ - **The chase key, and why it is not a column.** §9 said `Proposal.ownSpanHash`
133
+ is minted and never persisted, so either it joins `memories` or `strike` takes
134
+ a content predicate. It joins the PROSE META instead — `origin.spanHash`,
135
+ beside the session/scope/ref the mint already mirrors there. A column would
136
+ have needed `SCHEMA_VERSION` 4 → 5 (`openOperational` returns early on a
137
+ version match, so `ADDED_COLUMNS` never runs without a bump), which makes a
138
+ revert a store the previous build refuses to open (`SCHEMA_AHEAD`) — a one-way
139
+ door on the owner's live memory, bought for a field the prose can hold. And
140
+ §16 G9 argues the same way: a hash of low-entropy content is brute-forceable,
141
+ and `chaseRemoved` blanks `content_hash`/`prose_path` on the skeleton
142
+ precisely so no pointer to removed content outlives the removal. In the prose
143
+ meta the pointer dies with the document. In a column it would not.
144
+ - **The half that works retroactively.** Every accepted proposal has always
145
+ written `{spanHash, proposalId, own}` into the scope's `coverage.jsonl`, and
146
+ the mint has always stored the proposal id in `origin_ref`. So a memory minted
147
+ months before this branch is addressable by its `own: true` coverage marks,
148
+ with no migration. `chaseHashes()` reads both sources. ONLY `own` marks: the
149
+ other spans a proposal covered are the conversation around it, and striking
150
+ those because one memory cited them would be a destruction nobody asked for.
151
+ - **The order.** The strike runs BEFORE the box-2 chase and before the prose is
152
+ unlinked, because those are what carry the addressing. Read-everything-first
153
+ (§16 G13) is now doing work rather than being a rule about the contamination
154
+ scan.
155
+ - **The body never enters a struct.** `spanChase` on the plan carries a scope
156
+ and hashes. The content fallback reaches the seam as a CLOSURE the console
157
+ builds over a local, so no printed surface, no plan object and no record ever
158
+ holds a word of what is being erased (§16 G15).
159
+ - **The report says what happened to the other two places.** A struck hash is
160
+ KEPT in `consumed.jsonl` — that is what stops a re-capture, a restore or an
161
+ orphan merge re-admitting the words — and a claim file rewritten under a
162
+ worker mid-arc is called out by name. Both are printed lines, not stored
163
+ counts; the durable `removal_record` is still four stages.
164
+ - **One state is still `NOT chased`, and it is the honest one.** Prose already
165
+ gone AND no span hash recorded: nothing left to address the buffer with. It
166
+ stays in `unchasable`, counts as `unchased: 1`, and says which way it is
167
+ blind. `held` moved out of `unchasable` and into `surfaces`.
168
+ - **The echo, found by the adversarial read of the first draft.** On the live
169
+ store a note is taken MID-CONVERSATION, so the Stop hook has already captured
170
+ the turn in which the words were said into `buffer.jsonl`. The first draft
171
+ counted that line in the plan (`spanLinesIn` matched by hash OR by text) and
172
+ the strike then took only the jot — plan said 2, report said 1, and `grep`
173
+ still answered. Two fixes, both about honesty rather than reach: the plan now
174
+ counts exactly what the strike will take (`needle` is passed only when there
175
+ is no hash), and the leftover is counted SEPARATELY as `spans echo` and
176
+ printed on the `unchased` line. It is left on purpose — a conversation span is
177
+ many turns joined, belongs to no single memory, and striking it because one
178
+ memory quoted it would destroy material nobody named. `test/cli.test.ts` has
179
+ the fixture: `captureSpans` a turn holding the marker, then `note`, then
180
+ remove, and assert the plan's count equals the strike's.
181
+
182
+ **What the adversarial review (2026-09-05) changed, because none of it was
183
+ caught by the suite:**
184
+
185
+ - **F4, the one that would have reached the live store.** The content fallback
186
+ was `text.includes(body)` with `scope: null` visiting every scope. Measured by
187
+ the reviewer: removing "buy milk" destroyed two unrelated jots in two
188
+ unrelated projects and ledgered both hashes. Live-reachable because
189
+ `tools/migrate/apply.ts` writes `origin: { ref }` and nothing else, so all
190
+ ~12,000 imported rows have no scope and no span hash — the exact shape that
191
+ falls through to the fallback. Now: **full-text equality on a jot after trim,
192
+ never a substring**, and **only inside the memory's recorded `origin_scope`**.
193
+ With no scope the console REFUSES, prints the candidate files and line counts
194
+ (no text), and points at `--strike-by-content-across-scopes`, which is the
195
+ owner saying it in so many words. The dry run also states which evidence it is
196
+ acting on — `matched by the span hash its mint recorded` vs `matched by
197
+ content` — because the two are not equally strong and the reader is about to
198
+ type an id back.
199
+ - **F1, the invisible aside.** `jsonlUnder()` collected `*.jsonl` only, so a
200
+ crashed strike's `jots.jsonl.striking` was invisible to the residue walk and a
201
+ later `remove` printed "not applicable" over words that were on disk and that
202
+ `backup` would copy. The walk names `*.jsonl.striking` now, and the strike's
203
+ own recovery pass folds any aside home before it runs, so naming it is not a
204
+ promise the chase cannot keep.
205
+ - **F6, the third category.** The echo was filed under `unchased (dark via the
206
+ deny-list…)`, which describes a conversation turn as though it had an id and a
207
+ tombstone. It has its own `leftAlone` list and its own line now, in the plan
208
+ and in the completion report, in the same words: *left on purpose — not a
209
+ failure, this removal was never entitled to it.*
210
+ - **F5, a claim that was simply false.** The printed line said the sweep drains
211
+ the echo. It does not: `crashedSessions()` excludes any session that ended
212
+ normally and nothing else prunes `buffer.jsonl`, so the echo is permanent.
213
+ Said as such, everywhere, and filed as `remember/INTERFACE-GAPS.md` §9.
214
+ - **The failure arm** reused the plan's success sentence, so a strike that threw
215
+ printed "the removal strikes them out of it" underneath a strike that had not.
216
+ It has its own wording.
217
+
218
+ **Verified:** `test/cli.test.ts` runs §I2's own repro end to end — note through
219
+ the jot door, remove, `grep -r` the whole data dir (nothing), `backup` and grep
220
+ that (nothing) — plus the two-notes case proving the strike is a rewrite and not
221
+ a truncation. `test/remember.test.ts` covers the seam itself, including that the
222
+ sweep is never shown a struck span. The install loop gained two steps (35/35):
223
+ the §7 plan's `spans` lines are checked against QUICKSTART verbatim, and a
224
+ non-interactive `--confirm` still refuses.
225
+
226
+ ## 2026-09-04 — `verify` is a census by default; the rebuild is opt-in
227
+
228
+ **The sharp edge, found by the adversarial review of PR #37 (the default-data-dir
229
+ fix).** `verify` opened the store WRITABLE and called `store.rebuildCache()`,
230
+ which begins with `resetCache` — and `resetCache` drops every box-3 table
231
+ INCLUDING `embeddings`. This console wires no embedder, so every vector came back
232
+ `unrecomputed` and gone: on the owner's live store, ~13,700 vectors that each
233
+ cost a paid network call. `store/cache.ts` says the same thing in its own voice
234
+ about why `backfillLengths` is not a rebuild. Before #37 a bare `counterparts
235
+ verify` was saved only by ACCIDENT — it failed the layout check on the old
236
+ default before it ever reached a store — and after #37 the default resolves to
237
+ the live store. An accident is not a guard.
238
+
239
+ What shipped:
240
+
241
+ - **Bare `verify` is a read-only census.** Observer stance, one box at a time
242
+ (store opened, read, closed; then box 3 on its own connection), and it
243
+ rebuilds nothing. It prints canonical rows, the deny-list count, box 3's
244
+ index/length/ranking/embedding counts, live memories with no vector, and one
245
+ line saying whether the cache covers every canonical row. That last line is a
246
+ **set diff**, not arithmetic: `indexed + denied == canonical` can agree by
247
+ coincidence and cannot say which way it is wrong, so both directions are named
248
+ (canonical rows not indexed, indexed ids that are not canonical rows).
249
+ - **`verify --rebuild` is the old behavior**, and it REFUSES while box 3 holds
250
+ embeddings this console cannot recompute, unless `--drop-vectors` says out loud
251
+ that losing them is the intent. The count is read BEFORE a writable store is
252
+ opened, so the refusal path never constructs one.
253
+ - **The guard fails CLOSED.** A count that could not be taken is not a count of
254
+ zero: box 3 is the file the Stop-hook worker writes vectors into, so a locked
255
+ read there is ordinary, and a guard whose failure mode is "could not count the
256
+ vectors, so dropped them" is not a guard. An unreadable-but-present cache
257
+ refuses the same way a populated one does. An ABSENT cache still proceeds —
258
+ there is nothing to lose.
259
+
260
+ **Why refuse-unless-flag rather than preserve the vectors.** Preserving them
261
+ across a rebuild is a CORE change and this was an adapter-only fix. The core
262
+ follow-ups, named so they are not lost: `Store.rebuildCache({ keepVectors })`
263
+ (re-index the token side without dropping `embeddings`), and
264
+ `Store.embeddingCount()` — because there is no read API for "how many vectors
265
+ does box 3 hold". `unembeddedCount()` is the coverage denominator (live rows with
266
+ no vector), which is a different number. Until that exists, the census opens
267
+ `cache.sqlite` directly with `openDb`, the same deep import `snapshot.ts` and
268
+ `export.ts` already make (INTERFACE-GAPS §5), gated on the file existing so the
269
+ census cannot mint the box it is inspecting.
270
+
271
+ **`verify` stays on `OWNER_OPS`,** so `--observer verify` still refuses even
272
+ though the census writes nothing. That is a false refusal in the safe direction,
273
+ and taking it off the list is stance semantics — threading the stance into the
274
+ command so `--rebuild` alone refuses — which is a separate decision, not a
275
+ safety fix. Left open deliberately.
276
+
277
+ ## 2026-09-05 — `migrate-cache`, and the two follow-ups above are closed
278
+
279
+ `counterparts migrate-cache` converts box 3's vectors from JSON text to float32 BLOBs in
280
+ place — dry run by default, `--apply` to convert, one transaction per `--batch` (500),
281
+ `VACUUM` at the end. The design and the measurements live in `src/core/store/NOTES.md`
282
+ (2026-09-05); what belongs here is why it is a COMMAND and not a flag on `verify`.
283
+
284
+ **A rebuild recomputes; this recovers.** The entry above ends with "preserving the vectors
285
+ across a rebuild is a CORE change" and files two follow-ups. Both now exist, so the
286
+ console has three doors instead of two:
287
+
288
+ - `verify --rebuild` — unchanged, and still refuses while box 3 holds vectors it cannot
289
+ recompute. The refusals now NAME the safe option; they did not get quieter.
290
+ - `verify --rebuild --keep-vectors` — `Store.rebuildCache({ keepVectors })`. Re-indexes
291
+ the text side, keeps every vector whose memory is still canonical, drops the ones that
292
+ are not. Passing it together with `--drop-vectors` is refused rather than guessed at.
293
+ - `migrate-cache` — the format conversion, which is neither of those: it neither drops nor
294
+ recomputes, it re-writes the same numbers in the shape they should have been in.
295
+
296
+ The census learned the shape too (`vector format: N float32 BLOB (v4), M JSON text (v3)`),
297
+ because a partly-converted cache is a real state — every reader tolerates it — and one
298
+ that nothing named would sit there unfinished. `Store.embeddingCount()` exists now as
299
+ well; the census still opens `cache.sqlite` directly, because that read is gated on the
300
+ FILE existing and a `Store` constructor cannot promise not to mint the box being
301
+ inspected.
302
+
303
+ `migrate-cache` is on `OWNER_OPS`: box 3 is rebuildable, and rewriting it is still a
304
+ write.
305
+
306
+ **Three things the adversarial review changed, and each is a rule this console already
307
+ had.**
308
+
309
+ 1. **The dry run is READ-ONLY, not merely honest.** It opened box 3 with `openCache`, which
310
+ stamps `cache_meta.schemaVersion` — so on the v3 store this will actually be run against,
311
+ one row changed and the file's hash moved under a line saying nothing had. The first fix
312
+ made the command SAY so, which was the right instinct and the wrong repair: every
313
+ question the dry run asks is a `SELECT`, so it opens with `openDb` and `openCache` is
314
+ reserved for `--apply`. "Reads are pure" (§5 G9) means the bytes, not the disclosure.
315
+ 2. **`--apply` names its store and asks.** `resolveDir` falls through to `dataDir()`, which
316
+ on a real machine is the owner's live memory, and this command is the one operation here
317
+ whose result a `git revert` cannot undo. So `--apply` refuses a data dir that came from
318
+ the default — **before it looks at a single path**, because a guard that reads the
319
+ default directory before refusing it has already been pointed at the store it meant to
320
+ refuse — and then asks, `remove`-style, unless `--yes`.
321
+ 3. **Converted-but-not-compacted is a state with a door.** `VACUUM` is the step most likely
322
+ to fail: it takes an exclusive lock and the Stop worker holds box 3. The first version
323
+ ran it only after a conversion, and the already-converted arm refused BEFORE it — so one
324
+ lost lock left the entire 177 MiB behind an "already converted" refusal, unreachable
325
+ through the tool that exists to reclaim it. Now the dry run reports the reclaimable
326
+ bytes and `--apply` compacts, converting nothing. The probe is a real `VACUUM INTO` a
327
+ throwaway copy in the OS temp dir: `PRAGMA freelist_count` reads **0** in that state,
328
+ because the pages are fragmented rather than free, and a probe that reads zero where the
329
+ answer is 59% is worse than no probe.
330
+
331
+ ## 2026-09-05 — `repair-merged-beliefs`, and the first un-archive the store has
332
+
333
+ The console gained its tenth owner operation. It exists because a core fix landed
334
+ the same night (`sleep/NOTES.md` §14: a `type: "schema"` row is no longer a
335
+ dedup candidate) and **stopping a bug does not undo it**. On a store that ran a
336
+ cycle before that fix, a belief whose statement matched an ordinary memory's
337
+ body was archived `merged` and stopped being a belief. Migration settles the
338
+ DIRECTION of that loss and not its frequency: migrated elements were minted at
339
+ the import day while migrated memories kept their v1 birth day, so the memory is
340
+ never younger and the element always loses — but a pair needs two distinct v1
341
+ items whose gated text is byte-identical, and nothing in the code says how often
342
+ that happened. **This command is the measurement**, which is why its dry run is
343
+ the answer to G17 rather than an adjective in a document.
344
+
345
+ **Two sources, unioned, because either can be the surviving evidence.** The
346
+ `memory.merged` events whose `candidateId` is a `sch_` id — the owner's own
347
+ read-only check, filed as G17 — and the archived schema rows whose
348
+ `archived_reason` is the merge, which still reads true after the event log has
349
+ rolled. Removed ids are skipped: the deny-list answers before this tool does.
350
+
351
+ **It prints statements AND entity names, and `backfill-claims` says not to.**
352
+ That command's header says "IDS AND NUMBERS ONLY — a repair report is not a
353
+ place to print bodies", and this one prints two things that are not ids: the
354
+ first 60 characters of each statement, and **the entity's name** — the line
355
+ reads `sch_0dc7784034fc Ada lived day 0`. A person's name is author content as
356
+ squarely as a statement is, and it is named here so a later reader finds a
357
+ choice made twice rather than an unnamed second deviation.
358
+
359
+ Both are the same decision, and it is the one the command exists to enable: a
360
+ claim restored to the store is a claim the system will state in a briefing, and
361
+ "restore `sch_198628843ffb`?" is not a question a person can answer. Without the
362
+ entity the owner cannot tell which Ada, or whether the belief belongs to a
363
+ person still in their life. This runs on the owner's own terminal, at the
364
+ owner's own keystroke, against the owner's own store — the same reader who could
365
+ open the prose file beside it. Ids-only would have been safer and useless.
366
+
367
+ **The durable record stays ids and numbers only**, and that is the line that
368
+ actually matters: `memory.unmerged` carries `{event, day, candidateId,
369
+ originalId, mergedOnDay, usesDelta}` and no text of any kind (§5 G10). The
370
+ deviation is console-only — one printed line, at the moment of a decision, and
371
+ nothing written down.
372
+
373
+ **The core door it needed did not exist, and is the smallest one that works.**
374
+ `Store` has no `unarchive` and must not grow one: the prune, the revision and
375
+ the removal all archive, and each is archived for a reason a repair tool has no
376
+ business reversing. `store/owner-op-seam.ts#unarchiveMerged` accepts
377
+ `archived_reason: "merged"` and refuses everything else by its own error code —
378
+ `UNMERGE_NOT_A_MERGE`, `UNMERGE_SUPERSEDED`, `REMOVED`, `ID_UNKNOWN` — crosses
379
+ the same observer stance check every write crosses, and appends a latched
380
+ `memory.unmerged` record inside the same transaction, so a second `--apply`
381
+ writes nothing at all. The seam's export list grew from three names to six and
382
+ `test/store.test.ts` pins the new list, which is the point of pinning it.
383
+
384
+ **It re-indexes box 3, and the reason is a moving target.** `archive()` leaves
385
+ box 3 alone on master as this was written, so a restored row was findable with
386
+ no extra work. PR #64 (`overnight/df-live-rows`) adds `deindexDoc` to `archive()`
387
+ so document frequency is counted over live rows — and then whichever of the two
388
+ lands second would leave this command restoring a belief that is live, listed in
389
+ `beliefs(entity)`, and **invisible to lexical recall**, with no cheap way back
390
+ (a cache rebuild without an embedder drops every vector on the store). Measured
391
+ by the adversarial review at `doc_tokens` 7 → 0 on archive → 0 after `--apply`.
392
+ So the seam re-indexes on restore, through the narrowest grant member that could
393
+ do it (`OwnerOpAccess.reindexLexical`) — the LEXICAL half only, because a repair
394
+ that made a paid embedding call, or dropped a vector nothing here can recompute,
395
+ would be worse than the bug. The test simulates #64's deindex and would fail
396
+ without the call; it also asserts the embedding survives untouched.
397
+
398
+ **It prints which store it opened**, before the list. `--dir` is optional and the
399
+ default resolves to `~/.counterparts/store`, and this is the command the owner is
400
+ asked to type `--apply` at. `status`, `note` and `recall` print `Store: <dir>`;
401
+ `backfill-claims` does not, and should.
402
+
403
+ **The `uses` the merge credited is left standing.** Reversing it would rewrite a
404
+ physics count whose band may already have been materialized and whose crossing
405
+ may already be a durable `band.transition` row, in order to undo a single use on
406
+ a memory that really was looked at that evening. The delta goes into the
407
+ `memory.unmerged` record instead, so the credit is auditable rather than
408
+ silently reversed. The merge record and the `memory.merged` event are both left
409
+ exactly where they are — constitution 7: a repair that tidied away the evidence
410
+ of the bug would be the same class of mistake as the bug.
411
+
412
+ **`--dry-run` is a declared flag that does nothing.** Dry run is already the
413
+ default. It is declared because the owner's runbook line spells it out, and a
414
+ console that refuses `--dry-run` as an unknown flag on a command that IS a dry
415
+ run is the 2026-09-04 `--dirr` lesson pointed at the owner's own hands.
416
+
417
+ **Never run against the live store by this build's authors.** Every test uses a
418
+ temp store; the one demonstration of `--apply` was on a copy of a deliberately
419
+ poisoned scratch store. The owner runs the read-only
420
+ `counterparts repair-merged-beliefs --dry-run --dir ~/.counterparts/store`.
421
+
422
+ ## Verified live? No
423
+
424
+ Every test runs against a temp store. Per CLAUDE.md's definition of done this is
425
+ **merged, not verified**: the outstanding proof is one real snapshot of a real
426
+ store, restored and read.
427
+
428
+ ## 2026-09-05 — two refusals and a help page, from the cold stranger's list
429
+
430
+ **`status` on a missing store exits 1.** It printed the right sentence on
431
+ stdout and exited 0, so `set -e` around `counterparts status` sailed straight
432
+ past a typo'd `--dir` — and a typo in the one flag that says WHICH STORE is the
433
+ sharpest edge this console has (the same edge `unknownFlag` was built for one
434
+ round earlier). `usage`, not `failed`: nothing broke, the line named a place
435
+ with no store in it. The sentence moved to stderr with it, because a non-zero
436
+ exit whose only output is on stdout is half a refusal. It still does not create
437
+ the store by looking for it.
438
+
439
+ **And the remedy names the dir that was passed.** `Run 'counterparts init'`,
440
+ offered under a line that had just named `--dir /somewhere`, would create the
441
+ store in the DEFAULT place — advice that works, somewhere else. Both copies of
442
+ the sentence carry the dir now; the dashboard's is `bin/dashboard.ts`'s
443
+ `describeStoreError`, and it moved for the same reason on the same day.
444
+
445
+ **`counterparts <command> --help` answers the question it was asked.** It
446
+ printed the whole console's usage, so the flags a command actually takes were
447
+ listed nowhere a person could ask for them: the only surface that knew was the
448
+ refusal you got AFTER typing one wrong. `commandHelp` reads `COMMAND_FLAGS` and
449
+ `COMMON_FLAGS` — the same table `unknownFlag` reads — so the help page and the
450
+ parser cannot drift; `FLAG_HELP` gives each flag a sentence and the test fails
451
+ on a flag added without one. Bare `--help` still prints the console's usage,
452
+ and both still exit 0 and open nothing.
453
+
454
+ ## 2026-09-05 — `--yes` means one thing (G31)
455
+
456
+ **The disagreement.** Two commands merged the same night each took `--yes`, and
457
+ meant different things by it. `migrate-cache --apply` asks `remove`-style for a
458
+ typed `yes`, and `--yes` skips the asking; the store must be named (`--dir` or
459
+ `COUNTERPARTS_DATA_DIR`) either way. `repair-dates --apply` asks nothing, and
460
+ its `--yes` was the second way to aim the rewrite at a store nobody named — the
461
+ default store, which on a real machine is the owner's live memory. The one
462
+ `FLAG_HELP` sentence that had to describe both meanings described both, which
463
+ is how the review saw it (LAUNCH-STATUS G31).
464
+
465
+ **The ruling.** `--yes` ONLY ever skips an interactive confirmation. A command
466
+ that writes always requires the store named by `--dir`, and `--yes` never
467
+ stands in for it. `repair-dates` has no confirmation to skip, so `yes` left its
468
+ flag list rather than staying as a no-op: a flag the help page lists is a flag a
469
+ reader tries, and a no-op that used to mean "aim here" is the worst kind.
470
+
471
+ **Where it is enforced.** `repairDatesCommand` refuses `--apply` whenever
472
+ `--dir` was not passed — `defaultedDir` is `flags.dir === undefined`, so an
473
+ exported `COUNTERPARTS_DATA_DIR` does not count as naming it, which was already
474
+ this command's rule — in the shape `migrate-cache` uses: `refused:` on stderr,
475
+ `EXIT.refused`, the remedy naming `--dir <path>` and nothing else. `--yes` on
476
+ `repair-dates` now falls to `unknownFlag` before the store is looked at. The
477
+ test is `test/repair-dates.test.ts`, "the console door": refused without
478
+ `--dir`, refused as unknown with `--yes`, through with `--dir`, and the dry run
479
+ still unguarded. `FLAG_HELP.yes` carries the one meaning, so
480
+ `migrate-cache --help` says it too. `migrate-cache`'s own door is unchanged: it
481
+ already refused the default regardless of `--yes`.
482
+
483
+ **What still says `--yes` and means something else.** `counterparts-dashboard
484
+ serve --yes` means "open the DEFAULT store" (QUICKSTART §11.1, README). It is
485
+ read-only and it is not this console, so it was left alone under a ruling about
486
+ commands that write; but it is the last `--yes` with a second meaning, and a
487
+ rename (`--default-store`, say) is the obvious follow-up once the owner rules.
488
+ (It landed as `--default-store` in #78, the same day.)
489
+
490
+ ## 2026-09-05 — one definition of "named", and one door in front of every bulk write
491
+
492
+ **What the review found (#77).** The entry above closed the `--yes` half and
493
+ left the other half open, in the same sentence. `repair-dates --apply` refused a
494
+ store named only by `COUNTERPARTS_DATA_DIR`; `migrate-cache --apply` counted the
495
+ variable as having named it. So
496
+ `COUNTERPARTS_DATA_DIR=<store> counterparts migrate-cache --apply --yes` walked
497
+ through, printed the plan and reached the conversion, while the identical line
498
+ one command over refused — under one `FLAG_HELP.yes` sentence asserting the two
499
+ agreed ("it never stands in for `--dir`, which a command that writes still
500
+ requires"). Two definitions of "named" in one console, and a help page that
501
+ named the stricter one. The reviewer also found that `backfill-claims --apply`
502
+ (salience across every authored memory) and `repair-merged-beliefs --apply`
503
+ (un-archives rows) had **no door at all** — `grep` found the guard at exactly
504
+ two sites.
505
+
506
+ **The ruling (owner, 2026-09-05).** `--yes` only ever skips an interactive
507
+ confirmation. A command that performs a BULK WRITE always requires the `--dir`
508
+ FLAG; neither `--yes` nor `COUNTERPARTS_DATA_DIR` stands in for it. Ordinary
509
+ per-memory commands — `note`, `recall`, `remove`, `init`, `install`, `status`,
510
+ and `verify` without a writing flag — keep today's behaviour: the variable names
511
+ their store, which is what QUICKSTART §3 teaches. The distinction is blast
512
+ radius, not "writes": an exported variable is a shell's memory of where a store
513
+ lives, and a rewrite of the whole store asks for a sentence typed about THIS
514
+ rewrite.
515
+
516
+ **The helper.** `requireDirFlagForBulkWrite(dir, io, flags, label, what)` in
517
+ `commands.ts`, beside `unknownFlag` — one test (`typeof flags["dir"] ===
518
+ "string"`, the dispatcher's own), one refusal shape (`refused:` on stderr,
519
+ `EXIT.refused`, `it would have been <dir>`, `Name the store: --dir <path>.`,
520
+ `Nothing has changed.`), returning the exit code or `null`. It is the FIRST
521
+ statement in each writing body, before `storeExists` and before any planning
522
+ read: a guard that opened the directory before refusing it has already pointed
523
+ the command at the store it meant to refuse.
524
+
525
+ **The doors, all seven invocations of them.** `repair-dates --apply`,
526
+ `migrate-cache --apply`, `backfill-claims --apply`,
527
+ `repair-merged-beliefs --apply`, and `verify --rebuild` / `--prune-index` /
528
+ `--drop-vectors`. `--drop-vectors` is guarded although it is inert without
529
+ `--rebuild`: it is a standing consent to lose embeddings, and consent typed at a
530
+ store nobody named is the thing the door is for. The dry runs — each of these
531
+ without its writing flag, and `verify`'s census — still read the variable, and
532
+ `test/cli.test.ts` asserts that they do.
533
+
534
+ **What moved with it.** The `dirWasNamed` computation left the dispatcher, so
535
+ `migrate-cache` no longer has an answer of its own; its doc-comment rule 2 and
536
+ the usage block's paragraph both said "`--dir` or `COUNTERPARTS_DATA_DIR`" and
537
+ now say `--dir`. `FLAG_HELP.yes` is true of every command that prints it, which
538
+ today is `migrate-cache` alone: "skip the typed confirmation, and nothing else —
539
+ it never stands in for `--dir`, which `--apply` requires". Each bulk command's
540
+ `COMMAND_BLURB` ends with `--apply requires --dir.` (verify names its three
541
+ flags). QUICKSTART §10's recap and §11.1 carry the exception — §11.1 now lists
542
+ two, this one and `serve`'s.
543
+
544
+ **The tests.** `test/cli.test.ts`, "a bulk write names its store with `--dir`,
545
+ and nothing else names it": each of the seven refused on the variable alone with
546
+ the store proven byte-identical by a sha256 fingerprint of the whole tree, each
547
+ through with `--dir`, and the dry runs unguarded. The reviewer's exact case
548
+ (`migrate-cache --apply --yes` on the variable) is asserted in the
549
+ `migrate-cache` block, including that stdout carries no `Store:` line — proof it
550
+ stopped AT the door rather than one step in at box 3's "nothing to convert"
551
+ refusal, since both are exit 2. `test/repair-dates.test.ts`'s "console door"
552
+ stays as it was.
553
+
554
+ ## 2026-09-20 — the day-1 surfaces (new-user findings 2, 3, 4, 6)
555
+
556
+ The owner's next act is to follow the QUICKSTART on a blank store as a stranger, so what
557
+ these commands SAY on day 1 is the product. N2's hermetic dry run measured it and the news
558
+ was not good: `fired` opened with twenty-eight `never` lines, `status` buried its four
559
+ numbers under a ten-line block naming `assertLayout()` and "Box 3", and `doctor` printed a
560
+ red about a key both pages say is optional.
561
+
562
+ **`fired` on a young store.** The report now carries `young`, `livedDay` and
563
+ `calendarDays`, so the console, doctor and the dashboard share ONE definition instead of
564
+ each deciding. Only the TEXT renderer narrows; the report itself is whole, `--all` prints
565
+ it, and the bounds line still counts every state. **Both clocks have to agree** — a lived
566
+ day is advanced by the worker, so a store whose worker has been dead a fortnight also
567
+ reads lived day 0, and that store must get the full list, because the full list is its
568
+ diagnosis.
569
+
570
+ **`status`.** The census leads, the prose follows, `Layout:` is behind `--layout`. The
571
+ day's facts are two new lines. `Today` is counted INSIDE the census walk and not with
572
+ `countMemories({ learnedOnFrom })`, which counts removed and superseded rows: the first
573
+ draft printed `2 new` beside `Memories: 1`, which is the kind of disagreement between two
574
+ numbers on one page that makes a reader stop trusting both.
575
+
576
+ **`readHost` lives in `install.ts`, not in `doctor.ts`.** It is the other half of what that
577
+ file prints — `settingsBlock` and `mcpCommand` — and it uses that file's own names
578
+ (`HOST_EVENTS`, `MCP_SERVER_NAME`). `doctor.ts` takes the reading and grades it, exactly
579
+ as it already takes `checkout` and `open`, so the adapters stay leaves that do not import
580
+ each other and the host's vocabulary lives in one place.
581
+
582
+ Everything it reads belongs to the host. `~/.claude.json` is documented as a file the host
583
+ writes for itself, so every answer names the files it looked at and the finding is amber,
584
+ never red: when one of these paths moves, the line must read "I looked here and did not
585
+ find it", not "you did not install it". Paths verified against the host's documentation on
586
+ 2026-09-20 — true for now, and worth re-checking rather than trusting.
587
+
588
+ **`doctor --dir` under the explicit-dir guard.** `--dir` is a name, so the refusal was
589
+ never really about the store: it was about the DEFAULT CONFIGURATION beside it, whose
590
+ `credentialsFile` points at the owner's live keys. That file is now simply not opened, the
591
+ store is graded on its own, and one amber says which questions therefore went unasked. On
592
+ cut-over day this is the difference between pointing `doctor` at the parked store and a
593
+ refusal with nothing to do.
594
+
595
+ **Precisely, because the first version of this note overstated it** (adversarial review,
596
+ 2026-09-20): what is not read is OUR configuration — `claude-code.json`, the credentials
597
+ file it names, the embedder setting, the snapshot policy, the stance. `readHost` still
598
+ runs, so `doctor --dir <anything>` opens the four host settings files and `~/.claude.json`
599
+ on the real home. Those are the HOST's, they are read-only, and the Host line names every
600
+ one of them — but "reads no configuration at all" was not true of them and should not have
601
+ been written.
602
+
603
+ ---
604
+
605
+ ---
606
+
607
+ ## `start-fresh` — starting over as one command (2026-09-20, N1)
608
+
609
+ **What it is.** One command that parks the store beside itself under a dated
610
+ name, parks the snapshots folder the same way, and creates a blank store back at
611
+ the same path. It exists because the trial loop the owner wants — use it as a
612
+ stranger, collect every rough edge, fix, start over, repeat — otherwise runs
613
+ through the floor plan's §2 step 5 by hand, five commands with seventeen
614
+ thousand private memories on the other side of a typo.
615
+
616
+ **The rule, and why the module is arranged around it.** It never deletes and
617
+ never opens the old store, *including read-only*: under WAL a commit lives in the
618
+ `-wal` until somebody checkpoints it, and an opener is somebody. `start-fresh.ts`
619
+ makes exactly one mutating call, `rename`, and imports nothing that can open a
620
+ database.
621
+
622
+ **Decisions taken, each a working default:**
623
+
624
+ - **The store comes from the CONFIGURATION, and `--dir` is refused.** The store
625
+ that matters is the one the hooks and the MCP server open. `--dir` is a common
626
+ flag, so it parses on every command; ignoring it silently here would be the
627
+ `--dirr` scar pointed at the most dangerous verb in the package.
628
+ - **The new store lands at the SAME path**, which is where this departs from the
629
+ floor plan's step 5 (`store-v2` beside the old one, then re-run `claude mcp
630
+ add`). Parking in place means `dataDir` does not move, so `claude-code.json`
631
+ and `credentials.env` are kept byte for byte — `install` without `--force`
632
+ keeps both — and there is no MCP re-registration to forget, which was named as
633
+ failure mode (b) of the clean cut.
634
+ - **`install` does the creating**, called as itself rather than re-implemented.
635
+ Its host-steps tail is skipped by the one caller it is false for: printing
636
+ "register the MCP server" on this path would send the owner to run a command
637
+ he does not need, on the day he is most likely to follow instructions
638
+ literally. Its ceiling is handed back from the configuration for the same
639
+ reason — otherwise the run ends on "NO injectionBudgetBytes was written",
640
+ which is true of a cold start and false when the file was kept.
641
+ - **Snapshots first, store second**, so a kill between the two renames leaves the
642
+ configuration pointing at a store that is still there. The window where it
643
+ points at nothing is two syscalls wide, and the rollback lines are printed
644
+ before the first rename, so even a kill inside it leaves the way back on the
645
+ screen.
646
+ - **What counts as "a store is here" is a filesystem question** — the directory
647
+ exists and holds something — never `storeExists()`, which looks for the
648
+ canonical database by name. After F5 that name changes, so on cut-over day
649
+ `storeExists()` would answer "no store here" about the store being protected.
650
+ - **A fresh `-shm` warns; it does not refuse.** Measured on this build:
651
+ under `bun:sqlite` the `-wal` and the `-shm` survive a clean close, so that
652
+ file is recent after any console command at all — including the `doctor`
653
+ somebody ran a minute before typing this one. Refusing on it made the command
654
+ refuse itself in testing. The refusal rests on the live-session registry
655
+ instead, which is genuinely about a host that has not ended a session.
656
+ - **The confirmation is the real gate, and says so.** No cheap read can see an
657
+ idle open session: it writes nothing. So the prompt states that in those words
658
+ rather than implying the checks above it were sufficient.
659
+ - **The record of the beginning is a meta row, not a durable event.**
660
+ `store.started`, `store.started.by`, `store.previous.parked` in box 2's
661
+ general-purpose key space, beside `embed.failed.<id>` and `sleep.pruned.<id>`.
662
+ A durable event name would have had to be added to `core/counterpart.ts` and
663
+ accounted for in `fired`'s registry — where a mechanism that fires once in a
664
+ store's lifetime would read "never" forever on every store that was simply
665
+ installed. `status` reads the rows back; nothing else does.
666
+
667
+ **Known, and left alone for now.** A kill between the install and that record
668
+ leaves a blank store that `status` simply says nothing about. A state file to
669
+ close it would be a second source of truth about a directory, for a line of
670
+ output; the next run's printed plan says exactly what is on the ground instead.
671
+ A test asserts the silence, so nobody later turns it into a guess.
672
+
673
+ **Two duplicated strings, and the honest reason.** `start-fresh.ts` spells
674
+ `"store"` and `"snapshots"` rather than importing `DEFAULT_STORE_SUBDIR` and
675
+ `SNAPSHOTS_DIR_NAME`. Both are only *recognition* tests — "does this store sit in
676
+ the layout this package creates, so that a sibling `snapshots` is ours to park" —
677
+ and getting either wrong costs a folder not parked, never a byte moved.
678
+
679
+ The tempting justification is wrong and is written down here so nobody rests on
680
+ it: importing `adapters/snapshots.ts` would not "pull `openDb` into the import
681
+ graph" in any way that matters, because this file already imports
682
+ `core/store/index.js`, which reaches the whole store. **The module's promise is
683
+ about CALLS, not imports** — it opens no database, and the one store function it
684
+ calls, `preRowsMarkersIn`, reads filenames. If the layout names ever move, this
685
+ file is the second place to look.
686
+
687
+ **The merge-up over F5 (2026-09-20).** Four things changed underneath this
688
+ command, and none of them changed its design — which was the point of asking the
689
+ filesystem rather than the floor.
690
+
691
+ - **The fixture stopped being a stand-in.** `test/old-floor-fixture.ts` extracts
692
+ the pinned tag with `git archive` (never a second worktree — that touches the
693
+ shared repository) and runs THAT build's `Store` API in a child to write a real
694
+ v5 store. It is worth the seconds: the hand-made version proved that the
695
+ command tolerates three filenames, and the claim is about a store with bodies
696
+ in files, archived versions, a journal, spans, a cache and a WAL. On the
697
+ fixture as measured `operational.sqlite` is 4 KB and its `-wal` is ~600 KB, so
698
+ "never opens it" is load-bearing rather than decorative: an open-and-close
699
+ could checkpoint 600 KB out of the sidecar and into the file.
700
+ - **`storeExists()` now answers true for a pre-rows store** (F5, so that ~20
701
+ console commands reach the named refusal instead of "run init"). This command
702
+ still keeps `sight()`, and the difference is real rather than stylistic: a
703
+ half-made store holding only a `cache/` is "no store" to `storeExists` and
704
+ "something is here" to `sight`. The second answer parks it; the first would let
705
+ `install` mint a store beside a stale box 3 belonging to another store's rows.
706
+ Both readings are pinned by a test across four directories.
707
+ - **The plan says which floor it found**, through `preRowsMarkersIn` — filenames,
708
+ never an open. A reader on cut-over day has just met F5's refusal somewhere
709
+ else; being told it is the same fact, and that it is the reason parking is
710
+ right, is cheaper than leaving them to connect it.
711
+ - **F5's rotation already refuses to delete or count a copy holding pre-rows
712
+ markers**, so parking `snapshots/` is belt and braces — kept, because the
713
+ bracing is free and the failure it prevents is not. What DID need correcting is
714
+ the sentence about a `snapshots.dir` pointed elsewhere: "the new rotation will
715
+ count the old copies" is now only true of copies this floor wrote. Old-floor
716
+ copies are recognised and left alone; new-floor ones count toward `keep`. Both
717
+ the printed line and QUICKSTART say that now.
718
+
719
+ ---
720
+
721
+ ## What the adversarial review changed (2026-09-20)
722
+
723
+ The rule held — the reviewer could not make it delete anything and could not make
724
+ it open the store it parks — and everything found was in the ring AROUND the
725
+ rename. Five of the fixes changed the design rather than a sentence.
726
+
727
+ **The order is the fix for two findings at once.** The blank store is now built
728
+ in a sibling (`store.new-<pid>`, same filesystem) BEFORE anything is parked, and
729
+ moved into place with one atomic rename. That closes M1 — `install` could refuse
730
+ *after* both renames, on a fractional `injectionBudgetBytes` that `loadConfig`
731
+ accepts and `installCommand` does not, leaving the configuration pointing at
732
+ nothing — because an install that refuses now costs a temporary directory. And it
733
+ shrinks M4: the window in which a real SessionStart hook could mint a store at
734
+ `dataDir` went from a whole `install` to two renames. The window cannot be closed
735
+ entirely — `rename` needs the old directory out of the way first — so the second
736
+ rename REFUSES on a non-empty destination and names all three directories rather
737
+ than burying one inside another.
738
+
739
+ **The cold arm had a store in it all along (B1).** An absent configuration meant
740
+ "a machine with nothing on it", so `storeDir` was `""`, the install pin was
741
+ skipped, and `installLayout` fell back to `$COUNTERPARTS_DATA_DIR` else
742
+ `~/.counterparts/store`. One mistyped character on `--config` was enough to open
743
+ and stamp the live store. It now computes the landing place up front from the
744
+ CONFIGURATION'S OWN directory and an EMPTY environment — so the variable cannot
745
+ redirect it — prints it (the `Store:` line is never blank again, which is what let
746
+ two contradictory sentences share a screen), pins it, and refuses if anything at
747
+ all is there.
748
+
749
+ **A plan that is read and a plan that runs must not differ (M2).** The date is
750
+ frozen for the whole run, so a UTC midnight cannot rename the plan out from under
751
+ the printed block. The re-read after the confirmation now refuses when the ground
752
+ moved instead of silently executing a different plan. And the way back is printed
753
+ again *after* the renames, from the plan that ran, listing only the steps that
754
+ actually moved.
755
+
756
+ **A bare `mv` is not a move (M3).** `mv a b` where `b` exists moves `a` INSIDE
757
+ `b`, exit 0 — measured. Every printed line is guarded, and the way back is a
758
+ command now (`--undo`) with the same discipline. The test parses the printed lines
759
+ out of real output and runs them through `/bin/sh`, against a free destination and
760
+ against one that exists; proving a guard any other way proves the intention
761
+ instead.
762
+
763
+ **Two of my own premises were wrong**, and the code moved rather than the test.
764
+ `--undo` could never hit its own destination check for the blank store, because it
765
+ picks a free name; the reachable collision is a snapshots folder the rotation puts
766
+ back, and it is LEFT and said rather than merged or refused-over. And the undo's
767
+ pre-check read the ground as it stands rather than as it will be at each step, so
768
+ it refused its own plan — step 1 is exactly what frees the path step 2 needs.
769
+
770
+ **`--yes` is not enough on a store with something in it.** The reviewer's own
771
+ machine had two dashboards holding the live store open while the review was being
772
+ written, and neither leaves a record this command can read. `--yes` exists for a
773
+ script and for the install loop, where the store is a throwaway; on a real one the
774
+ typed confirmation is the only instrument that catches an idle dashboard, so
775
+ skipping it needs a second sentence: `--nothing-is-open`.
776
+
777
+ **And a symlinked `snapshots` no longer refuses the whole command.** Symlinking a
778
+ backup folder onto an external disk is an ordinary thing to have done, and there
779
+ was no way through but editing the configuration. It is treated exactly as a
780
+ configured `snapshots.dir` is: left, and said out loud. The store still moves,
781
+ which is what the owner came for.
782
+
783
+ ---
784
+
785
+ ## The confirmation review, and the one thing it taught (2026-09-20)
786
+
787
+ The forward command came through closed — every earlier finding re-run and
788
+ fixed, a real v5 store byte-identical through a refusal, a dry run, a cut-over
789
+ and the full printed rollback. The BLOCKER was in `--undo`, and the lesson is
790
+ worth more than the fix.
791
+
792
+ **`--undo` was new code that ran none of the old code's refusals.** Not because
793
+ anyone decided it should not: because it was written as its own path, and the
794
+ refusals lived inside `planStartFresh`. So a configuration whose `dataDir` is
795
+ inside `~/.bansai` — which the forward command refuses BY NAME, in the words of
796
+ CLAUDE.md's second safety rule — was renamed twice by the command whose whole
797
+ job is being the safe way back. With no tampering at all.
798
+
799
+ The fix is parity, and the shape of it matters: **one function, called by both**.
800
+ `pathGuard()` is the whole battery — present, absolute, not a forbidden root by
801
+ either spelling, not a root, not the home directory, not a directory holding the
802
+ configuration, not a symlink — and there is now a structural test asserting that
803
+ the forward plan and the undo plan return the *identical sentence* for the same
804
+ bad path. Two implementations of "what may I rename" is how the two came to
805
+ disagree; one function and a test that compares their answers is what stops it
806
+ happening again.
807
+
808
+ **And a record is data.** `store.previous.parked` is a row in the new store's
809
+ `meta` table, so anything that can open the store can write it — the reviewer
810
+ pointed it at `~/.bansai/store` and watched v1's memory get renamed onto
811
+ `dataDir`, at the store's own parent to get a directory planned into its own
812
+ child, and at a symlink to make `dataDir` become one. `parkedSiblingRefusal`
813
+ pins the shape instead of trusting the value: same directory as the store, and a
814
+ name this package actually writes. The fallback already only produced those; the
815
+ recorded value now obeys the same rule.
816
+
817
+ The rest was parity too — the liveness check, the re-read after the
818
+ confirmation, the way back in the failure branch — plus two honest sentences:
819
+ the dry run says it reads the new store's record and may rewrite its `-shm`, and
820
+ the header comment no longer claims an undo of an undo, because there is not
821
+ one. The two guarded lines that do it by hand are printed instead.
822
+
823
+ ## 2026-09-20 — `export --markdown`, and the five choices inside it (F7)
824
+
825
+ Ruling 4 said "`export --markdown` omits confidential rows unless
826
+ `--include-confidential`, and says how many it omitted". Five things that ruling
827
+ does not decide, decided here, each true for now.
828
+
829
+ 1. **The tree is rendered from ROWS, not from a walk of `<store>/journal/`.**
830
+ The copy on disk is derived; a stale one — an episode removed while its copy
831
+ could not be written — would be exported as though it were live. Rendering
832
+ from rows cannot do that, and it uses the copy's OWN path function and the
833
+ same `renderMarkdown`, so the bytes are identical either way. "Included as
834
+ is" is kept by using its code, not by copying its files.
835
+ 2. **Grouped by kind** (`memories/fact/`, `memories/person/`, …), not by month.
836
+ Kind is the axis `status` and the dashboard already show, it is a closed set
837
+ of six, and it does not move when a memory is revised — by month splits one
838
+ belief's life across directories.
839
+ 3. **Filenames are ids.** A title can be as sensitive as a body, and a directory
840
+ listing is the part of an export that gets read over somebody's shoulder.
841
+ 4. **`--markdown --passphrase` is supported rather than refused**, and it is the
842
+ safest path of the three: the tree is built in memory, sealed, and written as
843
+ one blob, so it never makes a scratch file at all. (The database export keeps
844
+ F5's 0700 `mkdtemp` and its bounded sweep, which is what review B's MAJOR-4
845
+ and review C's NEW-MINOR-6 bought.) A test counts `counterparts-export-*`
846
+ directories in `$TMPDIR` across a markdown export and asserts the number does
847
+ not move.
848
+ 5. **`--with-versions`, not `--versions`.** `self-page` already takes both
849
+ `--versions` and `--version`, and the help-page totality test reads flags as
850
+ substrings — an `export --versions` puts the string `--version` on export's
851
+ help page, naming a flag export does not take. A real constraint from a real
852
+ test, not a preference.
853
+
854
+ **TWO FACTS ABOUT `export` THAT ARE THE OWNER'S TO RULE ON, AND ARE UNRULED.**
855
+ Both landed with F7 and neither has been decided by anybody but the builder; the
856
+ f6f7 review measured what they actually do (MINOR-5) and they are written here
857
+ so the ruling can be made from facts rather than from a diff.
858
+
859
+ 1. **The ordinary `export` now opens the canonical database FOR WRITING.** It
860
+ opened `observer: true` before. The reason is the `store.export` row and
861
+ nothing else; the review fingerprinted every file under the store and found
862
+ the effect confined to exactly that — the owner's export moves
863
+ `counterparts.sqlite-wal` and the two `-shm` files, and nothing else; no
864
+ file, no `journal/` write, no scratch. An export against a store another
865
+ process was holding with `BEGIN IMMEDIATE` still returned 0, so there is no
866
+ lock regression of the I38 shape. The row's `catch {}` means a row lost to
867
+ contention is silent, which is one more way "did anything leave" can answer
868
+ "no" when the answer was "yes".
869
+ 2. **An instrument can now perform a full egress.** `export` came off
870
+ `OWNER_OPS`, so `--observer export` — which refused outright before — makes a
871
+ complete readable or sealed copy of every memory, confidential ones included
872
+ with one flag, and writes no trace in the store (the durable row is what
873
+ stands down, and the report says so). That is the egress question stated
874
+ plainly: the stance that means "read, do not change" now permits the one
875
+ operation by which memory leaves the machine.
876
+
877
+ **The line to revert, if the owner wants it back:** `"export"` in `OWNER_OPS`
878
+ (`commands.ts`), and `Store.open({ dir, observer })` back to `observer: true` in
879
+ `exportCommand`. The durable row goes with it, and `fired.ts`'s `export` row
880
+ becomes blind the way `backup` is. Nothing else depends on either.
881
+
882
+ **Two refusals that are new, and one removal.** A non-empty target is refused
883
+ unless `--into-non-empty`: an export is a whole copy, and one written over
884
+ another is a mixture nothing can tell apart. `--include-confidential` and
885
+ `--with-versions` without `--markdown` are refused BY NAME rather than ignored —
886
+ they decide what goes into the tree, and a database export carries every row
887
+ there is, so honouring either there would be a lie in one direction and silence
888
+ in the other. And `export` came off `OWNER_OPS`, the only removal that list has
889
+ had: an export READS the store and writes outside it, so standing the command
890
+ down under `--observer` refused a read. The one write it now makes to the store
891
+ is the durable row, and that is what stands down instead — the copy is still
892
+ made and the report says the row was not written. `backup` is the same shape and
893
+ deliberately stays on the list: it could follow, but nobody has ruled on it.
894
+
895
+ ## 2026-09-20 — the f6f7 review's five, and what each one cost
896
+
897
+ Read the review for the measurements; this is what changed and why, in one place.
898
+
899
+ - **The journal module never follows a symlink** (MAJOR-1). `journalFiles` walked
900
+ with `statSync`, so a link anywhere under `journal/` made a core module a
901
+ writer and a deleter outside the store — the reviewer put a chapter's whole
902
+ body in an external directory and watched a removal ceremony delete a file out
903
+ there and report it as chased. One rule now: a link anywhere at or under
904
+ `journal/` and the module stands down by name (`journal-symlink`), removal arm
905
+ included, because an absence it cannot vouch for must not read as "nothing
906
+ beside the row".
907
+ - **A broken `journal/` is one row a day** (MAJOR-2), through the store's own
908
+ `dedupKey` latch, and a directory-level failure ends the backfill pass instead
909
+ of re-discovering itself 25 times. Measured before: 80 rows across five
910
+ chapters and three worker cycles. The starvation half was only reasoned in the
911
+ review and is measured here.
912
+ - **The journal-echo disclosure is exact** (MAJOR-3). It rode on a ranked top-20
913
+ search and went silent on exactly the store that needs it: a real chapter plus
914
+ twenty-five near-identical memories, and the episode fell off the list while
915
+ the report said `journal(0, nothing beside the row)` and `unchased: nothing`.
916
+ Now `meta.episodeId` first and a bounded containment scan second, with the
917
+ bound REPORTED.
918
+ - **`assertSafeTarget` resolves symlinks** (MAJOR-4), on both sides and on the
919
+ v1 roots, and refuses a dangling link by name instead of by `mkdirSync`'s
920
+ `EEXIST`. It fixes `backup` at the same time. The macOS trap is why both
921
+ sides: `$TMPDIR` is itself reached through `/var` → `/private/var`, so
922
+ resolving one side would have stopped every inside-the-store case from being
923
+ detected.
924
+ - **`journal/` leaves the backup set** (MAJOR-5), because copying a derived
925
+ directory put removed episodes' words into every rotating snapshot as plain
926
+ markdown, and the rows are in the snapshot anyway. Paired with a cold-start
927
+ bound so a restore is readable after one pass rather than forty, and with a
928
+ sentence in the removal report about the copies already on disk.
929
+
930
+ **What the durable row carries, and what it does not.** `store.export`: the
931
+ kind, whether it was encrypted, files, bytes, rows, how many confidential rows
932
+ were omitted, whether versions went, how many rows would not render. **Not the
933
+ target path.** Where the owner sent his memories is more than the row needs to
934
+ prove the door works (§5 G10), and the terminal has already told him. F2's blind
935
+ `backup` row and its "one `store.backup` event would fix it" are untouched:
936
+ that is a different door and still an open gap.