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,1258 @@
1
+ # Counterparts — install
2
+
3
+ This is the one canonical install path. `tools/install-loop/run.sh` runs this
4
+ page's CONSOLE commands verbatim — each one is grepped out of this file before it
5
+ is executed, so a doc edit that changes one fails the loop — in a throwaway home
6
+ directory with no copy of this repository on its PATH. It packs the tarball
7
+ itself and feeds the hook its own payload. It cannot reach the npm registry, and
8
+ it cannot run `git clone`, `claude mcp add`, `export PATH` or Claude Code; §10
9
+ lists what that leaves unverified.
10
+
11
+ No API key required. The scripted version of this page — install, configure,
12
+ hook, note, recall, the MCP round trip, the removal plan, the session write and the
13
+ scope switch — is
14
+ 52 checks and runs end to end in two to three seconds; the part that takes you time is
15
+ §4, pasting two blocks into Claude Code's own configuration.
16
+
17
+ ---
18
+
19
+ ## 1. What you need
20
+
21
+ - **[bun](https://bun.sh) 1.3 or newer.** Counterparts ships as TypeScript
22
+ sources and runs them directly; bun is the runtime. `curl -fsSL https://bun.sh/install | bash`
23
+ - **npm, only if you install from source** (§2, second half): `npm pack` is how
24
+ you build the tarball from a clone. It comes with Node; a machine set up by the
25
+ bun line above may not have it. (`bun pm pack` exists but is not what §2 was
26
+ tested with, so this page does not tell you to use it.) The ordinary install
27
+ needs bun and nothing else.
28
+ - **[Claude Code](https://claude.com/claude-code)**, if you want the hooks and
29
+ the MCP tools. The store, the console and the dashboard work without it.
30
+ - **No API keys.** Counterparts runs with none; §6 says exactly what you give up.
31
+
32
+ **Node is not verified.** The core targets built-in `node:sqlite`, which needs
33
+ Node 22.5+ behind a flag and 23.4+ by default. Everything on this page was run
34
+ under bun 1.3.10 on macOS. Nobody has run Counterparts under Node, so nothing
35
+ here claims it works there. There is no build step and no `dist/`; if a Node
36
+ target is ever added, it will need one.
37
+
38
+ ---
39
+
40
+ ## 2. Install
41
+
42
+ ```
43
+ bun add -g counterparts
44
+ ```
45
+
46
+ That is the whole install. It copies the package into bun's own global folder;
47
+ nothing else on your machine is read or changed, and §3 is where a store gets
48
+ made. It puts four executables into bun's global bin directory:
49
+
50
+ | | |
51
+ |---|---|
52
+ | `counterparts` | the owner's console — status, install, backup, export, removal |
53
+ | `counterparts-hook` | the Claude Code hook entry point; one executable, five events |
54
+ | `counterparts-mcp` | the MCP server — `note`, `recall`, `status`, `session_end`, `chapter` |
55
+ | `counterparts-dashboard` | read-only views of what is in the store |
56
+
57
+ **Check that directory is on your PATH before going on:**
58
+
59
+ ```
60
+ counterparts --help
61
+ ```
62
+
63
+ If that says `command not found`, bun told you so during the install
64
+ (`warn: To run "counterparts", add the global bin folder to $PATH`) and the fix is
65
+ `export PATH="$HOME/.bun/bin:$PATH"` in your shell profile. A fresh bun install
66
+ does not always do this for you.
67
+
68
+ ### Installing from source instead
69
+
70
+ For contributors, for a version that is not published yet, or for a tarball
71
+ somebody sent you. **Already have the repository? Skip the clone and run
72
+ `npm pack` there. Were you sent a tarball? Skip to `bun add -g`.** Run the clone
73
+ somewhere that does not already hold a directory named `counterparts` — `git
74
+ clone` refuses, harmlessly, if one is there.
75
+
76
+ ```
77
+ git clone https://github.com/mlapeter/counterparts.git
78
+ cd counterparts
79
+ npm pack
80
+ ```
81
+
82
+ `npm pack` writes `counterparts-<version>.tgz` into the current directory and
83
+ prints its name. Install that file, by absolute path:
84
+
85
+ ```
86
+ bun add -g "$PWD"/counterparts-*.tgz
87
+ ```
88
+
89
+ Two things about that line, both learned the hard way:
90
+
91
+ - **The path must be absolute.** bun 1.3.10 fails a relative tarball path with
92
+ `error: ENOENT extracting tarball from ./x.tgz`.
93
+ - **The same error means "no file by that name."** If you typed a filename that
94
+ does not exist, you get the identical message. Check `ls *.tgz` first.
95
+
96
+ What lands is the same package the registry serves, in the same place. The clone
97
+ is only where the tarball was made: nothing reads it again, and you can delete it.
98
+
99
+ **Running from the clone instead of installing.** `bun install` in the clone, then
100
+ every `counterparts …` below becomes `bun run src/adapters/cli/bin/counterparts.ts …`,
101
+ `counterparts-hook` becomes `bun run <repo>/src/adapters/claude-code/bin/hook.ts`,
102
+ and `counterparts-mcp` becomes `bun run <repo>/src/adapters/mcp/bin/serve.ts`.
103
+ Those four paths are stable; the live host has pointed at them since 2026-09-03.
104
+
105
+ ---
106
+
107
+ ## 3. Set it up
108
+
109
+ ```
110
+ counterparts install --budget 9000 --name "Your Name"
111
+ ```
112
+
113
+ That is the command you want the first time. Before you run it, one paragraph on
114
+ the other one, because the difference is not recoverable by guessing.
115
+
116
+ ### `install` or `init` — which one
117
+
118
+ ```
119
+ counterparts init --dir /somewhere/else/store --name "Your Name"
120
+ ```
121
+
122
+ `init` makes **just a store**: a data dir, an identity core if you name one, and
123
+ a printout of the same install steps. It writes nothing under `~/.counterparts/`,
124
+ no configuration and no credentials file, and it touches no host settings.
125
+
126
+ Use `install` for your first, real memory — it is the cold start, it owns
127
+ `~/.counterparts/`, and it is the only one that produces a config the hooks will
128
+ read. Use `init` for a second store, a scratch store, or a store on another disk
129
+ that you only want to reach from the console and the dashboard. A store made by
130
+ `init` has no host wiring at all: the hooks will not see it, because they read one
131
+ configuration — the default one, unless something names another (`--config`,
132
+ below) — and `init` writes none.
133
+
134
+ Both take `--name`, and both mean the same thing by it: the identity core is
135
+ minted then and there, by the same door, so a store made either way has it as its
136
+ first live row. `counterparts status` on a directory with no store points you at
137
+ `init`, which is the right answer for the case you are usually in when you see
138
+ that message.
139
+
140
+ ### What `install` writes
141
+
142
+ Replace `Your Name` with yours. It seeds the identity core — the thing the memory
143
+ is *about* — and there is no default for it anywhere.
144
+
145
+ Nothing is composed for you to read at that instant: a fresh store has lived no
146
+ boundary, so `SessionStart` prints the honest bootstrap line until one exists
147
+ (§7). The first wake that *is* composed — at the end of your first real session,
148
+ or right now with `counterparts rebrief` (§7) — opens with your name:
149
+
150
+ ```
151
+ Who I am:
152
+ This memory is for Your Name. No identity has formed here yet — identity is earned at the boundary that ends a session, from what recurs across distinct days.
153
+ ```
154
+
155
+ That is the whole of it on day 0, and it is deliberately the whole of it: the
156
+ wake states what the store knows and never invents a first belief about you. The
157
+ line stays until an identity element is earned — reinforcement on several
158
+ distinct days, decided at a boundary — and disappears the moment one is. Without
159
+ `--name` there is no core, and no such line.
160
+
161
+ This command writes three things that are **yours**:
162
+
163
+ ```
164
+ ~/.counterparts/
165
+ ├── claude-code.json the adapter's configuration
166
+ ├── credentials.env 0600, holding only comments that name the two keys
167
+ └── store/ the memory itself — the default data dir
168
+ ├── counterparts.sqlite the memories, their prior versions, everything
169
+ └── cache/ rebuildable index; losing it costs a re-index
170
+ ```
171
+
172
+ **One file holds your memory.** The bodies, their revision history and every
173
+ structured field are rows in `counterparts.sqlite`, so a backup is a file copy
174
+ and a memory can never disagree with its own bookkeeping. You read your memories
175
+ through the dashboard, `counterparts recall`, or by asking — and
176
+ **`counterparts export --out <dir> --markdown --plaintext` writes everything out
177
+ as one readable tree of Markdown files** (confidential memories are left out,
178
+ and the export says how many; `--include-confidential` takes them too). (SQLite
179
+ keeps two sidecars beside it, `-wal` and `-shm`; they belong to the database and
180
+ are copied with it.)
181
+
182
+ **Your journal is already readable, without exporting anything.** Every chapter
183
+ the counterpart writes is copied to `store/journal/<year>/<date>-<id>.md` as it
184
+ lands — open one in any editor. It is a copy: the database is the original, and
185
+ deleting `journal/` loses nothing (the next chapter writes it again, and the
186
+ background worker refills anything still missing, a few files per run). Because
187
+ it is a copy, **`backup` and the daily snapshot deliberately leave it out** and
188
+ a restored store writes the files again from its rows — which also means a
189
+ memory you removed does not go on living as plain markdown inside fourteen old
190
+ snapshots.
191
+
192
+ Three more directories appear under `store/` the first time they are needed and
193
+ not before: `spans/` (lived experience awaiting encoding, written by the hooks
194
+ and by `counterparts note`), `journal/` (the counterpart's diary, also written
195
+ as Markdown files as each chapter lands) and `sessions/` (the live-session
196
+ registry, §5). A fresh store has none of them, and `counterparts status` lists
197
+ them either way.
198
+
199
+ …and `install` **prints**, without applying, the two things that belong to Claude
200
+ Code: the hooks block and the MCP registration. It never opens
201
+ `~/.claude/settings.json`.
202
+
203
+ Re-running it is safe: an existing config or credentials file is kept and
204
+ reported, never merged and never rewritten. `--force` is the only way past that.
205
+
206
+ Flags: `--budget <bytes>` (§4), `--name <owner>`, `--embedder` (§6),
207
+ `--dir <store>` (below), `--force`.
208
+
209
+ ### Why the store is `~/.counterparts/store` and the config is one level up
210
+
211
+ The store classifies every top-level entry of its data directory and refuses to
212
+ open on one it does not recognise (`src/core/store/paths.ts`, `LAYOUT` +
213
+ `assertLayoutClassified`) — and `claude-code.json` is not one of them. A data dir
214
+ with the config inside is a store that will not open.
215
+
216
+ So the shape is: `~/.counterparts/` holds the configuration and the credentials,
217
+ and the store is `~/.counterparts/store` beneath it. That is also the default data
218
+ dir, so `COUNTERPARTS_DATA_DIR` and `--dir` are conveniences, not requirements.
219
+ `install` writes the resolved `dataDir` into the config anyway — a configuration
220
+ that names its store is clearer than one relying on a default.
221
+
222
+ ### `--dir` moves the STORE, and only the store
223
+
224
+ You can put the memory itself anywhere — another disk, an encrypted volume:
225
+
226
+ ```
227
+ counterparts install --budget 9000 --name "Your Name" --dir /Volumes/vault/counterparts-store
228
+ ```
229
+
230
+ **The configuration does not follow it.** `~/.counterparts/claude-code.json` is the
231
+ path every entry point reads when nothing names another one, so a config written
232
+ somewhere else with nothing pointing at it is an ambient half that never fires,
233
+ and no hook will tell you: a hook that stands down says so on stderr and exits 0
234
+ (§5 has the one exception). The hook falls back to `COUNTERPARTS_DATA_DIR` only
235
+ when the config it read names no `dataDir` at all, and `install` always writes
236
+ one — so a hand-written config with no `dataDir` is the one shape that can still
237
+ land on the default store.
238
+
239
+ `install` keeps the config where the hooks look, points its `dataDir` at wherever
240
+ you sent the store, and says so in its output when you use `--dir`.
241
+
242
+ The one `--dir` it refuses is `~/.counterparts` itself, which would put the config
243
+ inside the data dir. It says so instead of creating a store that will not open.
244
+
245
+ ### `--config` moves the CONFIGURATION — one rule, every entry point
246
+
247
+ ```
248
+ counterparts install --budget 9000 --name "Your Name" --config /opt/counterparts/claude-code.json
249
+ ```
250
+
251
+ **One sentence, and it is the same for all four entry points:** `--config
252
+ <absolute path>` if the command line carries one, else `COUNTERPARTS_CONFIG` if
253
+ the environment does, else the default — `~/.counterparts/claude-code.json` for
254
+ `counterparts-hook`, its worker and `counterparts-mcp`; for the console, the
255
+ config beside the store (`<dir>/../claude-code.json`) and then that same home
256
+ path (§7).
257
+
258
+ The environment variable is the flag's equivalent, for hosts that launch a
259
+ process from a static registration and have no command line to write into —
260
+ which is exactly how Claude Code launches an MCP server (§4).
261
+
262
+ A path you named and this cannot use is **refused**, at every entry point that
263
+ reads a configuration, and nothing falls back to the default: naming a
264
+ configuration is how you say which memory you mean, and quietly using another one
265
+ is how a scratch run writes into a live store. Three shapes refuse — a relative
266
+ path, an absolute path to a file that is not there, and a file that is not a JSON
267
+ object. **The mistyped path is the one that matters**: before 2026-09-05 it was
268
+ honoured silently, read as "no configuration", and the store then fell back to
269
+ the default one. An absent *default* is still ordinary, because a fresh machine
270
+ has none and the hook must still start.
271
+
272
+ The hook refuses by standing down — one line on stderr, exit 0, nothing injected
273
+ — because a hook never fails the host. The MCP server refuses by not starting
274
+ (exit 1). `counterparts install` is the exception to all of this: `--config`
275
+ names the file it is about to *write*, so a path that does not exist yet is the
276
+ ordinary case there.
277
+
278
+ `--config` on `install` moves the whole base: the configuration goes where you
279
+ said, `credentials.env` goes beside it, and the store defaults to `store/`
280
+ beneath it (`--dir` still overrides the store). Everything is then printed with
281
+ the flag filled in, so the hooks block and the `claude mcp add` line point at the
282
+ configuration you chose. Without it, nothing is printed with a flag — the default
283
+ path is the rule, and a hooks block that spells it out is one that breaks the day
284
+ you move a home directory.
285
+
286
+ **Every entry point says which file it used.** The console prints it (`rebrief`'s
287
+ `budget … from <path>` line, §7); the MCP server and the worker write one line to
288
+ stderr at launch; the hook, which has no channel to you — its stdout is the
289
+ model's context — records it as the `config` field of
290
+ `<dataDir>/sessions/<id>.json`.
291
+
292
+ ### The `injectionBudgetBytes` number
293
+
294
+ `--budget 9000` is the number the live host runs on, measured on Claude Code on
295
+ 2026-09-03: a wake of 8,859 bytes was delivered under it. It is **your host's**
296
+ ceiling, not a Counterparts constant, and this package has no default for one
297
+ anywhere — a briefing refuses to render rather than compose to a number nobody
298
+ chose. Omit `--budget` and the key is left out of the config, the wake is
299
+ injected unbounded, and an `adapter.budget.unreported` event says so.
300
+
301
+ ---
302
+
303
+ ## 4. Wire Claude Code
304
+
305
+ `counterparts install` printed both of these, filled in. They are yours to apply.
306
+
307
+ **The hooks.** Merge into `~/.claude/settings.json` — one script, five events.
308
+ `counterparts install` prints this with your own absolute paths filled in; the
309
+ shape is:
310
+
311
+ ```json
312
+ {
313
+ "hooks": {
314
+ "SessionStart": [{ "hooks": [{ "type": "command",
315
+ "command": "\"/abs/path/to/bun\" run \"/abs/path/to/counterparts/src/adapters/claude-code/bin/hook.ts\"" }] }],
316
+ "UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "<the same string>" }] }],
317
+ "Stop": [{ "hooks": [{ "type": "command", "command": "<the same string>" }] }],
318
+ "SessionEnd": [{ "hooks": [{ "type": "command", "command": "<the same string>" }] }],
319
+ "PreCompact": [{ "hooks": [{ "type": "command", "command": "<the same string>" }] }]
320
+ }
321
+ }
322
+ ```
323
+
324
+ **Both paths are absolute, and that is not cosmetic.** `counterparts-hook` is a
325
+ shim whose first line is `#!/usr/bin/env bun`, so it only runs if bun is on the
326
+ PATH of whatever launched it — and a host's process environment is not your login
327
+ shell's. This package measured exactly that on day 0 of its parallel run: both
328
+ API keys were exported in `~/.zshrc` and neither reached a single hook process.
329
+ A `PATH` without `~/.bun/bin` turns every hook into "command not found", which
330
+ looks from the outside like a memory that simply never happens.
331
+
332
+ If you already have hooks on those events, add this one beside them — hooks on
333
+ one event run in parallel. The hook reads `~/.counterparts/claude-code.json` for
334
+ everything else, so the hooks block passes it no arguments and sets no environment
335
+ variable — **that default is the rule** (§3), and `counterparts install` prints
336
+ the block without a flag unless you moved the configuration with `--config`, in
337
+ which case the same block carries `--config "<your path>"` on every event. (The
338
+ hook still reads its own process environment: the two API keys come from there
339
+ first, §6, and the store falls back to `COUNTERPARTS_DATA_DIR` if the config it
340
+ read names none.)
341
+
342
+ **The MCP server.** Run the line `counterparts install` printed; its shape is:
343
+
344
+ ```
345
+ claude mcp add counterparts -s user -e COUNTERPARTS_DATA_DIR="$HOME/.counterparts/store" -- "/abs/path/to/bun" run "/abs/path/to/counterparts/src/adapters/mcp/bin/serve.ts"
346
+ ```
347
+
348
+ **Keep `COUNTERPARTS_DATA_DIR` in that line, and keep it absolute.** It is how the
349
+ server finds a store that is not at the default; `install` prints it even for the
350
+ default store, because Claude Code launches MCP servers from a static
351
+ configuration with no per-session substitution — the server gets no session id and
352
+ no working directory it can trust, so the one thing it should not also have to
353
+ guess is where the memory is. (Absent it, the server falls back to the same
354
+ default the console uses. That is a fallback, not a plan.)
355
+
356
+ That same static registration is why `COUNTERPARTS_CONFIG` exists: a server
357
+ launched from it has no command line you can put `--config` on, so a non-default
358
+ configuration travels as a second `-e` — `-e COUNTERPARTS_CONFIG="/your/path"` —
359
+ and `counterparts install --config` prints exactly that. The two answer different
360
+ questions: `COUNTERPARTS_DATA_DIR` says which store, `COUNTERPARTS_CONFIG` says
361
+ whose keys and whose embedder knob (§6, §11.3). The server prints the
362
+ configuration it read on stderr at launch, before any protocol.
363
+
364
+ Then **restart Claude Code**. Hooks are read at session start; MCP servers are
365
+ launched at session start.
366
+
367
+ ---
368
+
369
+ ## 5. What the pieces do
370
+
371
+ **The hooks** are the ambient half. `SessionStart` injects the wake — what the
372
+ last boundary published, plus a preface naming the system, the day and the
373
+ store's size. `UserPromptSubmit` recalls against the turn. `Stop`, `SessionEnd`
374
+ and `PreCompact` are boundaries: they capture the conversation into `spans/` and,
375
+ at most once in a while, ask you a question through the model. No hook ever fails
376
+ your session — that is the one failure mode this adapter does not have. Every hook
377
+ exits 0, with one deliberate exception: a Stop that has a question to ask exits 2
378
+ and writes the ask to stderr, because on this host that is the channel the model
379
+ actually reads (`hook.ts#hostDelivery`, measured; §10). That 2 is the feedback channel,
380
+ not a failure.
381
+
382
+ **The MCP server** is the deliberate half: `note` (remember this), `recall` (ask
383
+ memory a question), `status`, `session_end` (write the session's memories),
384
+ `chapter` (write the episode). A chapter of the journal can come back from `recall`
385
+ — it is a first-person account and may rightly come to mind — and every result that
386
+ is one says so: `journal: true` on the tool's row, `[journal]` in the console, and
387
+ `Journal:` in front of the line the hook injects. An account is not a memory.
388
+
389
+ **`sessions/`** is how those two halves find each other. The hooks know the
390
+ session id — the host hands it to every hook — and the MCP server does not. So
391
+ the hooks leave a small record at `<dataDir>/sessions/<id>.json` (an id, a scope,
392
+ three timestamps, no content) and the server binds to a live one lazily. Deleting
393
+ the directory costs a lazy bind and nothing else; it is deliberately not backed
394
+ up.
395
+
396
+ **After an upgrade, restart your sessions.** An MCP server keeps the code it was
397
+ launched with for the life of the session. A session open across an upgrade goes
398
+ on serving the old server until it restarts.
399
+
400
+ ---
401
+
402
+ ## 6. Keys, and what happens without them
403
+
404
+ `~/.counterparts/credentials.env` is the one file Counterparts reads keys from,
405
+ and only because `claude-code.json`'s `credentialsFile` names it. It exists
406
+ because a hook's process environment is not your login shell's: on the live host,
407
+ both keys were exported in `~/.zshrc` and neither reached a single hook process.
408
+ A value already present in the environment always wins; the file only fills gaps.
409
+
410
+ Format is `KEY=value` per line (`export KEY=value`, quotes and CRLF tolerated,
411
+ `#` comments skipped). Exactly two names are honored; anything else is ignored
412
+ and counted. Keep it 0600 — a group- or world-readable file is warned about on
413
+ stderr, never refused.
414
+
415
+ | key | what it buys | without it |
416
+ |---|---|---|
417
+ | `ANTHROPIC_API_KEY` | the crash-recovery sweep's one model call | the worker still runs the day — the clock, the flush, the semantic cue, the embedding backfill, the sleep cycle and the briefing — and SKIPS the sweep, writing `sweep.gate` with `reason: "no-credential"` so the skip is on the record. A crashed session's captured spans stay uninterpreted. Nothing else changes — this is *not* the ordinary write path. |
418
+ | `VOYAGE_API_KEY` | embeddings | recall runs on the lexical channel alone (see below) |
419
+
420
+ **No embed key is a supported mode, and the code says so, by name.** An embedding
421
+ is an input the caller supplies, and "its absence degrades to lexical-only rather
422
+ than failing" — the same sentence, verbatim, in `src/core/recall/cues.ts:26` and
423
+ `src/core/recall/index.ts:27`. The encoder's preselect records
424
+ `channelRecord("skipped", "no-chunk-vector")` rather than dropping silently
425
+ (`src/core/encode/preselect.ts:126`); novelty comes back
426
+ `{ novelty: null, reason: "no-chunk-vector", blind: true }`
427
+ (`src/core/encode/salience.ts:60`). You get recall — cue-based and temporal — and a
428
+ countable record of what you are not getting.
429
+
430
+ It also says so on the wire. Every `recall` answer carries a `semantic` field
431
+ naming how the semantic channel got its input on that ask — this is a real result
432
+ from the install loop, on a store with no key and no embedder:
433
+
434
+ ```json
435
+ { "path": "question", "reason": "answered", "semantic": "embedder-off",
436
+ "considered": 2, "consideredCap": 24, "storeSize": 4, "returned": 2, ... }
437
+ ```
438
+
439
+ The values, and exactly what each one means
440
+ (`src/adapters/mcp/server.ts#embedQuestion`, `deliberate.ts#answerQuestion`):
441
+
442
+ | `semantic` | meaning |
443
+ |---|---|
444
+ | `embedder-off` | **no embedder was built**, because `embedder.enabled` is not `true` (or the server stood down as an observer). This is the no-key mode *with the knob off* — the state you are in after a plain `counterparts install`, and the state the console is always in. |
445
+ | `embed-failed` | an embedder was built and the call did not return a vector. **This is what a knob turned on with no `VOYAGE_API_KEY` looks like** — the client exists, the call raises `NO_API_KEY`, and lexical answers. Also a network failure or an empty vector. |
446
+ | `in-line` | the question WAS embedded and the semantic channel ran. Key present, knob on. |
447
+ | `none` | the `handle` and `ids` paths — an exact address does no scoring at all. |
448
+
449
+ If you have no key and see `in-line`, something is supplying one: the MCP server
450
+ reads `~/.counterparts/claude-code.json` for the embedder knob and the credentials
451
+ file it names, whatever `--dir` or `COUNTERPARTS_DATA_DIR` say about the store.
452
+ That is a real trap — the cold-stranger review of 2026-09-04 hit it, running a
453
+ scratch store against an existing config — and it is worth knowing that the store
454
+ you point at and the credentials you use are chosen by two different files. The
455
+ lever, since 2026-09-05, is `--config` / `COUNTERPARTS_CONFIG` (§3): point the
456
+ second file somewhere too, and the server names the file it read on stderr at
457
+ launch.
458
+
459
+ **The embed key alone is not enough.** Embedding means sending memory text to a
460
+ third party, so it is a decision, not a capability a stray environment variable
461
+ switches on. Add `"embedder": { "enabled": true }` to `claude-code.json`, or pass
462
+ `--embedder` to `counterparts install`. Absent, no client is built and no socket
463
+ opens whatever keys are lying around.
464
+
465
+ ---
466
+
467
+ ## 7. Check it
468
+
469
+ `$HOME/.counterparts/store` is the default data dir, so the commands below work
470
+ with nothing set. If your store is somewhere else — or you would rather be
471
+ explicit than rely on a default — say so once for this shell:
472
+
473
+ ```
474
+ export COUNTERPARTS_DATA_DIR="$HOME/.counterparts/store"
475
+ ```
476
+
477
+ Every command in this section takes `--dir <store>` instead if you prefer; the
478
+ console and the dashboard read one or the other. The console reads
479
+ `claude-code.json` for exactly one thing — `rebrief` without `--budget` takes
480
+ `injectionBudgetBytes` from the config named by `--config` /
481
+ `COUNTERPARTS_CONFIG` if one was named, else from `<store>/../claude-code.json`,
482
+ else from `~/.counterparts/claude-code.json`, and prints which — and never for the
483
+ store, the keys or the embedder.
484
+
485
+ The default can also be **turned off**. In a shell that must never reach
486
+ `~/.counterparts` by accident — a scratch store beside a real install, a CI job,
487
+ an agent's terminal — export `COUNTERPARTS_REQUIRE_EXPLICIT_DIR=1`. Then any
488
+ command, hook, server or library call that names no store (no `--dir`, no
489
+ `COUNTERPARTS_DATA_DIR`) refuses before it opens anything, naming the guard, the
490
+ directory it would have opened, and the two ways to name one; the same variable
491
+ makes the hook, the worker, the MCP server and `install` refuse an unnamed
492
+ configuration, because `~/.counterparts/claude-code.json` names a store too. It
493
+ arms on `1`, `true` or `on`, and stands down on `0`, `false` or `off` — case and
494
+ surrounding whitespace ignored, blank the same as absent — so `=0` turns it off
495
+ rather than tripping it. **Any other value is refused, not read as off**: `=yes`
496
+ gets a sentence naming the value, the three words that arm it and the three that
497
+ turn it off, because a safety guard that cannot read its own switch fails closed.
498
+ Unset — which is every installed host — nothing changes. It is a guard for shells, not
499
+ a setting: the store it protects is the one you would have reached without it.
500
+
501
+ One refusal near that door needs no variable at all, because it answers a real
502
+ accident rather than a shape: **`install` will not write the default
503
+ `~/.counterparts/claude-code.json` with a `dataDir` under the system temp
504
+ directory.** That file is what the hook, the worker and the MCP server read when
505
+ nothing names another, so a throwaway store written into it becomes the machine's
506
+ live memory until the OS deletes it — which is how three days went unrecorded on
507
+ this project's own machine on 2026-09-04. Point a scratch install somewhere of its own instead: `--config
508
+ <absolute path outside ~/.counterparts>` moves the configuration, the credentials
509
+ and the store together. A clean room whose whole `$HOME` is temporary (the install
510
+ loop's, the test suite's) is not this case and is not refused.
511
+
512
+ ### Store some memories and ask for one back
513
+
514
+ This is the product. Three commands, no host, no keys:
515
+
516
+ ```
517
+ counterparts note "The espresso machine in the kitchen is a Rancilio Silvia."
518
+ counterparts note "Postgres in dev listens on port 5433, not 5432."
519
+ counterparts recall "which port does postgres use in dev?"
520
+ ```
521
+
522
+ `note` prints the store it wrote to, then `Remembered mem_… — minted.` `recall`
523
+ prints the same `Store:` line first, then a header line, the memories it found,
524
+ and what the tier on each one means:
525
+
526
+ ```
527
+ Store: /Users/<you>/.counterparts/store
528
+ question · answered · semantic embedder-off · considered 1 of 3 live rows · returned 1
529
+
530
+ mem_30fbdaa753c5 [quiet] fact
531
+ Postgres in dev listens on port 5433, not 5432.
532
+
533
+ quiet = quietly available; the ambient path would have footnoted it, not said it
534
+ Nothing here came back vividly, so treat these as leads rather than answers.
535
+ ```
536
+
537
+ (A real capture, on a store made the way §3 says — `--name`, either door — and
538
+ then those two notes. **Three** live rows for two memories: the identity core
539
+ `--name` seeded is the third, because `live rows` counts every unarchived row and
540
+ not only the memories. That is why this number and the wake preface's
541
+ `N memories` are two different numbers about one store, and `counterparts status`
542
+ prints the split. One question, one answer out of two candidate memories: that is
543
+ recall discriminating, not a store too small to have a choice.)
544
+
545
+ These are the same two doors the MCP tools use — `note` captures the words into
546
+ the span buffer and then deposits a draft that claims that span by hash; `recall`
547
+ calls the same deliberate-recall dispatcher — so what you see here is what Claude
548
+ Code will see. `--kind`, `--title` and `--salience` shape a note; `--id <mem_…>`
549
+ asks for one memory in full instead of asking a question; `--json` prints the
550
+ tool's own payload.
551
+
552
+ **Read the tier, not the word `answered`.** `answered` means the question reached
553
+ something; it is not a claim that the something is right. The tiers are the only
554
+ confidence signal in the output, and the line under the results says what the
555
+ ones you got mean. Asked something this store genuinely does not know — *"what
556
+ colour is the sky on Mars?"* — the same store returns the espresso machine at
557
+ `[quiet]`, with the same "treat these as leads" line (captured, same run). A cue-based
558
+ channel with no embedder answers with the nearest thing it has; a `[quiet]` or
559
+ `[dim]` result is the system saying *this is what I would have murmured*, not
560
+ *this is your answer*.
561
+
562
+ It also works on the very first memory: a store holding one memory answers the
563
+ question about it. On the store §3 makes that reads `considered 1 of 2 live rows`
564
+ — the memory, and the identity core beside it; on a store made by a bare `init`,
565
+ with no `--name` and so no core, `1 of 1`. The install loop checks the bare case
566
+ on every run, because it is the first thing anyone does and it is invisible to
567
+ any test that seeds two rows.
568
+
569
+ ### Look at the store
570
+
571
+ ```
572
+ counterparts status --dir "$HOME/.counterparts/store"
573
+ ```
574
+
575
+ A census of what is held, what left, and what was removed. Read-only, and it
576
+ opens the store in observer stance so looking at your memory cannot change it.
577
+
578
+ The first line names four populations because they are four different things,
579
+ and adding them together is how one store came to report three different sizes:
580
+ **`Memories:`** is what the AI learned, and it is the number the wake preface
581
+ states back to the model at every session start; **`Beliefs and entities:`** is
582
+ what it believes about people and things, which decay and are revised under their
583
+ own rules; **`Journal:`** is episodes, the source a memory was made from, which
584
+ never decay; **`Archived:`** and **`Superseded:`** are what has left. The `by
585
+ kind` and `by band` lines below are over memories and beliefs together, and the
586
+ band is computed from each row's physics today rather than read from the column
587
+ it was born with — which is why it matches the dashboard's.
588
+
589
+ Under them, two lines of the day's own facts: how many memories were born today,
590
+ what lived day the store is on, when it was last active, when the last boundary
591
+ was, whether a self page has been written, how old the newest snapshot is, and
592
+ which journal mode the database is in. `counterparts doctor` grades all of that;
593
+ this command only counts it.
594
+
595
+ `--layout` adds a block naming the directories the store keeps and which of them
596
+ a backup carries. It is written for whoever maintains a store rather than for
597
+ whoever owns one, which is why it is behind a flag.
598
+
599
+ ```
600
+ counterparts-dashboard status --dir "$HOME/.counterparts/store"
601
+ ```
602
+
603
+ The same store, rendered. `browse`, `stories` and the other views take `--id`,
604
+ `--limit`, `--band`, `--kind`.
605
+
606
+ Pointed with `--dir` at a directory with no store in it, both consoles say `No
607
+ store at <dir>. Run 'counterparts init --dir <dir>' to create one.` and exit 1 — a
608
+ census of nothing at all is not a success, and a script wrapping `counterparts
609
+ status` should hear about a mistyped `--dir` rather than sail past it. Neither
610
+ one creates the store by looking for it.
611
+
612
+ Every command has its own help: `counterparts <command> --help` prints what
613
+ that command does and every flag it takes, and opens nothing.
614
+
615
+ ### Remove a memory, and read what removal does not reach
616
+
617
+ ```
618
+ counterparts remove mem_b77c9e0e9808 --dir "$HOME/.counterparts/store"
619
+ ```
620
+
621
+ **A dry run by default.** It prints the plan — every surface it would chase, with
622
+ counts; the ids (never the text) of other memories whose words overlap; and one
623
+ line for the raw capture buffer — then says `Dry run. Nothing has changed.`
624
+ Add `--confirm` to do it, and the command asks you to type the id back before
625
+ anything moves. There is no `--force`: removal is the one owner operation with a
626
+ human in the loop.
627
+
628
+ Read the `spans` line before you confirm. On a memory that was taken as a note it
629
+ says this — one line in the terminal, wrapped here:
630
+
631
+ ```
632
+ chase spans: 1
633
+ chased — spans/be4b7f492c17/jots.jsonl — the raw capture buffer holds this
634
+ memory's words (matched by the span hash its mint recorded);
635
+ the removal strikes them out of it.
636
+ ```
637
+
638
+ The parenthesis is not decoration. There are two ways this command can find your
639
+ words, and they are not equally strong: `matched by the span hash its mint
640
+ recorded` is identity, and `matched by content` is a jot whose whole text is this
641
+ memory's body. Read which one you are about to run before you confirm.
642
+
643
+ That directory name is a 12-hex key derived from the project the note was taken
644
+ in, not the project's path; the command prints your real one.
645
+
646
+ A note is captured verbatim into the span buffer before it is minted, and until
647
+ 2026-09-05 `remove` reached the database, the links and the cache but
648
+ not that file — so a removed note's words survived there, and a backup taken
649
+ afterwards copied them. They do not now: the buffer is a chased surface like
650
+ every other. The line the doomed span rode on is rewritten out of every file that
651
+ held it (the live streams, any claim a worker is mid-arc on, the quarantine), its
652
+ hash is kept in the buffer's own `consumed.jsonl` so nothing re-captures the same
653
+ words, and the id goes dark on the deny-list so nothing can quietly resurrect the
654
+ memory. Take a backup afterwards and grep it: the note's own capture is gone.
655
+
656
+ **What it deliberately does not take, and says so.** If you asked for the note in
657
+ conversation, the turn you said it in is also in the buffer — a conversation span
658
+ is many turns joined together, it belongs to no single memory, and striking it
659
+ because one memory quotes it would destroy material you never named. So it is
660
+ left, on its own line, which is neither `chased` nor `unchased`:
661
+
662
+ ```
663
+ LEFT on purpose — spans echo: 1 line of conversation quoting these words —
664
+ transcript, not this memory's capture. Left on purpose. Nothing prunes the
665
+ buffer today, so it stays there.
666
+ ```
667
+
668
+ Read that last clause literally. **Nothing prunes `buffer.jsonl` for a session
669
+ that ended normally** — the crash-fallback sweep only claims sessions that went
670
+ silent without a session-end boundary — so a conversation turn quoting a removed
671
+ memory stays on disk indefinitely, and a `grep` of the whole store will keep
672
+ answering. The memory is gone; the transcript of having said it is not, and
673
+ nothing today will take it. (Filed as `src/core/remember/INTERFACE-GAPS.md` §10.)
674
+
675
+ **The one chase this command refuses to make on its own.** A memory whose
676
+ provenance recorded no scope — every row the owner's one-off v1 import wrote
677
+ looked like this — can only be found in the buffer by matching its text, and
678
+ matching text with no scope means visiting every project on the machine. So it
679
+ does not. It tells you what it would have matched, by file and count, and stops:
680
+
681
+ ```
682
+ NOT chased — spans/ — this memory's provenance records no scope and no span
683
+ hash, so a chase by content would have to visit EVERY project on this machine.
684
+ NOT done: 1 jot line whose whole text is this memory's body would have
685
+ matched, in spans/8c1e4a90b21f/jots.jsonl (1). Look, then re-run with
686
+ --strike-by-content-across-scopes if they are yours to remove …
687
+ ```
688
+
689
+ Look at the file it names before you pass that flag. Even with it, only a jot
690
+ whose **whole text** is the memory's body is taken — a longer note that merely
691
+ mentions the same words is somebody else's memory and is never touched.
692
+
693
+ On a memory that never rode the buffer the same `spans` line reads `spans: not
694
+ applicable`, which is stated rather than omitted — a surface that goes silent
695
+ when it is empty is how the residue stayed invisible in the first place. One
696
+ state is still `NOT chased`, and it is the honest one: a memory whose words are
697
+ already gone from its row AND whose mint never recorded a span hash cannot be
698
+ addressed in the buffer at all. The command says which way it is blind, and counts itself
699
+ `unchased: 1`.
700
+
701
+ ### Prove the hook works without opening Claude Code
702
+
703
+ ```
704
+ echo '{"hook_event_name":"SessionStart","session_id":"smoke","cwd":"'"$PWD"'"}' | counterparts-hook
705
+ ```
706
+
707
+ On a store that has never lived a boundary this prints the honest bootstrap line
708
+ — *"No briefing has been composed yet — this store has not lived a boundary."* —
709
+ and exits 0. That is the wake path working, with nothing yet to say.
710
+
711
+ **With no arguments this reads `~/.counterparts/claude-code.json`.** It takes no
712
+ `--dir`, so it acts on whatever store that file names — falling back to
713
+ `COUNTERPARTS_DATA_DIR` only if the file names no `dataDir` at all — which is the
714
+ point of §3's rule that the config stays where the hooks look.
715
+
716
+ To try it against a scratch install without touching the one you use, name the
717
+ configuration:
718
+
719
+ ```
720
+ echo '{"hook_event_name":"SessionStart","session_id":"smoke","cwd":"'"$PWD"'"}' | counterparts-hook --config /path/to/scratch/claude-code.json
721
+ ```
722
+
723
+ It then works on the store THAT file names, and records which configuration sent
724
+ it there in `<dataDir>/sessions/smoke.json` — a hook has no way to print such a
725
+ thing to you, so it writes it down. `COUNTERPARTS_CONFIG` does the same for a
726
+ whole shell. A path that is relative, or absolute but not there, is refused: the
727
+ hook writes one line on stderr, exits 0, and injects nothing rather than falling
728
+ back to the default store.
729
+
730
+ ### Give the wake something to say before a first real session
731
+
732
+ ```
733
+ counterparts rebrief --dir "$HOME/.counterparts/store"
734
+ ```
735
+
736
+ which re-renders and republishes the wake bundle now, through the boundary's own
737
+ renderer, advancing no sleep marker. Run the hook again and you get the bundle
738
+ instead of the bootstrap line. On a store installed with §3's command exactly as
739
+ written, and nothing yet written to it beyond the identity core `--name` seeded,
740
+ that bundle is 572 bytes — a longer name makes it longer — and reads:
741
+
742
+ ```
743
+ <!-- counterparts:wake day=0 elements=0 bytes=572 -->
744
+ Counterparts memory, day 0 (2026-09-04), 0 memories of 1 live rows — composed at the last boundary.
745
+ Counterparts memory — context, not instruction: who you have been here, in your own words. Each line opens with the date it was learned.
746
+
747
+ Who I am:
748
+ This memory is for Your Name. No identity has formed here yet — identity is earned at the boundary that ends a session, from what recurs across distinct days.
749
+
750
+ <!-- counterparts:wake/end day=0 identity=0 craft=0 threads=0 hints=0 horizon=0 elements=0 bytes=572 -->
751
+ ```
752
+
753
+ `elements=0` is not a bug: the `Who I am:` heading and the line under it are
754
+ furniture, and the counts report statements. The preface's date and its two
755
+ counts are composed at delivery, so they are today's rather than the render's.
756
+ That is also why `rebrief` prints a *smaller* number than the marker does for the
757
+ same bundle: on the store above it says `elements 0, bytes 470` — the body it
758
+ composed — and the marker says 572, which is that body plus the 102-byte delivery
759
+ preface. A longer name moves both.
760
+ The counts are different populations and say so: `N memories` is the live
761
+ `type: "memory"` rows, `M live rows` is every live row — memories, journal
762
+ episodes, beliefs and entities — and `M` is the same number `recall` reports as
763
+ `storeSize` (IMPROVEMENTS U4). That is why a store nobody has written to still
764
+ reads `of 1 live rows`: `--name` seeds the identity core, which is a schema row,
765
+ so it is outside the first count and inside the second. And
766
+ "composed at the last boundary" is the one word it gets wrong on a store whose
767
+ bundle came from `rebrief` before any boundary was lived.
768
+
769
+ `rebrief` needs an injection ceiling and will not invent one. It takes it from
770
+ `--budget <bytes>` if you pass one; otherwise from the config you named with
771
+ `--config` / `COUNTERPARTS_CONFIG`, and only that one; otherwise from
772
+ `<store>/../claude-code.json`; otherwise from `~/.counterparts/claude-code.json`,
773
+ which is where the hooks read. **It always prints which**, as `budget 9000 bytes
774
+ from <path>` (with `(named by --config)` when you named it) — a ceiling taken out
775
+ of a file you did not name should never be silent — and if nothing answers, it
776
+ refuses and lists every path it tried.
777
+
778
+ To recap the two questions and their two answers. **Which store**: the console and
779
+ the dashboard take `--dir` or `COUNTERPARTS_DATA_DIR` — with one exception, the
780
+ console's bulk repairs (`migrate-cache --apply`, `repair-dates --apply`,
781
+ `backfill-claims --apply`, `repair-merged-beliefs --apply`, and `verify` with
782
+ `--rebuild`, `--prune-index`, `--retry-skipped` or `--drop-vectors`), which rewrite a whole store at
783
+ once and take `--dir` alone, refusing a store named only by the variable; the MCP server takes
784
+ `--dir` or `COUNTERPARTS_DATA_DIR`; the hook and its worker take neither and use
785
+ the `dataDir` in the configuration they read, falling back to
786
+ `COUNTERPARTS_DATA_DIR` only if it names no store. **Which configuration**: one
787
+ rule for all four — `--config <absolute path>`, else `COUNTERPARTS_CONFIG`, else
788
+ the default (`~/.counterparts/claude-code.json`; for the console,
789
+ `<dir>/../claude-code.json` first). The console reads that file only for
790
+ `rebrief`'s ceiling; the store, the keys and the embedder knob in it are the
791
+ hooks' and the MCP server's.
792
+
793
+ ---
794
+
795
+ ## 8. Which directories it remembers
796
+
797
+ The hooks are registered once, globally, so a session in ANY directory is
798
+ remembered by default. `counterparts scope` is where you say otherwise, one
799
+ directory at a time. It writes the host's own registry — `scopes.json`, beside
800
+ `claude-code.json`, so `--config` moves the two together — and it opens no
801
+ store: it takes no `--dir` and works on a machine that has none yet.
802
+
803
+ From inside the directory you mean:
804
+
805
+ ```
806
+ counterparts scope . --off
807
+ ```
808
+
809
+ and nothing there is recorded or read again: the hooks produce no output and
810
+ write nothing at all, and every MCP tool refuses by name (`scope-off`). The
811
+ other three modes:
812
+
813
+ - `--on` — the default: capture, deposit, wake and recall, as everywhere else.
814
+ - `--observer` — reads only. The wake and recall are delivered; nothing is
815
+ captured or deposited, and `note`, `session_end` and `chapter` stand down.
816
+ This is the same stance §6's observer configuration produces, said in one word.
817
+ - `--pause` — off for now, remembering what to go back to.
818
+
819
+ `--resume` undoes a pause, and turns an `--off` directory back on:
820
+
821
+ ```
822
+ counterparts scope . --resume
823
+ ```
824
+
825
+ To see what one directory resolves to and which entry decided it — a
826
+ subdirectory inherits its nearest ancestor, so turning a project off turns off
827
+ every worktree under it:
828
+
829
+ ```
830
+ counterparts scope .
831
+ ```
832
+
833
+ and for the whole registry, with the file it came from:
834
+
835
+ ```
836
+ counterparts scope --list
837
+ ```
838
+
839
+ Two more things worth knowing. **Nothing set means on**: a directory nobody has
840
+ answered for behaves exactly as it did before any of this existed — which is why
841
+ the first session in an unset directory asks you, once, which of the three you
842
+ want, and records your answer with the command above. And `--note "<text>"`
843
+ keeps the reason beside the entry, for the version of you that reads the list in
844
+ six months.
845
+
846
+ ---
847
+
848
+ ## 9. Upgrading
849
+
850
+ ```
851
+ bun add -g counterparts@latest
852
+ ```
853
+
854
+ (From source: `git pull && npm pack` in the clone, then the tarball line from §2.)
855
+
856
+ Then restart every open Claude Code session (§5). Your store is untouched:
857
+ `counterparts install` never rewrites an existing config or credentials file.
858
+
859
+ ---
860
+
861
+ ## 9a. Starting over
862
+
863
+ You may want a blank memory — to see what a new user sees, or because the first
864
+ few days of a store are mostly you learning what it does. One command:
865
+
866
+ ```
867
+ counterparts start-fresh --config ~/.counterparts/claude-code.json
868
+ ```
869
+
870
+ **Close every Claude Code session and every dashboard first.** A running session's
871
+ hooks and its MCP server hold the store open by a file handle, and a handle does
872
+ not follow a rename — until they restart, they go on writing into the directory
873
+ that was just parked. **Nothing in the command can check this for you**: a session
874
+ sitting idle writes nothing, so it leaves no record and no timestamp. What you can
875
+ do, in another terminal:
876
+
877
+ ```
878
+ pgrep -fl counterparts
879
+ ```
880
+
881
+ Look for lines running one of **ours**: `serve.ts` (an MCP server), `dashboard.ts`,
882
+ `hook.ts`, `runner.ts` (the worker). Each of those is holding the store open.
883
+ **Ignore anything that merely has the word in a path** — `pgrep -f` matches the
884
+ whole command line, so an editor, a `tail`, a dev server in a directory with this
885
+ name in it will all show up and none of them matters. This command will be in the
886
+ list too, while it waits for you.
887
+
888
+ A dashboard and an MCP server leave **no live-session record at all**, so the
889
+ command cannot see them however hard it looks. That is why it asks you to type the
890
+ name, and why `--yes` on a store with anything in it is refused unless you also
891
+ pass `--nothing-is-open` — which is you saying the sentence `--yes` does not.
892
+
893
+ **Run it from a plain terminal, not from inside Claude Code.** Your own session's
894
+ record is one the check refuses on, so it will turn you away — correctly — and you
895
+ will have closed the session anyway by the time you can answer.
896
+
897
+ The command asks you to type the parked directory's name back before it does
898
+ anything.
899
+
900
+ What it does, in order:
901
+
902
+ 1. Renames `~/.counterparts/snapshots` to `snapshots.parked-<today>`, and then
903
+ `~/.counterparts/store` to `store.parked-<today>` (with a shared `-2` if you
904
+ have done this already today — both directories always wear the same suffix). **One atomic rename each. It never copies, never
905
+ deletes, and never opens the old store — not even read-only.**
906
+ 2. Creates a blank store back at `~/.counterparts/store`, by running `install`.
907
+ It builds it **beside** your memory first and moves it into place with one
908
+ rename, so there is never a stretch where the configuration points at nothing
909
+ and a stray hook could mint a store there.
910
+ 3. Leaves `claude-code.json`, `credentials.env` and `scopes.json` exactly as they
911
+ were, byte for byte. Your keys, your ceiling and your per-directory settings are
912
+ host wiring, not memory — and leaving `scopes.json` alone is the point: a
913
+ directory you turned **off** stays off on the new store, rather than quietly
914
+ starting to record again.
915
+
916
+ The date in the parked name is **UTC**, like every other date this system writes,
917
+ so an evening run west of Greenwich parks under tomorrow's date. It is a label,
918
+ not a claim about your clock.
919
+
920
+ Then **restart Claude Code**. There is almost certainly nothing to re-register: if
921
+ you registered the MCP server the way `install` prints it
922
+ (`-e COUNTERPARTS_DATA_DIR=<your store>`), that path has not moved and the blank
923
+ store is sitting at it. The command cannot read your host's files to check — it
924
+ never touches them — so if you want to be sure, `claude mcp get counterparts` says
925
+ what it was actually registered with.
926
+
927
+ **`--dry-run` prints every rename and every file it would write and changes
928
+ nothing.** Run that first if you want to see it.
929
+
930
+ **Going back is one command:**
931
+
932
+ ```
933
+ counterparts start-fresh --undo
934
+ ```
935
+
936
+ It parks the blank store, puts your memory back, puts the snapshots back — one
937
+ rename each, nothing deleted, nothing opened, and it refuses rather than moving
938
+ one directory inside another. It runs **exactly the same refusals as the forward
939
+ direction** — the same forbidden roots, the same symlink and absolute-path rules,
940
+ the same live-session check, the same `--yes` rule — and it will not act on a
941
+ recorded path that is not a parked directory of this store, because that record
942
+ is a row in a database. Restart Claude Code again afterwards.
943
+
944
+ There is **no undo of an undo**: the store it displaces is parked under a
945
+ `blank-<date>` name, which nothing reads as a parked store. A successful undo
946
+ prints the two guarded lines that bring that one back.
947
+
948
+ The same three moves are also **printed as shell lines**, before anything moves
949
+ and again afterwards, so the way back is on your screen even if this is
950
+ interrupted. Each printed line is guarded:
951
+
952
+ ```
953
+ if [ -e "<destination>" ]; then echo "REFUSING: … already exists" >&2; false; else mv "<source>" "<destination>"; fi
954
+ ```
955
+
956
+ That guard is not decoration. A bare `mv a b` where `b` is an existing directory
957
+ does not refuse and does not overwrite — it moves `a` **inside** `b`, and reports
958
+ success. The refusal exits non-zero, so a pasted block stops rather than carrying
959
+ on past it. The blank store is *parked* by the first line, not removed: nothing in
960
+ this command deletes anything, including an undo.
961
+
962
+ Two more things it will not do:
963
+
964
+ - It refuses `--dir`. The store it parks is the one your **configuration** names,
965
+ because that is the one your hooks and your MCP server open; a second answer on
966
+ the command line is how the wrong store would get moved. Use `--config` to name
967
+ a different configuration.
968
+ - It refuses by name to touch anything under `~/.bansai` or `~/.claude-engram`.
969
+ - It parks the snapshots folder only when that folder is the one this layout owns
970
+ (`~/.counterparts/snapshots`). A `snapshots.dir` or `snapshots.mirror` you pointed
971
+ somewhere of your own is **left alone** — it is your directory — and the command
972
+ says so. The new store's rotation then shares that folder with whatever is already
973
+ in it: copies of a store on the old floor are recognised there and never deleted
974
+ or counted, but copies this floor wrote do count toward `keep`, so the new store's
975
+ oldest copy could rotate out sooner than you expect.
976
+
977
+ **On cut-over day, deploy first.** If you are moving from an older build, update
978
+ the checkout *before* you run this, not after: the older build does not have this
979
+ command at all, and in the gap between a fresh start and a deploy any session that
980
+ starts would run the old build against the new store and write half a memory into
981
+ each of them. The new build's hooks stand down cleanly and harmlessly against an
982
+ old store, so deploy-first costs nothing. Close everything, back up with the old
983
+ build (the new one cannot open an old store), deploy, then run this.
984
+
985
+ If the store being parked was written **before this build's floor** — that same
986
+ case — the command says so, names the files it recognised, and carries on. It has nothing to open, so the
987
+ floor is not its problem: a rename does not care what is inside a directory. That
988
+ is also why the store you park stays readable by the build that wrote it
989
+ (`floor/v5-last`), exactly as it was.
990
+
991
+ `counterparts status` on the new store will say what day it began on and where the
992
+ previous one is parked.
993
+
994
+ ---
995
+
996
+ ## 10. What is actually verified, and what is not
997
+
998
+ The install loop (`tools/install-loop/run.sh`) runs in a throwaway HOME with no
999
+ repo on its PATH and checks, every time:
1000
+
1001
+ - `npm pack` produces a tarball, and it carries every relative file this page and
1002
+ the README link to — no dead links inside the package;
1003
+ - the tarball installs globally under bun and puts four working executables on
1004
+ PATH, and the package's own `exports` map imports;
1005
+ - `counterparts install` produces a store that opens, a config at
1006
+ `~/.counterparts/claude-code.json`, and a 0600 credentials file, and writes no
1007
+ host configuration;
1008
+ - the printed hook command runs on a PATH with **no bun on it** — the one failure
1009
+ a real host is likeliest to hit and the rest of the loop is blind to;
1010
+ - the `SessionStart` hook, fed a real payload on stdin, returns a wake block and
1011
+ exits 0, and registers the session under `<dataDir>/sessions/`;
1012
+ - `counterparts note` then `counterparts recall` round-trips on the console, and
1013
+ a `note` then `recall` round trip through `counterparts-mcp` over stdio
1014
+ JSON-RPC returns the note;
1015
+ - **and the one-memory case** (§7): one note in a fresh store, recalled by
1016
+ question, comes back. It is its own step because a bug at store size one is
1017
+ invisible to every check that seeds two rows — which is how one survived to a
1018
+ stranger's first minute on 2026-09-04;
1019
+ - a `session_end` through a separate `counterparts-mcp` process **binds lazily** to
1020
+ the session the hook registered, and mints the memory — the deliberate write
1021
+ path a real session uses, without a real session;
1022
+ - the **one config rule** (§3) at the two entry points that could not be checked
1023
+ before it existed: `counterparts-hook --config <a second config>` works on the
1024
+ store that file names, records it in the session file, and leaves the default
1025
+ store untouched; `COUNTERPARTS_CONFIG` launches `counterparts-mcp` on a named
1026
+ configuration; and a path that is named but unusable — relative, or absolute and
1027
+ not there — refuses at both, the hook by standing down at exit 0, the server by
1028
+ not starting;
1029
+ - `rebrief` names the file its injection ceiling came from, falls back to the
1030
+ hooks' config for a store that has none beside it, and refuses — listing every
1031
+ path it tried — when nothing supplies one;
1032
+ - `rebrief` renders a bundle and the next `SessionStart` injects it;
1033
+ - the dashboard opens the same store.
1034
+
1035
+ **The loop cannot reach the npm registry.** It installs the tarball it packed,
1036
+ from disk. `bun add -g counterparts` (§2) and `bun add -g counterparts@latest`
1037
+ (§9) deliver that same package by another road, and that road is *unverified by
1038
+ the loop*: only a real machine with a network can settle it.
1039
+
1040
+ **The loop cannot launch Claude Code.** So these are *unverified by it* and only a
1041
+ real session can settle them: that Claude Code reads the hooks block from
1042
+ `settings.json` and runs `counterparts-hook` on all five events; that the wake
1043
+ text actually reaches the model's context; that the Stop ask arrives (it is
1044
+ delivered on stderr with exit 2, the one channel measured to work on this host);
1045
+ and that `claude mcp add` registers a server the client then launches. **All four**
1046
+ are verified on the owner's machine by the parallel run
1047
+ ([`docs/PARALLEL-RUN-STATUS.md`](https://github.com/mlapeter/counterparts/blob/master/docs/PARALLEL-RUN-STATUS.md),
1048
+ in the repository), not by this loop.
1049
+
1050
+ The fifth host behaviour — `session_end` binding to a live session **through the
1051
+ registry**, since the server is never told a session id — the loop now does
1052
+ exercise, end to end: the hook writes `sessions/<id>.json`, a separate
1053
+ `counterparts-mcp` process is given only the data dir and the scope, and its
1054
+ `session_end` binds to that record and mints the memory (loop step 34; the
1055
+ refusals `session-unknown`, `scope-mismatch` and `session-required` are what the
1056
+ step fails on). What is still unverified is the same thing as above: that this
1057
+ happens inside a real Claude Code session, where the id comes from the host
1058
+ rather than from a script.
1059
+
1060
+ ---
1061
+
1062
+ ## 11. Known rough edges
1063
+
1064
+ 1. **Four entry points, two questions — and two deliberate exceptions.** WHICH
1065
+ STORE: `counterparts` and `counterparts-dashboard`'s **views** read `--dir` or
1066
+ `COUNTERPARTS_DATA_DIR`; `counterparts-mcp` reads `--dir` or
1067
+ `COUNTERPARTS_DATA_DIR`; `counterparts-hook` and its worker take neither and
1068
+ use the `dataDir` in the configuration they read, falling back to
1069
+ `COUNTERPARTS_DATA_DIR` only when it names no store. The first exception is
1070
+ the console's BULK REPAIRS — `migrate-cache --apply`, `repair-dates --apply`,
1071
+ `backfill-claims --apply`, `repair-merged-beliefs --apply`, and `verify` with
1072
+ `--rebuild`, `--prune-index`, `--retry-skipped` or `--drop-vectors`. Each rewrites a whole store
1073
+ in one go, so each takes `--dir` and **refuses** a store named only by the
1074
+ variable: an exported path is a shell's memory of where a store lives, not a
1075
+ sentence you typed about this rewrite. `--yes`, where a command has one, skips
1076
+ the typed confirmation and never stands in for `--dir`. The dry runs — every
1077
+ one of these without its writing flag — read the variable as usual. The second
1078
+ is `counterparts-dashboard serve`: it takes `--dir` and **refuses** to take the
1079
+ store from `COUNTERPARTS_DATA_DIR` alone, because §7 tells you to export that
1080
+ variable with the live store's path in it and `serve` puts a whole memory on a
1081
+ socket in a browser — that choice is made in the command or not at all.
1082
+ `--default-store` means the default (and reads the variable) if you want it.
1083
+ WHICH CONFIGURATION: one rule for all four — `--config <absolute path>`, else
1084
+ `COUNTERPARTS_CONFIG`, else the default. The asymmetry that is left is the
1085
+ hook's: it is the one entry point with no `--dir`, so pointing it at another
1086
+ store means pointing it at another configuration (§3, §7). Both defaults can
1087
+ be refused wholesale with `COUNTERPARTS_REQUIRE_EXPLICIT_DIR=1` (§7): with it
1088
+ set, an unnamed store or an unnamed configuration is a refusal, not a fallback
1089
+ — the one exception being `rebrief`'s ceiling, a number read from the default
1090
+ config for a store you already named, which stays readable.
1091
+ 2. **`bun add -g` needs an absolute tarball path — and the same error means "no
1092
+ such file".** On bun 1.3.10 a relative path fails with
1093
+ `error: ENOENT extracting tarball from ./x.tgz`, and so does an absolute path
1094
+ naming a file that does not exist. Check `ls *.tgz`. Hence
1095
+ `"$PWD"/counterparts-*.tgz` in §2.
1096
+ 3. **The store you point at and the host settings you get come from two different
1097
+ files** — and you now have to move both. `--dir` / `COUNTERPARTS_DATA_DIR`
1098
+ choose the store; the configuration supplies host settings — the embedder knob
1099
+ and the credentials file for the MCP server and the hooks, and, as a last
1100
+ resort, the injection ceiling for `counterparts rebrief` (§7). Running a
1101
+ scratch store on a machine that already has a configured install will use that
1102
+ install's keys unless you also pass `--config` / `COUNTERPARTS_CONFIG` (§3),
1103
+ and can compose a briefing under that install's ceiling. §6 says how to tell
1104
+ from the `semantic` field; `rebrief` names the file it read, and the server
1105
+ names it on stderr at launch.
1106
+ 4. **The vector cache stores embeddings as JSON text.** On the owner's migrated
1107
+ store that is 177 MB at 13.9K vectors, with a nearest-neighbour scan of
1108
+ 0.6–1.0 s. Irrelevant to a fresh store; a named debt.
1109
+ 5. **`parallel: { enabled: true }`** appears in the owner's live config. It is the
1110
+ parallel-run knob and makes Counterparts stand down unless another file says
1111
+ it may speak. Do not copy it.
1112
+ 6. **Removal reaches the span buffer — with two things it names rather than
1113
+ takes.** A note is captured verbatim into `spans/<12-hex key>/jots.jsonl`
1114
+ before it is minted. Until 2026-09-05 `remove` chased the database,
1115
+ the links and the cache and not that file, so a removed note's words survived
1116
+ there and a backup taken afterwards copied them. The buffer is chased now
1117
+ (§7). **Check it in three lines** — the marker text is only there so `grep`
1118
+ has something to find:
1119
+
1120
+ ```
1121
+ counterparts note "ZQPROBE the culvert gate key is under the third fence post." --dir "$HOME/.counterparts/store"
1122
+ counterparts remove <the mem_… it printed> --confirm --dir "$HOME/.counterparts/store"
1123
+ grep -rl ZQPROBE "$HOME/.counterparts/store"
1124
+ ```
1125
+
1126
+ Nothing answers. Run the same three lines with the note taken through the MCP
1127
+ tool mid-conversation and one file can still answer — `buffer.jsonl`, holding
1128
+ the turn in which you SAID it. That is transcript, not the memory, and it is
1129
+ left on purpose; `remove` counts it on a `spans echo` line rather than
1130
+ passing over it. The other thing it names: a memory whose words are already
1131
+ gone from its row AND whose mint recorded no span hash — an old row, or one
1132
+ edited in the database by hand — cannot be addressed in the buffer at all, and
1133
+ `remove` says which way it is blind on its `NOT chased` line and counts it
1134
+ `unchased: 1` rather than reporting `nothing`.
1135
+ 7. **The package ships the modules' own `CONTRACT.md`, `NOTES.md` and
1136
+ `INTERFACE-GAPS.md`** — 40 files, 0.45 MB, in a 2.2 MB package (measured
1137
+ 2026-09-04 on `npm pack --dry-run`, 742.2 kB packed over 168 files, plus the
1138
+ tarball's own listing; the TypeScript sources are the bulk of the rest, and
1139
+ the Markdown grows as the modules record what they learned). Deliberate: those files are what
1140
+ `src/` is documented by, and this page points at them. Delete `src/**/*.md`
1141
+ from your install if you would rather not carry them.
1142
+ 8. **A configuration the hooks cannot read is a silent session with no memory.**
1143
+ A named configuration that is missing, unreadable or not JSON is refused (§3),
1144
+ and the refusal happens before anything opens, so a stood-down hook leaves no
1145
+ ring event, no session record, nothing durable — the right choice (it will not
1146
+ write into a store it was not told about) with an unhelpful symptom: nothing
1147
+ happens, and nothing says why. Two lines diagnose it:
1148
+
1149
+ ```
1150
+ echo '{"hook_event_name":"SessionStart","session_id":"smoke","cwd":"'"$PWD"'"}' | counterparts-hook
1151
+ env | grep COUNTERPARTS_CONFIG
1152
+ ```
1153
+
1154
+ The first prints the stand-down reason on stderr; the second finds a stale
1155
+ `COUNTERPARTS_CONFIG` exported into the environment Claude Code was launched
1156
+ from, which is the likeliest cause and the hardest to see.
1157
+
1158
+ ---
1159
+
1160
+ ## 12. If the terminal says something at session start
1161
+
1162
+ Claude Code prints one line of its own when a session starts and Counterparts has
1163
+ found something RED. **On a fresh install there is nothing red, so there is no
1164
+ line** — a store that has never had an API key is a supported way to run (§6),
1165
+ and as of 2026-09-20 `doctor` grades that amber rather than red. The example
1166
+ below is a store that HAD a key and lost it, which is the case the notice was
1167
+ built for:
1168
+
1169
+ ```
1170
+ SessionStart:startup says: counterparts: Credentials — …/credentials.env holds no key:
1171
+ ANTHROPIC_API_KEY is missing, so the worker will run without an interpreter; nothing is
1172
+ encoded. Run: counterparts credentials set ANTHROPIC_API_KEY …
1173
+ run: counterparts doctor
1174
+ ```
1175
+
1176
+ It is not an error and it blocks nothing: the wake still goes out on the same
1177
+ turn, unchanged. **Red only** — the notice fires for the things that mean part of
1178
+ the system is not running, never for the merely imperfect. Nothing red, and the
1179
+ hook prints exactly what it always printed.
1180
+
1181
+ This exists because of a week in September 2026 when it did not. The credentials
1182
+ file had been rewritten to its template by a forced install; every detached
1183
+ worker was refused at every boundary; the lived-day clock froze, no sleep cycle
1184
+ ran, nothing was embedded, and every ask was capped against a day that never
1185
+ rolled over. Every visible surface — the wake, recall, capture, `verify`, the
1186
+ daily record — read healthy the whole time.
1187
+
1188
+ ### `counterparts doctor`
1189
+
1190
+ The same reading, in full, on demand, and read-only. It opens the store in
1191
+ observer stance, writes nothing, and never prints a credential value:
1192
+
1193
+ ```
1194
+ counterparts doctor
1195
+ counterparts doctor --json # the findings as JSON: ids, counts, severities
1196
+ ```
1197
+
1198
+ Worst first, one line of facts and one line naming the fix. Exit code **1** if
1199
+ anything is red, 0 otherwise, so a script can branch on `$?`. What it reads:
1200
+
1201
+ | finding | red when |
1202
+ |---|---|
1203
+ | Config | the file the hooks read is missing or will not parse |
1204
+ | Store | there is no store where the config points |
1205
+ | Embedder | — (amber when `embedder.enabled` is not literally `true`) |
1206
+ | Stance | — (amber under `observer`) |
1207
+ | Credentials | `ANTHROPIC_API_KEY` is absent from the file (amber for the embed key, or a mode that is not 0600) |
1208
+ | Checkout | the checkout the hooks run is not an ancestor of `origin/master`, or has tracked modifications (amber when it is merely behind) |
1209
+ | Clock | — (amber when `lastActiveDate` is older than the newest boundary: sessions are ending and the worker is not running) |
1210
+ | Sweep / Sleep / Backfill / Credit | the newest `sleep.cycle` did not run, or the backfill embedded nothing twice running |
1211
+ | Spawn | the worker has been refused as many times in a row as the escalation threshold |
1212
+ | Vectors | — (amber while live memories have no vector) |
1213
+
1214
+ Two things it does differently from every other command, and both matter. It
1215
+ reads the store the **configuration** names (`--dir` overrides it), because the
1216
+ question is whether the store the hooks open is healthy. And it reads the
1217
+ credentials from the **file**, against an empty environment — a doctor that
1218
+ counted your own shell would read green on a machine whose `~/.zshrc` exports
1219
+ both keys while every hook process, which inherits neither, stayed blind.
1220
+
1221
+ ### `counterparts credentials set <NAME>`
1222
+
1223
+ The repair, in one command, with the value never touching your shell history:
1224
+
1225
+ ```
1226
+ printf '%s' "$KEY" | counterparts credentials set ANTHROPIC_API_KEY
1227
+ counterparts credentials set VOYAGE_API_KEY --from-env MY_VOYAGE_KEY
1228
+ counterparts credentials list
1229
+ ```
1230
+
1231
+ The value comes from stdin or from one named environment variable, never from the
1232
+ command line, and is never echoed or logged — the command prints
1233
+ `set ANTHROPIC_API_KEY in /…/credentials.env` and nothing else. It writes the file
1234
+ the configuration names, creating it 0600 or putting it back to 0600, replaces
1235
+ that name's line (the template's commented placeholder included) and keeps every
1236
+ other line and comment. `credentials list` says which of the two names the file
1237
+ holds — names only.
1238
+
1239
+ Restarting is not required for the hooks: each is a fresh process and picks the
1240
+ file up at the next event. The MCP server reads it once, at launch, so a running
1241
+ session's `recall` keeps whatever it started with until the session restarts.
1242
+
1243
+ ### Two things to know about both
1244
+
1245
+ **`doctor` will not open a store nobody named when the guard is armed.** In a
1246
+ shell exporting `COUNTERPARTS_REQUIRE_EXPLICIT_DIR=1` — this repo's own sessions
1247
+ do — `counterparts doctor` refuses unless you name a configuration
1248
+ (`--config <path>`, or `COUNTERPARTS_CONFIG`) or a store (`--dir <path>`). A
1249
+ configuration found at the default path names the live store, and the guard is
1250
+ armed precisely so that nothing nobody named gets opened. Without the guard set,
1251
+ nothing changes: plain `counterparts doctor` reads the default configuration.
1252
+
1253
+ **On a red day with a very long wake, the terminal may say nothing.** The host
1254
+ caps a hook's output at 10,000 characters, and past that it replaces the text
1255
+ with a preview — which would cost the session its whole wake. So when the wake
1256
+ plus the notice would not fit, the hook prints the wake alone and drops the
1257
+ notice (it leaves an `adapter.notice.dropped` row behind). `counterparts doctor`
1258
+ still prints the finding in full.