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.
- package/CONSTITUTION.md +68 -0
- package/LICENSE +21 -0
- package/README.md +348 -0
- package/docs/ELI5.md +84 -0
- package/docs/QUICKSTART.md +1258 -0
- package/docs/module-map.md +81 -0
- package/package.json +63 -0
- package/src/adapters/claude-code/CONTRACT.md +606 -0
- package/src/adapters/claude-code/INTERFACE-GAPS.md +655 -0
- package/src/adapters/claude-code/NOTES.md +1055 -0
- package/src/adapters/claude-code/bin/hook.ts +820 -0
- package/src/adapters/claude-code/bin/runner.ts +522 -0
- package/src/adapters/claude-code/config.ts +778 -0
- package/src/adapters/claude-code/credentials.ts +199 -0
- package/src/adapters/claude-code/doctor.ts +2557 -0
- package/src/adapters/claude-code/embed-client.ts +617 -0
- package/src/adapters/claude-code/hooks.ts +2240 -0
- package/src/adapters/claude-code/index.ts +224 -0
- package/src/adapters/claude-code/interpret-client.ts +395 -0
- package/src/adapters/claude-code/page-writer.ts +462 -0
- package/src/adapters/claude-code/primacy.ts +162 -0
- package/src/adapters/claude-code/spawn.ts +241 -0
- package/src/adapters/claude-code/standdown.ts +536 -0
- package/src/adapters/claude-code/transcript.ts +661 -0
- package/src/adapters/claude-code/vectors.ts +415 -0
- package/src/adapters/cli/CONTRACT.md +255 -0
- package/src/adapters/cli/INTERFACE-GAPS.md +350 -0
- package/src/adapters/cli/NOTES.md +936 -0
- package/src/adapters/cli/bin/counterparts.ts +74 -0
- package/src/adapters/cli/commands.ts +6095 -0
- package/src/adapters/cli/export.ts +766 -0
- package/src/adapters/cli/index.ts +103 -0
- package/src/adapters/cli/install.ts +670 -0
- package/src/adapters/cli/removal.ts +1186 -0
- package/src/adapters/cli/repair-dates.ts +659 -0
- package/src/adapters/cli/self-page.ts +229 -0
- package/src/adapters/cli/snapshot.ts +279 -0
- package/src/adapters/cli/start-fresh.ts +1228 -0
- package/src/adapters/config-path.ts +342 -0
- package/src/adapters/dashboard/CONTRACT.md +67 -0
- package/src/adapters/dashboard/INTERFACE-GAPS.md +139 -0
- package/src/adapters/dashboard/NOTES.md +474 -0
- package/src/adapters/dashboard/activity.ts +121 -0
- package/src/adapters/dashboard/ansi.ts +82 -0
- package/src/adapters/dashboard/bin/dashboard.ts +479 -0
- package/src/adapters/dashboard/browse.ts +298 -0
- package/src/adapters/dashboard/identity.ts +182 -0
- package/src/adapters/dashboard/index.ts +183 -0
- package/src/adapters/dashboard/layout.ts +149 -0
- package/src/adapters/dashboard/registries.ts +291 -0
- package/src/adapters/dashboard/resolve.ts +206 -0
- package/src/adapters/dashboard/source.ts +48 -0
- package/src/adapters/dashboard/status.ts +327 -0
- package/src/adapters/dashboard/stories.ts +194 -0
- package/src/adapters/dashboard/web/app.html +1731 -0
- package/src/adapters/dashboard/web/brain.html +463 -0
- package/src/adapters/dashboard/web/fired.ts +31 -0
- package/src/adapters/dashboard/web/flow.ts +457 -0
- package/src/adapters/dashboard/web/narrate.ts +1042 -0
- package/src/adapters/dashboard/web/reveal.ts +135 -0
- package/src/adapters/dashboard/web/server.ts +287 -0
- package/src/adapters/dashboard/web/views.ts +1744 -0
- package/src/adapters/expansions.ts +569 -0
- package/src/adapters/fired.ts +1580 -0
- package/src/adapters/mcp/CONTRACT.md +240 -0
- package/src/adapters/mcp/INTERFACE-GAPS.md +271 -0
- package/src/adapters/mcp/NOTES.md +205 -0
- package/src/adapters/mcp/bin/serve.ts +349 -0
- package/src/adapters/mcp/deliberate.ts +619 -0
- package/src/adapters/mcp/index.ts +101 -0
- package/src/adapters/mcp/protocol.ts +170 -0
- package/src/adapters/mcp/server.ts +1740 -0
- package/src/adapters/mcp/stdio.ts +56 -0
- package/src/adapters/mcp/tools.ts +779 -0
- package/src/adapters/scopes.ts +657 -0
- package/src/adapters/sessions.ts +402 -0
- package/src/adapters/snapshots.ts +1069 -0
- package/src/adapters/stance-env.ts +137 -0
- package/src/core/associate/CONTRACT.md +118 -0
- package/src/core/associate/INTERFACE-GAPS.md +173 -0
- package/src/core/associate/NOTES.md +194 -0
- package/src/core/associate/buffer.ts +66 -0
- package/src/core/associate/edges.ts +188 -0
- package/src/core/associate/index.ts +570 -0
- package/src/core/associate/pending.ts +383 -0
- package/src/core/associate/spread.ts +149 -0
- package/src/core/associate/tunables.ts +123 -0
- package/src/core/bridge.ts +272 -0
- package/src/core/briefing.ts +67 -0
- package/src/core/counterpart.ts +3855 -0
- package/src/core/encode/CONTRACT.md +151 -0
- package/src/core/encode/INTERFACE-GAPS.md +135 -0
- package/src/core/encode/NOTES.md +146 -0
- package/src/core/encode/aliases.ts +71 -0
- package/src/core/encode/battery.ts +284 -0
- package/src/core/encode/chunk.ts +265 -0
- package/src/core/encode/emotion.ts +119 -0
- package/src/core/encode/floor.ts +76 -0
- package/src/core/encode/index.ts +100 -0
- package/src/core/encode/precision.ts +162 -0
- package/src/core/encode/preselect.ts +269 -0
- package/src/core/encode/salience.ts +108 -0
- package/src/core/encode/secrets.ts +265 -0
- package/src/core/encode/tunables.ts +99 -0
- package/src/core/encode/types.ts +286 -0
- package/src/core/encode/words.ts +75 -0
- package/src/core/handoff/CONTRACT.md +199 -0
- package/src/core/handoff/INTERFACE-GAPS.md +166 -0
- package/src/core/handoff/NOTES.md +206 -0
- package/src/core/handoff/index.ts +957 -0
- package/src/core/mint.ts +279 -0
- package/src/core/observer.ts +28 -0
- package/src/core/physics/CONTRACT.md +341 -0
- package/src/core/physics/NOTES.md +155 -0
- package/src/core/physics/clock.ts +51 -0
- package/src/core/physics/index.ts +1054 -0
- package/src/core/prospective/CONTRACT.md +137 -0
- package/src/core/prospective/INTERFACE-GAPS.md +112 -0
- package/src/core/prospective/NOTES.md +160 -0
- package/src/core/prospective/derive.ts +188 -0
- package/src/core/prospective/index.ts +1030 -0
- package/src/core/prospective/tunables.ts +72 -0
- package/src/core/prospective/windows.ts +187 -0
- package/src/core/recall/CONTRACT.md +326 -0
- package/src/core/recall/INTERFACE-GAPS.md +163 -0
- package/src/core/recall/NOTES.md +472 -0
- package/src/core/recall/activate.ts +521 -0
- package/src/core/recall/cues.ts +275 -0
- package/src/core/recall/gate.ts +441 -0
- package/src/core/recall/index.ts +692 -0
- package/src/core/recall/probe.ts +239 -0
- package/src/core/recall/reference.ts +201 -0
- package/src/core/recall/render.ts +285 -0
- package/src/core/recall/session.ts +403 -0
- package/src/core/recall/tunables.ts +329 -0
- package/src/core/remember/CONTRACT.md +293 -0
- package/src/core/remember/INTERFACE-GAPS.md +189 -0
- package/src/core/remember/NOTES.md +373 -0
- package/src/core/remember/fallback.ts +452 -0
- package/src/core/remember/index.ts +103 -0
- package/src/core/remember/owner-strike-seam.ts +479 -0
- package/src/core/remember/proposals.ts +609 -0
- package/src/core/remember/spans.ts +1310 -0
- package/src/core/remember/tunables.ts +111 -0
- package/src/core/remember/updates.ts +198 -0
- package/src/core/retrieval.ts +96 -0
- package/src/core/revision.ts +441 -0
- package/src/core/schemas/CONTRACT.md +190 -0
- package/src/core/schemas/INTERFACE-GAPS.md +172 -0
- package/src/core/schemas/NOTES.md +260 -0
- package/src/core/schemas/aliases.ts +160 -0
- package/src/core/schemas/index.ts +1459 -0
- package/src/core/schemas/tunables.ts +44 -0
- package/src/core/schemas/types.ts +387 -0
- package/src/core/self/CONTRACT.md +459 -0
- package/src/core/self/INTERFACE-GAPS.md +284 -0
- package/src/core/self/NOTES.md +1057 -0
- package/src/core/self/briefing.ts +980 -0
- package/src/core/self/episodes.ts +483 -0
- package/src/core/self/freeze.ts +103 -0
- package/src/core/self/identity.ts +604 -0
- package/src/core/self/index.ts +2130 -0
- package/src/core/self/journal-file.ts +760 -0
- package/src/core/self/page.ts +404 -0
- package/src/core/self/tunables.ts +244 -0
- package/src/core/self/writer.ts +714 -0
- package/src/core/sleep/CONTRACT.md +298 -0
- package/src/core/sleep/INTERFACE-GAPS.md +262 -0
- package/src/core/sleep/NOTES.md +770 -0
- package/src/core/sleep/briefing.ts +86 -0
- package/src/core/sleep/consolidate.ts +241 -0
- package/src/core/sleep/cycle.ts +598 -0
- package/src/core/sleep/decay.ts +237 -0
- package/src/core/sleep/dedup.ts +373 -0
- package/src/core/sleep/index.ts +112 -0
- package/src/core/sleep/log.ts +116 -0
- package/src/core/sleep/markers.ts +164 -0
- package/src/core/sleep/prune.ts +170 -0
- package/src/core/sleep/strength-cache.ts +176 -0
- package/src/core/sleep/tunables.ts +135 -0
- package/src/core/sleep/types.ts +542 -0
- package/src/core/store/CONTRACT.md +446 -0
- package/src/core/store/NOTES.md +1068 -0
- package/src/core/store/cache.ts +709 -0
- package/src/core/store/db.ts +275 -0
- package/src/core/store/errors.ts +134 -0
- package/src/core/store/index.ts +2450 -0
- package/src/core/store/operational.ts +610 -0
- package/src/core/store/owner-op-seam.ts +428 -0
- package/src/core/store/paths.ts +494 -0
- package/src/core/store/prose.ts +165 -0
- package/src/core/store/render.ts +87 -0
- package/src/core/store/walk-seam.ts +78 -0
- package/src/core/types.ts +68 -0
- package/tools/install-loop/run.sh +1063 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# `recall/` — interface gaps
|
|
2
|
+
|
|
3
|
+
Things this module needs 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 like.
|
|
5
|
+
|
|
6
|
+
## 1. `store/` has no meta enumeration or expiry — gate-state rows are unbounded
|
|
7
|
+
|
|
8
|
+
**Owner:** `store/`.
|
|
9
|
+
**Needed:** per-session gate state with a defined store AND lifetime (recall contract §5
|
|
10
|
+
G12).
|
|
11
|
+
**Have:** `Store.getMeta` / `Store.setMeta`, a flat key/value table with no way to list
|
|
12
|
+
keys by prefix and no way to remove one. `setMeta` is the only seam, so gate state is one
|
|
13
|
+
JSON row per session at `recall.gate.<sessionId>`.
|
|
14
|
+
**Workaround:** the ROW bounds itself — `MAX_SESSION_RECORDS` caps the surfaced and
|
|
15
|
+
credited maps, and every row stamps `lastDay` so a future sweep has something to sweep
|
|
16
|
+
on. The KEYSPACE does not: a long-lived store accumulates one dead row per session
|
|
17
|
+
forever.
|
|
18
|
+
**Known race, recorded not fixed — scar §2.1 shape:** the row is read-modify-written.
|
|
19
|
+
`setMeta` is transactional per call, but `load → mutate → save` is not, so two writers on
|
|
20
|
+
one session — a turn's `recall()` and a late `resolveUse()` from the boundary, in
|
|
21
|
+
different processes, which is exactly the multi-process case this persistence exists for
|
|
22
|
+
— can have the second save drop the first's records. This is scar §2.1's own sentence
|
|
23
|
+
("hand-serialized structured state with more than one writer mints consistency bugs")
|
|
24
|
+
arriving inside a transactional database, because the transaction is around the wrong
|
|
25
|
+
span. Papering over it with a merge-on-save would be the sidecar-plus-discipline answer
|
|
26
|
+
the scar rejects; the fix is the table below, where each record is its own row.
|
|
27
|
+
|
|
28
|
+
**Real fix (store's call, not recall's):** either `metaKeys(prefix)` plus a meta removal
|
|
29
|
+
that respects no-silent-destruction, or a dedicated `gate_session` table with a
|
|
30
|
+
`last_day` column and a retention sweep alongside `pruneSupersededVersions`. The latter
|
|
31
|
+
is probably right: this is operational state with a lifetime, which is what box 2 is for,
|
|
32
|
+
and a table can be pruned where a meta row cannot.
|
|
33
|
+
|
|
34
|
+
## 2. No alias / handle index — ambiguity is caller-supplied
|
|
35
|
+
|
|
36
|
+
**Owner:** `encode/` (aliases are first-class and change only through explicit alias
|
|
37
|
+
operations — §4.2 G4).
|
|
38
|
+
**Needed:** "a name pointing at two people retrieves neither well and must not teach the
|
|
39
|
+
graph either" (§9 G5) requires knowing that a handle resolves to more than one memory.
|
|
40
|
+
**Have:** nothing. Aliases live in prose `meta` at best; the cache indexes title+body as
|
|
41
|
+
undifferentiated text.
|
|
42
|
+
**Workaround:** `Turn.aliases?: ReadonlyMap<string, readonly string[]>` — the caller
|
|
43
|
+
passes the handle map, and a handle with two or more ids fires at `AMBIGUOUS_WEIGHT` and
|
|
44
|
+
sets `trains: false`, which `Recall.resolveUse` enforces as a refusal. Both halves are
|
|
45
|
+
live; only the SOURCE of the map is borrowed.
|
|
46
|
+
**Real fix:** an alias table in box 2 written by `encode/`'s alias operations, and a
|
|
47
|
+
store read (`aliasesFor(token)` or `ambiguousHandles()`) that recall consults itself.
|
|
48
|
+
Until then a caller that forgets the map silently loses the safety half — which is
|
|
49
|
+
exactly the scar §2.6 shape, so this gap is the one to close first.
|
|
50
|
+
|
|
51
|
+
## 3. No document-frequency statistics on the cache — idf is approximated by probing
|
|
52
|
+
|
|
53
|
+
**Owner:** `store/` (box 3).
|
|
54
|
+
**Needed:** rarity weighting (§9 G4) needs `df(token)` over the index.
|
|
55
|
+
**Have:** `Store.search(cue, limit)` returns up to `limit` hits with summed term
|
|
56
|
+
frequency. There is no `df`, and no way to ask the inverted table a question directly.
|
|
57
|
+
**Workaround:** one probe per distinct cue token, `df = hits.length`, capped at
|
|
58
|
+
`PER_CUE_FETCH`. Two consequences worth stating: a token appearing in more than
|
|
59
|
+
`PER_CUE_FETCH` documents is recorded as exactly `PER_CUE_FETCH`, so very common tokens
|
|
60
|
+
are scored slightly RARER than they are (the wrong direction, though the smoothed idf
|
|
61
|
+
keeps them near zero anyway); and cue extraction costs one query per token.
|
|
62
|
+
**Real fix:** `Store.documentFrequency(tokens: string[]): Map<string, number>` — a single
|
|
63
|
+
`GROUP BY token` over `doc_tokens`, which the schema already supports.
|
|
64
|
+
|
|
65
|
+
**Closed in part, 2026-09-04:** the *document-length* half of this gap is gone. `doc_lens`
|
|
66
|
+
joined box 3 (cache schema v3) and `Store.search(cue, limit, norm)` takes the normalization
|
|
67
|
+
constants, so the cue channel no longer has to pretend every document is the same size. The
|
|
68
|
+
`df` half above is unchanged.
|
|
69
|
+
|
|
70
|
+
## 3a. `doc_tokens` outlives the memory — removed rows still count in `df` and `avgLen`
|
|
71
|
+
|
|
72
|
+
**Owner:** `store/` (box 3).
|
|
73
|
+
**Have:** removal takes an id dark in box 2 and `activate` filters it with `deniedIds()`,
|
|
74
|
+
but nothing deletes its rows from `doc_tokens`. Only `rebuildCache()` clears them.
|
|
75
|
+
**Consequence, small and worth stating:** a removed memory still contributes to the `df`
|
|
76
|
+
probe (so its tokens read as very slightly less rare than they are) and to `AVG(len)` (so
|
|
77
|
+
the normalization constant is computed over a corpus that includes the dead). Neither leaks
|
|
78
|
+
content — the ids never become candidates — and both are noise at the store's current size.
|
|
79
|
+
**Real fix:** delete the row's `doc_tokens` and `doc_lens` entries at the `dark` stage,
|
|
80
|
+
where the deny-list entry is already written.
|
|
81
|
+
|
|
82
|
+
## 4. The observer predicate lives in `store/`
|
|
83
|
+
|
|
84
|
+
Not a defect, and recorded so nobody "fixes" it: `Recall.observer` reads
|
|
85
|
+
`store.observer` and never re-derives the predicate. `docs/observer-mode.md` G7 says a
|
|
86
|
+
second definition is a leak waiting to happen — v1 shipped exactly that. If a second core
|
|
87
|
+
module needs the predicate, the store's own note says to MOVE `store/observer.ts` to
|
|
88
|
+
`src/core/observer.ts`; recall will follow the move without changing behavior.
|
|
89
|
+
|
|
90
|
+
## 5. Reference resolution (§9.2) has no home yet — CLOSED 2026-09-14
|
|
91
|
+
|
|
92
|
+
`Recall.resolveUse(sessionId, memoryId, tier)` routes a DECIDED tier to physics through
|
|
93
|
+
the store seam. Deciding which memories the reply actually used — assistant turns only,
|
|
94
|
+
no model, no file reads, precision over recall — is §9.2's rule and was not implemented
|
|
95
|
+
anywhere. **Closed:** `recall/reference.ts` decides (pure; expansions from recall tool
|
|
96
|
+
calls, verbatim eight-word windows against what surfaced loud), `Counterpart.creditReferences`
|
|
97
|
+
applies it through `resolveUses`, and `adapters/claude-code/hooks.ts#creditAtBoundary` calls
|
|
98
|
+
it on the slice capture just took, at every session-ending hook. Measured before the close
|
|
99
|
+
(IMPROVEMENTS U10): 1,374 memories minted since launch, all at `uses = 0`. Proof:
|
|
100
|
+
`test/lifecycle.test.ts` — the lifecycle through the adapter, the two fixtures (ids named
|
|
101
|
+
in prose credit nothing; expanded-then-contradicted credits), the new-slice-only rule, and
|
|
102
|
+
the wake not reinforcing what it renders.
|
|
103
|
+
|
|
104
|
+
## 6. Nothing computes the turn's embedding — CLOSED 2026-09-04, by moving it
|
|
105
|
+
|
|
106
|
+
**Owner:** was nobody's, which was the defect.
|
|
107
|
+
**Needed:** `Turn.vector` is an input this module has taken since it was written, and
|
|
108
|
+
guarantee 1's whole point is that the ambient path MAY consult an embedding.
|
|
109
|
+
**Had:** neither live caller set it. The UserPromptSubmit hook built its turn without
|
|
110
|
+
one; the MCP recall tool built its own without one. So the semantic channel was live
|
|
111
|
+
code reached only by tests and by the sweep's card preselection, and the store's 13,862
|
|
112
|
+
embeddings were consulted by nothing a person could feel — the §2.6 shape again ("a
|
|
113
|
+
pure function over caller-owned state is only as real as its caller"), one layer up.
|
|
114
|
+
|
|
115
|
+
**Closed, but NOT by giving recall a client.** There is still no fetch in this
|
|
116
|
+
directory. Two things moved instead:
|
|
117
|
+
|
|
118
|
+
1. `Counterpart.recallForTurn` now wires the semantic channel the way it already wires
|
|
119
|
+
aliases, temporal cues and hops — from the composition root, so a caller cannot
|
|
120
|
+
forget it. What it wires is a **lagged** cue: `recall/session.ts`'s `gate_session`
|
|
121
|
+
`semantic` row, written by the detached worker after the previous turn.
|
|
122
|
+
2. The row carries a **ranking**, not a vector. This is the part worth remembering:
|
|
123
|
+
moving the embedding call off the hot path would not have been enough, because
|
|
124
|
+
`Store.nearestTo` reads and `JSON.parse`s every row in box 3 and measured 590-1040 ms
|
|
125
|
+
at the live index's size — inside a 1200 ms budget that aborts rather than degrades.
|
|
126
|
+
|
|
127
|
+
**What is still borrowed, and from whom:** the WORDS. `adapters/claude-code/vectors.ts`
|
|
128
|
+
decides what text becomes the cue (the owner's prompt to 2000 bytes plus 800 bytes of
|
|
129
|
+
the reply) and does the embedding and the ranking. That is correct — the host owns its
|
|
130
|
+
transcript and its credential — but it means a host that never runs that worker gets a
|
|
131
|
+
permanently dark semantic channel, and the only sign is `semanticSource` staying
|
|
132
|
+
`"none"` on every turn. That field exists so the sign is legible.
|
|
133
|
+
|
|
134
|
+
**The real fix, if box 3 ever earns it:** an approximate index (IVF/HNSW) would make
|
|
135
|
+
`nearestTo` cheap enough that the hot path could rank a vector itself, and the lag would
|
|
136
|
+
become a choice rather than a constraint. Not built: constitution line 15, and one
|
|
137
|
+
measured failure is not yet a case for an index.
|
|
138
|
+
|
|
139
|
+
## 7. Box 3 is 278 MB and 65% of it is JSON punctuation — NAMED, not fixed here
|
|
140
|
+
|
|
141
|
+
**Owner:** `store/` (box 3).
|
|
142
|
+
**Measured 2026-09-04**, on the live cache (`dbstat`, 15,421 indexed documents):
|
|
143
|
+
|
|
144
|
+
| table | bytes | note |
|
|
145
|
+
|---|---|---|
|
|
146
|
+
| `embeddings` | 177.5 MB | 13,868 vectors × 1024 dims, stored as **TEXT JSON** |
|
|
147
|
+
| `doc_tokens` + its 2 indexes | 99.1 MB | 1,070,086 rows |
|
|
148
|
+
| everything else | 1.6 MB | |
|
|
149
|
+
|
|
150
|
+
A 1024-dim float32 vector is 4,096 bytes. As `JSON.stringify(number[])` the same vector
|
|
151
|
+
averages **12,690 bytes** — a 3.1× multiplier, and `nearest()` then pays `JSON.parse` on
|
|
152
|
+
every row of a full-table scan for every semantic query. Stored as a `BLOB` the embeddings
|
|
153
|
+
table would be roughly 57 MB and the scan would be a `Float32Array` view rather than a
|
|
154
|
+
parse.
|
|
155
|
+
|
|
156
|
+
**Why it is not fixed in the change that measured it:** it is a box-3 storage-format change
|
|
157
|
+
with a migration of its own, it sits under the semantic channel gap 6 has just closed, and
|
|
158
|
+
the measured problem there was ranking, not size. Gap 6's 590-1040 ms `nearestTo` and this
|
|
159
|
+
table are the same fact seen twice: the scan is slow BECAUSE every row is parsed from JSON. Named so it is a decision somebody makes rather
|
|
160
|
+
than a number that quietly gets worse. Related and cheap: the same 278 MB is what makes the
|
|
161
|
+
FIRST recall in a fresh hook process cost ~800 ms of page-cache warming (`BUDGET_MS`'s day-0
|
|
162
|
+
recalibration).
|
|
163
|
+
|
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
# `recall/` — 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 a
|
|
5
|
+
recorded choice rather than re-deriving one.
|
|
6
|
+
|
|
7
|
+
## 1. The relative bar is LEAVE-ONE-OUT
|
|
8
|
+
|
|
9
|
+
The contract says surfacing is judged "relative to this turn's own background
|
|
10
|
+
distribution". Read literally — background = all of this turn's activations — the rule
|
|
11
|
+
is self-defeating: the strongest candidate drags `mean + k·sd` up by roughly the amount
|
|
12
|
+
it stands out, so a lone perfectly-cued memory is measured against itself and can never
|
|
13
|
+
clear its own bar. Measured on the first fixture built here: bar 7.20 against a top
|
|
14
|
+
activation of 7.61, which the salience modulator then pushed to 8.40 and the memory went
|
|
15
|
+
dark.
|
|
16
|
+
|
|
17
|
+
So the background for candidate *i* is the turn's OTHER activations (`looBar`). The
|
|
18
|
+
whole-sample `mean`/`sd`/`bar` are still reported in the decision record for replay; the
|
|
19
|
+
number each candidate actually faced rides on its own verdict (`CandidateVerdict.bar`),
|
|
20
|
+
because in this regime a single turn-level bar would be a fiction.
|
|
21
|
+
|
|
22
|
+
## 2. Two absolute regimes, both named
|
|
23
|
+
|
|
24
|
+
`background()` returns a `Regime`, and the record carries it:
|
|
25
|
+
|
|
26
|
+
- `absolute-cold-start` — store below `COLD_START_MIN_STORE`. Cold start is stricter,
|
|
27
|
+
not looser (§9 G13): a higher floor replaces the bar entirely and the candidate cap
|
|
28
|
+
tightens. Small stores over-surface.
|
|
29
|
+
- `absolute-thin-background` — fewer than `MIN_BACKGROUND_SAMPLE` cued candidates, or
|
|
30
|
+
zero variance. A background of one is not a distribution, and saying so in the record
|
|
31
|
+
is better than computing a number that means nothing.
|
|
32
|
+
|
|
33
|
+
Salience modulates the bar in the `relative` regime only. The absolute regimes exist
|
|
34
|
+
precisely to be un-negotiable.
|
|
35
|
+
|
|
36
|
+
## 3. Emotion is a modulator, not a channel — which is STRICTER than v1
|
|
37
|
+
|
|
38
|
+
v1 lists emotion among the single channels that are tier-capped, implying an
|
|
39
|
+
emotion-only candidate can exist. Here it cannot: a memory becomes a candidate only
|
|
40
|
+
through the token index or the vector index, so emotional salience can lower a cued
|
|
41
|
+
memory's bar (`gatedSal`) but can never summon an uncued one. Hard gate (a) is therefore
|
|
42
|
+
structural rather than checked. This is a deliberate tightening; if replay shows real
|
|
43
|
+
retrievals lost to it, the fix is an emotion seed channel, not a weaker gate (a).
|
|
44
|
+
|
|
45
|
+
The turn gate on emotional salience (§9 G10) is `detectAffect().selfFelt`, and the
|
|
46
|
+
subject rules of G11 are split as the spec splits them: the FLAG fires on any subject's
|
|
47
|
+
stated feeling, the CUE only on the speaker's own.
|
|
48
|
+
|
|
49
|
+
## 4. `detectAffect` uses its own splitter, and that is not a second tokenizer
|
|
50
|
+
|
|
51
|
+
Cue matching imports `tokenize` from the store so cues are word-bounded exactly the way
|
|
52
|
+
the index was built. Affect detection cannot: `tokenize` drops tokens under two
|
|
53
|
+
characters, which throws away "I". Affect detection never touches the index, so a local
|
|
54
|
+
splitter is not a second definition of the same thing — it is a different thing.
|
|
55
|
+
|
|
56
|
+
Its precision limits are real and recorded as a probe question: a fixed feeling
|
|
57
|
+
vocabulary, a five-word backward window for the subject, object pronouns excluded, and a
|
|
58
|
+
stop at the nearest third-person subject. "She told me Robin was upset" reads as stated,
|
|
59
|
+
not self-felt. Turns that bury the pronoun further back read as not-self-felt, which is
|
|
60
|
+
the safe direction.
|
|
61
|
+
|
|
62
|
+
## 5. Session dedup subsumes the arrival refractory
|
|
63
|
+
|
|
64
|
+
The harvest names four rules that were dark in v1. Three are implemented as named
|
|
65
|
+
mechanisms: session dedup, the emotional refractory, cue carry-over. The fourth —
|
|
66
|
+
"refractory suppression of arrival cues" — is subsumed: a surfaced memory is suppressed
|
|
67
|
+
outright for the rest of the session, so there is no arrival boost left to damp. If
|
|
68
|
+
dedup is ever softened to a penalty rather than a suppression, this rule comes back as
|
|
69
|
+
its own mechanism.
|
|
70
|
+
|
|
71
|
+
## 6. Carried cues are turn TOKENS in box 2 — a deliberate, bounded call
|
|
72
|
+
|
|
73
|
+
Cue carry-over needs last turn's cue tokens, and persisting them means user words land
|
|
74
|
+
in the operational database. The call: keep it, bounded to `MAX_CUES` tokens, overwritten
|
|
75
|
+
every turn, scoped to one session, never emitted as telemetry. The decision record and
|
|
76
|
+
every event carry counts and hashes only — a cue token is turn text, and turn text is
|
|
77
|
+
exactly what telemetry may not carry. Revisit if the retention review disagrees.
|
|
78
|
+
|
|
79
|
+
## 7. Deliberately NOT built (Amendment 15 — complexity is earned)
|
|
80
|
+
|
|
81
|
+
- **Deliberate recall (§9.1)** — the explicit ask, its lower-confidence labeled tier and
|
|
82
|
+
bodies-for-footnotes. Different thresholds on purpose; a different entry point. Not
|
|
83
|
+
needed by the ambient path and not built here.
|
|
84
|
+
- **Edge traversal / spreading activation** — `associate/` owns it (module map ruling 1).
|
|
85
|
+
Recall's channels are cue, semantic and arrival; when `associate/` ships, its hops feed
|
|
86
|
+
a fourth channel and the gate does not change.
|
|
87
|
+
- **The query-aware inhibition relaxation (§9 G14)** — the cluster-majority rule is
|
|
88
|
+
machinery earned by a v1 incident with a live-data regression fixture we do not have.
|
|
89
|
+
Shipped: plain near-duplicate suppression at `NEAR_DUPLICATE`. Ship the relaxation with
|
|
90
|
+
the fixture that proves it, not before.
|
|
91
|
+
- **A census surface (§9.1 G6)** — belongs with deliberate recall.
|
|
92
|
+
|
|
93
|
+
`G15` (a suppressed candidate reclaims a slot only as competition, never as
|
|
94
|
+
un-inhibition) holds by construction: suppressed candidates are dropped, and slots fill
|
|
95
|
+
from the ranked remainder. An empty slot stays quiet — nothing lowers a bar to fill one.
|
|
96
|
+
|
|
97
|
+
## 8. Every tunable is CAL, inherited, not measured — except five, now
|
|
98
|
+
|
|
99
|
+
`tunables.ts` carries v1's live calibration as starting points, marked CAL. That is a
|
|
100
|
+
record of what real use moved in v1's activation space, not a measurement of v2's — and
|
|
101
|
+
v2's cue weights are a different scale entirely (smoothed idf, not v1's normalized
|
|
102
|
+
similarities). Nothing here is calibrated until it is measured against v2's own corpus
|
|
103
|
+
(scar §2.8).
|
|
104
|
+
|
|
105
|
+
Five now are. `BUDGET_MS` was re-measured on day 0 of the parallel run, and
|
|
106
|
+
`CUE_LENGTH_NORM` / `CUE_TF_SATURATION` / `CUE_LENGTH_ONE_SIDED` / `CUE_DOC_CAP` on
|
|
107
|
+
2026-09-04 against a copy of the live store with `tools/recall-bench` — see the tunable's
|
|
108
|
+
own comment for the 23-cell grid, including the cell it picked (`b = 0.5`, clamped) over
|
|
109
|
+
the textbook BM25 default it was expected to pick.
|
|
110
|
+
|
|
111
|
+
## 10. Length normalization lives in the INDEX, not in the scorer
|
|
112
|
+
|
|
113
|
+
The obvious place to divide by document length is `activate.ts`, where the cue arithmetic
|
|
114
|
+
already is. It would not have worked. `searchIndex` takes the top `PER_CUE_FETCH` rows
|
|
115
|
+
**ordered by score**, so a scorer that normalizes after the fetch is re-ranking a set that
|
|
116
|
+
raw term frequency already chose — and on the live store the nine longest documents held
|
|
117
|
+
most of the slots for every cue. So the normalization is SQL, `Store.search` grew a `norm`
|
|
118
|
+
argument, and `activate` multiplies the cue's rarity weight by whatever evidence the index
|
|
119
|
+
reports. `tfFactor` is no longer applied there; applying it would saturate a saturated
|
|
120
|
+
number.
|
|
121
|
+
|
|
122
|
+
Two consequences to keep in mind when reading the code:
|
|
123
|
+
|
|
124
|
+
- **The length factor is CLAMPED at 1**, so the scale only ever moves DOWN. BM25's factor
|
|
125
|
+
is centered on the mean, which would have raised a short document up to ~1.6× its old
|
|
126
|
+
score — fine for ranking, not fine for the absolute floors (`FLOOR_GLOBAL_UNITS`,
|
|
127
|
+
`FLOOR_STRONG_DEFAULT_UNITS`), which a candidate has to clear in a fixed number of cue
|
|
128
|
+
units. The clamp was added to TEST whether those floors explained the loud-tier jump. They
|
|
129
|
+
did not: clamping moves the loud count by one, and the floors turned out not to be firing
|
|
130
|
+
at all (CONTRACT §7 OQ5, answered 2026-09-04 — document frequency was being read off the
|
|
131
|
+
length of a bounded top-K, so rarity stopped being measured as the store grew). The clamp
|
|
132
|
+
ships anyway, because it is the conservative arithmetic and because at `b = 0.5` it is the
|
|
133
|
+
only cell in the grid that recovers an ambient labeled positive.
|
|
134
|
+
- **The candidate union got an order of magnitude wider**, because the hubs are no longer
|
|
135
|
+
occupying every cue's fetch. `activate` therefore ranks from box 2 and reads prose only
|
|
136
|
+
for the survivors — an equivalence, not a heuristic, and the reason the change is
|
|
137
|
+
latency-neutral (warm, 13 real prompts: 160 ms before, 168 ms after).
|
|
138
|
+
|
|
139
|
+
## 11. The deliberate tool's result has a byte budget now, and it is the host's number
|
|
140
|
+
|
|
141
|
+
The ambient path has had `BUDGET_BYTES` since day one because scar §2.18 says the
|
|
142
|
+
injection ceiling is a host capability. The deliberate path had none, and on 2026-09-04
|
|
143
|
+
three real `recall` calls returned 7, 8 and 12 full bodies — 73,000 to 122,000 characters
|
|
144
|
+
— and all three overflowed the host's tool-result cap. An answer the host truncates is not
|
|
145
|
+
a smaller answer; the model cannot tell it from "nothing came".
|
|
146
|
+
|
|
147
|
+
So: a LIST answers *which memories* and ships 300-character excerpts; an ADDRESS (`handle`,
|
|
148
|
+
or the new `ids`, capped at three) answers *what it said* and ships up to 4,000 characters
|
|
149
|
+
each; the total is bounded at 12,000; and every cut is stated in the payload and in the
|
|
150
|
+
`mcp.recall` event. `ids` routes each id through `expandHandle`, so the confidentiality
|
|
151
|
+
boundary and the no-fuzzy-search rule are the same ones, not new copies.
|
|
152
|
+
|
|
153
|
+
## 9. The build/record split is a public seam
|
|
154
|
+
|
|
155
|
+
`Recall.build()` is exported rather than private. "Build and record are separate steps"
|
|
156
|
+
is only a real property if the build is separately callable; a private half is a promise.
|
|
157
|
+
`recall()` = build + record, and the latency abort returns before the record step, which
|
|
158
|
+
is what makes the abort side-effect-free.
|
|
159
|
+
|
|
160
|
+
One residual: an aborted build may already have caused the STORE to emit its own read
|
|
161
|
+
telemetry. Recall emits nothing and writes nothing. The guarantee is about recall's side
|
|
162
|
+
effects, and the store's read events are read events.
|
|
163
|
+
|
|
164
|
+
## 12. Rarity is undefined on a store of ONE — 2026-09-04
|
|
165
|
+
|
|
166
|
+
**Symptom.** A fresh store, no identity core, one authored memory through the MCP `note`
|
|
167
|
+
door. `recall` with a question that plainly matched it answered
|
|
168
|
+
`reason: "nothing-came", considered: 0, storeSize: 1`. Writing ANY unrelated second
|
|
169
|
+
memory made the same question find the first one. At `storeSize` 1 the `handle` and `ids`
|
|
170
|
+
paths returned the memory (`reason: "expanded"`), so the writer, the cache and the ranking
|
|
171
|
+
were all fine: the question path's candidate SET was empty at n=1. Reproduced on four
|
|
172
|
+
independent fresh stores by a cold-stranger reviewer, and again here at both doors.
|
|
173
|
+
|
|
174
|
+
**Cause.** `cues.ts#informativeness` — `Math.log((storeSize + df) / (2 * df))`. On a store
|
|
175
|
+
of one, the only memory holds every token, so `df = 1 = storeSize` and the expression is
|
|
176
|
+
`log(2 / 2)` = `log(1)` = **exactly zero, for every token in the turn**. `buildCues` drops
|
|
177
|
+
a zero-weight cue (`if (idf <= 0) continue`), so the cue list came back empty, the token
|
|
178
|
+
index was never probed, and the gate never saw a candidate to refuse. Not a floor, not
|
|
179
|
+
BM25 length normalization (`avgDocLen` on one document gives a length factor of exactly 1,
|
|
180
|
+
which is what it should give), not a `LIMIT` — the smoothing's own zero.
|
|
181
|
+
|
|
182
|
+
The zero is the RIGHT answer to the question the formula asks. It is the wrong question at
|
|
183
|
+
n=1: rarity is a claim about alternatives, and a token that spans a one-memory store is not
|
|
184
|
+
ubiquitous, it is merely present. §9 G4's "informativeness weighting replaces stop-lists"
|
|
185
|
+
needs at least two documents before "spans the whole store" distinguishes anything.
|
|
186
|
+
|
|
187
|
+
**Fix.** `MIN_RARITY_STORE = 2`, and the store size is read as
|
|
188
|
+
`Math.max(storeSize, MIN_RARITY_STORE)`. Definitional rather than tunable — it names the
|
|
189
|
+
domain of the rule, not a dial — so it sits beside the function and not in `tunables.ts`.
|
|
190
|
+
No floor was retuned; the root cause was never a floor.
|
|
191
|
+
|
|
192
|
+
**And the tier is capped at that size** (`gate.ts`, verdict
|
|
193
|
+
`cold-start-undiscriminating`). Making the first memory cueable has a cost, and it is
|
|
194
|
+
larger than it first looks: at N=1 EVERY token the memory holds is maximally rare, and
|
|
195
|
+
`COLD_START_MIN_STORE` is 15, so N=1 is always the cold-start regime with
|
|
196
|
+
`strongFloor = 4.5 x 0.4055 = 1.8246`. MEASURED 2026-09-04 with the fix in and before the
|
|
197
|
+
cap: one ordinary three-sentence note against five unrelated turns sharing nothing but
|
|
198
|
+
`the` / `that` / `and` / `not` went **`surfaced` — the LOUD tier — on all five**, at
|
|
199
|
+
activation 1.82, 1.88, 1.99, 2.19 and 2.24. (The reviewer who found it measured the same
|
|
200
|
+
shape on a different note: loud on three of five at 2.78 / 2.87 / 2.87, footnoted on the
|
|
201
|
+
other two.) Session dedup bounds it to once per session, and N=2 cures it on its own — the
|
|
202
|
+
same five turns at N=2 footnote at 0.36-0.62, one of them not a candidate at all — but
|
|
203
|
+
"bounded and self-curing" is not the same as "right", and the doctrine at
|
|
204
|
+
`gate.ts#background` is that cold start is STRICTER, not looser. So below
|
|
205
|
+
`MIN_RARITY_STORE` the loud tier is closed: arrival makes a memory warm, and at a size
|
|
206
|
+
where there is no relevance to measure, nothing makes it loud. The floors are untouched;
|
|
207
|
+
`cold-start-undiscriminating` is a loud-tier BLOCK, so it reaches a reader as
|
|
208
|
+
`loudBlockedBy` on an admitted candidate and adds no field to the decision record (G12
|
|
209
|
+
class IDENTICAL, `800a9a9421cd969f`). Inert at N >= 2 by construction.
|
|
210
|
+
|
|
211
|
+
**At scale.** `df >= 1` always, so `storeSize >= 2` is the only regime that can be affected
|
|
212
|
+
and it is untouched by construction: the fix changes nothing but `storeSize === 1`. The
|
|
213
|
+
weight of one maximally-rare cue, before and after — N=1: **0 -> 0.4055**; N=2: 0.4055
|
|
214
|
+
(unchanged); N=3: 0.6931; N=100: 3.9220; N=14,000 (the live store): 8.8537 — every one of
|
|
215
|
+
them bit-identical, which a test asserts against the pre-fix expression rather than
|
|
216
|
+
claiming. `storeSize: 0` still returns 0, which the quiet-turn record depends on
|
|
217
|
+
(`index.ts` denominates a no-candidate turn in `floorUnit(0)`). So the #25/#28 bench on the
|
|
218
|
+
14,000-memory store cannot move: loud 3/13 turns, 2.8 delivered per turn, hubs 0 stand
|
|
219
|
+
untouched. That bench needs a copy of the owner's live store and cannot be run from here —
|
|
220
|
+
**bench re-run: NEEDS-OWNER**.
|
|
221
|
+
|
|
222
|
+
What does change at `storeSize` 1, and it is the intended change: the ambient path can now
|
|
223
|
+
footnote the lone memory when the turn shares a cue with it (`floorUnit(1)` goes 0 ->
|
|
224
|
+
0.4055, so the cold-start floor there goes 0 -> 0.1622 and stops being vacuous), and a turn
|
|
225
|
+
sharing no token still goes quiet — an absent token has `df = 0` and is still worth
|
|
226
|
+
nothing. The stop-list guarantee is genuinely OFF at that size, which is what the tier cap
|
|
227
|
+
above is for.
|
|
228
|
+
|
|
229
|
+
**Left alone, deliberately.** The same arithmetic makes a token with `df === storeSize`
|
|
230
|
+
score zero at n=2 and n=3 as well: two memories that share the question's only content word
|
|
231
|
+
are both invisible to it. That is NOT rare in the default flow, and the first draft of this
|
|
232
|
+
note said it was — the rationale "the second memory usually shares nothing" is false.
|
|
233
|
+
MEASURED: `chapter` writes an `epi_` row that `list({archived: false})` counts and
|
|
234
|
+
`doc_tokens` indexes, so a session that journals and then notes the same subject reaches
|
|
235
|
+
N=2 with `df = 2` on every shared content word, and the question comes back
|
|
236
|
+
`nothing-came, considered: 0` WITH this fix in (`ids = [epi_…, mem_…]`,
|
|
237
|
+
`storeSize: 2`, `df(sourdough) = 2`).
|
|
238
|
+
|
|
239
|
+
The choice stands anyway, for a different reason: the generalizations that would soften it
|
|
240
|
+
— `max(storeSize, df + 1)`, or a `log((N + 1) / (df + 0.5))`-style smoothing — give every
|
|
241
|
+
whole-store token a small non-zero weight at EVERY scale, trading the stop-list guarantee
|
|
242
|
+
on a 14,000-memory store for a small-store miss. That is a bad trade to make blind, and
|
|
243
|
+
this branch is a one-line fix under adversarial review, not the place to re-derive the
|
|
244
|
+
smoothing. Two findings are FILED for the owner rather than folded in here: (a) recall
|
|
245
|
+
counts, indexes and delivers journal (`epi_`) rows at all, which is what makes the n=2
|
|
246
|
+
collision the default rather than the exception; (b) `df` counts indexed rows in
|
|
247
|
+
`doc_tokens` while `storeSize` counts live rows in `memories`, so `df > storeSize` is
|
|
248
|
+
reachable (an archived sibling, a superseded head) and re-zeroes a rare token — revise the
|
|
249
|
+
first memory on a fresh store and it goes dark again. Both want a decision about what the
|
|
250
|
+
denominator IS, which is a bigger question than this bug.
|
|
251
|
+
|
|
252
|
+
## 13. The two denominators, answered: the index is the LIVE store — 2026-09-04
|
|
253
|
+
|
|
254
|
+
§12 filed finding (b) and said the denominator wanted a decision. This is the decision.
|
|
255
|
+
|
|
256
|
+
**Symptom.** A fresh store, one note through the MCP `note` door, one revision — and the
|
|
257
|
+
same question that answered a moment ago comes back `nothing-came`, `storeSize: 1`. Not
|
|
258
|
+
the N=1 degeneracy §12 fixed: the store still holds exactly one live memory, and it is the
|
|
259
|
+
successor, which nothing had ever asked about before.
|
|
260
|
+
|
|
261
|
+
**Cause.** `informativeness(df, storeSize)` reads two numbers that come from two boxes and
|
|
262
|
+
count two different populations. `storeSize` is `store.list({ archived: false }).length` —
|
|
263
|
+
box 2, LIVE rows. `df` was `COUNT(*)` over `doc_tokens` — box 3, every row ever indexed,
|
|
264
|
+
including the archived and superseded ones, because nothing ever took a row OUT of the
|
|
265
|
+
index. `revision.ts:385` calls `Store.supersede`, which archives the head and leaves its
|
|
266
|
+
token rows in place, so `df(sourdough) = 2` stood against `storeSize = 1`. And
|
|
267
|
+
`log((max(N,2) + df) / (2·df))` is exactly zero at `df ≥ N`: every cue is dropped, the
|
|
268
|
+
index is never probed, and the gate never sees a candidate to refuse. §12's zero, reached
|
|
269
|
+
by revising rather than by being first.
|
|
270
|
+
|
|
271
|
+
**Fix — deindex, not a second count.** `cache.ts#deindexDoc` deletes the row's
|
|
272
|
+
`doc_tokens` and `doc_lens`; `Store.archive` and `Store.supersede` call it; `rebuildCache`
|
|
273
|
+
skips rows that are archived or superseded and counts them out in `skippedArchived`, which
|
|
274
|
+
`counterparts verify --rebuild` prints and includes in its accounting.
|
|
275
|
+
|
|
276
|
+
The alternative — counting `df` over live rows only — was refused on two grounds. Box 2
|
|
277
|
+
and box 3 are separate sqlite FILES, so it needs an `ATTACH` or a copy of "which rows are
|
|
278
|
+
live" kept inside the cache: a second source of truth that drifts from the first, which is
|
|
279
|
+
scar §2.6's shape. And it fixes one number where the whole statement was wrong: the index
|
|
280
|
+
is read by `docFrequency` AND by `searchIndex`, and both of those feed a pass that
|
|
281
|
+
discards dead rows anyway. Deindexing makes `df ≤ storeSize` structural rather than a
|
|
282
|
+
filter someone must remember, and the rule it states is the simpler one (constitution 15):
|
|
283
|
+
**the text index is the index of the LIVE store.** Brain analog: reconsolidation replaces
|
|
284
|
+
a trace; it does not leave the old one competing at retrieval.
|
|
285
|
+
|
|
286
|
+
**The second half, which had not been named.** `searchIndex` returns the top `PER_CUE_FETCH`
|
|
287
|
+
per cue, and `activate.ts` then throws away every hit whose row is archived or superseded
|
|
288
|
+
(`skipped`). So a dead row was spending a candidate SLOT before it was refused — the
|
|
289
|
+
candidate SET was narrowed by rows that could never be delivered. That is the same failure
|
|
290
|
+
that put length normalization inside the SQL before `ORDER BY … LIMIT`: re-ranking a wrong
|
|
291
|
+
set is not choosing a right one. `test/recall.test.ts` pins it ("a dead row does not
|
|
292
|
+
occupy a candidate slot in the index either").
|
|
293
|
+
|
|
294
|
+
**…and it is closed on the LEXICAL channel only. The semantic half is OPEN.** The first
|
|
295
|
+
draft of this entry, and of `deindexDoc`'s docblock, said that nothing reads a dead row's
|
|
296
|
+
vector and that no reader could tell. Both were false, and an adversarial review measured
|
|
297
|
+
it: `cache.ts#nearest` does `SELECT memory_id, vec FROM embeddings` with **no filter**,
|
|
298
|
+
`activate.ts` takes that ranking as `SEMANTIC_TOP_M` candidates, and only then discards
|
|
299
|
+
the archived or superseded row — after it has spent the slot. Measured on the branch:
|
|
300
|
+
after a `supersede`, `store.nearestTo(v, 10)` returned the **dead row first of three**.
|
|
301
|
+
This is not a regression (master had it on both channels; this change is strictly better
|
|
302
|
+
on one) and it is reachable in production, not theoretical — the lagged worker
|
|
303
|
+
(`adapters/claude-code/vectors.ts` → `counterpart.ts` → `recall/session.ts`) is the door
|
|
304
|
+
the semantic channel reaches the owner's store through today. What is true, stated
|
|
305
|
+
narrowly: **nothing can be DELIVERED from a dead row, and its vector can still displace a
|
|
306
|
+
live neighbour from the semantic slate.**
|
|
307
|
+
|
|
308
|
+
**FOLLOW-UP, filed not built:** filter inside `Store.nearestTo` — over-fetch and drop the
|
|
309
|
+
non-live against box 2, the same shape the lexical half just got — and the same for
|
|
310
|
+
`nearestVectors`, which is the novelty context slice and shares the scan. Not done here
|
|
311
|
+
because it widens a core diff the night before a merge, and because it wants the
|
|
312
|
+
over-fetch factor measured rather than guessed.
|
|
313
|
+
|
|
314
|
+
**What it changes, arithmetically.** `storeSize` does not move, so `floorUnit` —
|
|
315
|
+
`informativeness(1, storeSize)` — is bit-identical at every size and **no floor and no
|
|
316
|
+
tier was retuned.** Only `df` moves, from `k + a` to `k`, where `k` is the live rows
|
|
317
|
+
holding the token and `a` the dead ones. Weight of that token, before → after:
|
|
318
|
+
|
|
319
|
+
| N | k live | a dead | before | after | Δ |
|
|
320
|
+
|---|---|---|---|---|---|
|
|
321
|
+
| 1 | 1 | 1 | 0 | 0.4055 | +0.4055 — the reported case; dark → cueable |
|
|
322
|
+
| 2 | 1 | 1 | 0 | 0.4055 | +0.4055 (journal + note, the note revised) |
|
|
323
|
+
| 2 | 2 | 1 | 0 | 0 | 0 — §12's "left alone" case, still left alone |
|
|
324
|
+
| 3 | 1 | 1 | 0.2231 | 0.6931 | +0.4700 |
|
|
325
|
+
| 100 | 1 | 1 | 3.2387 | 3.9220 | +0.6833 |
|
|
326
|
+
| 100 | 10 | 2 | 1.5404 | 1.7047 | +0.1643 |
|
|
327
|
+
| 14,000 | 1 | 1 | 8.1607 | 8.8537 | +0.6931 |
|
|
328
|
+
| 14,000 | 24 | 5 | 5.4884 | 5.6773 | +0.1889 |
|
|
329
|
+
| 14,000 | 574 | 10 | 2.5246 | 2.5412 | +0.0166 |
|
|
330
|
+
|
|
331
|
+
The shape: a rare token with one dead twin gains at most `log 2` ≈ 0.693 cue units at any
|
|
332
|
+
scale, and a common token barely moves. So the change is **largest exactly where the bug
|
|
333
|
+
bit** — the small store, the rare word, the revised memory — and is noise on the words that
|
|
334
|
+
span a 14,000-memory index. That is the opposite asymmetry from §12's bug, which grew with
|
|
335
|
+
the store.
|
|
336
|
+
|
|
337
|
+
**On the live store this MOVES OUTPUT, and by an amount this session cannot read.** `a` is
|
|
338
|
+
the number of archived-or-superseded rows still sitting in `doc_tokens`, and the owner's
|
|
339
|
+
store is off-limits here. It is not zero: the migration archives rows (`tools/migrate/
|
|
340
|
+
apply.ts`), sleep's dedup and prune archive, `schemas` fades, `self` regrows episodes.
|
|
341
|
+
`counterparts verify --dir <store>` now prints that population on its own line — *indexed
|
|
342
|
+
but not live (archived or superseded)* — so the owner reads `a` before deciding anything.
|
|
343
|
+
**Bench re-run: NEEDS-OWNER** — the #25/#28 bench needs a copy of the live store and cannot
|
|
344
|
+
be run from here, and unlike §12 this change cannot be argued bit-identical at N=14,000.
|
|
345
|
+
|
|
346
|
+
**The fix is PROSPECTIVE, so it ships with its own migration.** `archive` and `supersede`
|
|
347
|
+
keep the invariant from here on; the rows that went dark before this change are still in
|
|
348
|
+
the index. `rebuildCache` would clear them and drop every paid vector box 3 holds on the
|
|
349
|
+
way — ~13.9K on the owner's store, and master records that figure two ways (13,862 and
|
|
350
|
+
13,868), which is the claims auditor's to settle rather than this note's — and
|
|
351
|
+
`counterparts verify --rebuild` refuses outright while box 3 holds any, so a rebuild is not
|
|
352
|
+
a repair the owner of a real store can actually run. So the migration is
|
|
353
|
+
`Store.pruneDeadIndex()` / `counterparts verify --prune-index`: it diffs box 3's indexed
|
|
354
|
+
ids against box 2's live rows and deindexes the difference, touching no embedding. Same
|
|
355
|
+
shape and same reason as `backfillLengths`, which exists because the v2→v3 lengths were
|
|
356
|
+
derivable and a `resetCache` would have cost the vectors. It is NOT run at open — an
|
|
357
|
+
instrument writes nothing at open, and a write at open takes the write lock — so the owner
|
|
358
|
+
runs it by name, once.
|
|
359
|
+
|
|
360
|
+
**Left alone, deliberately, and with the reason corrected.** `embeddings`. A vector cost a
|
|
361
|
+
paid network call and box 3's float layout is being rewritten in the same night's work, so
|
|
362
|
+
`deindexDoc` drops tokens and lengths only. The reason first written here — "nothing reads
|
|
363
|
+
a dead row's vector" — was **wrong**, and the paragraph above records what the measurement
|
|
364
|
+
found instead. Two further tables this rule does not reach, both inert rather than wrong:
|
|
365
|
+
`ranking` keeps the dead row (keyed by id, read per-id by callers that already iterate live
|
|
366
|
+
rows), and `rebuildCache` does not carry a dead row's vector forward, because a rebuild
|
|
367
|
+
reproduces the live index — an archived row keeps its vector until the next rebuild.
|
|
368
|
+
|
|
369
|
+
**THREE index readers lose their archived hits**, and this is a real cost, not a rounding.
|
|
370
|
+
|
|
371
|
+
1. `cli/removal.ts`'s contamination scan (`store.search(body, 20)`). The removal probe's
|
|
372
|
+
largest residue surface is unaffected — the archived VERSION files under `versions/`
|
|
373
|
+
were never indexed at all — but a removed memory's archived sibling will no longer be
|
|
374
|
+
listed as contamination. The honest repair is a residue scan that reads canonical prose
|
|
375
|
+
rather than the recall index; filed, not worked around.
|
|
376
|
+
2. The dashboard's **search view** (`web/views.ts`). Note the seam this opens: the
|
|
377
|
+
dashboard still reports *"archived: N — held, not gone"* from `store.list`, while its
|
|
378
|
+
search box can no longer reach those rows. No UI control offers archived results, so
|
|
379
|
+
the loss is silent rather than a lie — but the two panels now disagree about what
|
|
380
|
+
"held" means, and that is worth one line of copy.
|
|
381
|
+
3. **`counterpart.ts`'s `updates:` content-match candidate source** — `store.search(query
|
|
382
|
+
.content, query.limit)`, with no archived filter of its own in `remember/updates.ts`. A
|
|
383
|
+
declared `updates:` can therefore no longer content-match an archived or superseded row.
|
|
384
|
+
It cuts both ways and both ways are small: a plain ARCHIVED match was already a dead end
|
|
385
|
+
(`revision.ts` refuses it as `target-archived`), so losing it is an improvement; a
|
|
386
|
+
SUPERSEDED head used to `resolve` forward to its live successor, so a declaration that
|
|
387
|
+
quoted the old wording was retargeted and now has to match the new wording instead. It
|
|
388
|
+
is a live behaviour change on the REVISION path either way, and belongs inside the G12
|
|
389
|
+
argument rather than beside it.
|
|
390
|
+
|
|
391
|
+
**Named, not fixed** (from the same review, none blocking): two predicates state one
|
|
392
|
+
invariant — `rebuildCache` reads `archived = 1 || superseded_by IS NOT NULL` while
|
|
393
|
+
`pruneDeadIndex` and `recall/index.ts` read `archived = 0` alone; equivalent today because
|
|
394
|
+
`supersede` writes both and nothing else writes either, but that is scar §2.6's shape and
|
|
395
|
+
wants one helper. `archive` now does box-3 work between the box-2 commit and its event, so
|
|
396
|
+
a throw in `deindexDoc` loses the `store.archive` event for a row that IS archived — the
|
|
397
|
+
house pattern from `put`/`supersede`, widened to a method that did not have it. And
|
|
398
|
+
`verify --rebuild --prune-index` together lets rebuild win silently where a one-line
|
|
399
|
+
refusal would be clearer.
|
|
400
|
+
|
|
401
|
+
## 14. A chapter is delivered, and says it is a chapter — 2026-09-04
|
|
402
|
+
|
|
403
|
+
Owner ruling, `docs/LAUNCH-STATUS.md` §I14: keep chapters RECALLABLE, label them journal in
|
|
404
|
+
every result. Both halves matter. The filter was the obvious fix and is the wrong one — a
|
|
405
|
+
chapter about the lighthouse conversation may rightly come to mind, and a question answered
|
|
406
|
+
worse is not a safer answer. What was actually wrong is that an `epi_` row arrived from
|
|
407
|
+
recall wearing a memory's clothes: note #12 above measured one coming back `quiet` on a
|
|
408
|
+
question and footnoted on the ambient path, with nothing on the row or the line to say that
|
|
409
|
+
it is the first-person ACCOUNT a memory was made from, that it sits outside every sleep
|
|
410
|
+
phase (`sleep/types.ts#isJournal`), and that the physics printed beside it is recorded and
|
|
411
|
+
never acted on.
|
|
412
|
+
|
|
413
|
+
**The label is data plus one word, and it is nothing else.** No candidate is added or
|
|
414
|
+
removed, no score moves, no ordering changes, and the surfacing decision record does not
|
|
415
|
+
grow a field — `surfaceSetHash()` is `800a9a9421cd969f` before and after. That hash covers
|
|
416
|
+
field NAMES only, so it is evidence that the record's SHAPE did not move and not evidence
|
|
417
|
+
that no value did: `bytes` moves on every turn that delivers a chapter, and `surfaced` /
|
|
418
|
+
`footnotes` move on a budget-tight one (see the delta at the end). The three doors:
|
|
419
|
+
|
|
420
|
+
- `render.ts` — `Resolved.journal` and `FRAMING.journal` (`"Journal:"`), in front of the
|
|
421
|
+
content in BOTH tiers, and outside `clip()`. The label is what tells a reader the line is
|
|
422
|
+
not a memory, so it can never be the part the byte budget eats; a line that does not fit
|
|
423
|
+
is dropped whole by the trim order, where that decision belongs.
|
|
424
|
+
- `mcp/deliberate.ts` — `journal: boolean` on `Recalled` and `BoundedMemory`, glossed once
|
|
425
|
+
in the payload (`JOURNAL_GLOSS`) so the flag is not a bare boolean the reader has to
|
|
426
|
+
guess at, and claimed in the tool description (`tools.ts`) where the calling model reads
|
|
427
|
+
it. `kind` stays PHYSICS kind: a chapter is usually `kind: "self"`, which is exactly the
|
|
428
|
+
ambiguity the boolean resolves rather than overwrites.
|
|
429
|
+
- `cli/commands.ts` — `[journal]` beside the tier, with its own legend line.
|
|
430
|
+
|
|
431
|
+
**The predicate is `ProseDoc.type === "episode"`**, the same field `isJournal` reads off the
|
|
432
|
+
row. Read at render time from the doc that is already in hand, so nothing was added to
|
|
433
|
+
`Candidate`, `CandidateVerdict` or the decision record to carry it — which is the whole
|
|
434
|
+
reason the hash does not move. The model is the dashboard's, which has flagged the row in
|
|
435
|
+
prose since #33 (`dashboard/web/views.ts`, `MemoryDetail.journal`); this is the same
|
|
436
|
+
sentence at the doors that had not learned it.
|
|
437
|
+
|
|
438
|
+
**The wake has TWO doors, and the first draft of this note only found one.** The scanned
|
|
439
|
+
lanes come from `self/identity.ts#scanActive`, which lists `type: "memory"` and nothing
|
|
440
|
+
else, so a chapter cannot reach identity, craft, threads or hints however it is shaped —
|
|
441
|
+
identity band, promoted, `unresolved`, skill-kind, maximum salience. `test/self.test.ts`
|
|
442
|
+
builds one of each and asserts none arrives. That much was true, and it is the tripwire for
|
|
443
|
+
the day that one filter moves.
|
|
444
|
+
|
|
445
|
+
**The horizon lane is the other door, and it was OPEN.** Found by the adversarial review of
|
|
446
|
+
PR #70. `req.horizon` never goes through `scanActive`: `briefing.ts#selfRenderer` fills it
|
|
447
|
+
from `prospective.horizon()`, which walks `store.list({ archived: false })` — every row
|
|
448
|
+
type — and `derive()` excluded only `kind: "skill"`. So a chapter carrying a content date
|
|
449
|
+
rendered in the wake as a thing about to happen. Reproduced end to end, with `at` inside the
|
|
450
|
+
chapter's own window, on a hermetic store: `Arriving: - 2026-09-05 (of 2026-09-10) · ## the
|
|
451
|
+
lighthouse conversation`. It is reachable on the live store — 224 migrated episodes carry
|
|
452
|
+
`happenedOn` and `learnedOn`, are `kind: "self"`, and were given a claimed salience floor —
|
|
453
|
+
and #67's `repair-dates` would widen it.
|
|
454
|
+
|
|
455
|
+
**And the fix there is a FILTER, not a label**, which is the one place in this branch where
|
|
456
|
+
the ruling's "label, don't filter" does not apply: a chapter's date is the day it was
|
|
457
|
+
LIVED, so "Arriving" is a category error about it no matter what word sits in front of the
|
|
458
|
+
line. `DerivableMemory.journal` and a `"journal"` `DeriveReason` refuse it in the predicate
|
|
459
|
+
rather than at one caller — `derive` has seven call sites in `prospective/index.ts`, and a
|
|
460
|
+
filter at one of them is a rule that holds where somebody remembered it. Tested at the
|
|
461
|
+
predicate (`test/prospective.test.ts`, including the negative control: the same row with
|
|
462
|
+
the flag off IS prospective) and end to end through the real composition root
|
|
463
|
+
(`test/seams.test.ts`).
|
|
464
|
+
|
|
465
|
+
**Still open, filed rather than fixed.** `self/identity.ts#enumerate()` has no type filter
|
|
466
|
+
either. It is closed today only because no writer gives an episode the identity band or the
|
|
467
|
+
protected flag — which is a fact about the writers, not a property of the enumeration.
|
|
468
|
+
|
|
469
|
+
**The one value-level delta, named.** A labelled line is 9 bytes longer ("Journal: "), so a
|
|
470
|
+
turn that delivers a chapter AND lands within 9 bytes of `BUDGET_BYTES` trims one more item
|
|
471
|
+
than it used to. That is recorded in `trimmed` like any other trim. Measured on the
|
|
472
|
+
fixture: the same turn renders 225 bytes before and 234 after.
|