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,137 @@
1
+ /**
2
+ * `COUNTERPARTS_OBSERVER` and `COUNTERPARTS_OWNER`, read the way the guard next
3
+ * door is read — and failing in the direction each of them is *for*.
4
+ *
5
+ * THE DEFECT (LAUNCH-STATUS G39). Two adapters matched these variables by exact
6
+ * string: `cli/commands.ts` and `mcp/bin/serve.ts#launchOptions` both accepted
7
+ * only the untrimmed `"1"` and `"true"`. One directory over,
8
+ * `COUNTERPARTS_REQUIRE_EXPLICIT_DIR` accepts `1|true|on`, trimmed and
9
+ * case-insensitive, and `store/paths.ts` says in a comment that observer is
10
+ * "deliberately NOT widened" *pending its own ruling* — because #80 promised to
11
+ * leave the live MCP server's launch path instruction-for-instruction identical
12
+ * and would not spend that promise on an unrelated variable. G39 is that ruling
13
+ * (HANDOFF 2026-09-08 item 4), and this module is where it lands.
14
+ *
15
+ * So `COUNTERPARTS_OBSERVER=True`, `=on`, or `= 1 ` — every one of which a
16
+ * person who read the guard's own documentation would reasonably type — now
17
+ * mean what they look like instead of silently meaning "ordinary session".
18
+ * The arming and disarming word lists are IMPORTED from the guard rather than
19
+ * retyped: two lists that must agree and are written twice have already begun
20
+ * to disagree.
21
+ *
22
+ * THE TWO FAIL DIRECTIONS ARE OPPOSITE, AND BOTH ARE "LESS POWER".
23
+ *
24
+ * - **Observer: junk ⇒ observer.** `docs/observer-mode.md` G5, "fail toward
25
+ * standing down: a config-load failure resolves to observer", mechanized in
26
+ * in `core/observer.ts`'s predicate — an unreadable stance value there already
27
+ * resolves to observer rather than to "encode anyway". A variable this
28
+ * cannot read is an unreadable stance, so it resolves the same way. Note
29
+ * that this is the OPPOSITE of the explicit-dir guard's junk handling, which
30
+ * REFUSES the process outright, and deliberately: refusing is fail-closed
31
+ * for a guard whose whole job is to stop a run, and standing down is
32
+ * fail-closed for a stance whose whole job is to withhold writes. An
33
+ * observer MCP server still answers every read; a refused one answers
34
+ * nothing and the host reports "MCP server failed". Withholding the writes
35
+ * is the smaller, more recoverable failure, and it is the one the module's
36
+ * own doctrine already names.
37
+ * - **Owner: junk ⇒ not owner.** Same principle, opposite boolean, because
38
+ * the boolean's polarity is opposite: `owner` GRANTS reach and `observer`
39
+ * WITHHOLDS it, so least privilege is `false` for one and `true` for the
40
+ * other. It is the same helper either way — only the collapse of the
41
+ * malformed case differs, one line apart, which is why they are read here
42
+ * together rather than one of them being left behind.
43
+ *
44
+ * Junk is never silent in either direction: the reading carries the text, and
45
+ * the caller prints one line (`unreadableStanceLine`) on the surface it has —
46
+ * stderr for the MCP server, `io.err` for the console. A stance that changed
47
+ * because a shell had a typo in it must be legible in the transcript, or the
48
+ * next person debugs the tool instead of the variable (scar §2.4).
49
+ */
50
+ import { EXPLICIT_DIR_ARMING_VALUES, EXPLICIT_DIR_DISARMING_VALUES } from "../core/store/index.js";
51
+
52
+ export const OBSERVER_ENV = "COUNTERPARTS_OBSERVER";
53
+ export const OWNER_ENV = "COUNTERPARTS_OWNER";
54
+
55
+ /** What a boolean environment variable says, read without judgement. */
56
+ export type EnvSwitch =
57
+ /** `1`, `true` or `on`. */
58
+ | { readonly state: "on" }
59
+ /** `0`, `false` or `off` — present, and saying no. */
60
+ | { readonly state: "off" }
61
+ /** Unset, or blank. */
62
+ | { readonly state: "absent" }
63
+ /** Present and not a word this reads; `value` is the text, as typed after trimming. */
64
+ | { readonly state: "malformed"; readonly value: string };
65
+
66
+ /**
67
+ * The same three readings the explicit-dir guard takes, from the same two word
68
+ * lists: trimmed, case-insensitive, blank is absent. Pure; never throws.
69
+ */
70
+ export function readEnvSwitch(
71
+ env: Record<string, string | undefined>,
72
+ name: string,
73
+ ): EnvSwitch {
74
+ const raw = (env[name] ?? "").trim();
75
+ if (raw.length === 0) return { state: "absent" };
76
+ const word = raw.toLowerCase();
77
+ if (EXPLICIT_DIR_ARMING_VALUES.includes(word)) return { state: "on" };
78
+ if (EXPLICIT_DIR_DISARMING_VALUES.includes(word)) return { state: "off" };
79
+ return { state: "malformed", value: raw };
80
+ }
81
+
82
+ /** A stance bit, and the text that could not be read if there was one. */
83
+ export interface StanceReading {
84
+ readonly on: boolean;
85
+ /** Null unless the variable held something this would not guess at. */
86
+ readonly malformed: string | null;
87
+ }
88
+
89
+ /**
90
+ * OBSERVER. A flag beats the environment; junk STANDS DOWN (G5, above).
91
+ */
92
+ export function observerFromEnv(
93
+ env: Record<string, string | undefined>,
94
+ flag = false,
95
+ name: string = OBSERVER_ENV,
96
+ ): StanceReading {
97
+ const reading = readEnvSwitch(env, name);
98
+ if (flag) return { on: true, malformed: reading.state === "malformed" ? reading.value : null };
99
+ switch (reading.state) {
100
+ case "on":
101
+ return { on: true, malformed: null };
102
+ case "malformed":
103
+ return { on: true, malformed: reading.value };
104
+ default:
105
+ return { on: false, malformed: null };
106
+ }
107
+ }
108
+
109
+ /**
110
+ * OWNER. A flag beats the environment; junk is NOT owner — least privilege
111
+ * again, and for this variable least privilege is the other boolean.
112
+ */
113
+ export function ownerFromEnv(
114
+ env: Record<string, string | undefined>,
115
+ flag = false,
116
+ name: string = OWNER_ENV,
117
+ ): StanceReading {
118
+ const reading = readEnvSwitch(env, name);
119
+ if (flag) return { on: true, malformed: reading.state === "malformed" ? reading.value : null };
120
+ return {
121
+ on: reading.state === "on",
122
+ malformed: reading.state === "malformed" ? reading.value : null,
123
+ };
124
+ }
125
+
126
+ /**
127
+ * The one sentence a surface prints when a stance variable could not be read.
128
+ * It names the variable, quotes the value as typed, says what it did INSTEAD,
129
+ * and lists the words that work — so the remedy needs no second document.
130
+ */
131
+ export function unreadableStanceLine(name: string, value: string, resolvedTo: string): string {
132
+ return (
133
+ `[counterparts] ${name} is set to '${value}', which is not a value this reads — ` +
134
+ `${resolvedTo}. It takes ${EXPLICIT_DIR_ARMING_VALUES.join(", ")} for yes and ` +
135
+ `${EXPLICIT_DIR_DISARMING_VALUES.join(", ")} for no (case and surrounding whitespace ignored).`
136
+ );
137
+ }
@@ -0,0 +1,118 @@
1
+ # `associate/` — CONTRACT
2
+
3
+ ## 1. Purpose
4
+
5
+ Memories that come to mind together become linked: co-activation strengthens a typed,
6
+ valenced edge, and recall spreads activation across those edges.
7
+
8
+ ## 2. Brain analog
9
+
10
+ Hebbian plasticity — "cells that fire together wire together" — plus spreading activation
11
+ through the resulting associative network. **Named deviations** (constitution line 12):
12
+ (a) credit is **retrospective and graded** — full only when the reply actually used the
13
+ memory, weak when it surfaced unused, **zero for the merely footnoted**, where in humans
14
+ every retrieval trains; (b) homeostasis is enforced structurally (a per-node edge cap and
15
+ a bounded outgoing weight with proportional renormalization) rather than emerging from
16
+ metabolic limits.
17
+
18
+ ## 3. Keeps
19
+
20
+ - **Credit is retrospective and graded, and the ignorable tier does not train.** [v1]
21
+ behavioral-spec §10 G1 — resolved at the boundary, with the reply known.
22
+ - **Homeostasis is structural.** [v1] §10 G2 — the strength-saturation scar prevented in
23
+ edge space rather than patched after.
24
+ - **Evicted edges are archived, never dropped.** [v1] §10 G3 — no-silent-destruction
25
+ applies to learned structure too; the archive may over-record on a crash but must never
26
+ lose the only record of an eviction.
27
+ - **At most once, and the direction of the failure is chosen.** [v1] §10 G4 — the write
28
+ ordering is picked so a crash **drops one flush's deltas rather than applying them
29
+ twice**. Doubling is what the contract rules out; bounded loss is inside tolerance. (v1's
30
+ earlier ordering silently inverted this.)
31
+ - **Cross-process exclusion with skip-on-busy**, and a buffer drain bounded to what was
32
+ read, so a concurrent arrival is never deleted unflushed. [v1] §10 G5.
33
+ - **The declared durability exemption.** [v1] §10 G6 — per-turn deltas may buffer in fast
34
+ mutable state and batch-flush at the boundary: **a crash loses at most one session's
35
+ reinforcement, never a memory.** *Declared rather than discovered* is the part that
36
+ travels.
37
+ - **A failed publish emits no success telemetry.** [v1] §10 G7 — an event claiming an
38
+ update that never landed is worse than silence.
39
+ - **Spreading activation is bounded**: a hop limit with per-hop decay, and fan
40
+ normalization so a hub node does not flood. [v1] §9 TUNABLE (v1: 2 hops, hop decay 0.5,
41
+ fan normalization on).
42
+ - **An erased or pruned id must stop conducting.** [v1] scar §2.2 — v1's erase deleted edge
43
+ rows from the index and then `rebuild()` reloaded the edge file wholesale and
44
+ **resurrected them**, so the erased id kept conducting activation between its former
45
+ neighbors: an association fingerprint that outlived the content.
46
+
47
+ ## 4. Drops / simplifies
48
+
49
+ - **The hand-serialized edge file is gone.** Edges live in the canonical operational
50
+ database as rows (owner rescope 1, settled). This removes the whole class the harvest
51
+ named: ghost edges, the flush-ordering inversion, the erase-then-rebuild resurrection —
52
+ all three were sidecar bugs, and prose files never minted one (scar §2.1).
53
+ - **The learned-edge type coupling becomes a decision instead of an inheritance.**
54
+ **PROPOSED** — owner call at check-in. In v1, learned co-activation edges were written as
55
+ the same type the activation pass boosts by 1.6×, so learning silently rode a multiplier
56
+ intended for *stated* relations. Whether learned edges should be privileged over stated
57
+ ones is a real question; this contract asks it rather than inheriting an answer.
58
+ - **Weak credit's numeric weight is not inherited.** It ships bounded by fixtures naming
59
+ what breaks on each side, or disabled (scar §2.8).
60
+
61
+ ## 5. Contract
62
+
63
+ **Inputs** — the surfacing decision record (what was surfaced, footnoted, and with what
64
+ activation); the assistant's reply and the reference-resolution verdict; the memory graph;
65
+ the lived day; the observer predicate.
66
+ **Outputs** — edge weight deltas, buffered per turn and flushed at the boundary — or
67
+ drained to the pending file when the boundary is a different process from the pass
68
+ (`pending.ts`, claimed and flushed there); archived eviction records; activation vectors
69
+ for `recall/`; telemetry by reference.
70
+
71
+ **Guarantees** — **[M]** mechanized, **[A]** advisory:
72
+
73
+ 1. **[M] Footnotes never train.** The ignorable tier is ignorable in both directions.
74
+ 2. **[M] Per node, the edge count is capped and the total outgoing weight is bounded**,
75
+ with proportional renormalization.
76
+ 3. **[M] Every eviction is archived before the edge is removed.**
77
+ 4. **[M] At most once**: the flush ordering guarantees a crash loses deltas rather than
78
+ double-applying them, and a test asserts the direction, not merely the invariant.
79
+ 5. **[M] A contended flush skips and stays buffered**; the drain is bounded to what was
80
+ read.
81
+ 6. **[M] A failed publish emits no success event.**
82
+ 7. **[M] Observers train nothing**, checked before any other work (scar E7).
83
+ 8. **[M] A removed id's edges are removed everywhere and cannot be resurrected by a
84
+ rebuild** — asserted by a test that erases a node, rebuilds the cache, and checks that
85
+ activation no longer flows between its former neighbors (scar §2.2).
86
+ 9. **[M] Pinned or under-audit memories are frozen in both directions** — an arc under
87
+ audit does not change mid-audit.
88
+ 10. **[A] Hop count, hop decay, and fan normalization are knobs**, recorded with v1's
89
+ calibration and re-earned here.
90
+ 11. **[M] The durability exemption is declared in this contract and nowhere else.** Any
91
+ second place that buffers non-reconstructible state fails review.
92
+
93
+ ## 6. Scars honored
94
+
95
+ **E5** (rescoped: edges are transactional rows, not a hand-serialized file with three
96
+ writers) · **E7** (observers train nothing) · **E8** (base-level decay on lived days) ·
97
+ **§2.1** (multi-writer structured state needs a transaction) · **§2.2** (a removed id must
98
+ stop conducting; supersede retargets edges too — v1's `gist.merge` set `merged_into` and
99
+ nothing re-pointed the edges, so successors started cold) · **§2.4** (no success telemetry
100
+ for a publish that did not land) · **§2.8** (credit weights ship measured or disabled) ·
101
+ **§2.17** (edges have an exit path — eviction — and its count is reported).
102
+
103
+ ## 7. Open questions
104
+
105
+ 1. **Should this module exist at all?** *The module map's standing check-in question:*
106
+ **fold `associate/` into `physics/` (the update is math) plus `recall/` (the traversal
107
+ is retrieval)?** The case for folding: constitution line 10 says one brain function per
108
+ module, and "Hebbian linking" may be two halves of functions that already have homes —
109
+ the weight update is arithmetic like every other number on `physics/`'s page, and
110
+ spreading activation is the first stage of retrieval. The case against: the durability
111
+ exemption (§10 G6) and the flush ordering are a *lifecycle* neither host module owns,
112
+ and burying a declared exemption inside a larger module is how declared things become
113
+ discovered things. **Left open deliberately — the owner decides at check-in.**
114
+ 2. **Are learned edges the same kind of thing as stated relations?** See §4. v1 answered by
115
+ accident; either answer is defensible, and the answer changes what activation means.
116
+ 3. **Does an association need a valence at all** if strength already carries readiness? v1
117
+ typed and valenced its edges and the harvest does not record the valence ever being
118
+ read.
@@ -0,0 +1,173 @@
1
+ # `associate/` — interface gaps
2
+
3
+ What this module needed from a neighbour and worked around instead of editing. Each
4
+ entry names the owner, the workaround now in the code, and what the real fix looks
5
+ like. Nothing here is implemented in `associate/` — these are decisions for the seam.
6
+
7
+ ## 0. Nothing was stubbed
8
+
9
+ `physics/` supplied the decay curve (`decayCurve`) and the tier vocabulary
10
+ (`UseTier`); `store/` supplied the edge rows, the transactional `linkMany`, the
11
+ deny-list and the observer stance. **No local stub of a store or of physics exists
12
+ in this module.** The only physics symbol imported is `decayCurve` — the edge
13
+ arithmetic is this module's by the module-map ruling, but the CURVE FAMILY is not
14
+ redefined here.
15
+
16
+ ## 1. `recall/` has no fourth channel yet — the traversal is exported, not wired
17
+
18
+ **Owner:** `recall/` (its NOTES.md §7 already names the seam: "when `associate/`
19
+ ships, its hops feed a fourth channel and the gate does not change").
20
+ **Have:** `spread(input, tunables)` — a pure function — and `Associate.spreadFrom()`,
21
+ which supplies the store-backed `edgesFrom` and `conducts`. Both are exported and
22
+ tested. **`recall/` is untouched** (no-cross-edits).
23
+ **The wiring, when someone does it:** in `recall/activate.ts`, after the cue and
24
+ semantic channels have produced their candidate set, call `spreadFrom(seeds, day)`
25
+ with the cued candidates as seeds and add each `Contribution.activation` to the
26
+ matching candidate's activation.
27
+
28
+ **And the one real collision, which is recall's call to make, not associate's:**
29
+
30
+ > A hop contribution can reach a memory **no cue and no embedding touched**. Recall's
31
+ > hard gate (a) — *an uncued memory is dark, whatever its salience* — is currently
32
+ > STRUCTURAL: an uncued memory is never fetched, so its salience arithmetic is never
33
+ > evaluated. A hop channel that can *create* a candidate converts that structural
34
+ > property into a checked one.
35
+
36
+ Three defensible answers, and the choice belongs to whoever owns the gate:
37
+ (a) hops **modulate only** — a contribution is added to candidates that already
38
+ exist and never mints one (keeps gate (a) structural, and is the conservative
39
+ default); (b) hops may mint candidates but are excluded from `cueFraction`, so a
40
+ hop-only memory can reach the footnote tier and never the loud one (the closest
41
+ analogue to §9 G9's single-channel tier cap); (c) hops count as conversation. This
42
+ module takes no position — `spread()` returns contributions and says which depth
43
+ each came from, which is what any of the three needs.
44
+
45
+ ## 2. `store/` has no eviction archive for edges — "removal" is a zeroed weight
46
+
47
+ **Owner:** `store/` (box 2).
48
+ **Needed:** contract G3 — "every eviction is archived BEFORE the edge is removed",
49
+ and the archive "may over-record on a crash but must never lose the only record of
50
+ an eviction".
51
+ **Have:** an `edges` table with `(src, dst)` as the primary key, `INSERT OR REPLACE`
52
+ through `link`/`linkMany`, and — correctly — **no delete of any kind** anywhere in
53
+ the store's surface.
54
+ **Workaround:** an evicted edge is written to **weight 0**. It stops conducting
55
+ (below `EDGE_FLOOR`), stops counting toward the per-node live-edge cap, and the
56
+ eviction is reported in `FlushReport.evictions` (with its prior weight) and evented
57
+ as `associate.edge.evicted`. So the eviction is *observable* and its count is
58
+ *reported* (scar §2.17) — but the prior weight survives only in the event ring and
59
+ the returned report, both of which are in-memory and bounded.
60
+ **Consequence, stated plainly:** an eviction that happens in a process that then
61
+ dies leaves the row at zero with no durable record of what it used to be. That is
62
+ weaker than G3 asks for.
63
+ **Real fix (store's call):** an `edges_archive` table in box 2 —
64
+ `(src, dst, weight, last_day, evicted_day, reason)`, append-only — written inside
65
+ the same transaction as the zeroing row, so the archive lands before (or with) the
66
+ eviction and can only ever over-record. `Store.linkMany` would take the archive rows
67
+ alongside the edge rows, or a sibling `evictEdges(rows)` would do both.
68
+
69
+ ## 3. No cross-process exclusion — skip-on-busy is in-process only
70
+
71
+ **Owner:** `store/` (or a shared lock primitive; SEAMS is the right registry).
72
+ **Needed:** contract G5 — "cross-process exclusion with skip-on-busy, and a buffer
73
+ drain bounded to what was read".
74
+ **Have:** the drain half is real and tested (`DeltaBuffer.drain()` swaps the map, so
75
+ a concurrent arrival lands in the fresh one and is never deleted unflushed). The
76
+ exclusion half is a **single-process reentrancy guard** (`Associate.flushing`),
77
+ which is enough for one host process with a hook that can re-enter, and nothing at
78
+ all for two processes.
79
+ **Why it was not built here:** the honest options were a `meta` row (read-modify-write
80
+ — scar §2.1's exact shape, and `recall/INTERFACE-GAPS.md` §1 already records that
81
+ trap) or a lock file at the top level of the data dir (which `Store.assertLayout()`
82
+ would reject as an unclassified path, correctly). Both are worse than declaring the gap.
83
+ **Real fix:** a lock the operational database can hold — a `locks` table with an
84
+ owner token and an expiry, taken and released inside box 2's transaction, or an
85
+ advisory `BEGIN IMMEDIATE` seam exposed by the store.
86
+
87
+ **Until then the flushers are the WORKERS, one per boundary** — the credit pass does
88
+ not flush at all. It drains its buffer to `sessions/association/pending.jsonl`
89
+ (`pending.ts`) and the boundary's detached worker claims that file by renaming it
90
+ aside, absorbs the deltas and flushes them in its own process
91
+ (`counterpart.ts#applyPendingAssociations`). **Each pass is claimed by exactly one
92
+ worker**, because the rename is atomic and a second claimant meets an ENOENT. Two
93
+ workers running at once are still two flushers, and the failure mode of two flushers
94
+ is not corruption (`linkMany` is one transaction and rows are absolute) but a
95
+ lost-update race between two absolute writes — inside the same "bounded loss, never
96
+ doubling" tolerance the contract already accepts.
97
+
98
+ **Two residuals of the claim, named rather than hidden.** (a) A claim whose apply
99
+ fails is left on disk and retried by a later run, so nothing is lost; a claim that
100
+ was applied and then could not be REMOVED (the `rmSync` and the rename-aside that
101
+ follows it both failing) would be applied a second time, which is the doubling G4
102
+ rules out. It is counted — `stuck` on the `associate.flush` row and a
103
+ `counterpart.associate.claim.stuck` event — rather than assumed away. (b) A claim
104
+ file renamed aside as `.applied` after a failed remove is never claimed again and is
105
+ never cleaned up either; on the machine where that has happened, it is a file of
106
+ counts and ids sitting in `sessions/association/claims/`.
107
+
108
+ ## 4. Nobody calls `retargetOnSupersede` — supersede does not know about edges
109
+
110
+ **Owner:** `store/` and whoever owns revision (scar §2.2: "supersede retargets edges
111
+ too — v1's `gist.merge` set `merged_into` and nothing re-pointed the edges, so
112
+ successors started cold").
113
+ **Have:** `Associate.retargetOnSupersede(oldId, newId, day)`, tested: the successor
114
+ inherits the old head's live edges symmetrically, by `max` (so a re-run cannot
115
+ inflate), and the old rows stay put and simply stop conducting.
116
+ **Gap:** `Store.supersede()` returns a new id and knows nothing about `associate/`,
117
+ which is right — the store must not depend on a core module above it. So the call
118
+ belongs to whichever layer composes them (the boundary adapter, or `sleep/` when a
119
+ consolidation supersedes). **Until someone wires it, every supersede leaves the
120
+ successor cold**, which is the scar, live again.
121
+
122
+ ## 5. The credit tiers arrive from a reference-resolution step that has no home
123
+
124
+ **Owner:** the boundary adapter (`recall/INTERFACE-GAPS.md` §5 records the same gap
125
+ from the other side).
126
+ **Needed:** `coactivate(members)` takes `{id, tier}` — the tier being §9.2's
127
+ retrospective verdict, resolved with the reply known.
128
+ **Have, since the credit seam landed:** `Counterpart.creditReferences` resolves the
129
+ tiers once (`recall/reference.ts`) and hands the SAME list to both halves —
130
+ `recall.resolveUse` per memory, `associate.coactivate` for the set. Two independent
131
+ resolutions would be two clocks, and there is one.
132
+ **And the flush goes with it (2026-09-17).** `coactivate` buffers in process and
133
+ `flush()` publishes, so the two must run in the same process or nothing is ever
134
+ written. Deferring the flush to the session boundary is only safe where the boundary
135
+ is the same process; on this host every hook is a fresh one, and for the whole of
136
+ the parallel run the buffer died at hook exit. What crosses the process line now is
137
+ the FILE: the credit pass drains its buffer into `sessions/association/pending.jsonl`
138
+ (`pending.ts`) and the boundary's worker claims it and flushes it
139
+ (`counterpart.ts#applyPendingAssociations`). `sessionEnd`'s own flush is what a
140
+ single-process caller still gets, and it runs before the carried claims.
141
+
142
+ ## 6. `store.edgesFrom(src)` is the only edge read
143
+
144
+ **Owner:** `store/`.
145
+ **Have:** outgoing edges for one node. No `edgesInto`, no enumeration, no count.
146
+ **Consequences, both accepted here:** (a) symmetry is maintained by *writing* both
147
+ directions, never by reading backwards — which is why `planFlush` emits two rows per
148
+ pair; (b) the per-node count cap and its evictions are therefore **directional**: a
149
+ hub evicting its edge to a quiet node does not touch the quiet node's edge back, so
150
+ the pair can conduct one way and not the other until the quiet node's own flush
151
+ settles it. That is defensible (synapses are directional) but it is a consequence of
152
+ the read surface, not a decision.
153
+ **Real fix if a dashboard or a hygiene sweep needs it:** `edgesInto(dst)` and an
154
+ `edgeCount()`/`edges(limit, offset)` enumeration. A dead-edge sweep (rows sitting at
155
+ zero forever) also has no home today.
156
+
157
+ ## 7. Guarantee 9 is half-reachable: there is no "under audit" flag
158
+
159
+ **Owner:** `self/` or whoever owns the audit/protected vocabulary.
160
+ **Needed:** "pinned or under-audit memories are frozen in both directions — an arc
161
+ under audit does not change mid-audit."
162
+ **Have:** `MemoryRow.protected`. Associate refuses to accumulate any delta touching
163
+ a protected endpoint (`frozen-protected`, tested). **"Under audit" has no
164
+ representation in v2's schema at all**, so that half of the guarantee is unreachable
165
+ rather than unimplemented. Recorded rather than invented — a flag minted here would
166
+ be a second vocabulary for a concept another module owns.
167
+
168
+ ## 8. The observer predicate still lives in `store/`
169
+
170
+ Not a defect, and recorded so nobody "fixes" it: `Associate.observer` reads
171
+ `store.observer` and never re-derives it. `docs/SEAMS.md` queued item 4 already says
172
+ the hoist to `src/core/observer.ts` is a MOVE, not a rewrite; associate is now the
173
+ third consumer and will follow the move without changing behavior.
@@ -0,0 +1,194 @@
1
+ # `associate/` — implementation notes
2
+
3
+ Where the contract was silent, ambiguous, or asked for machinery this build has not
4
+ earned yet. Each entry says what was decided and why, so the next session argues with
5
+ a recorded choice rather than re-deriving one.
6
+
7
+ ## 1. Why the edge arithmetic is here and not on `physics/`'s page
8
+
9
+ The contract's open question 1 ("should this module exist at all?") is closed by the
10
+ module map's 2026-08-25 ruling: `associate/` stays a module. This build takes the
11
+ ruling literally in both directions — **all** the edge arithmetic lives in
12
+ `edges.ts` (increment, cap, lived-day decay, count cap, renormalization), and
13
+ `physics/` gains nothing. The one import across that line is `decayCurve`: edges
14
+ decay on the same CURVE FAMILY as memories, with their own stability constant
15
+ (`S_EDGE = 30` against memory's `S_BASE = 60`). That is what "a physics-family
16
+ curve, own constants" means, and it is why there is no second `Math.exp` in this
17
+ directory.
18
+
19
+ ## 2. Weak credit ships DISABLED, and that is the contract's instruction
20
+
21
+ Contract §4: *"Weak credit's numeric weight is not inherited. It ships bounded by
22
+ fixtures naming what breaks on each side, or disabled (scar §2.8)."* No such fixture
23
+ exists, so `EDGE_WEAK_CREDIT = 0`: today only a **referenced × referenced** pair
24
+ mints an edge. v1's weak reinforcement weight (0.25, `physics.TUNABLES.W_SURFACED`)
25
+ is recorded in the tunable's comment as the calibration to re-earn, deliberately not
26
+ wired in — reusing it here would be inheriting exactly the number §4 says not to
27
+ inherit, and *edge* credit is not the same quantity as *strength* credit anyway.
28
+
29
+ The consequence is worth stating: with weak credit at zero, a surfaced-but-unused
30
+ memory is reported as `ignorable-tier`, the same reason a footnote gets. They are
31
+ not the same thing — one is structural and permanent (a footnote must never train),
32
+ the other is a disabled knob. `tierFactor()` keeps them separate in the code:
33
+ `footnoted` returns a literal `0`, `surfaced` returns the tunable.
34
+
35
+ ## 3. `HEBB_RATE` has no ancestry, and says so
36
+
37
+ v1's harvest records the tier STRUCTURE of credit (§10 G1) and never an edge
38
+ increment, so unlike most constants here there is no v1 calibration to quote. 0.1 is
39
+ an assistant-chosen starting point with a stated shape — ten fully-credited
40
+ co-activations reach the cap — in the same class as `physics.PHI_PRUNE`: CAL, no
41
+ provenance, and `tools/replay` is where it gets earned.
42
+
43
+ ## 4. Decay is REALIZED at flush, which is why the shape is pinned
44
+
45
+ Two ways to carry edge decay: keep the weight fixed and decay lazily at every read
46
+ (pure, and what `edgeWeightAt` does for reads), or realize the decay into the stored
47
+ weight whenever the row is rewritten (`weight := decayed`, `last_day := d`). This
48
+ build does both, and they agree **only because the curve is exponential**:
49
+ `w·e^(-Δ₁/S)·e^(-Δ₂/S) = w·e^(-(Δ₁+Δ₂)/S)`. A flat or power-law edge curve would make
50
+ the realized value depend on how often the row happened to be rewritten — the same
51
+ "two clocks" fiction physics avoids.
52
+
53
+ So `EDGE_DECAY_SHAPE` is pinned to `"exponential"` and the tunable's comment says
54
+ changing it requires a `last_reinforced_day` column, not a new constant. Note that
55
+ this is a deliberate divergence from `physics.DECAY_SHAPE`, whose three-way is
56
+ decided by replay: memories may end up on a power law while edges stay exponential,
57
+ and that is fine — they are different quantities on different clocks.
58
+
59
+ ## 5. Symmetry is written, not read — and it can legitimately break
60
+
61
+ `store.edgesFrom(src)` is the only edge read (INTERFACE-GAPS §6), so a pair is kept
62
+ symmetric by writing **both** directed rows, never by reading backwards. Two places
63
+ where the two directions then diverge, both accepted:
64
+
65
+ - **Renormalization** scales one node's outgoing edges. A hub over its outgoing
66
+ bound scales its edge to a quiet node; the quiet node's edge back is untouched.
67
+ - **Eviction** is per node. A hub past `MAX_EDGES_PER_NODE` zeroes its weakest edge;
68
+ the other endpoint keeps its edge to the hub until its own flush settles it.
69
+
70
+ Both are true to the analog (synapses are directional and scale locally), and both
71
+ are visible: `linked()` is symmetric-by-conjunction, `weightAt()` is directional.
72
+
73
+ ## 6. Three traversal choices the contract left open
74
+
75
+ 1. **Seeds receive no contribution.** A round trip (a → b → a) would hand a seed its
76
+ own activation back as if the graph had independently proposed it. Contributions
77
+ are what the graph ADDS; the seed's own activation is the caller's.
78
+ 2. **Contributions SUM across paths; depth keeps the shallowest arrival.** Two
79
+ co-active seeds pointing at the same memory really is more evidence than one.
80
+ First-arrival-only was the alternative and is also defensible; this one is the
81
+ standard spreading-activation shape, and `Contribution.paths` makes the
82
+ difference inspectable.
83
+ 3. **A node is expanded once**, at the shallowest depth it was reached. With the
84
+ hop limit at 2 the difference is small; it is what keeps a dense graph from
85
+ re-walking itself.
86
+
87
+ Also: a non-conducting destination is excluded from the **fan denominator**, not
88
+ merely from the output. An erased id must not even shape the arithmetic between its
89
+ former neighbours — if it stayed in the denominator, erasing a memory would quietly
90
+ weaken every hop out of the nodes it used to touch.
91
+
92
+ ## 7. Guarantee 9 is implemented on `protected` only
93
+
94
+ A protected endpoint freezes the pair in both directions (`frozen-protected`), and
95
+ the freeze is checked at BOTH ends of the buffer's life: at accumulation, so a
96
+ protected memory's edges are never even pending, and again at publish, so a pin that
97
+ lands between the turn and the boundary still freezes the arc it was meant to freeze
98
+ — an arc that goes under audit mid-session must not change. "Under audit" itself has
99
+ no flag in v2's schema;
100
+ inventing one here would mint a second vocabulary for a concept another module owns.
101
+ Recorded in INTERFACE-GAPS §7 rather than approximated.
102
+
103
+ Note the freeze deliberately does NOT try to stop decay on a frozen memory's
104
+ existing edges. Decay is a pure function of stored state and elapsed lived days;
105
+ "frozen" here means *this module writes nothing about that memory*, which is the
106
+ honest reading of a freeze that must survive a crash.
107
+
108
+ ## 8. Deltas are dated at the FLUSH, not at the turn
109
+
110
+ The buffer holds `{a, b, delta}` and no day. A session that crosses the active-day
111
+ boundary therefore credits its co-activations to the flush day. The error is bounded
112
+ by one lived day and lands in the same tolerance §10 G6 already declares for the
113
+ buffer; carrying a per-delta day would mean either N transactions or planning
114
+ against several "current" weights for one edge, and neither is earned.
115
+
116
+ Relatedly: **there is no one-occasion-per-lived-day cap on edges**, though there is
117
+ one on memories (`physics.creditUse`). Repeated co-activation across a day's turns
118
+ is genuine repeated co-activation, and `EDGE_CAP` already bounds where it can get to.
119
+ If replay shows a single chatty session saturating a pair, the fix is a per-flush
120
+ delta cap, named, not a silent one-per-day rule copied over from a different
121
+ quantity.
122
+
123
+ ## 9. Open question 2, answered as a build default: learned edges are NOT privileged
124
+
125
+ The contract asks (and §4 flags as an inheritance v1 never decided): *are learned
126
+ co-activation edges the same kind of thing as stated relations?* v1 wrote learned
127
+ edges as the same type its activation pass boosted by 1.6×, so learning silently
128
+ rode a multiplier intended for stated relations.
129
+
130
+ **This build ships one weight and no type multiplier at all.** There is no edge
131
+ `type` column in box 2, no valence, and nothing in `spread()` that could privilege
132
+ one edge over another except its weight. That is the simplest brain-faithful rule
133
+ that could work (Amendment 15) and it makes the question answerable later with
134
+ evidence: if replay shows stated relations need to out-pull learned ones, the fix is
135
+ a typed edge with a measured multiplier, and the harvest's "1.6×" is a starting
136
+ point, not a default. The owner may overrule this at any check-in; it is recorded as
137
+ a default, not a ruling.
138
+
139
+ Open question 3 ("does an association need a valence at all?") is answered the same
140
+ way and for the same reason: no valence is stored, because the harvest never records
141
+ v1's valence being read.
142
+
143
+ ## 10. Deliberately NOT built (Amendment 15 — complexity is earned)
144
+
145
+ - **A typed/valenced edge vocabulary** — see §9.
146
+ - **A durable eviction archive** — INTERFACE-GAPS §2; eviction is a zeroed weight
147
+ plus a report and an event, and the archive table is the store's call.
148
+ - **Cross-process locking** — INTERFACE-GAPS §3; the in-process guard is real, and a
149
+ meta-row lock would rebuild scar §2.1 inside a transactional database.
150
+ - **A dead-edge sweep.** Zeroed rows accumulate (bounded by `MAX_EDGES_PER_NODE` per
151
+ node, so the table cannot grow without bound in the count-cap direction). Whoever
152
+ builds hygiene should sweep them; nothing here depends on it.
153
+ - **`edgesInto` / whole-graph enumeration** — INTERFACE-GAPS §6.
154
+ - **Wiring the traversal into `recall/`** — the gate decision is recall's
155
+ (INTERFACE-GAPS §1), and this module must not edit it.
156
+
157
+ ## 11. The declared durability exemption is declared in exactly two places
158
+
159
+ `associate/CONTRACT.md` §5 G11 and the header of `buffer.ts`. Contract G11 says any
160
+ second place that buffers non-reconstructible state fails review; this note is the
161
+ pointer, not a third declaration. Everything in the buffer is an increment to
162
+ learned structure that the next co-activation re-earns — a crash loses at most one
163
+ session's reinforcement, never a memory.
164
+
165
+ ## 12. The pending file, and why the hook does not flush (2026-09-17)
166
+
167
+ `coactivate` buffers and `flush` publishes, and on the host this ships against those
168
+ two run in different processes: the credit pass is inside a Stop hook, the boundary
169
+ is inside the detached worker that Stop spawns. The buffer died at hook exit for the
170
+ whole parallel run — 430 edges in the owner's store, every one stamped with the
171
+ import's lived day, through 214 credit passes.
172
+
173
+ The first repair moved the flush into the hook. It worked, and it put two SQLite
174
+ writes on a path that meets the worker's own write lock: an adversarial probe
175
+ measured 5.3 s apiece under a held lock (I38's scenario, `database is locked` in 3 of
176
+ 8 runs), with the drained deltas then recorded nowhere durable at all. **The
177
+ direction of a failure is a choice** (§10 G4), and "the hook waits ten seconds and
178
+ then loses the work silently" is not the choice this module makes.
179
+
180
+ So the pass drains to a file and the worker applies it (`pending.ts`). Three things
181
+ are worth writing down:
182
+
183
+ - **The claim is a rename, and the file is removed only after the apply.** A claim
184
+ whose apply met a busy database is left where it is and retried; nothing is lost,
185
+ and the row that eventually lands says how old the carried work was. The residual —
186
+ an applied claim that cannot be removed would be applied twice — is counted on the
187
+ row (`stuck`) rather than assumed away.
188
+ - **The cap drops the NEWEST pass, not the oldest line.** Dropping the oldest would
189
+ mean rewriting a file that other hook processes are appending to. A delta is
190
+ re-earnable; somebody else's line is not.
191
+ - **Where it lives is a deploy fact, not a taste.** `assertLayout()` runs in the
192
+ store's constructor, so a new top-level name would stop every store opened by code
193
+ that predates it — and after a deploy, the MCP servers of running sessions are that
194
+ code. `sessions/` is already classified, and the file is a subdirectory inside it.