counterparts 0.3.25 → 0.3.27

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 (70) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/docs/QUICKSTART.md +6 -0
  3. package/package.json +1 -1
  4. package/src/adapters/claude-code/CONTRACT.md +12 -1
  5. package/src/adapters/claude-code/bin/hook.ts +2 -0
  6. package/src/adapters/claude-code/bin/runner.ts +36 -1
  7. package/src/adapters/claude-code/doctor-feedback.ts +104 -0
  8. package/src/adapters/claude-code/doctor.ts +5 -2
  9. package/src/adapters/claude-code/embed-client.ts +16 -1
  10. package/src/adapters/claude-code/hooks.ts +15 -1
  11. package/src/adapters/claude-code/transcript.ts +28 -1
  12. package/src/adapters/claude-code/vectors.ts +6 -0
  13. package/src/adapters/cli/commands-readings.ts +1 -1
  14. package/src/adapters/cli/help.ts +3 -1
  15. package/src/adapters/dashboard/registries.ts +3 -3
  16. package/src/adapters/fired.ts +14 -2
  17. package/src/adapters/lifecycle.ts +70 -2
  18. package/src/adapters/mcp/CONTRACT.md +3 -2
  19. package/src/adapters/mcp/facts.ts +59 -9
  20. package/src/adapters/mcp/server-session-end.ts +9 -7
  21. package/src/adapters/mcp/server-words.ts +6 -3
  22. package/src/adapters/mcp/tools.ts +11 -8
  23. package/src/core/associate/CONTRACT.md +20 -0
  24. package/src/core/associate/at-write.ts +4 -0
  25. package/src/core/associate/index.ts +60 -0
  26. package/src/core/associate/tunables.ts +46 -2
  27. package/src/core/counterpart-boundary.ts +4 -0
  28. package/src/core/counterpart-events.ts +46 -2
  29. package/src/core/counterpart-types.ts +19 -3
  30. package/src/core/counterpart.ts +374 -64
  31. package/src/core/dream/CONTRACT.md +26 -1
  32. package/src/core/dream/day.ts +199 -0
  33. package/src/core/dream/index.ts +73 -4
  34. package/src/core/dream/tunables.ts +31 -0
  35. package/src/core/embed/static.ts +27 -0
  36. package/src/core/handoff/CONTRACT.md +17 -12
  37. package/src/core/handoff/NOTES.md +30 -0
  38. package/src/core/handoff/index.ts +75 -81
  39. package/src/core/handoff/last-here.ts +54 -15
  40. package/src/core/physics/CONTRACT.md +28 -2
  41. package/src/core/physics/index.ts +92 -8
  42. package/src/core/recall/CONTRACT.md +101 -7
  43. package/src/core/recall/activate.ts +197 -8
  44. package/src/core/recall/cues.ts +94 -21
  45. package/src/core/recall/gate.ts +114 -16
  46. package/src/core/recall/habituation.ts +150 -0
  47. package/src/core/recall/index.ts +203 -22
  48. package/src/core/recall/prime.ts +450 -0
  49. package/src/core/recall/probe.ts +5 -4
  50. package/src/core/recall/rated.ts +172 -9
  51. package/src/core/recall/session.ts +93 -7
  52. package/src/core/recall/standing.ts +26 -1
  53. package/src/core/recall/tunables.ts +125 -1
  54. package/src/core/reconsolidation.ts +21 -6
  55. package/src/core/retrieval.ts +9 -0
  56. package/src/core/schemas/NOTES.md +2 -1
  57. package/src/core/self/NOTES.md +21 -0
  58. package/src/core/self/briefing-room.ts +2 -2
  59. package/src/core/self/briefing.ts +25 -5
  60. package/src/core/self/identity.ts +93 -15
  61. package/src/core/self/index.ts +8 -1
  62. package/src/core/self/tunables.ts +12 -0
  63. package/src/core/sleep/consolidate.ts +20 -5
  64. package/src/core/store/CONTRACT.md +20 -0
  65. package/src/core/store/NOTES.md +4 -1
  66. package/src/core/store/cache.ts +181 -5
  67. package/src/core/store/index.ts +177 -23
  68. package/src/core/store/reads-memories.ts +47 -1
  69. package/src/core/store/shapes.ts +8 -0
  70. package/src/core/store/stem.ts +166 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,97 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.27 — 2026-10-19
