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,606 @@
1
+ # `adapters/claude-code/` — CONTRACT
2
+
3
+ ## 1. Purpose
4
+
5
+ The launch adapter: wake injection at session start, the end-of-session write, and crash
6
+ detection — everything host-specific, so the core stays host-agnostic. Session start is
7
+ where this adapter delivers a wake; it is no longer the only place one is read, because
8
+ since 2026-09-17 the core composes a read-only one into the crash fallback's prompt — the
9
+ same composer, minus the prospective lane and minus anything protected or confidential —
10
+ and this adapter's interpret client is what puts that prompt on the wire.
11
+
12
+ ## 2. Brain analog
13
+
14
+ None. This is the body, not the brain: the sensory and motor surface through which a
15
+ particular host delivers experience and receives context. **Named deviation** (constitution
16
+ line 5, "a layer, not a portal"): every host limit that v1 baked into its memory design —
17
+ the 9 KB injection cliff, the socket lifetime, the shell that happened to export a
18
+ credential — belongs here, discovered at runtime, never assumed by the core.
19
+
20
+ ## 3. Keeps
21
+
22
+ - **Hooks return in microseconds; heavy work runs detached under a watchdog.** [engram E4,
23
+ v1] The foreground path never blocks on a model call.
24
+ - **Every session-ending path is a boundary** — normal stop, session end, and
25
+ pre-compaction. [v1] behavioral-spec §2 G5 — compaction destroying the transcript must
26
+ not destroy the day. This is the compaction-amnesia backstop.
27
+ - **The wake never fails the session.** [v1] §1 G7 — missing bundle, unreadable config, or
28
+ failed telemetry means the bootstrap line or nothing, and a clean exit.
29
+ - **The injected block is framed as context, not instruction.** [v1] §1.
30
+ - **The delivery preface is composed HERE, at injection.** The bundle was composed at the
31
+ last boundary and is served unchanged to every session until the next one, so the line
32
+ naming which system this is, the lived day, TODAY'S DATE (the adapter's own fact) and the
33
+ store's current size can only be written at delivery. `self/` owns its wording and its
34
+ byte accounting; this adapter owns asking for it and reporting the delivered bytes,
35
+ sentinel included (2026-09-03: the memory system changed mid-day and the body went on
36
+ speaking as the old one).
37
+ - **Delivery telemetry, distinct from render telemetry.** [v1] scar §2.3 — the adapter is
38
+ the only thing that can report *arrival*, and v1 shipped eleven days of truncated wakes
39
+ because only the render was instrumented. SessionStart writes the sentinel it printed
40
+ into the session registry record, and the session's FIRST PROMPT reads the head of the
41
+ host's transcript for this package's SessionStart attachment — what the hook printed
42
+ beside what the host recorded as injected — and leaves one `adapter.wake.delivered` row
43
+ saying `delivered`, `truncated`, `mismatch`, `printed-unverified` (this host build
44
+ records no injected copy to check against), `not-found` or `no-wake-expected`, in counts
45
+ and flags. No text from the bundle rides on that row: the sentinel is compared where it
46
+ is found and only the answer comes back. The expectation is persisted rather than held in memory because every
47
+ hook is its own process: it was a `Map` on an adapter instance until 2026-09-17, tested
48
+ against a field no caller set, and wrote 0 rows in two weeks of live running (mechanism
49
+ inventory §3 S2).
50
+ - **Injected context is excluded from pacing but kept in capture.** [v1] §2 G11 —
51
+ host-injected material that is user-role but is not the user speaking must not pace a
52
+ ritual.
53
+ - **Conversational text only**; tool output, file contents, images, and injected context
54
+ never enter capture. [v1] §2 G10.
55
+ - **The blocked moment carries ONE ask, committed before it blocks**, and any error in
56
+ it is fail-open — collection never depends on the ritual. [v1] §13 G3–G5. *Violated
57
+ 2026-09-03/04 and restored: v2 grew a second ask (authorship) on a second pacer beside
58
+ the episode's, and the two fired on different Stops — about a dozen asks in a 13-turn
59
+ evening. "New features do not get to grow it back into two" is the guarantee, and the
60
+ feature was the return channel, not a second moment.*
61
+ - **A detached worker that cannot run escalates rather than re-logging, DURABLY.** [engram
62
+ E4's widening] v1's runner starved for two days for one project scope because it expected
63
+ to inherit a credential from whatever shell launched the session; the backlog drained
64
+ only when someone noticed. v2 repeated it for a WEEK (I32, 2026-09-11) because both
65
+ halves of the guarantee were ring-deep: the refusal left no durable row, and the
66
+ per-reason counter lived on an adapter instance that dies with its one-turn hook process,
67
+ so `escalate` read false at every one of a hundred boundaries. Since 2026-09-11 the
68
+ refusal writes `adapter.spawn.refused` / `adapter.spawn.failed` (one row per reason per
69
+ calendar date) and the counter lives in box 2's meta.
70
+ - **A worker DEGRADES step by step; it does not refuse the run.** [I32] Exactly one of the
71
+ worker's five jobs needs a model credential. Refusing the spawn without one stopped the
72
+ other four — the lived-day clock, the Hebbian flush, the semantic cue, the embedding
73
+ backfill and the whole sleep cycle — and froze the day's ask cap with them. Each step now
74
+ asks its own question and records its own answer by name (`sweep.gate` with
75
+ `reason: "no-credential"`; `no-credentials` / `embedder-off` on the vector steps).
76
+ - **The credential comes from the environment first and, where the host gives a process
77
+ none, from the ONE file this package's own config names (`credentialsFile`).** [v1's
78
+ `.env` fallback, ported as a scar rather than as code] Measured day 0 of the parallel
79
+ run: this host's hook processes carry neither documented name even with both exported in
80
+ the owner's shell rc. A file the config NAMES is "one configured source the package
81
+ owns" (§2.18); a file found by CONVENTION is not, and stays forbidden. Only the two
82
+ documented names are honored, the environment always wins, and only names and counts
83
+ ever leave.
84
+ - **Anti-loop re-entrancy guard on the turn hook.** [v1] test-triage `hooks.test.ts`.
85
+ - **Observer stands down at the hook boundary and at the store seam.** [v1] §15, scar E7.
86
+
87
+ ## 4. Drops / simplifies
88
+
89
+ - **The A/B day-alternating wake mute is gone** — the *day-alternation*, that is. Computing
90
+ a parity off an anchor date is not a memory property (§1) and no schedule decides who
91
+ speaks here. What survives is smaller and temporary: for the **parallel run** beside v1,
92
+ a **primacy resolver** (`primacy.ts`) behind the `parallel.enabled` config flag. It reads
93
+ v1's own assignment file and lets the delivering hooks speak only when that file names the
94
+ slot v2 occupies; it **fails toward mute** where v1 fails toward inject, so the joint
95
+ failure state is v1-only rather than two voices or none. Absent flag ⇒ v2 delivers, which
96
+ is the ordinary build. The flag, the resolver, and the two durable events are **retired at
97
+ PROMOTE** — they are scaffolding for a comparison, not a feature.
98
+ - **The 9,000-byte wake budget is not a constant here or anywhere.** The adapter
99
+ **discovers or asserts** its host's injection ceiling and reports it as a capability;
100
+ the core composes to whatever it is told (scar §2.18). v1's number was 90% of one host's
101
+ cliff, encoded as though it were physiology.
102
+ - **Multi-file API-key rotation and per-key cursor bookkeeping are dropped**; credentials
103
+ come from one configured source the package owns, not from an inherited shell
104
+ environment (scar §2.18: "nothing in the core depends on a tool, file, or environment the
105
+ host may not provide"). Settled by the scar.
106
+ - **Model-seat pins are dropped.** **PROPOSED** — owner call at check-in. Constitution
107
+ line 2 says which seat runs which job is a design choice, never doctrine, and the model
108
+ lineup will have moved. What is **kept** is the bake-off *method* (earned-mechanism #20:
109
+ real archived inputs through the real path, blind-judged, including the losing tier as a
110
+ judge) and scar §2.15's requirements: pinned snapshots rather than aliases, one knob per
111
+ seat rather than one shared across three call sites, and a placeholder that **expires**
112
+ so "never decided" cannot masquerade as "decided."
113
+
114
+ ## 5. Contract
115
+
116
+ **Inputs** — host hook events (session start, user turn, stop, session end, pre-compaction);
117
+ the host's transcript slice since the last boundary; host configuration.
118
+
119
+ Two of that transcript's shapes arrive **user-role and are not the owner speaking**, and
120
+ both are named here because a reader that misses either mints someone else's words as the
121
+ owner's (measured 2026-09-04, `fix/transcript-peer-speakers`):
122
+
123
+ - **`<cross-session-message from="…" from-name="…" from-mode="…">…</cross-session-message>`** —
124
+ a message from another of the owner's Claude Code sessions
125
+ ([docs](https://code.claude.com/docs/en/cross-session-messaging); the attribute set
126
+ `from`, `from-name`, `from-session`, `from-mode`, `hop-chain` read off the v2.1.260
127
+ bundle). The content is **real experience and is kept**; the wrapper is replaced **in
128
+ place** with `[message from another Claude session, <name>]: …`, because a span is text
129
+ and attribution has to survive in the words. The name is `from-name`, then
130
+ `from-session`, then `unnamed`; **`from` is deliberately not a fallback** — it is a
131
+ machine-local socket path, and a path has no business in prose that outlives the socket. A block that is nothing but a peer message
132
+ is `injected` (kept in capture, out of pacing); a block that mixes the owner's own text
133
+ with a wrapper stays `conversation`. The rewrite never splits a block into extra turns —
134
+ the per-session read cursor indexes into that list. The sibling **idle notice** is plain
135
+ text, not a wrapper (`[Cross-session idle notice] "x" is idle now` / `… has exited`), so
136
+ it gets no rewrite; it and any other `<cross-session-*>` wrapper the host may add are
137
+ classified `injected` as the conservative reading of a shape not yet measured.
138
+ - **`Stop hook feedback: …`** — the host returning a blocking Stop hook's stderr to the
139
+ model. It carries **this adapter's own asks**, so it is `ritual` and enters nothing
140
+ (G11). One carrying a v1 marker is still `foreign`: foreign is checked first.
141
+ **Outputs** — an injected context block or the empty string; appended spans; the
142
+ end-of-session ask; a detached worker spawn; capability reports (injection ceiling,
143
+ execution ceiling, socket lifetime, credential availability AND which source answered —
144
+ `env` or `file`, name-level only); delivery and stand-down telemetry.
145
+
146
+ **Guarantees** — **[M]** mechanized, **[A]** advisory:
147
+
148
+ 1. **[M] The core imports nothing from this directory**, and a test asserts the dependency
149
+ direction (constitution line 5).
150
+ 2. **[M] No hook ever fails the host.** Every failure is logged and swallowed; every hook
151
+ returns within its stated budget.
152
+ 3. **[M] Every session-ending path reaches the boundary**, and a test enumerates the host's
153
+ session-ending events and asserts each is wired.
154
+ 4. **[M] Host-dependent limits are discovered or asserted at runtime and surfaced as
155
+ checkable values**, never assumed; exceeding one is an event, not silent degradation
156
+ (scar §2.18).
157
+ 5. **[M] The spawner pins the child's environment last**, so no caller can leak a run into
158
+ the wrong store (scar §2.13).
159
+ 6. **[M] A long call proves it survives this host's ceilings, once, in this host** —
160
+ adapter-level evidence, per scar E3's rescope.
161
+ 7. **[M] Under observer, the boundary appends no span, resolves no references, spawns no
162
+ worker, and asks for no episode** — and logs that it stood down (scar E7, §2.4).
163
+ 8. **[M] The read cursor is per-session and advances only after a successful append**, and
164
+ a test covers the compaction case: a re-read of overlapping content must not re-encode
165
+ (the v1 hypothesis that was never verified — carried as a test to write).
166
+ 9. **[A] Hook names, wiring, and settings-file merge mechanics are host trivia** and may
167
+ change with the host without touching a core contract.
168
+ 10. **[M] Foreign injection never enters capture.** Text another memory system's hooks put
169
+ into this host's transcript is tagged `foreign`, and `enters()` refuses it — unlike
170
+ `injected`, which is kept and only excluded from pacing. The recognizers are ONE
171
+ exported constant (`FOREIGN_MARKERS`), so the preflight canary and the reader cannot
172
+ disagree about what foreign looks like. Without this, a parallel run makes each system
173
+ encode the other's briefing as a memory of having thought it.
174
+ 11. **[M] This system's OWN ritual text never enters capture, and the refusal is counted.**
175
+ A host that returns hook output into the model's context (`Stop hook feedback:`) hands
176
+ this adapter its own authorship and episode asks back as user-role prose. That text is
177
+ tagged `ritual`, `enters()` refuses it, and — because it is refused rather than dropped
178
+ quietly — it lands in the boundary record's `excluded` count, so a boundary that
179
+ captured nothing because everything was ritual is distinguishable from a boundary where
180
+ nothing happened. The ask's durable record is `adapter.ask`, not the transcript
181
+ copy. This **supersedes** the earlier reading that excluding the wrapper
182
+ would blind the reader to its own voice: what the transcript copy actually bought was
183
+ the ask's wording becoming a memory of having thought it.
184
+ 12. **[M] A peer session's words are kept, but never as the owner's.** A
185
+ `<cross-session-message>` block is rewritten in place to name its speaker before it can
186
+ reach a span, and a block that is only a peer message does not pace a ritual. Without
187
+ this the fallback sweep mints another instance's findings as things the owner said in
188
+ conversation — the failure this guarantee is named after.
189
+ 13. **[M] The live session is recorded where this host's TOOLS can find it, and that
190
+ record is also WHERE THE SESSION IS FILED.** SessionStart writes
191
+ `<dataDir>/sessions/<id>.json` (id, scope, started, last boundary, and the marks a
192
+ later hook process needs: which configuration was read, whether the first-launch
193
+ question went out, the wake's sentinel and whether its arrival has been checked), Stop
194
+ refreshes the clock — creating the record when it is missing — and SessionEnd closes
195
+ it. The writes
196
+ are atomic (temp + rename), tiny, and silent on failure, because a hook may not fail
197
+ the host (G2) and SessionEnd's hooks share 1.5 s between them. It exists because this
198
+ host launches its MCP servers from a static configuration and cannot tell them which
199
+ session they serve: without this note `session_end` refuses every dump — measured for
200
+ the whole of the first run — and the authored front door is shut.
201
+
202
+ **ONE SCOPE PER SESSION, FOR THE SESSION'S WHOLE LIFE.** Spans, boundaries, coverage,
203
+ the ask's coverage read, the registry record and the worker's session state all use
204
+ the directory the session STARTED in, whatever directory the agent's shell has since
205
+ moved to. `bin/hook.ts#sessionScope` takes it from this record first — the recorded
206
+ fact of where the session began, and the same string `mcp/server.ts` matches a deposit
207
+ against — then from `CLAUDE_PROJECT_DIR`, which the host documents as the project root
208
+ where the session started, exports to hooks and to stdio MCP servers alike, and keeps
209
+ put when the agent enters a worktree. `recordSession` sets the scope only at a start,
210
+ and only a SessionStart whose `source` says it is OPENING a session counts as one: a
211
+ compaction fires SessionStart mid-session, and re-anchoring there would split a long
212
+ session at every compaction.
213
+
214
+ The measurement that set the rule (2026-09-17): the payload's `cwd` follows the agent
215
+ into a git worktree, so one session's spans landed in FOUR scope directories and its
216
+ boundaries in all four, while its authored deposits and their coverage marks landed in
217
+ ONE — the server's scope is fixed at launch, and a deposit covers only spans in its own
218
+ scope. Everything in the other three stayed uncovered and was rewritten twelve hours
219
+ later by the crash fallback as though the session had died. Two worktree scopes on that
220
+ store hold 298 fallback memories and zero authored ones. An observer records nothing.
221
+ 14. **[M] The Stop ask names the session id and BOTH tools that take it**, says
222
+ `updates` is a FIELD rather than prose, and says salience is the author's to set. The
223
+ wording is advisory; every fact it carries is mechanized elsewhere — the id is what
224
+ the MCP server binds itself with (`mcp/server.ts#requireBoundSession`), the field is
225
+ what `remember/updates.ts` resolves, the unclaimed default is `physics/`'s. The old
226
+ wording ("say `updates: <id>`") produced four notes whose declaration landed as the
227
+ first words of their own prose, unlinked; and on the Stops where only the episode
228
+ half fired, the model got neither an id nor a tool name. The ask's text is the same
229
+ text G11 refuses when the host hands it back — delivered by the hook, recorded by
230
+ `adapter.ask`, never by its transcript copy.
231
+ 15. **[M] The prompt path opens no socket, and the semantic cue is LAGGED.** The
232
+ embedding a turn's recall consults is computed by the detached worker AFTER the
233
+ previous turn and read out of per-session gate state on the next one — the same
234
+ one-turn lag carried cues already run on (owner ruling, 2026-09-04). Measured on the
235
+ live store: `RecallTurn.vector` existed from `recall/`'s first commit and neither
236
+ live path ever set it, so 13,862 embeddings were consulted by nothing; and every
237
+ hook process already spends 700-1000 ms cold against a 1200 ms budget, so an in-line
238
+ embed would have bought a `latency-abort`, not a channel. A test spies
239
+ `globalThis.fetch` AND injects a throwing `embedFetch`, so neither route can quietly
240
+ reappear. **The RANKING travels with the cue, not the vector**: `Store.nearestTo`
241
+ over a live-sized index measured 590-1040 ms, so carrying a vector would have moved
242
+ the network call off the hot path and left the scan on it.
243
+ **It runs on EVERY boundary, outside the sweep gate and regardless of its verdict**,
244
+ and `stop()`/`sessionEnd()` spawn the worker unconditionally. The crash gate (open
245
+ question 3, answered) decides whether a *SWEEP* selects anything — its ordinary
246
+ answer is "nothing crashed", recorded as a durable `sweep.gate` row — and
247
+ the cue expires after one turn, so a step that fired only when the gate opened would
248
+ leave the semantic channel dark on every ordinary turn. The two are separately
249
+ ordered on purpose: the cue reads the LIVE span buffer and must precede the sweep's
250
+ claim, which would move those spans out of it.
251
+ 16. **[M] The worker gives vectors to memories that have none, at a bounded rate.** Up
252
+ to `BACKFILL_LIMIT` (64) per run, first-person material first — what the experiencer
253
+ authored and its own episodes, then everything else oldest-first — with
254
+ `{embedded, remaining, failed}` written durably (`adapter.embed.backfill`) so the
255
+ coverage watch reads a number out of the store rather than out of a dead process's
256
+ stderr. The authored door still warms its own vector when a `vectors` socket is
257
+ wired; this is the GUARANTEED path, because a memory that predates the embedder, or
258
+ arrived by migration, has nothing and no future deposit comes back for it.
259
+ 17. **[M] The deliberate ask MAY embed in line, and says which channel answered.** The
260
+ MCP entry point loads the same 0600 credentials file the hook entry point names and
261
+ hands the server an opened embedder or null; the server never sees a key. A missing
262
+ one degrades the ask to lexical-only and the result carries `semantic:
263
+ "embedder-off" | "embed-failed"` rather than a quietly narrower answer.
264
+
265
+ 18. **[M] ONE ask, on ONE pacer, capped per SESSION PER DAY, and the re-fire advances
266
+ nothing.** The pacer is `self/`'s and nothing else: first ask on the first real
267
+ substance (`FIRST_ASK_*`, or `SOLO_ASK_BYTES` alone so a one-prompt agentic session
268
+ still journals), re-ask on `REASK_TURNS` **and** `REASK_BYTES` since the last ask —
269
+ a conjunction, the way v1 re-asked, where v2 shipped a disjunction whose byte half
270
+ was a third of v1's. The cap is `MAX_ASKS_PER_SESSION` and each session spends only
271
+ its own, and only for the day it is spending: this host opens a session per
272
+ invocation, and a cap of four shared across every session a calendar day held refused
273
+ 196 of 264 Stops while the crash-fallback sweep wrote 888 memories to the author's 193
274
+ (2026-09-17) — while spent over a session's whole life the same six starved a session
275
+ that worked through a day and into the evening, whose handoff was never offered the
276
+ pen (2026-09-18, the day the allowance started resetting with the store's calendar
277
+ date). The conjunction holds the cadence — six asks in one day is roughly 46 real
278
+ turns — so the count is a backstop, and a session that has done no real work is still
279
+ refused, on substance.
280
+ The coverage read stays, as a RECORD of the unaskable tail and never as a second
281
+ condition. Exactly ONE durable row per Stop (`adapter.ask`) carries the outcome —
282
+ `asked` | `paced` | `capped` — and its date, so "how often was it asked today" is a
283
+ number in the store rather than a guess. The host's re-fire (`stop_hook_active`)
284
+ reaches the adapter as `reFired` and is refused there as well as at delivery: it
285
+ spends no pacing slot, no ask slot, and leaves no row.
286
+ **THE ASK GAINED A THIRD LINE on 2026-09-20 (E1) and is still ONE ask.** `handoff` is a
287
+ FIELD on the `session_end` call item 1 already names — no third tool, no second moment,
288
+ no second pacer — and it is numbered apart from item 1 because item 1 asks for what will
289
+ still be true next week and a handoff is the opposite claim: what is true only for the
290
+ next fortnight, in this directory. Reading them as one sentence is what would produce
291
+ handoffs filed as memories. The text's length bound moved 1,050 -> 1,300 with it; the
292
+ properties the bound defends — one screen, at most four numbered items, the session id
293
+ exactly twice — are asserted on their own.
294
+
295
+ **AND THE WAKE GAINED A THIRD DELIVERY-TIME FACT.** `sessionStart` passes the session's
296
+ directory and id to `counterpart.wake(budget, delivery, here)`, beside the date it
297
+ already passed, because the published bundle is one per store and read in every
298
+ directory. With no live handoff nothing is passed through and nothing is spliced.
299
+
300
+ 19. **[M] A directory set `off` gets NO OUTPUT AND NO WRITE — because nothing is
301
+ constructed.** The scope registry (`adapters/scopes.ts`,
302
+ `<config dir>/scopes.json`, longest-prefix, added 2026-09-10 for owner asks
303
+ G41–G43) is read at the ENTRY POINT, from the file `config-path.ts` resolved,
304
+ before a store is opened: an `off` or `paused` directory returns from
305
+ `bin/hook.ts#main` with byte-for-byte empty stdout, empty stderr, no session
306
+ record, no capture, no spawn and no store. `guard()` carries the same predicate
307
+ at the seam so a caller who builds an adapter directly inherits it, but the
308
+ guarantee itself is the absence of construction, and the install loop proves it
309
+ on a real process against a real clean-room install.
310
+
311
+ **TWO DIRECTORIES ARE CONSULTED, AND THE MOST RESTRICTIVE WINS**
312
+ (`scopes.ts#mostRestrictiveVerdict`) — because filing follows the session and
313
+ privacy has to follow the shell as well. The EVENT's own directory, the payload's
314
+ `cwd`, is looked up first and alone, before the configuration is read, so an
315
+ opted-out directory's silence stays exactly what it was. The SESSION's directory
316
+ (G13) is folded in after, because its first source is a record under the store the
317
+ configuration names; a session whose own directory is `off` stands down wherever
318
+ its shell has got to, and a session that walks INTO an `off` or `observer`
319
+ directory goes at least as quiet as that directory for as long as it is standing
320
+ there. Nothing is written before either verdict; the extra reading is a
321
+ configuration file and one small session record. The session's verdict wins a tie,
322
+ so the `unset` that raises the first-launch question (G41) is asked about the
323
+ directory the session is filed under.
324
+
325
+ It is SILENT on purpose, and that is a deliberate exception to "every stand-down
326
+ is observable" (`docs/observer-mode.md` G6): there is no ring to log to without
327
+ opening a store, and `UserPromptSubmit` fires every turn, so one line per event
328
+ would be a permanent noise floor in the host's log for a directory that asked to
329
+ be left alone. The record is the registry itself, and `counterparts scope <path>`
330
+ prints it. An `off` is not an instrument standing down; it is the owner saying
331
+ this directory is not part of the memory.
332
+
333
+ **The guarantee is the HOOKS', and only the hooks'.** The MCP server still opens
334
+ a store when the host launches it in an `off` directory (`mcp/bin/serve.ts`): it
335
+ refuses every tool but `scope` with `scope-off`, per call, before any session bind
336
+ — but the file handle exists and the store is created if it was absent. A server
337
+ that refused to launch is reported by this host as "MCP server failed", and the
338
+ `scope` tool is the door that turns the directory back on, so it has to answer.
339
+ "No store is opened" is therefore true of a hook process and not of a server
340
+ process; the owner's ruling on whether that gap should close is open (#92 review).
341
+
342
+ A REGISTRY THAT COULD NOT BE READ is a different exception, and not a silent one
343
+ (G23).
344
+
345
+ 20. **[M] Effective stance is the MOST RESTRICTIVE of the configuration's and the
346
+ registry's, and the registry only ever adds restriction.** `on < observer < off`
347
+ (`scopes.ts#effectiveStance`). A registry entry of `observer` folds into the
348
+ configuration the adapter opens on, so it IS the existing observer stance rather
349
+ than a second implementation of it; a configuration that already stood a session
350
+ down is never relaxed by a registry. The three private directories running on an
351
+ observer configuration and `COUNTERPARTS_OBSERVER` have no entry at all, and
352
+ behave exactly as they did before any of this existed.
353
+
354
+ 21. **[A] An UNSET directory raises the first-launch question once per session, and
355
+ never inside the wake.** `SCOPE_ASK` travels on `HookResult.ask`, which the host
356
+ delivery appends AFTER the injection — never inside it, because the wake's
357
+ sentinel states its own byte count and must remain its last line (G2, scar §2.3).
358
+ It is delivered only when it FITS the ceiling the host reported, wake bytes
359
+ included; with no room it is deferred with an event and the session record is left
360
+ unmarked, so the next session asks rather than the question being truncated or
361
+ smuggled past the limit. `SessionRecord.askedScope` is what makes "once" true
362
+ across a resume or a compaction. The WORDING is advisory; that an unset directory
363
+ raises the question exactly once and that any recorded mode ends it are the
364
+ mechanized parts.
365
+
366
+ 22. **[M] TURNING A DIRECTORY BACK ON NEVER REACHES BACK.** A session that lived
367
+ under `off` or `paused` left no session record and no span cursor, because the
368
+ hook process returned before anything was constructed (G19). Flip the registry
369
+ to `on` mid-session — `counterparts scope . --resume`, or the `scope` tool, which
370
+ is deliberately the one tool that answers in an off directory — and the next
371
+ boundary would otherwise slice the transcript from cursor 0 and deposit the whole
372
+ off conversation. It does not: a boundary that finds NO session record and a
373
+ cursor still at 0 (`hooks.ts#sealJoinedLate`) moves the cursor to the end of what
374
+ it can see, captures nothing at all, writes the session record so the tools can
375
+ bind, and leaves `adapter.scope.joined-late` in the ring with `joinedLate: true`
376
+ on its durable boundary row. What is said after the switch is captured normally.
377
+
378
+ The cost is stated rather than hidden: a session whose SessionStart never ran
379
+ inside this memory — hooks installed mid-session, a store moved or restored
380
+ without its `sessions/` directory, a SessionStart that failed — loses the
381
+ conversation so far at its first boundary. The privacy direction is the one the
382
+ owner asked for; the completeness direction is the one it costs.
383
+
384
+ 23. **[M] A REGISTRY IN TROUBLE IS NEVER SILENT, and that is a different exception
385
+ from G19's.** `off` is silent because the owner said leave this alone. A
386
+ registry file that could not be read has said nothing at all, and its fail
387
+ direction is `unset` — which is ON: the review measured one typo'd mode turning
388
+ every correctly typed `off` in the file back on, with no evidence anywhere but
389
+ a ring event in a process that lives for one turn. So a bad ENTRY is refused by
390
+ name and the rest of the file stands (`scopes.ts#parseRegistry`); a file that is
391
+ not a registry at all is still a whole-file failure; and either way
392
+ `describeScopeTrouble` puts one line on the hook's stderr at **SessionStart
393
+ only** — after the `off` return, so an off directory's silence stays
394
+ byte-for-byte — with `scopeRegistry: "unreadable" | "partial" | null` on the
395
+ session-start row for the day after. Both writers refuse rather than dropping
396
+ an entry they could not read: the console unless `--force`, the MCP tool always.
397
+ 24. **[M] A stand-down that is a FAULT reaches the owner's terminal; one that is
398
+ DELIBERATE stays as quiet as it was.** G2 is why every failure is swallowed;
399
+ it is not a reason for the owner never to learn of one. Until now a hook that
400
+ could not open its store wrote one line to stderr — which on this host goes
401
+ nowhere anybody looks — so a store with one missing prose file meant no wake,
402
+ no recall and no capture in every session, silently, while every visible
403
+ surface read green. *(That was the FILE floor. The same shape survives the
404
+ move to rows as a row whose words went missing — `MEMORY_BODY_MISSING` — and
405
+ since 2026-09-20 doctor, `verify` and `status` all name the row.)* So `bin/hook.ts` classifies its stand-downs
406
+ (`standdown.ts`): a directory scoped `off`, an observer with no store to read
407
+ (`STORE_UNINITIALIZED`), and the explicit-dir guard's two refusals are
408
+ DELIBERATE and unchanged; anything else is a FAULT and prints one
409
+ `systemMessage` — the channel I32's close measured and `bin/hook.ts#hostDelivery`
410
+ already uses for the red notice — on **SessionStart and
411
+ UserPromptSubmit**, the two events this host displays one on. Exit 0 as
412
+ always, nothing else in the object, no wake and no `additionalContext`, and
413
+ the stderr line is kept. What is said, and whether, is marked in a file under
414
+ `<dataDir>/sessions/` — because the thing that failed is the store, the mark
415
+ cannot live in it — and a mark that cannot be written means it is said again
416
+ rather than not at all.
417
+
418
+ **A FAULT IS PERSISTENT OR TRANSIENT, and they are not said the same way.**
419
+ A store that will not open is exactly as broken next turn: "memory is OFF for
420
+ this session", once, with a code and one clause of plain words capped at
421
+ `STANDDOWN_REASON_MAX_CHARS` — SessionStart always, UserPromptSubmit while the
422
+ session has not been told. A database that was merely BUSY (`db.ts#isLocked`,
423
+ one predicate for this and for F1's WAL conversion) is not that, and saying
424
+ it were would be both untrue and, at the rate a rollback-mode store produced,
425
+ a line people learn to scroll past. So: at a prompt it is recorded and stays
426
+ on stderr the FIRST time and is said from the second, at most once a session
427
+ ("skipped this turn"); at SessionStart it is said the first time, in its own
428
+ words, because a lock there means no wake was injected at all and that event
429
+ does not come round again; and at `TRANSIENT_ESCALATE_AFTER` skipped turns it
430
+ is said ONCE more, in the only transient wording allowed to use the word OFF,
431
+ because no test on an error can tell a contended database from a wedged one
432
+ and the soft line's promise that it will clear has by then become a lie. The
433
+ two counters are kept apart, so a session that met a busy database still
434
+ hears about a store that will not open.
435
+
436
+ **AND A FAILURE AFTER THE TURN'S WORK IS NOT A FAILURE OF THE TURN.** Once
437
+ `adapter.hook` has returned, this event's job is done — recall composed, the
438
+ turn captured, the session record written — and anything that throws after
439
+ that is the tidying-up, not the work. It stays on stderr, exactly as on
440
+ master. Without that gate a throw from the `close()` in the `finally` (I38's
441
+ own shape) told the owner "skipped this turn" about a turn that had just
442
+ succeeded, and a warning that is sometimes false is the one outcome this
443
+ guarantee cannot afford. The mark is never written into a directory the store
444
+ layer refuses to open, and never through a symlink: `writeMark` asks
445
+ `assertSafeDataDir` and writes tmp-then-rename, `sessions.ts`'s own rule for
446
+ the same directory.
447
+ `counterparts doctor` reads the same open with the same predicates
448
+ (`doctor.ts#readCounterpartOpen`) — RED for a store that will not open, AMBER
449
+ for one that was busy or that only an owner may initialize — so the terminal
450
+ and the console cannot disagree about what happened.
451
+
452
+ 25. **[M] THE WORKER TAKES ONE COPY OF THE STORE A DAY, AND THE COPY IS THE ONLY
453
+ THING HERE THAT DELETES.** A fourth step in `bin/runner.ts`, after the sleep
454
+ cycle and inside the `finally` so a failed boundary still gets its copy —
455
+ deliberately NOT a `core/sleep/` phase, because sleep must not learn that the
456
+ floor is changing. What it copies is `cli/snapshot.ts#snapshot` unchanged
457
+ (`Store.backupSet()`, so it is right on both floors); WHERE is a `snapshots/`
458
+ directory beside the store, never inside it; HOW MANY is `keep`, default 14,
459
+ one copy per calendar day UTC. It never throws, so a snapshot problem cannot
460
+ cost a consolidation cycle, and it writes `snapshot.taken` / `snapshot.failed`
461
+ / `snapshot.rotated` where tomorrow can read them.
462
+
463
+ The two consequential rules live in `adapters/snapshots.ts` and are tested one
464
+ by one: **rotation deletes only what it can prove is a snapshot** (a directory
465
+ directly inside the resolved directory, matching the one name pattern this
466
+ package writes, never through a symlink, never the copy just taken, never
467
+ after a copy that FAILED, and a broken `keep` reads as the default rather than
468
+ as "delete them all"); and **a half-copy is never a snapshot** — the copy is
469
+ written under a `.partial-…` name and renamed into place, so a worker killed
470
+ mid-copy leaves something that is not counted toward `keep`, does not satisfy
471
+ "today's exists", and is swept once it is too old to be a live run's.
472
+
473
+ *For now:* the default directory applies only inside the layout this package
474
+ creates (the store is the `store/` subdirectory of a base directory). A store
475
+ somebody pointed elsewhere takes no copy until `snapshots.dir` names one, and
476
+ doctor's Snapshot line says so in words rather than leaving a row per boundary.
477
+
478
+ **HOW TO RESTORE ONE, because a backup nobody knows how to open is not a
479
+ backup.** A snapshot is a whole store directory, so restoring is a copy:
480
+
481
+ 1. Stop every session using the memory (the MCP server and any hooks).
482
+ 2. Move the damaged store aside — never delete it — and copy the snapshot
483
+ directory into its place: `cp -R ~/.counterparts/snapshots/<iso>
484
+ ~/.counterparts/store`.
485
+ 3. `counterparts verify --dir ~/.counterparts/store --rebuild`, with the
486
+ embed key exported if the embedder is on.
487
+
488
+ What comes back with the copy: every memory, its archived versions, the
489
+ journal, the spans, the event log — the canonical halves. Since the floor
490
+ (schema v6, 2026-09-20) the memories' words are COLUMNS, so all of that is
491
+ inside `counterparts.sqlite` and there is no prose to come back separately. What does NOT, and why step 3
492
+ exists: `cache/` is classified out of the backup set on purpose (it is
493
+ rebuildable and unbounded), and it holds the lexical search index and every
494
+ vector. **Until the rebuild, `search()` returns nothing** — the memories are
495
+ all there and none of them can be found, which is exactly the shape that makes
496
+ somebody conclude the backup is empty. A rebuild without an embedder drops
497
+ every vector rather than keeping them, so semantic recall is thin until the
498
+ worker's backfill refills it over the following days; the lexical channel is
499
+ back immediately. Doctor prints these steps as the remedy on any Snapshot
500
+ finding that is not green.
501
+
502
+ ### The nightly page writer, in two modes (S2, 2026-09-20 — true for now)
503
+
504
+ **[M] Session mode is the default, and it costs the wake nothing.** When the writer is owed
505
+ the day just gone, the SessionStart hook puts the core's instruction in `HookResult.ask` —
506
+ the same field, beside the wake and never inside it, that the first-launch scope question
507
+ uses and for the same reason: the bundle's byte count and its tail sentinel are load-bearing.
508
+ The wake's `injection`, `bytes` and `sentinel` are byte-identical with the writer off and
509
+ with it on, and that is asserted rather than argued. **The first-launch question wins the
510
+ field** when both want it; the writer's is deferred with a ring event and the night stays
511
+ owed. **No room under the reported ceiling defers rather than truncating**, and claims
512
+ nothing. One session is asked once — a compaction re-firing SessionStart asks nothing — and
513
+ the mark is a DATE on the session's registry record, which is also the only evidence the
514
+ MCP server accepts for writing `by: "writer"` on the revision that comes back.
515
+
516
+ **[M] Host mode starts a windowless session of the self, and reads the outcome from the
517
+ store.** `claude -p`, so the ordinary SessionStart hook fires inside the child and the
518
+ writer wakes with the wake; exactly one pre-approved tool, the page's. The plan is pure and
519
+ decides everything; the starter is six lines. The package's own values go onto the child's
520
+ environment LAST (§2.13), and `COUNTERPARTS_SESSION` / `COUNTERPARTS_SCOPE` are REMOVED
521
+ rather than inherited — a whole new host session that inherited the parent's session id
522
+ would bind its MCP server to a session that has already ended. The night it is writing rides
523
+ as a pinned DATE (`COUNTERPARTS_PAGE_WRITER`), because a windowless child's session id is
524
+ minted by the host after the launcher is gone. **The child's stdout is never parsed into a
525
+ verdict**: what the run did is read from the page's version chain and from the row the tool
526
+ left, and the exit code decides only between "nothing to say" and "could not run". The
527
+ child's own SessionStart raises no writer ask — session mode only — or a session started to
528
+ do the writing would be asked to do it.
529
+
530
+ **[M] The ask is measured, not predicted, and a deferral is not a silence.** The composed
531
+ block is checked against the host's reported ceiling AFTER composing (the estimate is its
532
+ shortest shape; the delivered one is longer), and re-composed once against the room the
533
+ first attempt proved was really there. A block that will not fit, or that can carry none of
534
+ the day, is DEFERRED — and the deferral leaves a durable `skipped` row, deduped one per
535
+ night per reason, which claims nothing and can never close a night. The first-launch scope
536
+ question still wins the field, but only once per night: on a blank store it is exactly what
537
+ is pending on nights 1–3, and an unanswered one used to starve the writer for ever.
538
+
539
+ **[M] It never costs anything else.** The writer runs last in the detached worker, inside
540
+ the same `finally` as the snapshot, so a day whose sweep broke is still a day that gets
541
+ written about; it never throws; and a failure never fails a wake, a boundary or a session.
542
+ Doctor's `Page writer` line is GREEN when it has never run on a store with no yesterday and
543
+ GREEN on a night that had nothing to say, AMBER only on a failure or a refusal or on the
544
+ writer being off while a page stands, and never RED.
545
+
546
+ **[M] The child gets the day on STDIN and a stance this package chose.** The instruction is
547
+ not in `argv`, where `ps` shows it to every process on the machine, and
548
+ `COUNTERPARTS_OBSERVER` is deleted from the child's environment beside the two session
549
+ variables: a shell that exported it would hand the child an observer store whose
550
+ `self_page` refuses, and the night would then read `nothing-to-say` — fail-closed, but a
551
+ silently wrong answer. A child that ignores SIGTERM is escalated to SIGKILL on its process
552
+ group and then given up on, so the worker cannot be held past its own watchdog.
553
+
554
+ **UNVERIFIED, and named rather than claimed:** no build has started a real `claude -p`.
555
+ Everything above about host mode is proved against a stub executable. What a real machine
556
+ has to answer is keychain access from a background process (`claude setup-token` is the
557
+ documented route, spec §16), which is why `session` is the default.
558
+
559
+ ## 6. Scars honored
560
+
561
+ **E3** (streaming, with the host's socket ceiling proven here rather than assumed by the
562
+ core) · **E4** (detached execution, watchdogs, and a worker that alarms when it cannot
563
+ start) · **E7** (stand-down at the hook boundary) · **§2.3** (delivery telemetry) ·
564
+ **§2.13** (the spawner pins the data directory; no environment default) · **§2.15** (pinned
565
+ model snapshots, one knob per seat, placeholders that expire) · **§2.18** (a guarantee
566
+ carried by something you don't own is not a guarantee — this scar is this adapter's
567
+ charter).
568
+
569
+ ## 7. Open questions
570
+
571
+ 1. **Does the host offer an in-the-moment jot channel at all?** The owner's decision allows
572
+ jots "where the host allows"; whether this host does, and at what cost to the turn, is
573
+ unmeasured.
574
+ 2. **What is the honest bound on the orphanable tail** — the stretch after the last
575
+ session-ending event nobody can ask about — in this host specifically? v1 bounded it by
576
+ its re-ask threshold and logged it, which is the right shape; the number is host-local.
577
+ 3. ~~**Which host event, if any, means "crashed"?**~~ **ANSWERED 2026-09-04 (owner
578
+ ruling).** *No host event does* — and that is the answer, not a gap. This host has no
579
+ crash signal: an abrupt exit, a killed terminal and an ordinary close all leave the
580
+ same trace. So "crashed" is defined on the boundary record instead, and the definition
581
+ is host-agnostic enough to live in the core (`remember/spans.ts#crashedSessions`):
582
+
583
+ > A session is CRASHED when it holds uncovered spans, has recorded **no `session-end`
584
+ > boundary**, and has had **no boundary activity for `CRASH_STALE_MS`** (12 hours,
585
+ > CAL).
586
+
587
+ Two consequences this adapter owns. First, `session-end` is now load-bearing beyond
588
+ its ask: it is the host's own statement that the author got the pen, and a session
589
+ carrying one is never swept, however much trailing material it left. **That this host
590
+ actually delivers it is measured, not assumed** (2026-09-04, live store): durable
591
+ `adapter.boundary` rows carry `hook: "session-end"` for 5 of the 9 sessions that ever
592
+ reached a boundary, and the other 4 are sessions still open. The hook is wired in the
593
+ host settings and lands inside its shared budget. It stays a **standing watch** rather
594
+ than a settled fact — session-end boundaries per ended session, on the daily — because
595
+ the whole "a normally-ended session is never swept" clause rests on it: were the hook
596
+ to go silent, the live behaviour would degrade to "everything is swept once it goes
597
+ quiet", which still fixes the Stop-time twin race but moves the twin risk to idle
598
+ sessions. Second,
599
+ `pre-compact` is **not** a crash. It was the closest thing to a named catastrophe and
600
+ it is still wired — but what answers compaction is the unconditional *capture* at that
601
+ boundary, not a model call; the sweep follows only if that session then goes silent.
602
+
603
+ The hook path is unchanged by this: boundaries still capture at all three paths and
604
+ the worker still spawns at Stop and SessionEnd for the Hebbian flush and the sleep
605
+ cycle. Only the worker's sweep step is gated, and its skip is a durable `sweep.gate`
606
+ row so a quiet sweep is distinguishable from a dead one.