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,298 @@
1
+ # `sleep/` — CONTRACT
2
+
3
+ ## 1. Purpose
4
+
5
+ The librarian: pure physics on a cycle — the decay refresh, dedup, consolidation, floor
6
+ pruning, and re-rendering the wake briefing. No standing model calls.
7
+
8
+ ## 2. Brain analog
9
+
10
+ Systems consolidation during sleep: replay, schema integration, synaptic downscaling, and
11
+ the pruning of what was never used. **Named deviations** (constitution line 12): (a) it runs
12
+ as boundary-time micro-sleeps rather than one nightly block, because a session end is when
13
+ the material is freshest and the host is idle; (b) it prunes at the floor — human forgetting
14
+ is loss of access, not deletion, and this module deletes, loudly and on physics' verdict
15
+ alone.
16
+
17
+ ## 3. Keeps
18
+
19
+ - **The cycle moves MEMORIES, and the journal is not one.** [added 2026-09-04, measured]
20
+ An episode is the owner's first-person account and the source a memory was made from —
21
+ "context and source, in that order, ingested ONCE as an ordinary memory"
22
+ (`self/episodes.ts`). Forgetting applies to what was minted FROM an episode, never to the
23
+ episode itself (constitution 6: the owner owns the data, in prose readable in any editor;
24
+ 7: memory changes like human memory — a claim about memories). Every phase here was
25
+ written when every row in the store was a memory; episodes only became real when the
26
+ chapter door shipped, and on the live store all **224 migrated episodes sit in the
27
+ episodic band at zero on every salience dimension**, so the floor prune would have
28
+ archived the entire journal — and an archived episode stops reconciling, so the memories
29
+ it had not yet minted would never exist.
30
+ - **Detached from the host, single writer, hard watchdog.** [engram E4, v1 §5 G1] — one
31
+ lock; a live holder inside its lease is respected; a stale lease is reclaimed
32
+ **atomically**, so N simultaneous reclaimers produce exactly one winner. (v1's earlier
33
+ unlink-then-create reclaim produced two live writers and a double-ticked clock.)
34
+ - **Two watchdog levels and a cross-key invariant binding them** — configuration **refuses**
35
+ any setting where the hard kill could land after the lock becomes reclaimable. *The
36
+ single-writer lease depends on a wedged runner dying before its lock can be taken.*
37
+ [v1 §5 G2]
38
+ - **Per-concern completion markers, advanced only after the work *and* its persist succeed**,
39
+ gating on "active day > my marker", never on a transient "is this a new day" flag. A crash
40
+ between the clock ticking and the work finishing **replays that day exactly once**. Markers
41
+ only move forward. [v1 §5 G3, engram E8]
42
+ - **A budget is not a debt** — a day the work wasn't needed is not arrears to make up.
43
+ [v1 §5 G4] *Where a phase RESUMES under that rule is a separate question, and a working
44
+ answer rather than a guarantee: `NOTES.md` §8.*
45
+ - **Phase order is behavior, not implementation.** [v1 §5 G5] The consequences that must
46
+ survive: decay runs *after* the boundary's own writes (hence the same-lived-day
47
+ reinforcement exemption); revision-dependent renders run *after* revision, so they see this
48
+ boundary's own supersedes; the briefing is the **last content write**.
49
+ - **Degrade, don't abort** — index rebuild, embedding refresh, horizon computation, backup,
50
+ and every prune each fail without failing the cycle. [v1 §5 G6]
51
+ - **The claim is truncated only after results are applied AND persisted.** [v1 §5 G7, E6]
52
+ - **Environment is pinned by the spawner, last**, so no caller can leak a run into the wrong
53
+ store. [v1 §5 G8, scar §2.13]
54
+ - **Decay's skip list is behavior, and each skip is reported separately** — archived
55
+ memories; anything under audit; **identity-band memories** (the named deviation); and
56
+ **anything reinforced the same lived day**. [v1 §11 G5]
57
+ - **Calm by default** — a quiet day produces almost no motion. [v1 §11 G8]
58
+ - **A torn clock is loud, and repair moves forward only** — clamped forward against canonical
59
+ stamps, markers snapped with it, so recovery never retro-runs history; an upgraded store
60
+ initializes markers to the present. [v1 §11 G9]
61
+ - **Expiry archives, never deletes, and names what it archived** [v1 §11 G7] — still true of
62
+ everything except the floor prune, which is the one deletion and is recorded. *(The floor
63
+ prune has since resolved toward archival — `NOTES.md` §2. What this module DOES delete,
64
+ loudly and counted, is telemetry: superseded-version rows past `H` and, since
65
+ 2026-09-05, unlatched event-log rows past the retention window — §5 G16. Neither is a
66
+ memory; v1's spec names telemetry as "the one system-path exception to no-deletion —
67
+ bounded-retention logs" (`docs/harvest/behavioral-spec.md` #17; `log-audit.md` §3
68
+ records v1's `pruneLogs` as exactly that exception), and the sweep is not silent.)*
69
+ - **Autonomous, budgeted, and loud**: at most once per lived day, on its own trigger, never
70
+ an owner chore — *"I won't remember to run random scripts occasionally."* [v1 §7 G8]
71
+ - **Over-budget is measured at full membership, not on the rendered output** — a renderer
72
+ that demotes until it fits *by construction never reports being over budget*. [v1 §7]
73
+ - **Auto-consolidation on a cycle** (v0: every 3 days) — the pass that links a memory to its
74
+ schemas and sets the consolidation bonus in `physics/` §5.2. [v0]
75
+
76
+ ## 4. Drops / simplifies
77
+
78
+ - **The librarian is pure physics with ZERO standing model calls at launch** (owner decision
79
+ 2026-08-25, settled). Definitionally: zero *generative* calls. **Embedding lookups are
80
+ permitted arithmetic** — the owner's own dedup-by-cosine decision presumes them — and they
81
+ degrade to lexical-only rather than fail (scar E1). The v1 phases that were model calls go
82
+ with their subsystems: the interpretation sweep (now a crash fallback owned by
83
+ `remember/`), the accommodation invitation (replaced by strength-weighted revision), the
84
+ gist-merge proposal pass, and the recompression proposal pass. What remains of
85
+ recompression is the render and its archive-first discipline — see open question 3.
86
+ - **The daily materialize-decay pass is released** (owner rescope 1, settled). Strength is a
87
+ pure function of stored state and the clock (`physics/` §5.4); this module refreshes the
88
+ cached column used for ranking. Because the number is derived, a replayed day is a no-op by
89
+ construction rather than by a per-item stamp. *(Amended 2026-09-14, IMPROVEMENTS U8: the
90
+ box-2 `band` column is the exception and is the band of record — the decay pass writes a
91
+ row's band back when the column disagrees with `band(m, d)`, so the table cannot contradict
92
+ the `band.transition` rows the same pass emits. Strength is still cache-only, the write
93
+ fires only on disagreement, the reconciliation counts into the phase's `changed` and is
94
+ reported as `reconciled` on the phase report and the durable `sleep.cycle` row, and
95
+ `NOTES.md` §5 carries the reasoning.)*
96
+ - **The accommodation phase, the ledger phase, and their forensics holds are gone** (owner
97
+ decision, settled) — see `schemas/CONTRACT.md` §4.
98
+ - **Hygiene's model-proposed gist merges are dropped in favour of physics dedup**: hash plus
99
+ embedding cosine, ambiguous near-dupes left alone (owner decision, settled). v1's own
100
+ record supports it — `hygiene.run` fired twice in a month.
101
+ - **Floor pruning is added, and it is the one place the system deletes.** Physics alone
102
+ decides (`physics/` §5.8); no model holds delete power on any path (owner decision,
103
+ settled). **This is a real departure from v1**, where fading was explicitly not deletion
104
+ and ~10K of 12.4K memories sat at the floor as "the thesis working, not a backlog."
105
+ Flagged, not resolved: open question 1.
106
+
107
+ ## 5. Contract
108
+
109
+ **Inputs** — the store; the lived-day clock and its completion markers; the lock; the
110
+ observer predicate; the host's reported execution ceiling.
111
+ *THE SELF PAGE does not cross into the identity band, from 2026-09-18 — and nothing else
112
+ changes. Proved reachable: forty cycles over a page carrying the physics repeated credit
113
+ leaves produced a `band.promoted` record on a row no lane can rank. The guard is the PAGE
114
+ by role, and deliberately NOT schema rows generally: `physics#decay` returns 1 for a
115
+ promoted row, so withholding the crossing from beliefs, current-states and entities would
116
+ stop them becoming decay-exempt — a retention change for three row classes across a live
117
+ store, measured at four rows crossing on master and none under the wider guard. Whether a
118
+ belief should cross at all is a real question with a one-query answer against the live
119
+ store that nobody has; it is not this change's to take. The identity core is not exempted
120
+ either, for the same reason.*
121
+ **Outputs** — a refreshed strength cache; dedup merges; consolidation links; prune verdicts
122
+ and their records; the next session's briefing, written last; a per-cycle summary vector
123
+ (content-by-reference).
124
+
125
+ **Guarantees** — **[M]** mechanized · **[A]** advisory:
126
+
127
+ 1. **[M]** Zero generative model calls, asserted by a test over this module's call graph.
128
+ Embedding calls are permitted, isolated per batch, and degrade to empty-and-logged rather
129
+ than throwing (scar E1).
130
+ 2. **[M]** Single writer, atomic stale-lease reclaim, and a configuration check that refuses
131
+ any watchdog/lease setting where a wedged runner could outlive its lock.
132
+ 3. **[M]** Every day-gated concern is idempotent under replay — by being a pure function or
133
+ by carrying a per-item stamp; a test replays each twice and asserts the second is a no-op
134
+ (scar E8).
135
+ 4. **[M]** Markers advance only after the work and its persist both succeed, and only move
136
+ forward.
137
+ 5. **[M]** Phase order is asserted, including the three consequences in §3.
138
+ 6. **[M]** Every optional phase degrades without failing the cycle, and each degradation is a
139
+ distinct record — "did not run", "ran and found nothing", and "failed" are three things
140
+ (scar §2.4).
141
+ 7. **[M]** Nothing under audit or in a live revision chain is decayed, merged, or pruned.
142
+ **What the code enforces, stated exactly** (the wording above was wider than the
143
+ predicate, and 2026-09-04's dedup finding lived in the gap): PRUNE reads
144
+ `prune.ts#inLiveRevisionChain` — a row with a forwarding address, a row with standing
145
+ pressure, or a row whose version rows still point at a successor inside `H`. That
146
+ predicate reads FALSE for a fresh successor, which has none of the three, so it never
147
+ protected the head of a chain and dedup never consulted it at all. DEDUP's protection
148
+ of the head is G9b's, by its own rule, and after it the two known ways to lose a
149
+ successor to a merge are closed. *The gap this paragraph named on 2026-09-04 — an
150
+ element whose statement collides with an ordinary memory's body with no revision
151
+ anywhere, which G9b cannot reach — is closed by **9c** below (2026-09-05). Nothing is
152
+ open under this wording today.*
153
+ 8. **[M]** Every prune is recorded — counts, kind, dates; never a body, never a content hash
154
+ (scar §2.20) — and a failed record append means nothing moves.
155
+ 9. **[M]** A memory that declares `updates:` is never merged into its target (`physics/`
156
+ §5.7) — otherwise a refutation reinforces the belief it refutes.
157
+ **9b. [M] A revision's SUCCESSOR is never the losing candidate of a same-hash merge**,
158
+ and never merges with the challenger it was minted from in either direction
159
+ (`physics/` §5.7 G8b; `dedup.ts` reads `source: "accommodation"` + `origin_ref` off the
160
+ row — the two supersede sites that mint with lineage, `schemas/index.ts` for both
161
+ element arms and `revision.ts` for the identity arm). The successor carries the
162
+ challenger's own words, so the two share a content hash BY CONSTRUCTION and G9 cannot
163
+ reach the pair — its declaration names the PREDECESSOR. The rule is "never the loser"
164
+ rather than a pair relation because a THIRD row with the same text takes the original's
165
+ seat and the pair reads false against it; an accommodation row can never legitimately
166
+ lose such a merge, since its body is its challenger's body and every same-hash group it
167
+ is in is that challenger plus twins of the same sentence. The cosine path is untouched:
168
+ a merely SIMILAR row is an ordinary near-duplicate question. *Found 2026-09-04 on the
169
+ first store that ever crossed the pressure bar: the successor lost the tie-break
170
+ (`mem_` before `sch_`), was archived `merged` on the revision's own evening, and the
171
+ revised belief stopped rendering as a belief — constitution 7. The same shape as G15's
172
+ journal finding: a phase written when identical bodies could only mean a duplicate.*
173
+ **G9b IS STILL LOAD-BEARING under 9c**, and not belt-and-braces: `schemas/index.ts`
174
+ mints element successors as `type: "schema"` (which 9c now covers), but
175
+ `revision.ts`'s IDENTITY arm mints its successor as `type: "memory"`, and for that row
176
+ G9b is the only rule between it and the challenger whose words it carries. A test
177
+ pins exactly that case.
178
+ **9c. [M] A `type: "schema"` row is never a dedup candidate, in either direction, on
179
+ either path** (`types.ts#isSchemaRow`, read where `runDedup` builds the live set, so
180
+ `contentHashCandidates` and any injected cosine source are covered by construction
181
+ rather than one at a time; an injected source that hands one over anyway is named
182
+ `schema` in the skip map, not `already-archived`). A belief or a current-state row is
183
+ a standing claim with its own machinery for changing — `schemas/` §5.6 (a belief moves
184
+ only when a challenger's force beats its inertia, and the old version is kept with
185
+ lineage), §5 G1 (no operation edits a belief), §5 G4 (near collisions refuse LOUDLY
186
+ rather than merging) — and "these two say the same thing, so they are one thing" is a
187
+ claim about NOTES. Duplicates among elements are a `schemas/` question and are
188
+ deliberately not answered here. The exclusion is narrow: two ordinary memories with
189
+ one body still merge, and a test says so. *Probe H, found by the adversarial review
190
+ 2026-09-04 and closed 2026-09-05: an `addBelief` with statement X and a memory with
191
+ body X, born the same lived day, no revision anywhere. G9b could not apply, `mem_`
192
+ sorted before `sch_`, and the belief was archived `merged` — `beliefs(entity)` empty,
193
+ constitution 7 again. Migration settles the DIRECTION of the loss and not its
194
+ frequency: `tools/migrate/apply.ts` minted every element at the import day while
195
+ migrated memories kept their v1 birth day, so on any such pair the memory is never
196
+ younger and the element always loses — but a pair needs two distinct v1 items whose
197
+ gated text is byte-identical, so the count is unknown and only a scan can give it. The
198
+ repair for stores that already lost one is `counterparts repair-merged-beliefs`
199
+ (`cli/` §5, `store/owner-op-seam.ts#unarchiveMerged`).*
200
+ 10. **[M]** Observer sessions spawn no cycle at all — a cycle advances the clock, decays the
201
+ store, and rewrites the briefing: *the instrument mutating what it measures* (scar E7).
202
+ 11. **[M]** A worker that cannot run — missing credential, unmet dependency, repeated
203
+ identical failure — escalates on the *n*th occurrence instead of re-logging the same line
204
+ forever, and its backlog depth is a reported metric (scar E4: v1's runner starved for two
205
+ days on an inherited credential and drained only when someone noticed).
206
+ 12. **[A]** Cadences — consolidation every 3 lived days, backup daily, prune dwell — are
207
+ knobs. That each has a completion marker and a tripwire is mechanized.
208
+ 13. **[M]** Created-versus-exited counts per kind are reported every cycle; a kind with a
209
+ zero exit count after the bake-in window is a defect to investigate (scar §2.17).
210
+ 14. **[M]** Band moves are counted BY DIRECTION and the count is durable — the decay
211
+ materialization diffs each row's band against its last reading and appends a latched
212
+ `band.transition` record; a first materialization is not a crossing. At cycle end those
213
+ rows feed `physics.symmetryCheck` per kind and the verdict is reported. **Below
214
+ `SYMMETRY_MIN_SAMPLE` the verdict is `never-asked`, which carries `ok: true`: every
215
+ consumer reads the REASON, never the boolean** (scar §2.4). A store whose port cannot be
216
+ asked gets no verdict and says so, rather than six `never-asked` rows claiming a counter
217
+ that does not exist was consulted. *(Added 2026-08-25 — physics guarantee 12 had been
218
+ enforced in one place and consumed by nobody, which is how v1 ran 279 up-moves against
219
+ zero down-moves for three days with a tripwire already in the codebase — scar §2.10.)*
220
+
221
+ 15. **[M]** **The journal is outside every phase.** One predicate — `types.ts#isJournal`
222
+ — is read by decay, dedup, consolidate and prune, so the rule cannot hold in three
223
+ places and lapse in the fourth. A journal row is never decayed, never given a strength
224
+ row, never moved across a band, never consolidated or promoted, never merged, and never
225
+ pruned; it is **counted as a named skip** in each phase (`journal`) rather than passed
226
+ over in silence, and G13's created-versus-exited census counts memories only, since a
227
+ chapter written today is not a memory born today and would give its kind a permanent
228
+ created-without-exit imbalance — the exact signal that counter exists to raise. What
229
+ the journal produces IS subject to everything: the ingested memory decays, consolidates,
230
+ merges and is pruned like any other. *Two findings, a day apart and the same shape:
231
+ dedup merged an ingested memory into its own episode (identical prose, identical
232
+ content hash) at the boundary that minted it; and prune would have taken the whole
233
+ migrated journal at the floor.*
234
+
235
+ 16. **[M]** **The durable event log has bounded retention, and the cycle is what bounds
236
+ it.** The `log` phase — the cycle's LAST phase, after the briefing, which stays the
237
+ last CONTENT write (§3 G5: the sweep writes no content) — calls `Store.pruneEvents`
238
+ with the phase budget as its cap. **Retention:** an unlatched row is deleted once its
239
+ lived day is older than `retentionDays` lived days (`day < livedDay − retentionDays`).
240
+ `retentionDays` is the store's option, default `DEFAULT_RETENTION_DAYS` = 90 lived
241
+ days, and **the default is pinned ≥ 90 by a test** — the parallel run reads its
242
+ evidence off this table (`tools/parallel/readers.ts`) and needs ≥ 7 active days plus
243
+ review slack, so a shorter default would destroy the run's record from under it; no
244
+ reader found on 2026-09-05 needs more (`NOTES.md` §15 lists them). **Kept by kind:**
245
+ every row the store latches with a `dedup_key` — `memory.pruned`, `memory.merged`,
246
+ `memory.unmerged`, `band.promoted`, `band.transition`, `revision.pressure`,
247
+ `gate.chunk` — is kept at any age; that is what `repair-merged-beliefs`, the owner's
248
+ read-only check (`memory.merged` rows with `sch_` losers), the symmetry counter (G14)
249
+ and `schemas.story()` read, and the phase counts them as the named skip `latched`
250
+ rather than passing over them in silence. **Bounded per pass:** at most
251
+ `TUNABLES.BUDGETS.log` (5,000) rows go per cycle, OLDEST FIRST by `seq`, so a store
252
+ swept for the first time takes its backlog a cap's worth a day; the rows left are
253
+ `skippedForBudget`, reported and never owed (§3: a budget is not a debt). **Idempotent:**
254
+ once per lived day by marker (a replayed day is `already-done-today`), and a clean
255
+ window is `ran-nothing-found` on the phase and `pruned: 0` on the store. **Observer:**
256
+ computed from the read-only census, `changed` carries the would-delete count, and
257
+ nothing is attempted. **Legible before it runs** (constitution 16): `counterparts
258
+ verify` prints the rows held, the oldest row's lived day and date, the latched count,
259
+ and what the next pass would delete. *Filed 2026-09-05 as `NOTES.md` §13: `pruneEvents`
260
+ existed, documented this window, and had no caller anywhere in `src/` — every unlatched
261
+ row ever written was still there, and the dashboard's "I keep events for N lived days;
262
+ older ones are swept" described a sweep that never ran. Owner ruling the same day: wire
263
+ it into sleep.*
264
+
265
+ ## 6. Scars honored
266
+
267
+ **E1** (per-batch isolation on the embedding refresh) · **E4** (detached execution,
268
+ watchdogs, and a starved worker that alarms) · **E5** (rescoped: one documented lock at the
269
+ seam between the owner CLI and the background worker, staleness validated against every
270
+ watchdog that can hold it, never held across a human prompt) · **E6** (restore before
271
+ consume) · **E7** (no cycle under observer) · **E8** (active-day clock, idempotent under
272
+ replay) · **§2.1** (transactional state changes) · **§2.4** (every discard logs what and how
273
+ much) · **§2.11** (the backup phase is asserted against the layout; the canonical database is
274
+ checkpointed, never copied — see `cli/`) · **§2.13** (the spawner pins the environment last) ·
275
+ **§2.17** (curation paths must fire) · **§2.20** (prune records are content-by-reference).
276
+
277
+ ## 7. Open questions
278
+
279
+ 1. **Does the floor prune actually delete?** The module map calls it "real forgetting"; v1's
280
+ §11 G6 says the opposite in as many words ("fading is not deletion... human forgetting
281
+ deletes; this only fades"), and v1's live shape — ~10K of 12.4K memories at the floor — was
282
+ read as the thesis working. Deleting is simpler and honest to constitution line 3; not
283
+ deleting costs disk and keeps a strong cue able to reach anything. **Flagged, not
284
+ resolved.**
285
+ 2. **Ebbinghaus versus flat-per-lived-day decay** — `physics/` open question 1. The choice
286
+ changes what a "calm day" looks like in this module's telemetry.
287
+ 3. **Does recompression need a model?** Shortening a statement while preserving first person,
288
+ the author's voice, and load-bearing specifics is a generative job. *Correction (adversarial
289
+ review, finding 4): v0's briefing WAS model-compressed — `generateBriefing` was an API call
290
+ instructed to fit 2,000 chars; the earlier text here inverted that evidence.* The honest
291
+ position: launch renders the briefing WITHOUT a model (rank by strength, take what fits the
292
+ budget, verbatim statements) — not because v0 did, but because Amendment 15 says the simple
293
+ rule goes first. If briefing quality fails in use with a named failure, recompression is the
294
+ first candidate to earn a model call back — and v0 is the precedent FOR that call, not
295
+ against it.
296
+ 4. **Is one lock still the right shape** when the operational box is transactional? The
297
+ remaining need is coordinating prose writes with the owner CLI — a narrower job than v1's
298
+ lock did.
@@ -0,0 +1,262 @@
1
+ # `sleep/` — interface gaps for the coordinator
2
+
3
+ *What this module needed from a neighbour and could not have, what it worked
4
+ around instead of cross-editing, and what the real fix looks like. Nothing here
5
+ is implemented in `sleep/`, on purpose.*
6
+
7
+ ## 0. What was NOT stubbed
8
+
9
+ `physics/` supplied every verdict the cycle applies — `strength`, `band`,
10
+ `promotionEligibility` / `promote`, `pruneVerdict`, `dedupVerdict`, `pressureAt`,
11
+ `supersededResolvable` — and `store/` supplied every write. **Sleep invents no
12
+ arithmetic.** The one criterion it states itself is §5 below, and it is built
13
+ only from physics' own exports.
14
+
15
+ Two seams are genuinely stubbed and both are declared: the briefing renderer
16
+ (§2) and the ranking-cache writer (§1).
17
+
18
+ ---
19
+
20
+ ## 1. `store/` — box 3 has no strength column and no box-3 writer (WORKED AROUND)
21
+
22
+ **Owner:** `store/`.
23
+ **Needed:** the decay tick materializes `strength(m, d)` and `band(m, d)` into
24
+ the CACHE box for ranking speed. That is a box-3 write.
25
+ **Have:** `Store` owns the box-3 connection privately. `cache.ts` has
26
+ `doc_tokens`, `embeddings`, `cache_meta` — no ranking table — and no `Store`
27
+ method reaches any of them except `rebuildCache()`.
28
+ **Workaround:** `sleep/strength-cache.ts` — a `StrengthCache` port with a default
29
+ implementation over its own SQLite file at `<dataDir>/cache/strength.sqlite`,
30
+ opened LAZILY and closed with the cycle. It deep-imports `openDb` from
31
+ `store/db.js` (house precedent: `encode/` deep-imports `store/prose.js`).
32
+
33
+ Three consequences, recorded rather than hidden:
34
+
35
+ - **`rebuildCache()` does not clear it.** `resetCache` drops only its own three
36
+ tables. This is acceptable — every row is re-materialized by the next decay
37
+ tick from canonical state, because strength is a pure function — but it means
38
+ box 3 currently has two owners and only one rebuild story.
39
+ - A **separate file** is deliberate, not laziness: the store holds an open
40
+ connection to `cache.sqlite` and takes `BEGIN IMMEDIATE` on it, so a second
41
+ connection would contend for write locks on a file the store thinks it owns.
42
+ - `paths.LAYOUT` classifies `cache/` as a directory and never inspects its
43
+ contents, so nothing breaks — but `LAYOUT`'s `why` line for `cache` no longer
44
+ describes everything in there.
45
+
46
+ **Real fix (store's call):** a `ranking` table in `cache.sqlite` plus
47
+ `Store.setRanking(rows)` / `Store.ranking(id)`, and `resetCache` dropping it with
48
+ the rest. Then `sleep/` injects `store` as the cache and this file goes away.
49
+
50
+ ---
51
+
52
+ ## 2. `self/` — the briefing render seam (INJECTED, and deliberately not imported)
53
+
54
+ **Owner:** `self/`.
55
+ **Needed:** the wake briefing re-render, as the cycle's LAST content write
56
+ (CONTRACT §3 G5).
57
+ **Have:** `self/` landed while this module was being built. `sleep/` still does
58
+ not import it — a test asserts the absence, and the two modules must be
59
+ composable in either order.
60
+ **Workaround:** `RenderFn`, injected through `SleepOptions.render`. Absent, the
61
+ phase reports `did-not-run / no-render-fn` — not a failure, and not "ran and
62
+ found nothing".
63
+
64
+ **The wiring, as of `self/`'s current surface** (one line at the coordinator):
65
+
66
+ ```ts
67
+ const self = new Self({ store, gate, onEvent });
68
+ const render: RenderFn = ({ day }) => {
69
+ const result = self.boundary({ day, budgetBytes: host.injectionCeiling, horizon });
70
+ return { bytes: result.briefing.bytes, elements: result.briefing.elements };
71
+ };
72
+ runCycle({ store, render, /* ... */ });
73
+ ```
74
+
75
+ Notes for whoever wires it:
76
+
77
+ - `budgetBytes` is **required** by `self/` and is the HOST's reported injection
78
+ ceiling (scar §2.18). `sleep/` has no business inventing it and does not carry
79
+ one; it must reach `runCycle`'s caller from the adapter.
80
+ - `horizon` comes from `prospective/`, not from `sleep/`.
81
+ - `self.boundary()` publishes. `sleep/` guarantees only ORDER: that the call
82
+ happens after revision, prune, and dedup, and that nothing writes content after
83
+ it. Atomic publish, the trim order, and the sentinel counts stay `self/`'s.
84
+ - The renderer is **never invoked under observer** — publishing is a content
85
+ write. `BriefingContext.observer` is therefore always `false` at the call site;
86
+ it exists so a future renderer cannot be handed an ambiguous stance.
87
+
88
+ ---
89
+
90
+ ## 3. `store/` — prune, promotion and merge records live in meta rows (WORKED AROUND)
91
+
92
+ **Owner:** `store/`.
93
+ **Needed:** an append-only, canonical, transactional record per prune, per
94
+ identity crossing, and per merge. CONTRACT §5 G8 makes the prune record
95
+ load-bearing: *a failed record append means nothing moves.*
96
+ **Have:** `appendRemovalRecord` is the OWNER-REMOVAL seam — its `dark` / `chased`
97
+ / `complete` stages populate `deniedIds()` and make the memory unreadable. Using
98
+ it for a floor prune would take the memory dark, which is precisely wrong: a
99
+ pruned memory stays readable. The only other durable seam is `setMeta`.
100
+ **Workaround:** one meta row per record, keyed by memory id —
101
+ `sleep.pruned.<id>`, `sleep.promoted.<id>`, `sleep.merged.<id>`. Keying by id
102
+ (never by day or sequence) makes the write idempotent under replay, which is what
103
+ §5 G3 needs. `setMeta` is transactional, which is the load-bearing part.
104
+ **Cost:** the keyspace is unbounded and unenumerable — the same shape
105
+ `recall/INTERFACE-GAPS.md` §1 filed for gate state, and SEAMS.md #5's
106
+ `gate_session` proposal. *The phase's own small state takes the same seam and
107
+ costs nothing like as much: `sleep.marker.<phase>` and, since 2026-09-18,
108
+ `sleep.cursor.<phase>` — one row each, a bounded keyspace, and transactional,
109
+ which is the load-bearing part.*
110
+ **Real fix:** one `sleep_record` table in box 2 (`memory_id`, `kind`, `day`,
111
+ `payload`), pruned alongside `pruneSupersededVersions`. One table serves all
112
+ three record types and all three become queryable, which is what the dashboard
113
+ (constitution line 16) will want anyway.
114
+
115
+ ---
116
+
117
+ ## 4. The minting seam — `updates:` must actually reach canonical state
118
+
119
+ **Owner:** whoever mints memories from `remember/`'s proposals.
120
+ **Needed:** CONTRACT §5 G9 — *a memory that declares `updates:` is never merged
121
+ into its target.* Physics checks the declaration FIRST, before hash and before
122
+ cosine, so the refusal is only as good as the field.
123
+ **Have:** `remember/` produces `Proposal.updates: UpdatesResolution | null`.
124
+ Nothing yet writes it anywhere `sleep/` can read.
125
+ **Workaround:** `dedup.declaredUpdates()` reads `doc.meta["updates"]` (a resolved
126
+ memory id, as a string) from canonical prose, which round-trips untouched
127
+ (`store/prose.ts` G6). A memory with no such key reads as "declared nothing".
128
+ **Real fix:** the minting seam persists the RESOLVED id there (or in a column),
129
+ and states which it is. Until then the guarantee is live in this module and
130
+ starved at the source — the exact shape of scar §2.6, so this is the gap to close
131
+ first.
132
+
133
+ ---
134
+
135
+ ## 5. `physics/` — there is no `consolidationEligibility()`
136
+
137
+ **Owner:** `physics/`.
138
+ **Needed:** "memories crossing the physics consolidation criteria get the flag".
139
+ **Have:** `consolidated` is an input to `base` (`cons(m)`, §5.2) and nothing in
140
+ physics decides when it turns on.
141
+ **Workaround:** stated in `consolidate.ts` and built ONLY from physics' exports —
142
+ *not already consolidated, not archived, at least one lived day past birth, and
143
+ `band(m, d) === "semantic"`.* Deliberately no reinforcement requirement: "a
144
+ formative one-shot consolidates without repetition" is a property physics
145
+ protects with a `max`, and a repetition gate here would quietly repeal it.
146
+ **Real fix:** `physics.consolidationEligibility(m, d): { eligible, reason,
147
+ blockedBy }`, mirroring `promotionEligibility`. Then this module executes a
148
+ crossing it does not define, exactly as it does for promotion — which is the
149
+ shape the whole contract is built on.
150
+
151
+ ---
152
+
153
+ ## 6. The adapter — the lock, the watchdog, and detachment (OUT OF SCOPE, DECLARED)
154
+
155
+ CONTRACT §3 and scars E4/E5 require: detached execution, a single writer with an
156
+ ATOMIC stale-lease reclaim, two watchdog levels, and the spawner pinning the
157
+ environment LAST. **None of it is in this module, deliberately** — `sleep/` is
158
+ pure math over an injected store, and a lock is neither.
159
+
160
+ What IS here, because it is arithmetic:
161
+
162
+ - `validateWatchdog(softMs, hardMs, leaseMs)` — the cross-key invariant of §5 G2.
163
+ It REFUSES any setting where the hard kill could land at or after the lease
164
+ becomes reclaimable, because the single-writer lease depends on a wedged runner
165
+ dying before its lock can be taken. The adapter must call it at configuration
166
+ load and refuse to start on a bad answer.
167
+ - `shouldSpawn(store)` — §5 G10's answer for the spawner: an observer session
168
+ spawns no cycle.
169
+ - `CycleKilled` — the error class `runCycle` does NOT degrade. The adapter's hard
170
+ kill is a process death, not an exception, but a watchdog that wants to abort
171
+ cooperatively should throw this so markers stay honest.
172
+
173
+ **Also unimplemented and owned by the adapter:** §5 G11's *escalate on the nth
174
+ identical failure* and its backlog-depth metric. `runCycle` records each phase
175
+ failure with its code and moves on; nothing here remembers yesterday's failures,
176
+ so nothing here can escalate. The supervisor that spawns the cycle is the only
177
+ component that sees the sequence.
178
+
179
+ ---
180
+
181
+ ## 7. `store/` — there is no "under audit" concept
182
+
183
+ CONTRACT §3's decay skip list names *anything under audit*, with the audit subset
184
+ counted separately so "pin bloat from stuck ledgers" stays distinguishable from
185
+ "a change is under audit". v2 dropped the ledger subsystem
186
+ (`schemas/CONTRACT.md` §4), and no audit or forensics-hold flag exists in box 2.
187
+
188
+ `DECAY_SKIPS` therefore enumerates `under-audit` and reports it as **structurally
189
+ zero** — an enumerated-but-never-fired category, which is a different record from
190
+ an absent one (scar §2.4). If an audit hold is ever added, it belongs on the
191
+ memory row and this category starts counting without a code change here.
192
+
193
+ ---
194
+
195
+ ## 8. Minor — `store.list()` has no strength or dwell filter
196
+
197
+ Every phase walks all ids and reads each row. At personal scale (v1: ~12.4K
198
+ memories) that is a few SQLite scans per boundary and the budgets bound it. It is
199
+ noted because the first time this module is slow, `WHERE last_used_day < ?` in
200
+ box 2 is the answer, not a cache in this module.
201
+
202
+ **The heaviest scan is `contentHashCandidates`**, and it is the one the phase
203
+ budget does NOT bound: the dedup budget caps PAIRS examined, but candidate
204
+ generation reads every live memory's prose body off disk to hash it, before the
205
+ first pair exists. `Store.bodyDigest(id)` (or a body-hash column maintained at
206
+ write time, which is where a content address belongs) would make the pass a
207
+ single query.
208
+
209
+ ---
210
+
211
+ ## 9. The symmetry verdict has no consumer with a face (`src/adapters/dashboard`)
212
+
213
+ **Owner:** the dashboard adapter. **Added 2026-08-25, with G12's wiring.**
214
+
215
+ The cycle now counts band moves BY DIRECTION (`band.transition` rows in box 2's
216
+ durable log, written by the decay materialization pass) and renders
217
+ `physics.symmetryCheck` per kind at cycle end, onto `CycleReport.symmetry` and a
218
+ `sleep.symmetry` event. That was the missing half of guarantee 12: v1 ran 279
219
+ up-moves against zero down-moves for three days and nothing fired, and the
220
+ tripwire was here from the start, enforced in one place and consumed by nobody.
221
+
222
+ It still has no consumer with a face, and the parallel run is exactly when it
223
+ earns its keep. Two things the status view needs, and neither is a formatting
224
+ preference:
225
+
226
+ 1. **Surface the verdict BY REASON, never by `ok`.** Below
227
+ `SYMMETRY_MIN_SAMPLE` (20 moves) the verdict is `never-asked` and it carries
228
+ `ok: true`. A view keyed on the boolean paints a starved tripwire green,
229
+ which is scar §2.4 in one pixel. `never-asked` / `within-expectation` /
230
+ `ratchet-suspected` / `reverse-ratchet-suspected` are four different facts and
231
+ the view should say which one it is holding, per kind, with `up:down` beside
232
+ it. A kind with a zero DOWN count after the bake-in window is the reading to
233
+ act on — the same shape as §5 G13's census.
234
+ 2. **`DURABLE_EVENT_NAMES` must learn two names.** `registries.ts` derives that
235
+ registry by TYPE from four record interfaces, so `band.transition` (this
236
+ module) and `gate.chunk` (the composition root) are invisible to it. The
237
+ empirical half of the dashboard's totality test — "no event reaches the
238
+ durable log that the registry does not know about" — passes today only
239
+ because its fixture sweeps nothing and lives one day; it will fail as soon as
240
+ the fixture sweeps or reaches a second lived day. This is precisely the hole
241
+ the dashboard's own INTERFACE-GAPS §5 predicted a type-level check could not
242
+ catch.
243
+
244
+ Two smaller notes that ride along:
245
+
246
+ - **The verdict is deliberately not persisted.** It is arithmetic over the
247
+ durable rows and is recomputed at every cycle end, so a stored copy could only
248
+ go stale. The counter is what is durable.
249
+ - **`SleepStore.eventLog?` is optional**, like `appendEvent?`. A port without it
250
+ gets NO verdicts and a loud `sleep.symmetry.unavailable` — six `never-asked`
251
+ rows would claim a counter was consulted when none exists.
252
+ - **The latched rows never prune.** `Store.pruneEvents()` deliberately keeps any
253
+ row carrying a `dedupKey`, and every `band.transition` carries one, so this
254
+ adds a durable consumer to the accepted rent SEAMS names at the end of wave 3.
255
+ The volume is one row per crossing (v1: ~38/day at 13.5K memories). The honest
256
+ fix when it matters is still an age-based sweep that keeps the latch and drops
257
+ the payload — but a swept counter would shrink the symmetry sample, so that
258
+ sweep needs a rolled-up total, not just a delete. *(2026-09-05: `pruneEvents`
259
+ now HAS a caller — the `log` phase, CONTRACT §5 G16 — and it still keeps every
260
+ latched row, so the symmetry sample is untouched by it. The rolled-up total
261
+ remains the thing to build when latched volume is the problem; unlatched
262
+ volume no longer is.)*