4
+
5
+ Recall learns from use, and finds "baking" when you say "bake". The memories a session rates useful, draws on or opens count as used, memories found useful together get linked, and one rated noise twice comes up less for a while; what the conversation has been about, and what is open in its folder, gives related memories a head start. Recall matches word forms and counts everyday words for less, a session's first prompt is matched by meaning too, footnotes skip what this session wrote, and a newer memory stands in for the one it replaced. Most of these are experiments, to be checked in a few days. `counterparts doctor` gains a Feedback loop line. No store migration (store v13) and no wiring change, so `counterparts connect` is not needed; the word index re-indexes itself once in the background (cache v6 to v7, under a second on a typical store). Going back to 0.3.26 is not a plain reinstall: its memory tools refuse the newer cache, and its hooks miss word matches without saying so. To go back, delete `~/.counterparts/store/cache/cache.sqlite*`, then run `counterparts verify --rebuild --keep-vectors --dir ~/.counterparts/store` on 0.3.26 (recall by meaning comes back over the next few sessions, as the background worker re-reads the memories); `counterparts rollback` does not cover a cache change.
6
+
7
+ - **Recall by meaning works on a session's first prompt.** Until now the first prompt of a
8
+ session, and any prompt whose background cue from the turn before wasn't ready, was
9
+ matched by words only. Those prompts are now matched by meaning too, computed on the spot
10
+ with the same local table. It adds a few tens of milliseconds on a typical store.
11
+ - **Asking for facts ignores "how many" and "how often" wording.** Words like "many",
12
+ "much", "often", "typical" and "usually" no longer count as part of what the question is
13
+ about, so they stop pulling in memories that merely contain them.
14
+ - **Footnotes no longer repeat what this session just wrote (an experiment).** A memory
15
+ written in the current conversation is already in front of the model, so it no longer
16
+ comes back as a footnote or a "came to mind" line there. After the conversation is
17
+ compacted, what it wrote before the compaction can come back again. Asking for a memory on
18
+ purpose still finds it.
19
+ - **The nightly dream replays what the day used (an experiment).** Memories the day opened,
20
+ quoted, drew on or rated useful are handed to the night's dream, even ones it already
21
+ dreamed over, with the ones that changed what was said first, and pairs used together
22
+ listed for it to link.
23
+ - **The nightly run's own sessions get no footnotes (an experiment).** The background
24
+ sessions that dream and reflect overnight are no longer handed memories at their first
25
+ prompt; they read what they need on purpose.
26
+ - **Rating what you were shown now counts, as an experiment.** When a session rates the
27
+ memories it was shown at the end, a 3 counts as a full use of the memory, a 2 most of one,
28
+ a 1 a little, and a footnote left unrated a glimpse; a 0 counts nothing. Used memories fade
29
+ more slowly, as before. This is deliberately strong so its effect can be seen, and will be
30
+ tuned after a few days.
31
+ - **A memory a session says it drew on counts as a full use, as an experiment.** Naming it
32
+ in `drewOn` now counts like opening it (it was half a use); still once a day, at most three
33
+ per boundary.
34
+ - **Memories found useful together get linked strongly.** Two memories rated useful (or
35
+ opened, quoted or drawn on) since the session last rated are linked strongly enough that
36
+ the second time it happens, one can bring the other to mind as a quiet pointer. Memories
37
+ shown on the same turn get a faint link, unless one was rated noise.
38
+ - **A memory rated noise twice comes up less for a while.** Rated 0 in two sessions within
39
+ a week, it needs a closer match to show as a footnote. It recovers when those ratings are
40
+ a week old, or at once when a later session rates it useful.
41
+ - **`counterparts doctor` has a Feedback loop line** with what the ratings credited by
42
+ score, the pairs they linked, the links now strong enough to show as pointers, and how
43
+ many memories are holding back as noise.
44
+ - **An earlier version of a memory no longer shows without the one that replaced it.** When
45
+ a turn's words lean towards a memory that a newer one has settled over, the newer one now
46
+ shows in its place (labelled with the earlier one), where before the earlier one could
47
+ slip through on its own as a quiet footnote. If the newer one doesn't clear the bar, the
48
+ earlier one stays out too. If the newer one was written in this same
49
+ session, neither is shown, since it's already in the conversation. This is a trial, to be
50
+ checked in a few days.
51
+ - **A new memory is no longer linked to what was shown when it was written, as an
52
+ experiment.** These faint links were almost never confirmed by use and mostly noise, and
53
+ memories found useful together are now linked by ratings instead. Links between memories
54
+ written one after another stay, and the links already made fade on their own.
55
+ - **A memory that looks like an older one's update no longer fades the older one right away,
56
+ as an experiment.** It is still marked "may be out of date" and the nightly dream is asked
57
+ to confirm it; only a confirmation fades it. The guess was wrong too often to cost the
58
+ older memory anything before then.
59
+ - **Recall matches word forms and quiets everyday words (an experiment).** A prompt that
60
+ says "bake" now finds a memory that says "baking" or "baked", and words like "any",
61
+ "what" or "you" count for much less when deciding what a prompt is about. This applies to
62
+ recall as you work and to asking for facts. The first time the background worker runs
63
+ after the update it re-indexes the words of your memories (under a second on a typical
64
+ store); until then recall matches both the old and the new word forms.
65
+ - **Recall follows the conversation's train of thought (an experiment).** What a
66
+ conversation has been about, what it opened, rated useful or wrote, and what was left
67
+ open in its folder now give related memories a head start, so they win close calls they
68
+ used to lose. Only memories the current message already touches can get one, a memory
69
+ the conversation wrote itself is still never handed back, and the head start fades
70
+ within a few messages once the topic moves on. A conversation's first message, with
71
+ nothing open in its folder, is recalled exactly as before.
72
+
73
+ ## 0.3.26 — 2026-10-18
74
+
75
+ The wake leads with what is live. "Still open" puts the questions touched in the last two weeks first and counts how many of the rest have gone untouched; a stale handoff says how stale it is in one sentence, and when every handoff listed is stale only the newest shows whole; the Yesterday line names the other folders worked in instead of counting them; and a session still open from an earlier day says its start with the date. Doctor reads mood matching, switched off since 10-10, as disabled rather than amber. No store-format change (store v13, cache v6) and no wiring change: nothing to run after upgrading from 0.3.25, and `counterparts connect` is not needed.
76
+
77
+ - **"Still open" shows what is live first.** Open questions touched in the last two weeks come
78
+ before the ones nobody has touched since, a plain one before one that may be out of date,
79
+ and the count says how many of the rest are weeks old.
80
+ - **A handoff says how stale it is in one sentence.** "2 days old; since then: a newer
81
+ chapter here; written on 0.3.24, 0.3.25 now". When every handoff in a folder is stale, the
82
+ wake shows the newest and lists the others by id.
83
+ - **The Yesterday line names the other folders worked in**, rather than counting "sessions in
84
+ other projects", and only the folders the "Today, elsewhere" line may name.
85
+ - **"Today, elsewhere" dates a session that started on an earlier day.** A session opened
86
+ the day before and still live read `open since 09:08 (live)`, a clock that looked like a
87
+ time later today; it now reads `open since 10-16 09:08 (live)`.
88
+ - **Doctor's Fired line reads mood matching as `disabled`** while both mood weights are 0
89
+ (stood down by decision since 10-10), instead of amber "gone quiet". Turning the weights
90
+ back up restores the ordinary grading.
91
+ - **Facts: a coarse event date only partly inside the time asked says so.** A month, year
92
+ or range that straddles the window reads `happened 2023-04 · may be inside the time
93
+ asked`, where a bare month beside a day window read as outside it. Held lightly.
94
+
3
95
  ## 0.3.25 — 2026-10-16
