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,329 @@
1
+ /**
2
+ * Every recall knob, in one visible place — the shape `physics/` uses, for the
3
+ * same reason: a threshold hiding in a function body cannot be audited.
4
+ *
5
+ * **CAL = calibration-required** (scar §2.8: no threshold ships unmeasured against
6
+ * the real space). Values marked CAL below are *v1's live calibration*, inherited
7
+ * as the best surviving record of what real use moved — the starting point, NOT a
8
+ * v2 measurement (recall/CONTRACT.md §4: "v1's values in behavioral-spec §9 are
9
+ * the best surviving record of what lived use moved — the starting point, not the
10
+ * default"). `tools/replay` is where they get re-earned against v2's own corpus.
11
+ *
12
+ * Structural (never tunable, never ablatable): the three hard gates, the
13
+ * build/record split, tier disjointness, the composed budget, the sentinel,
14
+ * the observer refusal.
15
+ */
16
+
17
+ export interface RecallTunables {
18
+ // ── cue extraction ───────────────────────────────────────────────────────
19
+ /** Minimum cue token length. Shorter tokens are noise, not names. [v1: 3] */
20
+ MIN_CUE_LENGTH: number;
21
+ /** Cap on distinct cue tokens taken from one turn — a latency bound. CAL. */
22
+ MAX_CUES: number;
23
+ /** Docs fetched per cue token. A postings bound and NOTHING else: it used to
24
+ * double as the df ceiling for rarity weighting, which meant rarity stopped
25
+ * being measured once a store held more than this many documents carrying a
26
+ * word. `Store.docFrequency` counts now (MEASURED 2026-09-04, see
27
+ * `store/cache.ts#docFrequency`). CAL. */
28
+ PER_CUE_FETCH: number;
29
+ /** Ambiguous-handle weight: a name pointing at two memories retrieves neither
30
+ * well, and trains nothing at all. [v1: 0.5] CAL. */
31
+ AMBIGUOUS_WEIGHT: number;
32
+ /** Cue carry-over: previous turn's cues re-enter at this weight, for one turn.
33
+ * [v1: 1 turn, decay 0.5] CAL. */
34
+ CARRY_DECAY: number;
35
+
36
+ // ── the document side of §9 G4: length normalization + a per-doc ceiling ──
37
+ /** tf saturation for a cue's evidence in ONE document (BM25 k1). At `k1 = 1`
38
+ * and `CUE_LENGTH_NORM = 0` this is exactly the previous `2·tf/(tf+1)`, which
39
+ * is why it is 1: the change ships length normalization and nothing else. CAL. */
40
+ CUE_TF_SATURATION: number;
41
+ /** How much of a cue's evidence is normalized by document length (BM25 b).
42
+ * 0 = none (the measured bug); 1 = fully proportional to length. CAL. */
43
+ CUE_LENGTH_NORM: number;
44
+ /** Clamp the length factor at 1: penalize a long document, never REWARD a
45
+ * short one. BM25's factor is centered on the mean, which raises short
46
+ * documents above their old scores — harmless for ranking, not harmless for
47
+ * the ABSOLUTE floors below, which are v1 inheritances calibrated against the
48
+ * old scale. See `store/cache.ts#LengthNorm.oneSided` for the measurement. CAL. */
49
+ CUE_LENGTH_ONE_SIDED: boolean;
50
+ /** Per-document ceiling on the cue channel, as a multiple of that document's
51
+ * single strongest cue. Corroboration is real evidence; sheer coverage is
52
+ * not. v1 capped the same quantity absolutely (`entityCueCap`); this is the
53
+ * scale-free form, because v2's cue weights are smoothed idf rather than v1's
54
+ * normalized similarities and an absolute number would not transfer. CAL. */
55
+ CUE_DOC_CAP: number;
56
+
57
+ // ── channels ─────────────────────────────────────────────────────────────
58
+ /** Weight on the embedding channel's contribution. CAL. */
59
+ SEMANTIC_WEIGHT: number;
60
+ /** Cosine below this is not a seed at all. [v1: 0.45] CAL. */
61
+ SEMANTIC_SEED_FLOOR: number;
62
+ /** Nearest-neighbour slice pulled from the vector index. [v1 top-M: 8] CAL. */
63
+ SEMANTIC_TOP_M: number;
64
+ /** Weight on base-level activation (strength). The recency/arrival channel:
65
+ * it can make a memory warm, never loud. [v1: 0.15] CAL. */
66
+ ARRIVAL_WEIGHT: number;
67
+
68
+ // ── the gate ─────────────────────────────────────────────────────────────
69
+ /** Relative admission: bar = mean + SNR_GLOBAL x sd of THIS turn's background. [v1: 1.2] CAL. */
70
+ SNR_GLOBAL: number;
71
+ /** Relative loud tier: bar = mean + SNR_STRONG x sd. [v1: 2.5] CAL. */
72
+ SNR_STRONG: number;
73
+ /** Hard gate (b): the absolute floor, checked BEFORE any salience adjustment.
74
+ * **In cue units** — multiples of `informativeness(1, storeSize)`, the weight
75
+ * of one maximally-rare cue (`gate.ts#floorUnit`). The `_UNITS` suffix is not
76
+ * decoration: this knob was `FLOOR_GLOBAL`, an absolute number on v1's 0-1
77
+ * cosine scale, and renaming it is how every stale reading of the old scale
78
+ * becomes a compile error rather than a silent miscalibration. CAL. */
79
+ FLOOR_GLOBAL_UNITS: number;
80
+ /** Per-kind OVERRIDES of the loud-tier floor, in the same cue units. The
81
+ * mechanism of §9 G12 — kinds may live on different activation scales — is
82
+ * kept; v1's numbers for it are not, because v2's own corpus refuses them
83
+ * (see the measurement at the value below). An empty map means no kind has
84
+ * earned an override yet. The BACKGROUND statistic stays global. CAL. */
85
+ FLOOR_STRONG_BY_KIND_UNITS: Record<string, number>;
86
+ /** The loud-tier floor for a kind with no override — today, every kind. CAL. */
87
+ FLOOR_STRONG_DEFAULT_UNITS: number;
88
+ /** Hard gate (c): fraction of a candidate's activation that must come from
89
+ * cues before it may go loud. Recency alone can never carry a memory there,
90
+ * however sacred. [v1: 0.5] CAL. */
91
+ MIN_CUE_FRACTION: number;
92
+ /** Two-sided salience modulation of the RELATIVE bar only. [v1 bar weight: 0.5] CAL. */
93
+ SAL_BAR_WEIGHT: number;
94
+ /** Salience's weight in the surfaced PICK's sort key — ordering and admission
95
+ * use deliberately different keys. [v1 sort weight: 0.5; fixture-bounded
96
+ * below ~0.3 and above ~1.2] CAL. */
97
+ SAL_SORT_WEIGHT: number;
98
+ /** Candidates carried into the gate. A count that must not become an
99
+ * undercount for aggregation lives in deliberate recall, not here. CAL. */
100
+ MAX_CANDIDATES: number;
101
+
102
+ // ── cold start: stricter, not looser (small stores over-surface) ──────────
103
+ /** Below this many live memories the variance estimate is meaningless. [v1: 15] CAL. */
104
+ COLD_START_MIN_STORE: number;
105
+ /** Cold-start absolute floor, replacing the relative bar entirely. In the same
106
+ * cue units as the other two floors — a store this small is exactly where an
107
+ * absolute number on the wrong scale does the most damage. CAL. */
108
+ COLD_START_FLOOR_UNITS: number;
109
+ /** Cold-start candidate cap. [v1: 3] CAL. */
110
+ COLD_START_MAX_CANDIDATES: number;
111
+ /** Fewer cued candidates than this and the background distribution is a
112
+ * fiction — the gate degrades to the absolute regime rather than comparing a
113
+ * candidate against itself (see NOTES.md, the sigma-zero degeneracy). CAL. */
114
+ MIN_BACKGROUND_SAMPLE: number;
115
+
116
+ // ── inhibition + caps ────────────────────────────────────────────────────
117
+ /** Near-duplicate similarity: above this, the weaker candidate is suppressed. [v1: 0.85] CAL. */
118
+ NEAR_DUPLICATE: number;
119
+ /** Hard cap on the loud tier. [v1: 2] */
120
+ MAX_SURFACED: number;
121
+ /** Hard cap on footnotes. [v1: 6] */
122
+ MAX_FOOTNOTES: number;
123
+
124
+ // ── affect ───────────────────────────────────────────────────────────────
125
+ /** Emotional salience a candidate needs before it can raise the affect flag. [v1: 0.7] CAL. */
126
+ AFFECT_MIN_EMOTION: number;
127
+ /** Turns the affect flag stays down after firing — the emotional refractory.
128
+ * A high-salience wound must not light up every turn. [v1: 2] CAL. */
129
+ AFFECT_REFRACTORY_TURNS: number;
130
+
131
+ // ── render ───────────────────────────────────────────────────────────────
132
+ /** Composed byte budget for the WHOLE injection, sentinel included. The host
133
+ * owns the real ceiling (scar §2.18) and passes it in; this is the default. CAL. */
134
+ BUDGET_BYTES: number;
135
+ /** Bytes of gist rendered per surfaced item before elision. CAL. */
136
+ GIST_BYTES: number;
137
+ /** Bytes of title rendered per footnote. CAL. 80 → 150 on 2026-09-14
138
+ * (IMPROVEMENTS U2): a title authored at session_end runs past 80 and was
139
+ * clipped mid-clause, and an 80-character title with one multi-byte dash
140
+ * lost its tail to the byte cap. Migrated titles are STORED at 80
141
+ * characters and render exactly as before. Six footnotes at 150 bytes plus
142
+ * ids and framing is ~1,100 bytes against a 2,048 default budget. */
143
+ FOOTNOTE_TITLE_BYTES: number;
144
+ /** Fraction of the budget above which a pressure tripwire fires (scar §2.4:
145
+ * every budget gets an event when it is approached, not only when it blows). */
146
+ BUDGET_PRESSURE: number;
147
+ /** Latency budget for the BUILD pass, milliseconds. On overrun: nothing
148
+ * injected, nothing buffered, no telemetry, no state written. CAL. */
149
+ BUDGET_MS: number;
150
+
151
+ // ── gate state ───────────────────────────────────────────────────────────
152
+ /** Cap on remembered per-session surfacing records. The store has no meta
153
+ * expiry (INTERFACE-GAPS.md #1), so the row bounds itself. CAL. */
154
+ MAX_SESSION_RECORDS: number;
155
+ }
156
+
157
+ export const TUNABLES: RecallTunables = {
158
+ MIN_CUE_LENGTH: 3,
159
+ MAX_CUES: 24,
160
+ PER_CUE_FETCH: 24,
161
+ AMBIGUOUS_WEIGHT: 0.5,
162
+ CARRY_DECAY: 0.5,
163
+
164
+ // MEASURED 2026-09-04 on a copy of the live store (15,421 indexed documents,
165
+ // mean 106 indexed tokens, max 3,184 — a 30x spread). Ambient recall returned
166
+ // the same nine memories of 9–20 KB for every topic across two unrelated
167
+ // sessions, judged 0-of-9 relevant by the instance that lived them, and 12 of
168
+ // 19 turns then read "all-gated" because those nine were spent.
169
+ //
170
+ // `tools/recall-bench` swept one-sided x b ∈ {0, 0.5, 0.75, 1.0} x
171
+ // cap ∈ {inf, 3, 2} — 23 cells — over the 13 prompts of that conversation.
172
+ // What the grid says, in order:
173
+ // - b = 0 (no normalization) is the bug: 31 of 32 delivered items were hubs,
174
+ // on 13 of 13 turns.
175
+ // - THE CAP ALONE MAKES IT WORSE. At b = 0, cap = 3 took hub hits from 31 to
176
+ // 52 — capping the hubs' sums compresses the turn's variance, which lowers
177
+ // the relative bar and admits MORE of them. The ceiling is the second half
178
+ // of this rule and is not a substitute for the first.
179
+ // - every b >= 0.5 takes hub hits to zero, at every cap and either sidedness.
180
+ // So b is chosen on what it COSTS, and the labeled positives decide:
181
+ // b = 1.0 loses one labeled positive (a long quoted passage) from the
182
+ // deliberate answer; cap = 2 loses a second one from it.
183
+ // - ONE cell in the grid delivers an AMBIENT labeled positive —
184
+ // one-sided, b = 0.5, cap = 3, which footnotes a third (a correction the
185
+ // owner once gave) on turn 4.
186
+ // Nothing else in 23 cells does, and "0 of 9 delivered footnotes were
187
+ // relevant" is the finding this change exists to move. It also carries the
188
+ // fewest recurring ids of the hub-free cells (7 ids / 33 of 79 deliveries,
189
+ // against 9 / 38 for two-sided b = 0.75) and keeps both deliberate
190
+ // positives. So: 0.5, clamped, cap 3 — not BM25's textbook 0.75, which is
191
+ // what the grid was expected to pick and did not.
192
+ // The bench measures the LEXICAL channel only (no embeddings on authored
193
+ // memories, and the bench passes no turn vector), so it is a floor, not a
194
+ // forecast. CAL.
195
+ CUE_TF_SATURATION: 1.0,
196
+ CUE_LENGTH_NORM: 0.5,
197
+ CUE_LENGTH_ONE_SIDED: true,
198
+ CUE_DOC_CAP: 3.0,
199
+
200
+ SEMANTIC_WEIGHT: 1.0,
201
+ SEMANTIC_SEED_FLOOR: 0.45,
202
+ SEMANTIC_TOP_M: 8,
203
+ ARRIVAL_WEIGHT: 0.15,
204
+
205
+ // 1.2 -> 1.6 (CAL, 2026-09-04). Once length normalization stopped nine hubs
206
+ // from setting every turn's variance, the relative bar admitted far more:
207
+ // over the 13-prompt bench, delivered items went from 2.5 to 6.1 per turn.
208
+ // 1.6 takes that to 4.8 without losing any of the four labeled positives; at
209
+ // 2.0 the ambient positive goes. Scale-free by construction — it is a count
210
+ // of standard deviations — which is why it is the volume knob that shipped
211
+ // and the absolute floors below are not. `tools/recall-bench --gate-sweep`.
212
+ SNR_GLOBAL: 1.6,
213
+ SNR_STRONG: 2.5,
214
+
215
+ // ── THE FLOORS, RE-EARNED. In cue units: multiples of one maximally-rare
216
+ // cue, `informativeness(1, storeSize)` (`gate.ts#floorUnit`).
217
+ //
218
+ // MEASURED 2026-09-04 on a copy of the live store (14,431 live memories,
219
+ // unit = 8.88), over the same 13 real prompts as `CUE_LENGTH_NORM` above.
220
+ // With document frequency finally COUNTED rather than read off the length of
221
+ // a bounded top-K (`store/cache.ts#docFrequency`), each turn's best candidate
222
+ // lands at, in units:
223
+ //
224
+ // turn 3 → 0.88 ("thanks, as before interesting to chat with you. where
225
+ // would you like to take the conversation from here?")
226
+ // turn 2 → 1.86 · 13 → 2.13 · 4 → 3.13 · 6 → 3.19 · 10 → 3.19
227
+ // turn 12 → 3.28 · 9 → 3.55 · 1 → 3.88 · 11 → 4.20
228
+ // turn 8 → 4.68 · 5 → 4.70 · 7 → 5.17
229
+ //
230
+ // The near-contentless turn is now FOUR TIMES below the busiest, on a scale
231
+ // that says the same thing at N=17 and N=15,000 — which is what the relative
232
+ // bar could never give (it ranked turn 3 FIRST, at 3.5 sd over its own thin
233
+ // background). And the scale-freeness is checked at the other end rather than
234
+ // asserted: a hermetic 17-memory fixture whose turn cleanly cues one memory
235
+ // lands at 3.00 units, INSIDE the live store's 0.88-5.17 band, where before
236
+ // this change the same fixture sat two orders of magnitude below the floors.
237
+ //
238
+ // `FLOOR_GLOBAL_UNITS` — hard gate (b), admission. A FIFTH of one
239
+ // maximally-rare cue: below that a candidate was grazed, not cued. Swept at
240
+ // 0 / 0.5 / 1.0 against the 13 prompts; 0 and 0.5 are identical (37
241
+ // deliveries, 2.8 per turn) and 1.0 costs six deliveries for nothing the
242
+ // targets asked for, so anywhere in [0, 0.5] is free on this corpus and the
243
+ // value is chosen at the OTHER end — by the weakest signal a channel is
244
+ // allowed to offer at full strength. That is a temporal arrival
245
+ // (`prospective.CUE_STRENGTH` 0.5 units) and an ambiguous handle
246
+ // (`AMBIGUOUS_WEIGHT` 0.5 of a cue that is itself rarely maximal): measured
247
+ // at 0.41 units for a two-way "Robin" on an eight-memory store. 0.2 sits
248
+ // under both with room. Zero is not an option — a floor of zero is the dead
249
+ // knob this change exists to retire.
250
+ //
251
+ // `FLOOR_STRONG_DEFAULT_UNITS` — the loud tier. Sorted, the thirteen best
252
+ // candidates leave their widest upper gap between 4.20 and 4.68, and 4.5 sits
253
+ // in it: loud on 3 of 13 turns (23%, against a target of "at most about one
254
+ // in four"), turn 3 silent, all four labeled positives kept. 4.0 gives 4 of 13
255
+ // and 3.5 gives 6 of 13 — the same knee read one notch looser; 5.0 gives 1 of
256
+ // 13, which is a different claim than "rarely". CAL.
257
+ FLOOR_GLOBAL_UNITS: 0.2,
258
+ // EMPTY, AND THE EMPTINESS IS THE MEASUREMENT. v1 shipped a per-kind shape
259
+ // (self/person/entity 0.6, place 0.8, skill/fact 1.0) because in v1 the kinds
260
+ // sat on different activation scales — person peaked near 0.79 where craft
261
+ // material floored at 1.0. On v2's corpus they do not: over 312 candidate
262
+ // rows from the 13 prompts, p50 runs 1.21-1.45 and p90 1.93-2.79 across
263
+ // `fact`, `person`, `self`, `skill` and `entity` — one distribution, not five.
264
+ // v2's activation is cue-driven and kind-agnostic, so there is nothing for a
265
+ // shape to correct. Scar §2.8 says a knob ships measured or disabled: the
266
+ // MECHANISM of §9 G12 stays (a kind that earns an override gets one), and
267
+ // v1's unearned numbers do not ride along inside it.
268
+ FLOOR_STRONG_BY_KIND_UNITS: {},
269
+ FLOOR_STRONG_DEFAULT_UNITS: 4.5,
270
+ MIN_CUE_FRACTION: 0.5,
271
+ SAL_BAR_WEIGHT: 0.5,
272
+ SAL_SORT_WEIGHT: 0.5,
273
+ MAX_CANDIDATES: 24,
274
+
275
+ COLD_START_MIN_STORE: 15,
276
+ // 0.7 on v1's cosine scale -> 0.4 CUE UNITS: TWICE `FLOOR_GLOBAL_UNITS`, so
277
+ // "cold start is stricter, not looser" is arithmetic rather than a comment.
278
+ // The old number could not be carried across because the two scales do not
279
+ // meet — on an eight-memory store one cue unit is 1.50, so v1's 0.7 was 0.47
280
+ // units there and 0.08 units on the live store: the same numeral meaning two
281
+ // different bars, which is the whole finding. CAL.
282
+ COLD_START_FLOOR_UNITS: 0.4,
283
+ COLD_START_MAX_CANDIDATES: 3,
284
+ MIN_BACKGROUND_SAMPLE: 3,
285
+
286
+ NEAR_DUPLICATE: 0.85,
287
+ // 2 -> 1 (CAL, 2026-09-04). §3 says the loud tier is for RARELY, and after
288
+ // length normalization it fired on 13 of 13 real turns. A cap could not fix
289
+ // the TURN count — only a floor can, and the floor above now does (3 of 13) —
290
+ // but the cap is what bounds a single turn, it is scale-free, and it halves
291
+ // what the owner reads uninvited. Left at 1: with the loud floor in place the
292
+ // cap binds on no turn of the 13, so raising it back to 2 would be trading a
293
+ // measured bound for an unmeasured one.
294
+ MAX_SURFACED: 1,
295
+ MAX_FOOTNOTES: 6,
296
+
297
+ AFFECT_MIN_EMOTION: 0.7,
298
+ AFFECT_REFRACTORY_TURNS: 2,
299
+
300
+ BUDGET_BYTES: 2048,
301
+ GIST_BYTES: 240,
302
+ FOOTNOTE_TITLE_BYTES: 150,
303
+ BUDGET_PRESSURE: 0.9,
304
+ // 250 → 1200 on day 0 of the parallel run (2026-09-03): the first recall in a
305
+ // fresh process — every hook is one — measured 794–819 ms warming the page
306
+ // cache over a 263 MB token index after the worker's writes, and 5 of 6 real
307
+ // turns aborted. bansai runs its surfacing at 800 ms; 1200 covers the measured
308
+ // cold case with headroom. The structural fix (why the index churns after each
309
+ // cycle) is the day-1 watch; this is the calibration that makes recall exist
310
+ // in the meantime. CAL.
311
+ BUDGET_MS: 1200,
312
+
313
+ MAX_SESSION_RECORDS: 200,
314
+ };
315
+
316
+ export function withTunables(overrides: Partial<RecallTunables> = {}): RecallTunables {
317
+ return { ...TUNABLES, ...overrides };
318
+ }
319
+
320
+ /**
321
+ * The loud-tier floor for one kind, in ACTIVATION, from the per-kind override
322
+ * table and the declared fallback (§9 G12). `unit` is `gate.ts#floorUnit` — the
323
+ * weight of one maximally-rare cue on this store — because the table is in cue
324
+ * units and a floor has to be a number in the same space as an activation before
325
+ * it can refuse one.
326
+ */
327
+ export function strongFloor(t: RecallTunables, kind: string, unit: number): number {
328
+ return (t.FLOOR_STRONG_BY_KIND_UNITS[kind] ?? t.FLOOR_STRONG_DEFAULT_UNITS) * unit;
329
+ }
@@ -0,0 +1,293 @@
1
+ # `remember/` — CONTRACT
2
+
3
+ ## 1. Purpose
4
+
5
+ The authorship contract: the experiencer writes its own memories at session end, jots in
6
+ the moment where the host allows, and a transcript sweep exists only as the crash fallback.
7
+
8
+ ## 2. Brain analog
9
+
10
+ Hippocampal encoding — binding a lived experience into a durable trace while the context
11
+ is still present. **Named deviation** (constitution line 12): in humans encoding is
12
+ involuntary; here it is authored. That is the whole thesis of this module, and its risk is
13
+ named honestly — an author can decline to write, where a hippocampus cannot. The mitigation
14
+ is that the ask is ambient (constitution line 8) and its coverage is measured, not assumed.
15
+
16
+ ## 3. Keeps
17
+
18
+ - **The lived mind writes its own memory.** [v0] v0 had the authorship shape right: the
19
+ model that lived the conversation wrote the dump, and a one-line strength formula did the
20
+ filing. [v1] behavioral-spec §4.1: an in-session proposal is "honored, not re-judged."
21
+ - **Encoding sits as close to the lived experience as the host allows.** [v1]
22
+ earned-mechanism (decisions-triage 08-05), now constitution line 2 nearly verbatim.
23
+ - **Self-assessed signals outrank inferred ones.** [v1] §4.1 G1 — stated inside the
24
+ narration block, not in the system prompt, so a stretch with no narration is not told to
25
+ narrow toward nothing.
26
+ - **A self-authored proposal is minted by the engine, not paraphrased by a sweep.** [v1]
27
+ §4.1 G2 — routing it through an interpreter returns the author's own words as someone
28
+ else's paraphrase and its self-assessment as someone else's guess.
29
+ - **Self-assessed salience is a floor, mechanized.** [v1] §4.1 G3 (the clamp now lives in
30
+ `physics/` §5.2 and governs every memory).
31
+ - **Coverage is claimed by hash, by the engine, and coverage means down-weight, not
32
+ deletion.** [v1] §4.1 G4 — successive writes *partition* a session rather than each
33
+ claiming the backlog. What the fallback loses is permission to write the same memory
34
+ twice, not sight of the material.
35
+ - **A rejected proposal claims no coverage.** [v1] §4.1 G5.
36
+ - **Coverage marks are prompt-side only** — never in the text the gates check, *so no gate
37
+ can be loosened by a mark the engine wrote.* [v1] §4.1 G6.
38
+ - **A malformed proposal degrades to an ordinary span**, read by the fallback. [v1] §4.1 G8.
39
+ - **Deliberate deposits are idempotent by CONTENT, not by span text.** [v1] §4.1 G9.
40
+ - **Every session-ending path is a boundary** — normal stop, session end, and
41
+ pre-compaction. Compaction destroying the transcript must not destroy the day. [v1] §2 G5
42
+ — the compaction-amnesia backstop, and the reason a fallback exists at all.
43
+ - **A span is never lost between read and encode**: the read cursor advances only after a
44
+ successful append; content-hash dedup makes the retry idempotent. **Bounded duplication
45
+ is an acceptable failure; loss is not.** [v1] §2 G2.
46
+ - **Two dedup layers, both needed** — a per-session read cursor for a growing transcript,
47
+ a content hash for exact repeats. Hash dedup alone cannot catch cursor regression,
48
+ because a superset slice hashes differently. [v1] §2 G3–G4.
49
+ - **Claim/consume is atomic-rename choreography, not a mutex**; the claim is truncated only
50
+ after results are applied *and* persisted; a failed restore forbids consuming the claim.
51
+ [v1] §2 G6–G7, [engram E6].
52
+ - **Every scope holding experience gets swept**, not only the one whose boundary fired.
53
+ [v1] §2 G9.
54
+ - **Conversational text only** — tool output, file contents, images, and injected context
55
+ never enter capture, and this is a **declared blind spot**. [v1] §2 G10.
56
+ - **Foreign material never enters** — text ANOTHER memory system's hooks put into the
57
+ host's context is `foreign`, and `enters()` refuses it outright (unlike `injected`,
58
+ which is kept and merely unpaced). Added for the parallel run beside v1: without it,
59
+ each system encodes the other's briefing as a memory of having thought it.
60
+ - **This system's OWN ritual text never enters either** — an ask this system emitted, read
61
+ back off a host that returns hook output into the model's context, is `ritual`, and
62
+ `enters()` refuses it. Foreign's mirror image: the failure there is encoding someone
63
+ else's words as ours, the failure here is encoding our own words as something that
64
+ happened to us. Both refusals are COUNTED in `CaptureResult.excluded`, so a boundary
65
+ that captured nothing because everything was excluded is distinguishable from a boundary
66
+ where nothing happened.
67
+ - **Boundaries are appenders, not thinkers.** Capture completes in microseconds; the host
68
+ never waits on a model call at a boundary. [v1] §2 G1, [engram E4].
69
+
70
+ ## 4. Drops / simplifies
71
+
72
+ - **The transcript-reading interpreter is demoted from primary path to crash fallback**
73
+ (owner decision 2026-08-25, settled). The experiencer writes at session end with lived
74
+ context (rung 2 of the authorship ladder); in-the-moment jots run where the host allows
75
+ them; transcript interpretation runs **only** when the experiencer never got the pen.
76
+
77
+ **What "crashed" means, mechanically** (owner ruling 2026-09-04, closing the adapter's
78
+ open question 3; implemented as `SpanBuffer.crashedSessions`). A session is crashed
79
+ when all three hold:
80
+
81
+ 1. it holds **uncovered spans** — something nobody authored;
82
+ 2. it has recorded **no `session-end` boundary**, ever;
83
+ 3. it has had **no boundary activity for `CRASH_STALE_MS`** (12 hours, CAL — see
84
+ `tunables.ts` for the measurement that set it and the falsifier still owed). A
85
+ session that recorded *no* boundary at all is therefore not crashed either: nothing
86
+ of it has ended, and its author may still get the pen.
87
+
88
+ Nothing else is swept. Not an ordinary Stop — the ask goes out at every Stop and the
89
+ author still has the pen. Not `pre-compaction` on its own: compaction destroying the
90
+ transcript is answered by the **capture** at that boundary, which is unconditional;
91
+ the sweep only follows if that session then never comes back. A host with no
92
+ end-of-session event has every session swept once it goes quiet, which is the intended
93
+ degradation for a host that cannot ask.
94
+
95
+ **Why the rule needed teeth.** The demotion was written here on 2026-08-25 and the
96
+ implementation drifted: the worker spawned at every Stop and the sweep took every
97
+ uncovered span it could see. Measured 2026-09-04 on the live store — one evening
98
+ billed 13 chunks and minted 61 memories beside 34 the model had authored itself,
99
+ producing paraphrase twins no dedup threshold can merge. A contract a mechanism does
100
+ not keep is a comment.
101
+
102
+ **Three named costs**, since this rule buys its savings with them:
103
+
104
+ - **Up to one ask-interval of trailing turns per session is never encoded** unless the
105
+ model deposited. A session that ends normally is never swept, so anything after its
106
+ last authored deposit is forgotten — by design (constitution 3: forget the trials),
107
+ but it is a real loss and it is this rule's price.
108
+ - **Those spans stay in the buffer.** Nothing consumes the spans of a session that
109
+ ended normally, so `buffer.jsonl` grows with every such session. Bounded growth is
110
+ not designed for here; it is named as open question 5 rather than pre-solved
111
+ (constitution 15).
112
+ - **An idle-but-alive session past the window is indistinguishable from a crash** and
113
+ will be swept. If its author later writes, that stretch has twins after all — which
114
+ is the measurement `CRASH_STALE_MS` owes: count sessions swept-then-authored. The
115
+ live store already produced one 4h07m idle-then-resume gap, which is why the window
116
+ is 12 hours and not the hour first proposed.
117
+
118
+ And the recovery is **delayed, never lost**: a crashed session's spans wait for the
119
+ first worker run past the window, which needs a boundary in *some* session to spawn
120
+ one.
121
+
122
+ **The fallback reads as ITSELF, not as a stranger** (owner ruling 2026-09-17). Ahead of
123
+ the transcript its prompt carries a WAKE — composed by the same composer a live session's
124
+ wake uses, but *not* the same bundle: no prospective/horizon lane, no protected and no
125
+ confidential rows, and against the reported budget whole where a live wake first reserves
126
+ its preface. It is built at most once per sweep, lazily, on the first chunk that reaches
127
+ the interpreter, against a byte cap (`SWEEP_WAKE_BYTES`, or the host's ordinary wake
128
+ budget) — and the reader is told to write in the first person, in its own voice, as the
129
+ author would have at the time. What makes a model call "me" is the
130
+ memory it wakes with; read cold, the fallback wrote the owner's own day back as
131
+ paraphrase (`docs/finding-12-diagnosis-2026-09-17.md`: 888 fallback memories against 193
132
+ authored). Three limits are mechanized, not intended: the wake is composed read-only and
133
+ moves no rotation or published bundle; confidential and protected rows never enter it,
134
+ because this prompt leaves the machine (constitution 6); and the memories it produces are
135
+ still `source: fallback`, so the authored/fallback ratio stays legible. A store with
136
+ nothing to say, or a host that reported no ceiling, carries no wake and behaves exactly
137
+ as before.
138
+ - **The v1 self-store tool is superseded by experiencer authorship** — self-writing became
139
+ the primary path, not silently dropped. Its doctrine is kept whole (lived salience is the
140
+ only legitimate identity input); only its delivery shape is gone. A tool the model must
141
+ remember to call is not ambient (constitution line 8), and v1's `selfstore.append`
142
+ recorded zero fires in the month after ship. **The starved-front-door lesson is the
143
+ design requirement here**: if the doctrine names the only legitimate inputs, those inputs
144
+ must be reachable **by construction** — which the end-of-session ask is and a tool
145
+ description is not.
146
+ - **The interpreter's chunked-sweep machinery shrinks with its role**, but does not
147
+ disappear: the fallback still chunks with per-chunk failure isolation, still guards
148
+ `stop_reason`, still streams, still restores on throw (scars E1, E2, E3, E6). A fallback
149
+ that runs after a crash is exactly the path that must not lose the day.
150
+ - **Threads/loops are not a special structure.** An open loop is an ordinary memory with an
151
+ `unresolved` flag, carrying salience, decay, and dedup like everything else; it closes
152
+ when a later memory declares `updates:` on it. This is v1's own recorded v2 direction
153
+ (§6.3): "as a special structure outside the memory model it became the one data type in a
154
+ forgetting-is-a-feature system that never forgets — and its exception tax was a whole bug
155
+ family."
156
+ - **Per-session gate state is persisted** rather than reconstructed per turn — see
157
+ `recall/`, where the decision belongs. Named here because span capture and gate state
158
+ share the session lifetime.
159
+
160
+ ## 5. Contract
161
+
162
+ **Inputs** — the session's turns since the last boundary; session identity, scope, the
163
+ lived day and the moment; the observer predicate; jots deposited in-session; on the
164
+ fallback path, claimed spans, their schema slices, and the composed wake the interpreter is
165
+ woken with.
166
+ **Outputs** — proposals handed to `encode/`; a claim record; coverage claims by hash; the
167
+ assistant's own turns kept separately (the substrate for "was a surfaced memory actually
168
+ used?"); telemetry by reference — including, since 2026-09-05, the gate's own per-gate
169
+ records RELAYED unread from the verdict to whoever writes the durable row (replay
170
+ INTERFACE-GAPS §2a; this module still never gates and never reads them).
171
+
172
+ **Guarantees** — **[M]** mechanized, **[A]** advisory:
173
+
174
+ 1. **[M] The host never waits on a model call at a boundary.** Capture is an append;
175
+ authorship and any fallback run detached, under a watchdog whose timeout is validated
176
+ against the lock-staleness window (scars E4, E5).
177
+ 2. **[M] Capture never throws into the host.** Every failure is logged and swallowed.
178
+ 3. **[M] Advance-after-success**, two-layer dedup, per-(scope, session) cursors, rename
179
+ choreography, restore-before-consume — all four, all structural.
180
+ 4. **[M] Restore-on-throw**: an outage means the arc is *retried*, not lost. The consumer
181
+ commits its output or restores its input; a test kills it mid-arc and asserts the input
182
+ is still claimable (scar E6). "Returned nothing" and "failed" are distinguishable in the
183
+ log (scar §2.4). **Retry is BOUNDED**: the sweep records each span's failures by lived day, and on
184
+ the `MAX_SPAN_FAILURES`-th distinct day the span is *quarantined* — written out in full, counted, and never
185
+ swept again — so a permanently-failing span cannot bill one model call per boundary
186
+ forever. Retried, then set aside; never silently dropped (NOTES §13).
187
+ 5. **[M] The engine claims coverage, never the author** — the author cannot see the buffer.
188
+ 6. **[M] A rejected proposal claims no coverage.**
189
+ 7. **[M] Coverage marks never enter gated text.**
190
+ 8. **[M] Observer sessions capture nothing, ask for nothing, and write nothing** — checked
191
+ at the store seam, not only at the entry point (scar E7).
192
+ 9. **[M] Dedup survives a re-read of overlapping content.** The transcript-compaction
193
+ cursor case — a superset slice hashes differently, so hash dedup misses it — is a v1
194
+ hypothesis that was never verified and carries into v2 **as a test to write**, not as
195
+ an assumption (scar list, "considered and excluded").
196
+ 10. **[M] No model-supplied identifier is trusted as an address without a fallback.** The
197
+ author declares `updates: <id>`; the engine validates that the id resolves, and on a
198
+ miss falls back to **content matching** against candidate memories — score and margin
199
+ both required, ambiguity refuses, the author's hint is a tiebreak inside the margin and
200
+ can never defeat a refusal, and score/margin/method are logged as provenance
201
+ (scar §2.5). A miss costs nothing durable: the memory still lands.
202
+ 11. **[A] The ask's wording is load-bearing and is part of the spec** — first person, the
203
+ author's own voice, what happened and what mattered, how it felt, what was learned
204
+ about the person and about oneself. It sanctions honesty about a routine stretch and
205
+ closes *"write for the next you, not as a report."* Wording is a preference; that an
206
+ ask exists at every session-ending path is mechanized.
207
+ 12. **[M] Coverage of the session is measured, not assumed.** The stretch after the last
208
+ session-ending event that nobody can ask about is **bounded and logged**, so the miss
209
+ is measurable before anyone debates a reconstruction fallback (§13 known gap: *that is
210
+ the right shape for an unfixable gap — bound it, measure it, don't pretend*).
211
+ 13. **[M] The fallback reads a transcript only for a CRASHED session**, by the
212
+ three-clause definition in §4, and every run records which of the two it was —
213
+ `sweep.gate` in the durable log carries `ran`, `skippedNotCrashed` and the window it
214
+ used, so "no sweep today" is a fact about the day and not a silence that could also
215
+ be a dead worker (constitution 16, scar §2.4). The gate is answered **before** the
216
+ claim, so a scope with nothing crashed costs no rename and no model call.
217
+ 14. **[M] A span can be destroyed on the owner's say-so, and only on the owner's say-so.**
218
+ The buffer holds lived experience verbatim, so "anything can be removed loudly"
219
+ (constitution 6/7) has to be true of it too — it was not, and a removed note's words
220
+ survived in `jots.jsonl` where a later backup copied them (LAUNCH-STATUS §I2). The
221
+ door is `owner-strike-seam.ts`, reachable only by importing that file: the buffer
222
+ hands it a capability at construction, `WRITE_SITES` carries `strike` so an
223
+ instrument's stand-down covers it, and a caller-universality test pins the two files
224
+ allowed to import it. It rewrites each text-bearing stream WITHOUT the struck lines,
225
+ by the same rename-aside choreography a claim uses, after recording the struck hashes
226
+ in the terminal ledger — so a re-capture, a restore and an orphan merge all refuse to
227
+ re-admit them. **Nothing is ever RAM-only across a destructive step**: survivors sit
228
+ on disk in the aside until a durable append has landed, and a crashed strike's aside
229
+ is folded home unconditionally by the next one, whatever that one was asked to do.
230
+ **A predicate may only ever take a jot** — a conversation span is many turns joined
231
+ and belongs to no single memory. It records counts and never a hash or a word
232
+ (§16 G9). One window is NAMED rather than closed: a worker already holding a claim in
233
+ memory finishes its arc (NOTES §14).
234
+
235
+ ## 6. Scars honored
236
+
237
+ **E1** (chunked fallback with per-chunk isolation) · **E2** (one client chokepoint; a
238
+ truncated response is a failure, not data) · **E3** (long generations stream) · **E4**
239
+ (detached execution + watchdogs; a worker that *cannot start* escalates rather than
240
+ re-logging the same line forever) · **E6** (buffer-restore-on-throw) · **E7** (observer
241
+ deposits nothing) · **§2.4** (returned-nothing versus failed are distinct records) ·
242
+ **§2.5** (the author proposes semantics; the engine resolves references) · **§2.16** (every
243
+ declarable field carries an admission test and a named negative example — v1's
244
+ `thread.open` shipped with no criteria and produced 33 opens and 0 closes in 13 days) ·
245
+ **§2.17** (a write path is not done until its read path has fired on real input).
246
+
247
+ ## 7. Open questions
248
+
249
+ 1. **The `remember`/`encode` boundary** — the module map's third standing check-in
250
+ question. See `encode/CONTRACT.md` open question 1; the two modules must be decided
251
+ together.
252
+ 2. **What does the fallback actually cost when it runs?** v1 ran the sweep as the primary
253
+ path, so there is no measurement of a sweep that only ever runs post-crash. Its blind
254
+ rate, its yield, and whether it needs the full preselection machinery are all unknown at
255
+ this scale. **Narrowed 2026-09-04**: the gate now makes the question answerable — count
256
+ `sweep.gate` rows with `ran > 0` against the days they cover.
257
+ 3. **Where do jots live between deposit and boundary** — in the buffer with spans, or as
258
+ already-formed proposals in the operational database? The second is simpler; the first
259
+ makes the ordering guarantees uniform.
260
+ 4. **Does the experiencer see its own `updates:` candidates?** It must, or every revision
261
+ degrades to content matching. But showing a census of ids is precisely what produced
262
+ v1's confabulation incident (scar §2.5: 7 of 8 rejected thread ids existed in the
263
+ schema, in a different section, in the identical `- [el_id]` format).
264
+ 5. **What retires the spans of a session that ended normally?** (Opened 2026-09-04 by the
265
+ crash gate.) Nothing does: they are never claimed, so the buffer keeps them. On the
266
+ parallel run's volume that is kilobytes a day and a file the owner can read, which is
267
+ why no pruner is built here (constitution 15) — but the growth is real, unbounded, and
268
+ should be watched. The candidate answers, in order of preference: a coverage-driven
269
+ retirement that consumes covered spans without any model call; an age-based sweep of
270
+ the buffer on the lived-day clock; nothing at all, if the measured growth stays
271
+ trivial.
272
+ 6. **A session that moved scope is judged per scope — and since 2026-09-17 no session on
273
+ the Claude Code adapter moves.** `crashedSessions` reads one scope's
274
+ `boundaries.jsonl`, so a session that captured under scope A and then ended under
275
+ scope B leaves A holding only `stop` boundaries — and A's spans for it are swept once
276
+ the window passes, even though the author did get the pen elsewhere. PR-1 found 11 real
277
+ session ids under more than one scope; the 2026-09-17 diagnosis found one session whose
278
+ spans were in four, its deposits in one, and 298 fallback memories with zero authored
279
+ ones in two worktree scopes. The CAUSE was in the adapter, not here: the hook payload's
280
+ `cwd` follows the agent into a worktree and was being used as the capture scope. That
281
+ adapter now files a session under one directory for its whole life
282
+ (`claude-code/CONTRACT.md` §5 G13), so the per-scope judgement below sees one scope per
283
+ session. The property itself is UNCHANGED and is still the right residual to record: an
284
+ embedder that hands this module two scopes for one session gets exactly the behaviour
285
+ described, and nothing here enforces otherwise. Stores written before that date keep
286
+ their split, by ruling: they are not repaired.
287
+ 7. **Is 12 hours the right window?** `CRASH_STALE_MS` is CAL and shipped enabled. It was
288
+ raised from a guessed 60 minutes after the live store falsified that number — session
289
+ `c781252f` sat idle 4h07m with its author still holding the pen, then resumed and
290
+ authored 20 more notes. The falsifier is unchanged and still owed: sessions swept under
291
+ this rule that later received an authored deposit. The other direction now has a cost
292
+ too — a genuinely crashed session waits up to half a day for its fallback, which is
293
+ only a delay but is a longer one than before.