4
96
 
5
97
  A chapter of the journal is now stood for by one short summary memory instead of a full copy: the `chapter` tool takes a `summary`, the engine writes a short one from the chapter's opening lines when the session gives none, and summaries fade like any other memory while the chapter itself keeps every word. The nightly reflection can propose closing items that have sat in "Still open" for days, and nothing closes until you say yes. The wake is shorter and lists more: long items as one line each, the tags on one line, today's date said once, "Coming up" only what is due today, and the self page written to about 4,600 bytes. Recall reads "in the last month" and "the past 3 months" as rolling windows, and facts' event dates carry their weekday. The plugin's sidebar says where you left off, can be clicked again in a few small ways, and the build from Anthropic's directory stands down beside the npm install. No store-format change (store v13, cache v6) and no wiring change: nothing to run after upgrading from 0.3.24, and `counterparts connect` is not needed.
@@ -156,6 +156,12 @@ Then go back in this order. The other order breaks every hook, and the older ver
156
156
  3. `counterparts connect`.
157
157
  4. If you connected Claude Desktop: quit it, then run `counterparts install --host claude-desktop`.
158
158
 
159
+ Going from 0.3.27 or later back to 0.3.26 or earlier also needs the search index rebuilt,
160
+ because 0.3.27 changed its format and `rollback` does not cover it. After step 2, delete
161
+ `~/.counterparts/store/cache/cache.sqlite` (and the `cache.sqlite-wal` and
162
+ `cache.sqlite-shm` beside it), then run `counterparts verify --rebuild --keep-vectors
163
+ --dir ~/.counterparts/store`. Recall by meaning comes back over the next few sessions.
164
+
159
165
  ## Start over
160
166
 
161
167
  To set your memory aside and start with a blank one, close every Claude Code session and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "counterparts",
3
- "version": "0.3.25",
3
+ "version": "0.3.27",
4
4
  "license": "MIT",
5
5
  "description": "Memory that turns AI tools into counterparts - a local-first, human-memory-modeled memory layer for AI.",
6
6
  "repository": {
@@ -324,6 +324,11 @@ row, saying which source answered, existed until the keys were removed — §1a.
324
324
  reappear. **The RANKING travels with the cue, not the vector**: `Store.nearestTo`
325
325
  over a live-sized index measured 590-1040 ms, so carrying a vector would have moved
326
326
  the network call off the hot path and left the scan on it.
327
+ **Amended 2026-10-19:** the prompt path still opens no socket, but a turn the lag never
328
+ reached (a session's first prompt, or a stale row) embeds its own text with the store's
329
+ local table and ranks it in line (`recall/session.ts#inLineSemantic`, recorded
330
+ `in-line`): ~18 ms cold on the live store's 2,207 vectors, where the 590-1040 ms above
331
+ was v1's JSON vectors.
327
332
  **It runs on EVERY boundary, outside the sweep gate and regardless of its verdict**,
328
333
  and `stop()`/`sessionEnd()` spawn the worker unconditionally. The crash gate (open
329
334
  question 3, answered) decides whether a *SWEEP* selects anything — its ordinary
@@ -867,7 +872,13 @@ whose liveness check refuses a session left open overnight (review of #282, find
867
872
  child's own session (`--session-id`, host-minted before 2026-10-09) is QUIET (`HookInput.nightRun`, from
868
873
  `COUNTERPARTS_NIGHT_RUN`): its hooks capture nothing (so it owes no write-up) and give no dream
869
874
  lines, plain reminders, Stop ask, write-up pointer or first-launch question. It still wakes
870
- with the ordinary wake.
875
+ with the ordinary wake. *Experiment started 2026-10-19 (feedback-loop build, part F; check on
876
+ ~10-22):* trying its prompt with **no ambient recall** either — no "came to mind", no footnotes, no quiet
877
+ pointers, no `recall.decision` row (`hooks.ts#userPromptSubmit`, reason `night-run`); only
878
+ the clock line — to see that night sessions stop showing up with footnotes in the day's
879
+ numbers. Before, only its temporal cues stood down (#453) and each child's launch prompt was
880
+ handed footnotes that landed in its gate state as shown. The run still reads memories on
881
+ purpose through its tools. Revert by deleting the `nightRun` early return.
871
882
 
872
883
  **[M] The catch-up runs first, and takes everything owed (2026-10-01, wake build 3; unbounded 2026-10-11 — held lightly).** A `night`
873
884
  run (never a reflection-alone one) writes up owed stretches, in ANY directory, before it
@@ -520,6 +520,8 @@ export function toHookInput(
520
520
  ...(transcriptPath === undefined ? {} : { transcriptPath }),
521
521
  // The model that last answered, for the session record (and so the chapter).
522
522
  ...(transcript.model === undefined ? {} : { model: transcript.model }),
523
+ // The last compaction, for the echo skip's window (2026-10-19, part C).
524
+ ...(transcript.compactedAt === undefined ? {} : { compactedAt: transcript.compactedAt }),
523
525
  // The host's re-fire of a blocked Stop, carried INTO the adapter and not
524
526
  // only handled at delivery: the pass that says nothing must also advance
525
527
  // nothing (`hooks.ts#askAtStop`).
@@ -127,6 +127,11 @@ export function runnerConfigChoice(
127
127
  return resolveConfigPath(argv, env as Record<string, string | undefined>);
128
128
  }
129
129
 
130
+ /** One run's share of the word index re-stem (v7): enough for a live-sized
131
+ * store in one run (the diagnosis's full rebuild, vectors and all, was 3.3 s),
132
+ * small enough that a run on a far larger store stops and resumes. */
133
+ const RESTEM_BUDGET_MS = 5_000;
134
+
130
135
  export interface RunReport {
131
136
  readonly ran: boolean;
132
137
  /** `ran` covers the keyless run too: the day HAPPENED, minus the sweep. The
@@ -145,6 +150,9 @@ export interface RunReport {
145
150
  /** The day's retention pass, or why it did not run. Null when the run refused
146
151
  * before it opened a store at all. */
147
152
  readonly retention: RetentionJobReport | null;
153
+ /** The word index's re-stem (v7 cache, 2026-10-19, an experiment), when this
154
+ * run did any: absent on an index that was already stemmed. */
155
+ readonly terms?: { readonly ready: boolean; readonly examined: number; readonly changed: number; readonly ms: number };
148
156
  /** The sidebar's status file (`adapters/sidebar-status.ts`), written after the
149
157
  * store closed; absent when the run was not asked to (no configuration path). */
150
158
  readonly sidebar?: SidebarWrite;
@@ -394,6 +402,22 @@ export async function runOnce(input: {
394
402
  noteFailure(counterpart, emit, code, "vectors", today);
395
403
  }
396
404
 
405
+ // 0c. THE WORD INDEX RE-STEM (v7 cache, 2026-10-19, an experiment; check
406
+ // ~10-22). A cache migrated from v6 holds surface words until this step
407
+ // re-stems it — bounded per run, resumable, never at open (a hook cannot pay
408
+ // for it). Until it finishes, lookups ask for both forms, so nothing is lost
409
+ // meanwhile. A no-op on an index that is already stemmed.
410
+ let terms: RunReport["terms"];
411
+ try {
412
+ const r = counterpart.store.restemIndex({ budgetMs: RESTEM_BUDGET_MS });
413
+ if (r.examined > 0) {
414
+ terms = r;
415
+ emit("runner.terms", { ready: r.ready, examined: r.examined, changed: r.changed, ms: r.ms });
416
+ }
417
+ } catch (err) {
418
+ noteFailure(counterpart, emit, err instanceof Error ? err.name : "UNKNOWN", "terms", today);
419
+ }
420
+
397
421
  // Step 4's answer, filled in the `finally` below and joined to whichever of
398
422
  // the two results the boundary produced. A `let` rather than a fourth return
399
423
  // arm because the copy must happen on BOTH paths and before `close()`.
@@ -436,7 +460,18 @@ export async function runOnce(input: {
436
460
  } catch (err) {
437
461
  noteFailure(counterpart, emit, err instanceof Error ? err.name : "UNKNOWN", "wake", today);
438
462
  }
439
- result = { ran: true, reason: "ran", swept, minted, code: null, lag, backfill, snapshot: null, retention: null };
463
+ result = {
464
+ ran: true,
465
+ reason: "ran",
466
+ swept,
467
+ minted,
468
+ code: null,
469
+ lag,
470
+ backfill,
471
+ snapshot: null,
472
+ retention: null,
473
+ ...(terms === undefined ? {} : { terms }),
474
+ };
440
475
  } catch (err) {
441
476
  const code =
442
477
  err !== null && typeof err === "object" && typeof (err as { code?: unknown }).code === "string"
@@ -0,0 +1,104 @@
1
+ /**
2
+ * `doctor`'s Feedback loop line (2026-10-19, an experiment; check on ~10-22).
3
+ *
4
+ * Trying ratings as use, strong co-use links and light habituation
5
+ * (`core/recall/rated.ts`, `habituation.ts`) to see whether the day starts
6
+ * teaching the system. This line is what the 2–3 day review reads: over the
7
+ * last week's `recall.rated` rows, the uses credited by tier and the pairs sent
8
+ * to be linked; the links now at or above the quiet-pointer weight; how many
9
+ * memories are habituated now, and how many were shown anyway. Pointers shown
10
+ * and later expanded are on the Association line. Informational: green, with
11
+ * the numbers. Reads only.
12
+ */
13
+ import type { Store } from "../../core/store/index.js";
14
+ import { RECALL_RATED_EVENT } from "../../core/counterpart.js";
15
+ import { TUNABLES as ASSOCIATE_TUNABLES, edgeWeightAt } from "../../core/associate/index.js";
16
+ import { TUNABLES as RECALL_TUNABLES } from "../../core/recall/tunables.js";
17
+ import { habituatedIds } from "../../core/recall/index.js";
18
+ import { finding, num, payloadOf } from "./doctor-finding.js";
19
+ import type { Finding } from "./doctor-finding.js";
20
+
21
+ /** How far back the line reads, in lived days. */
22
+ const FEEDBACK_WINDOW_DAYS = 7;
23
+ /** Rows read per name; a full read is a floor, and says so. */
24
+ const FEEDBACK_ROWS = 5_000;
25
+
26
+ /** The single-link weight the quiet-pointer lane needs — derived, never a constant of its own. */
27
+ export function pointerLinkWeight(): number {
28
+ return (RECALL_TUNABLES.LINK_POINTER_MIN_FRACTION * ASSOCIATE_TUNABLES.MAX_OUT_WEIGHT) / ASSOCIATE_TUNABLES.HOP_DECAY;
29
+ }
30
+
31
+ export function feedbackLoopFindings(store: Store): Finding[] {
32
+ const day = store.livedDay();
33
+ const since = Math.max(0, day - FEEDBACK_WINDOW_DAYS);
34
+ const credited = { shown: 0, ontopic: 0, useful: 0, referenced: 0 };
35
+ let notCredited = 0;
36
+ let coUsePairs = 0;
37
+ let together = 0;
38
+ let calls = 0;
39
+ let shownHabituated = 0;
40
+ let atPointer = 0;
41
+ let habituatedNow = 0;
42
+ let floor = false;
43
+ try {
44
+ const rows = store.eventLog({ name: RECALL_RATED_EVENT, sinceDay: since, order: "desc", limit: FEEDBACK_ROWS });
45
+ floor = rows.length >= FEEDBACK_ROWS;
46
+ for (const row of rows) {
47
+ const p = payloadOf(row);
48
+ const c = p["credited"];
49
+ if (c === null || typeof c !== "object") continue;
50
+ calls += 1;
51
+ const cr = c as Record<string, unknown>;
52
+ for (const k of ["shown", "ontopic", "useful", "referenced"] as const) credited[k] += num(cr, k) ?? 0;
53
+ const nc = p["notCredited"];
54
+ if (nc !== null && typeof nc === "object") for (const v of Object.values(nc)) if (typeof v === "number") notCredited += v;
55
+ const co = p["coUse"];
56
+ if (co !== null && typeof co === "object") coUsePairs += num(co as Record<string, unknown>, "pairs") ?? 0;
57
+ together += num(p, "together") ?? 0;
58
+ }
59
+ for (const row of store.eventLog({ name: "recall.decision", sinceDay: since, order: "desc", limit: FEEDBACK_ROWS })) {
60
+ const p = payloadOf(row);
61
+ for (const lane of ["surfaced", "footnotes"] as const) {
62
+ const list = p[lane];
63
+ if (Array.isArray(list)) for (const e of list) if (e !== null && typeof e === "object" && (e as { habituated?: unknown }).habituated === true) shownHabituated += 1;
64
+ }
65
+ }
66
+ const w = pointerLinkWeight();
67
+ for (const e of store.allEdges()) {
68
+ if (edgeWeightAt({ src: e.src, dst: e.dst, weight: e.weight, lastDay: e.last_day }, day, ASSOCIATE_TUNABLES) >= w) atPointer += 1;
69
+ }
70
+ habituatedNow = habituatedIds(store, day, RECALL_TUNABLES).size;
71
+ } catch {
72
+ return [];
73
+ }
74
+ const total = credited.shown + credited.ontopic + credited.useful + credited.referenced;
75
+ const detail =
76
+ calls === 0
77
+ ? `last ${String(FEEDBACK_WINDOW_DAYS)} lived days — no rating has counted yet (the experiment began 2026-10-19)`
78
+ : `last ${String(FEEDBACK_WINDOW_DAYS)} lived days, ${String(calls)} rating ${calls === 1 ? "call" : "calls"} — ${String(total)} uses credited (${String(credited.shown)} glimpses, ${String(credited.ontopic)} rated 1, ${String(credited.useful)} rated 2, ${String(credited.referenced)} rated 3), ${String(notCredited)} not credited; ${String(coUsePairs)} co-use ${coUsePairs === 1 ? "pair" : "pairs"} and ${String(together)} shown-together ${together === 1 ? "pair" : "pairs"} sent to be linked`;
79
+ return [
80
+ finding(
81
+ "feedback-loop",
82
+ "green",
83
+ "Feedback loop",
84
+ `${detail}. ${String(atPointer)} ${atPointer === 1 ? "link" : "links"} at or above the quiet-pointer weight (${pointerLinkWeight().toFixed(2)}). ${String(habituatedNow)} ${habituatedNow === 1 ? "memory" : "memories"} habituated now; ${String(shownHabituated)} habituated ${shownHabituated === 1 ? "showing" : "showings"} got through anyway` +
85
+ (floor ? ". More rows than were read: the counts are a floor" : ""),
86
+ "",
87
+ {
88
+ calls,
89
+ credited: total,
90
+ glimpses: credited.shown,
91
+ rated1: credited.ontopic,
92
+ rated2: credited.useful,
93
+ rated3: credited.referenced,
94
+ notCredited,
95
+ coUsePairs,
96
+ together,
97
+ atPointer,
98
+ habituatedNow,
99
+ shownHabituated,
100
+ floor,
101
+ },
102
+ ),
103
+ ];
104
+ }
@@ -143,6 +143,7 @@ import type { HostReading, DesktopReading } from "./doctor-host.js";
143
143
  import { readOwed, crashWriteUpFindings } from "./doctor-write-ups.js";
144
144
  import type { OwedSource, OwedReading } from "./doctor-write-ups.js";
145
145
  import { worstFirst } from "./doctor-report.js";
146
+ import { feedbackLoopFindings } from "./doctor-feedback.js";
146
147
 
147
148
  // What moved to the doctor-*.ts parts, re-exported so every import of this file still resolves.
148
149
  export { SEVERITIES } from "./doctor-finding.js";
@@ -719,8 +720,8 @@ function withdrawnFinding(input: DoctorInput): Finding | null {
719
720
  "embedder",
720
721
  "amber",
721
722
  RECALL_TITLE,
722
- `off in this process — the store's cache was written by a newer Counterparts (cache v${v.found}; this build reads v${v.expected}). Recall still matches on words`,
723
- `Either install the newer build again (${byInstall(input, "bun add -g counterparts@latest", "in Claude Code, /plugin → Installed → counterparts → Update now")}), or, to stay on this one, delete ${tilde(input.dir)}/cache/cache.sqlite* (the search cache alone; no memory is kept there, and it is rebuilt) — then in Claude Code run /mcp → Reconnect so the server opens it.`,
723
+ `off in this process — the store's cache was written by a newer Counterparts (cache v${v.found}; this build reads v${v.expected}). Recall still matches on words, but may miss words the newer build indexed in another form`,
724
+ `Either install the newer build again (${byInstall(input, "bun add -g counterparts@latest", "in Claude Code, /plugin → Installed → counterparts → Update now")}), or, to stay on this one, delete ${tilde(input.dir)}/cache/cache.sqlite* (the search cache alone; no memory is kept there) and run \`counterparts verify --rebuild --keep-vectors --dir ${tilde(input.dir)}\` to rebuild its word index — then in Claude Code run /mcp → Reconnect so the server opens it.`,
724
725
  { cacheAhead: true, found: v.found, expected: v.expected },
725
726
  );
726
727
  }
@@ -3391,6 +3392,8 @@ export function doctorFindings(input: DoctorInput): Finding[] {
3391
3392
  ["claim", () => claimFindings(store, input.host?.plugin ?? null)],
3392
3393
  // Association build 1 (2026-09-28): what spreading did, and the edges.
3393
3394
  ["association", () => associationFindings(store)],
3395
+ // The feedback loop (2026-10-19, an experiment): ratings as use, co-use links, habituation.
3396
+ ["feedback-loop", () => feedbackLoopFindings(store)],
3394
3397
  // LAST, and deliberately: it is the widest read here — the whole event log,
3395
3398
  // plus a pass over the ids for the table probes — so when the console's
3396
3399
  // reading is cut short this is the group that goes, and the `Budget` finding
@@ -167,7 +167,15 @@ export function createStaticEmbedder(
167
167
  } else hits += 1;
168
168
  return vec;
169
169
  };
170
- const embed: Embedder = Object.assign(compute, { identity });
170
+ // THE WORD WEIGHTS, only from a table someone has calibrated recall's
171
+ // everyday-word discount against (2026-10-19, an experiment: the ramp in
172
+ // `recall/tunables.ts` is in potion-base-8M's own units). Any other table
173
+ // offers none, and recall's word weights stay as they were.
174
+ const calibrated = WORD_NORM_CALIBRATED.has(model.model);
175
+ const embed: Embedder = Object.assign(
176
+ compute,
177
+ calibrated ? { identity, wordNorm: (word: string) => model.wordNorm(word) } : { identity },
178
+ );
171
179
  return {
172
180
  model: model.model,
173
181
  kind: "static",
@@ -182,6 +190,13 @@ export function createStaticEmbedder(
182
190
  };
183
191
  }
184
192
 
193
+ /**
194
+ * Tables whose row norms recall's everyday-word discount was calibrated on
195
+ * (`recall/tunables.ts#EVERYDAY_NORM_LOW`). Another table's norms are in its
196
+ * own units, so it gets no discount until someone measures it.
197
+ */
198
+ export const WORD_NORM_CALIBRATED: ReadonlySet<string> = new Set(["potion-base-8M"]);
199
+
185
200
  /**
186
201
  * The static table that was asked for and is not here: every ask answers null,
187
202
  * no identity (the store never reconciles against it, so nothing in box 3 is
@@ -513,7 +513,8 @@ export const PAGE_WRITER_TOOL = "counterparts self_page";
513
513
  * today's `additionalContext`, or the stderr and `reason` shapes older
514
514
  * transcripts hold.
515
515
  *
516
- * RATINGS (2026-10-14; Mike's call, tracking only): one clause asks the
516
+ * RATINGS (2026-10-14; Mike's call; since 2026-10-19 an experiment counts
517
+ * the scores as use, which `session_end`'s field says): one clause asks the
517
518
  * session to score the footnotes shown since it last wrote, and every `drewOn`
518
519
  * id — `session_end`'s `rated` field says the anchors and the rest. The ids
519
520
  * are not listed here: every Stop's injection is noise someone pays for.
@@ -987,6 +988,19 @@ export class ClaudeCodeAdapter extends Lifecycle {
987
988
  if (text.trim().length === 0) {
988
989
  return { ...out, ok: true, reason: "empty-prompt", injection: `${this.nowLine()}${context.length === 0 ? "" : `\n${context.trimEnd()}`}`, ...told };
989
990
  }
991
+ // THE NIGHTLY RUN'S OWN PROMPT GETS NO AMBIENT RECALL (2026-10-19, part
992
+ // F of the feedback-loop build): an experiment, to see night sessions
993
+ // drop out of the day's footnote numbers; check on ~10-22, revert by
994
+ // deleting this return. Until now only its cues
995
+ // stood down (`noCues`, #453): the launch prompt still ran the composed
996
+ // recall, so each child (dream, reflection, catch-up) was handed
997
+ // footnotes nobody reads, and they sat in its gate state — counted as
998
+ // shown on its boundary's credit row and rateable as if a day had seen
999
+ // them. The run reads memories on purpose, through its tools; nothing
1000
+ // comes to mind uninvited. The clock line stays.
1001
+ if (input.nightRun === true) {
1002
+ return { ...out, ok: true, reason: "night-run", injection: `${this.nowLine()}${context.length === 0 ? "" : `\n${context.trimEnd()}`}`, ...told };
1003
+ }
990
1004
  // The person's lines (reminders, the dream's) are the JSON form's other
991
1005
  // field, so they take nothing from recall's room (2026-10-10).
992
1006
  const budgetBytes = this.recallRoom(input, context);
@@ -422,6 +422,17 @@ export interface TranscriptRead {
422
422
  /** `message.model` of the last assistant entry the model wrote (not a host
423
423
  * stand-in, not a sidechain). Absent when none carried one. */
424
424
  readonly model?: string;
425
+ /**
426
+ * WHEN THIS CONVERSATION LAST COMPACTED (2026-10-19, feedback-loop part C),
427
+ * epoch ms: the `timestamp` of the newest `compact_boundary` system line the
428
+ * host wrote (measured on a 10-16 transcript: `{"type":"system","subtype":
429
+ * "compact_boundary","timestamp":…,"compactMetadata":{…}}`, the summary
430
+ * line just after it). Memories born before it may have left the model's
431
+ * context; ambient recall's echo skip counts only what was born since
432
+ * (`counterpart.ts#recallForTurn`). Absent: never compacted, or no line
433
+ * with a readable time. A sidechain's line is not this conversation's.
434
+ */
435
+ readonly compactedAt?: number;
425
436
  }
426
437
 
427
438
  /**
@@ -472,6 +483,7 @@ export function parseTranscript(raw: string): TranscriptRead {
472
483
  // one or the person sends anything else.
473
484
  let pending: string[] = [];
474
485
  let model: string | undefined;
486
+ let compactedAt: number | undefined;
475
487
  for (const line of raw.split("\n")) {
476
488
  if (line.trim().length === 0) continue;
477
489
  let entry: Record<string, unknown>;
@@ -489,6 +501,13 @@ export function parseTranscript(raw: string): TranscriptRead {
489
501
  corrupt += 1;
490
502
  continue;
491
503
  }
504
+ // A COMPACTION'S MARK (part C, 2026-10-19): the newest one wins. Not a
505
+ // turn; nothing else is read off it.
506
+ if (entry["type"] === "system" && entry["subtype"] === "compact_boundary" && entry["isSidechain"] !== true) {
507
+ const when = typeof entry["timestamp"] === "string" ? Date.parse(entry["timestamp"]) : Number.NaN;
508
+ if (Number.isFinite(when) && (compactedAt === undefined || when > compactedAt)) compactedAt = when;
509
+ continue;
510
+ }
492
511
  // A prompt typed while the model worked: a turn of its own, where it
493
512
  // stands in the file. A twin written later is skipped below, so the first
494
513
  // appearance is the one kept and the list only grows.
@@ -543,7 +562,15 @@ export function parseTranscript(raw: string): TranscriptRead {
543
562
  turns.push({ role, text: piece.text, source: piece.source, entry: ordinal });
544
563
  }
545
564
  }
546
- return { turns, ok: true, reason: "read", corrupt, expansions, ...(model === undefined ? {} : { model }) };
565
+ return {
566
+ turns,
567
+ ok: true,
568
+ reason: "read",
569
+ corrupt,
570
+ expansions,
571
+ ...(model === undefined ? {} : { model }),
572
+ ...(compactedAt === undefined ? {} : { compactedAt }),
573
+ };
547
574
  }
548
575
 
549
576
  /**
@@ -29,6 +29,12 @@
29
29
  * the one that cannot be raced against a 1200 ms synchronous budget. Ranking
30
30
  * stays in the worker for that reason alone.
31
31
  *
32
+ * **Amended 2026-10-19.** With the local table only, a turn the lag never
33
+ * reached — a session's first prompt, or a stale row — now embeds and ranks in
34
+ * line (`recall/session.ts#inLineSemantic`): measured ~18 ms cold on the live
35
+ * store's 2,207 vectors (~/counterparts-notes/2026-10-19-first-prompt-recall-diagnosis.md).
36
+ * This worker's lagged cue is unchanged for every turn it does reach.
37
+ *
32
38
  * Handing the hot path a vector
33
39
  * would have moved the network call off it and left that scan on it — the same
34
40
  * abort one layer down. So this file embeds AND ranks, and stores the top-M
@@ -118,7 +118,7 @@ export function probeCommand(dir: string, io: Io, namedDir: boolean): number {
118
118
  const credits = store.eventLog({ name: RECALL_CREDIT_EVENT, order: "desc", limit: PROBE_ROW_CEILING }).reverse();
119
119
  const rows = [...decisions, ...credits].map((r) => ({ name: r.name, day: r.day, payload: r.payload }));
120
120
  for (const line of renderProbe(probeOQ4(rows))) io.out(line);
121
- // THE RATINGS (2026-10-14; Mike's call, tracking only): what sessions
121
+ // THE RATINGS (2026-10-14; Mike's call; counted as use since 2026-10-19): what sessions
122
122
  // scored of what they were shown, beside the hit rate above.
123
123
  const ratings = store.eventLog({ name: RECALL_RATED_EVENT, order: "desc", limit: PROBE_ROW_CEILING }).reverse();
124
124
  const lookups = store.eventLog({ name: MCP_RECALL_EVENT, order: "desc", limit: PROBE_ROW_CEILING }).reverse();
@@ -379,7 +379,9 @@ export const COMMAND_DETAIL: Record<string, readonly string[]> = {
379
379
  "(recall/render.ts).",
380
380
  "",
381
381
  "Then the ratings: what sessions scored, 0 to 3, of what they were shown, by",
382
- "date and lane, beside drewOn and the hit rate. Tracking only.",
382
+ "date and lane, beside drewOn and the hit rate. Since 2026-10-19 (an",
383
+ "experiment) the scores also count as use; doctor's Feedback loop line says",
384
+ "what they did.",
383
385
  ],
384
386
  mechanisms: [
385
387
  "One line per memory mechanism: ● working this week, ◐ built but not firing,",
@@ -337,8 +337,8 @@ export const DURABLE_EVENTS = {
337
337
  // Durable since 2026-10-02: "Work here" had more lines than the wake carried.
338
338
  "self.work.overflow": "a session start had more \"Work here\" lines for its project than it carried — more than the wake shows, so they rotate, or fewer fitted the room (how many, how many shown)",
339
339
  "recall.credit": "a boundary decided which memories the replies actually used, and credited them",
340
- // Ratings (2026-10-14; Mike's call, tracking only): recorded, acted on by nothing.
341
- "recall.rated": "a session scored the memories it was shown, 0 to 3 (by lane, whether each was also drawn on, and how many of the footnotes since its last rating it scored) — tracking only, nothing changes",
340
+ // Ratings (2026-10-14; Mike's call). Since 2026-10-19 an experiment counts them as use.
341
+ "recall.rated": "a session scored the memories it was shown, 0 to 3 (by lane, whether each was also drawn on, and how many of the footnotes since its last rating it scored) — and, an experiment since 2026-10-19, what the scores credited and linked",
342
342
  // Learned association had no line in the log at all: an edge is its own
343
343
  // record, so a flush that never happened read exactly like a credit pass with
344
344
  // nothing to wire (2026-09-17, mechanism inventory §3 S3).
@@ -384,7 +384,7 @@ export const DURABLE_EVENTS = {
384
384
  // The update guard (2026-10-09). Ids, the reading and its numbers; no text.
385
385
  "contradiction.held": "a new memory said it changed or corrected one that looked unrelated to it, so the old one was left as it was and the two were not linked (the writer was shown it and asked to settle it if it meant to)",
386
386
  // The slot detector (2026-10-11, Group 2). Ids, the rule and the cosine; no text.
387
- "contradiction.proposed": "a new memory read as the newer state of the same thing as an older one (status moved on, or very close in meaning), so the older was marked possibly out of date and faded a little, until the writer or the dream confirms it or says they are two things",
387
+ "contradiction.proposed": "a new memory read as the newer state of the same thing as an older one (status moved on, or very close in meaning), so the older was marked possibly out of date (faded a little before 2026-10-19; a flag only since, as an experiment), until the writer or the dream confirms it or says they are two things",
388
388
  // What is not written up (2026-09-30). Ids and counts only; one row per stretch per state.
389
389
  "coverage.owed": "a session left a stretch that is not written up — three pieces or more over a quarter of an hour — and is no longer at work, so it owes a write-up (how many pieces, over how long)",
390
390
  "coverage.written": "a stretch of a session was written up (how many pieces, and by whom: the session itself, a \"nothing new\", a chapter, or the next session)",
@@ -61,6 +61,7 @@
61
61
  * came and went unanswered is the finding, and stays one.
62
62
  */
63
63
  import { TUNABLES as ENCODE } from "../core/encode/tunables.js";
64
+ import { TUNABLES as RECALL } from "../core/recall/tunables.js";
64
65
  import {
65
66
  DATE_FROM_META,
66
67
  DATE_LINEAGE_MAX,
@@ -469,6 +470,12 @@ export const MECHANISMS: readonly Mechanism[] = [
469
470
  module: "recall/mood.ts",
470
471
  evidence: { kind: "event", names: ["recall.decision"], positive: "moodMatched" },
471
472
  since: "2026-09-26",
473
+ // Off since 2026-10-10 (review 02 C3: both weights 0, code kept). Read,
474
+ // not retyped, as the classifier's row above: doctor read its silence as
475
+ // "gone quiet" on the owner's store, 2026-10-18.
476
+ ...(RECALL.MOOD_SAME_WEIGHT > 0 || RECALL.MOOD_CROSS_WEIGHT > 0
477
+ ? {}
478
+ : { disabled: "mood matching is off (both mood weights 0 in recall/tunables.ts, since 2026-10-10) — a named decision, not a fault" }),
472
479
  },
473
480
  {
474
481
  id: "salience",
@@ -518,9 +525,11 @@ export const MECHANISMS: readonly Mechanism[] = [
518
525
  evidence: { kind: "event", names: ["recall.credit"] },
519
526
  },
520
527
  {
521
- // Mike's call, 2026-10-14: tracking only. Nothing reads the rows to act.
528
+ // Mike's call, 2026-10-14. Since 2026-10-19 an experiment (check ~10-22)
529
+ // counts the scores as use, links what was co-used, and habituates a
530
+ // memory rated 0 twice (`core/recall/rated.ts`, `habituation.ts`).
522
531
  id: "rated",
523
- label: "a session scored the memories it was shown, 0 to 3 — recorded only, nothing changes",
532
+ label: "a session scored the memories it was shown, 0 to 3, and the scores count as use (an experiment since 2026-10-19)",
524
533
  module: "recall/rated.ts, mcp/server-session-end.ts",
525
534
  evidence: { kind: "event", names: ["recall.rated"] },
526
535
  since: "2026-10-14",
@@ -2269,6 +2278,9 @@ function readProbes(store: ReadOnlyStore, w: Window): Probed {
2269
2278
  // doctor's Reflection line splits the week's returns by source.
2270
2279
  for (const r of store.returnsOf(id)) {
2271
2280
  if (r.source === "legacy") continue;
2281
+ // A glimpse or a rating of 1 (2026-10-19, an experiment) is a partial
2282
+ // return, not a memory that came back: not counted as one here.
2283
+ if (r.source === "shown" || r.source === "ontopic") continue;
2272
2284
  bump(r.source === "dream" ? "returns.dream" : "returns.awake", { at: r.at });
2273
2285
  }
2274
2286
  if (row !== undefined && row.archived === 0 && row.source === "dreamed") {