counterparts 0.3.6 → 0.3.7

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 (87) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/docs/module-map.md +1 -0
  3. package/package.json +1 -1
  4. package/src/adapters/claude-code/CONTRACT.md +67 -5
  5. package/src/adapters/claude-code/NOTES.md +71 -0
  6. package/src/adapters/claude-code/bin/hook.ts +62 -2
  7. package/src/adapters/claude-code/bin/nightly.ts +76 -0
  8. package/src/adapters/claude-code/config.ts +80 -0
  9. package/src/adapters/claude-code/doctor.ts +307 -2
  10. package/src/adapters/claude-code/hooks.ts +253 -21
  11. package/src/adapters/claude-code/index.ts +20 -0
  12. package/src/adapters/claude-code/night-run.ts +504 -0
  13. package/src/adapters/claude-code/page-writer.ts +50 -16
  14. package/src/adapters/cli/commands.ts +4 -2
  15. package/src/adapters/cli/dream-core.ts +25 -6
  16. package/src/adapters/dashboard/web/README.md +51 -36
  17. package/src/adapters/dashboard/web/app.html +0 -3
  18. package/src/adapters/dashboard/web/pages/health/health.css +2 -0
  19. package/src/adapters/dashboard/web/pages/health/sections/mechanisms.js +9 -0
  20. package/src/adapters/dashboard/web/pages/home/home.css +7 -4
  21. package/src/adapters/dashboard/web/pages/home/index.js +4 -3
  22. package/src/adapters/dashboard/web/pages/home/sections/feel.js +9 -19
  23. package/src/adapters/dashboard/web/pages/home/sections/map.js +6 -5
  24. package/src/adapters/dashboard/web/pages/memories/index.js +29 -18
  25. package/src/adapters/dashboard/web/pages/memories/memories.css +32 -42
  26. package/src/adapters/dashboard/web/pages/memories/row.js +37 -24
  27. package/src/adapters/dashboard/web/pages/memories/sections/feel.js +13 -173
  28. package/src/adapters/dashboard/web/pages/memories/sections/hold.js +34 -36
  29. package/src/adapters/dashboard/web/pages/memories/sections/list.js +70 -36
  30. package/src/adapters/dashboard/web/pages/memories/sections/search.js +85 -88
  31. package/src/adapters/dashboard/web/pages/memories/sections/tools.js +5 -4
  32. package/src/adapters/dashboard/web/pages/memories/state.js +11 -5
  33. package/src/adapters/dashboard/web/pages/self/index.js +2 -0
  34. package/src/adapters/dashboard/web/pages/self/sections/map.js +417 -116
  35. package/src/adapters/dashboard/web/pages/self/self.css +23 -20
  36. package/src/adapters/dashboard/web/shared/memory-marks.css +1 -4
  37. package/src/adapters/dashboard/web/shared/memory-marks.js +2 -16
  38. package/src/adapters/dashboard/web/shared/memory-modal.js +45 -24
  39. package/src/adapters/dashboard/web/shared/modal.css +5 -0
  40. package/src/adapters/dashboard/web/shared/voice.js +18 -0
  41. package/src/adapters/dashboard/web/shared/widgets/feel-radar.js +137 -0
  42. package/src/adapters/dashboard/web/views/archive-words.ts +1 -1
  43. package/src/adapters/dashboard/web/views/memories.ts +98 -7
  44. package/src/adapters/dashboard/web/views/memory-words.ts +29 -1
  45. package/src/adapters/dashboard/web/views/memory.ts +3 -2
  46. package/src/adapters/fired.ts +1 -1
  47. package/src/adapters/mcp/NOTES.md +29 -0
  48. package/src/adapters/mcp/deliberate.ts +80 -5
  49. package/src/adapters/mcp/index.ts +2 -0
  50. package/src/adapters/mcp/server.ts +116 -18
  51. package/src/adapters/mcp/tools.ts +38 -12
  52. package/src/core/associate/CONTRACT.md +33 -4
  53. package/src/core/associate/INTERFACE-GAPS.md +70 -0
  54. package/src/core/associate/NOTES.md +220 -1
  55. package/src/core/associate/buffer.ts +12 -9
  56. package/src/core/associate/contiguity.ts +81 -0
  57. package/src/core/associate/edges.ts +117 -6
  58. package/src/core/associate/index.ts +224 -7
  59. package/src/core/associate/pending.ts +7 -3
  60. package/src/core/associate/spread.ts +154 -69
  61. package/src/core/associate/tunables.ts +75 -5
  62. package/src/core/counterpart.ts +398 -8
  63. package/src/core/dream/CONTRACT.md +79 -13
  64. package/src/core/dream/NOTES.md +67 -2
  65. package/src/core/dream/index.ts +1328 -223
  66. package/src/core/dream/mind.ts +120 -39
  67. package/src/core/dream/reflect.ts +292 -96
  68. package/src/core/dream/slices.ts +217 -0
  69. package/src/core/dream/tunables.ts +72 -12
  70. package/src/core/fit/CONTRACT.md +80 -0
  71. package/src/core/fit/INTERFACE-GAPS.md +16 -0
  72. package/src/core/fit/NOTES.md +37 -0
  73. package/src/core/fit/index.ts +499 -0
  74. package/src/core/recall/CONTRACT.md +13 -2
  75. package/src/core/recall/INTERFACE-GAPS.md +10 -0
  76. package/src/core/recall/NOTES.md +76 -0
  77. package/src/core/recall/activate.ts +320 -62
  78. package/src/core/recall/gate.ts +73 -4
  79. package/src/core/recall/index.ts +46 -10
  80. package/src/core/recall/render.ts +12 -1
  81. package/src/core/recall/session.ts +8 -0
  82. package/src/core/recall/tunables.ts +30 -0
  83. package/src/core/retrieval.ts +15 -6
  84. package/src/core/sleep/NOTES.md +11 -0
  85. package/src/core/sleep/decay.ts +16 -1
  86. package/src/core/sleep/prune.ts +16 -1
  87. package/src/core/store/index.ts +126 -2
@@ -64,11 +64,12 @@ import {
64
64
  preMigrationDir,
65
65
  } from "../../core/store/index.js";
66
66
  import { BUSY_TIMEOUT_MS, journalModeOf } from "../../core/store/db.js";
67
+ import { TUNABLES as ASSOCIATE_TUNABLES, isDead, pairKey } from "../../core/associate/index.js";
67
68
  import type { EventRow } from "../../core/store/index.js";
68
69
  // The ask allowance the amber hint names, read rather than retyped: a number in
69
70
  // a diagnostic's prose is a number that goes stale silently.
70
71
  import { SELF_TUNABLES } from "../../core/self/tunables.js";
71
- import { dreamingSetting } from "../../core/dream/index.js";
72
+ import { dreamingSetting, nightPartsWords, nightRunLost, nightRunOf, nightRunWords } from "../../core/dream/index.js";
72
73
  import type { DreamingSetting } from "../../core/dream/index.js";
73
74
  // The page's own reader, so this line cannot drift from what the wake prints.
74
75
  import { clearedMarker, findPageRow, readSelfPage } from "../../core/self/page.js";
@@ -2589,6 +2590,229 @@ export function reflectionFindings(input: DoctorInput, store: Store): Finding[]
2589
2590
  ];
2590
2591
  }
2591
2592
 
2593
+ /** How far back the lookup count reads, in lived days. */
2594
+ const LOOKUP_WINDOW_DAYS = 14;
2595
+
2596
+ /**
2597
+ * THE LOOKUP, MEASURED (2026-09-28, build B). A dream's and a reflection's
2598
+ * bundles show most memories as a line or an excerpt and name the lookup (the
2599
+ * recall tool, by id). This counts, over the last two weeks of lived days,
2600
+ * what each offered only in part and how many of those a receiver fetched
2601
+ * whole — each id counted once per run's index (`fit/noteLookups`), from
2602
+ * what the recall result delivered, so the rows' counts sum to distinct ids
2603
+ * looked up. If it stays near none, the lines are too thin or the instruction is
2604
+ * unclear — the check against "we just truncated again". Informational:
2605
+ * green, with the numbers.
2606
+ */
2607
+ export function lookupFindings(store: Store): Finding[] {
2608
+ const since = Math.max(0, store.livedDay() - LOOKUP_WINDOW_DAYS);
2609
+ const offered = { dream: 0, reflection: 0 };
2610
+ const runs = { dream: 0, reflection: 0 };
2611
+ const looked = { dream: 0, reflection: 0 };
2612
+ let unread = false;
2613
+ try {
2614
+ const begun = store.eventLog({ name: "dream.begun", sinceDay: since, order: "desc", limit: LOOKUP_ROWS });
2615
+ const recalls = store.eventLog({ name: "mcp.recall", sinceDay: since, order: "desc", limit: LOOKUP_ROWS });
2616
+ unread = begun.length >= LOOKUP_ROWS || recalls.length >= LOOKUP_ROWS;
2617
+ for (const row of begun) {
2618
+ const n = num(payloadOf(row), "offered");
2619
+ if (n === null) continue;
2620
+ runs.dream += 1;
2621
+ offered.dream += n;
2622
+ }
2623
+ for (const r of store.reflections({ limit: 60 })) {
2624
+ if (r.day < since) continue;
2625
+ try {
2626
+ const fit = (JSON.parse(r.detail) as { fit?: { offered?: unknown } }).fit;
2627
+ if (typeof fit?.offered !== "number") continue;
2628
+ runs.reflection += 1;
2629
+ offered.reflection += fit.offered;
2630
+ } catch {
2631
+ continue;
2632
+ }
2633
+ }
2634
+ for (const row of recalls) {
2635
+ const from = payloadOf(row)["fromIndex"];
2636
+ if (from === null || typeof from !== "object") continue;
2637
+ for (const m of ["dream", "reflection"] as const) {
2638
+ const v = (from as Record<string, unknown>)[m];
2639
+ if (typeof v === "number") looked[m] += v;
2640
+ }
2641
+ }
2642
+ } catch {
2643
+ return [];
2644
+ }
2645
+ const say = (m: "dream" | "reflection", runWord: string): string =>
2646
+ runs[m] === 0
2647
+ ? `${m}: no ${runWord} measured yet`
2648
+ : `${m}: ${String(looked[m])} looked up of ${String(offered[m])} offered in part, over ${String(runs[m])} ${runWord}${runs[m] === 1 ? "" : "s"}`;
2649
+ const none = runs.dream + runs.reflection > 0 && offered.dream + offered.reflection > 0 && looked.dream + looked.reflection === 0;
2650
+ return [
2651
+ finding(
2652
+ "lookups",
2653
+ "green",
2654
+ "Lookups",
2655
+ `last ${String(LOOKUP_WINDOW_DAYS)} lived days — ${say("dream", "night")}; ${say("reflection", "reflection")}` +
2656
+ (none ? ". None looked up yet: if that holds, the lines may be too thin or the lookup unclear" : "") +
2657
+ (unread ? ". More rows than were read: the counts are a floor" : ""),
2658
+ "",
2659
+ {
2660
+ dreamOffered: offered.dream,
2661
+ dreamLooked: looked.dream,
2662
+ dreamNights: runs.dream,
2663
+ reflectionOffered: offered.reflection,
2664
+ reflectionLooked: looked.reflection,
2665
+ reflections: runs.reflection,
2666
+ floor: unread,
2667
+ },
2668
+ ),
2669
+ ];
2670
+ }
2671
+
2672
+ /** Rows each lookup read takes, newest first; a read that comes back full is a floor. */
2673
+ const LOOKUP_ROWS = 2_000;
2674
+
2675
+ /** How far back the Association line reads turns, in lived days. */
2676
+ const ASSOCIATION_WINDOW_DAYS = 7;
2677
+
2678
+ /**
2679
+ * ASSOCIATION, MEASURED (2026-09-28, association build 1). What spreading
2680
+ * activation actually did on the last week's turns — how often it got past its
2681
+ * seeds (depth 2), how often the node budget stopped it, and how many of its
2682
+ * contributions LANDED on a candidate — and a census of the edges: how many,
2683
+ * how many still conduct, and where they came from. The source split is
2684
+ * DERIVED (the edge table records no source): an edge touching a dreamed gist
2685
+ * is a gist tie, a pair a dream's `link` named (not undone) is a dream link,
2686
+ * and the rest were learned from use. Informational: green, with the numbers.
2687
+ */
2688
+ export function associationFindings(store: Store): Finding[] {
2689
+ const day = store.livedDay();
2690
+ const since = Math.max(0, day - ASSOCIATION_WINDOW_DAYS);
2691
+ let turns = 0;
2692
+ let deep = 0;
2693
+ let nodeLimit = 0;
2694
+ let landed = 0;
2695
+ let computed = 0;
2696
+ let dropped = 0;
2697
+ let allTurns = 0;
2698
+ let unread = false;
2699
+ let pointersShown = 0;
2700
+ let pointersExpanded = 0;
2701
+ let contiguityPairs = 0;
2702
+ let contiguityLanded = 0;
2703
+ let contiguityEvictedOther = 0;
2704
+ let contiguityScaled = 0;
2705
+ let contiguityExcluded = 0;
2706
+ let contiguityLost = 0;
2707
+ let contiguityFailed = 0;
2708
+ const census = { total: 0, conducting: 0, gist: 0, dream: 0, hebbian: 0 };
2709
+ try {
2710
+ const rows = store.eventLog({ name: "recall.decision", sinceDay: since, order: "desc", limit: ASSOCIATION_ROWS });
2711
+ unread = rows.length >= ASSOCIATION_ROWS;
2712
+ allTurns = rows.length;
2713
+ for (const row of rows) {
2714
+ const p = payloadOf(row);
2715
+ const d = num(p, "dropped");
2716
+ if (d !== null) dropped += d;
2717
+ const s = p["spread"];
2718
+ if (s === null || typeof s !== "object") continue;
2719
+ const sp = s as Record<string, unknown>;
2720
+ turns += 1;
2721
+ if (typeof sp["depth"] === "number" && sp["depth"] >= 2) deep += 1;
2722
+ if (sp["stop"] === "node-limit") nodeLimit += 1;
2723
+ if (typeof sp["landed"] === "number") landed += sp["landed"];
2724
+ if (typeof sp["computed"] === "number") computed += sp["computed"];
2725
+ if (typeof sp["pointersShown"] === "number") pointersShown += sp["pointersShown"];
2726
+ }
2727
+ // The other half of the pointer measurement (2026-09-28): of the quiet
2728
+ // pointers shown, how many a reply went on to expand.
2729
+ for (const row of store.eventLog({ name: "recall.credit", sinceDay: since, order: "desc", limit: ASSOCIATION_ROWS })) {
2730
+ const n = num(payloadOf(row), "pointersExpanded");
2731
+ if (n !== null) pointersExpanded += n;
2732
+ }
2733
+ // Temporal contiguity (2026-09-28): what the boundaries buffered, what of
2734
+ // it LANDED as a conducting link, and what it cost — other links evicted
2735
+ // at the nodes it touched, those nodes scaled back — from their own
2736
+ // `associate.flush` rows (review of #281, findings 2 and 9).
2737
+ for (const row of store.eventLog({ name: "associate.flush", sinceDay: since, order: "desc", limit: ASSOCIATION_ROWS })) {
2738
+ const c = payloadOf(row)["contiguity"];
2739
+ if (c === null || typeof c !== "object") continue;
2740
+ const cr = c as Record<string, unknown>;
2741
+ contiguityPairs += num(cr, "buffered") ?? 0;
2742
+ contiguityLanded += num(cr, "landed") ?? 0;
2743
+ contiguityEvictedOther += num(cr, "evictedOther") ?? 0;
2744
+ contiguityScaled += num(cr, "renormalizedNodes") ?? 0;
2745
+ contiguityExcluded += num(cr, "excluded") ?? 0;
2746
+ contiguityLost += num(cr, "lostEarlier") ?? 0;
2747
+ if (cr["reason"] === "failed") contiguityFailed += 1;
2748
+ }
2749
+ const dreamed = new Set<string>();
2750
+ const dreamPairs = new Set<string>();
2751
+ for (const dream of store.dreams({ limit: 10_000 })) {
2752
+ for (const c of store.dreamChanges(dream.id)) {
2753
+ if (c.undone !== 0 || c.ref === null) continue;
2754
+ if (c.action === "gist") dreamed.add(c.ref);
2755
+ if (c.action === "link" && c.ref2 !== null) dreamPairs.add(pairKey(c.ref, c.ref2));
2756
+ }
2757
+ }
2758
+ for (const e of store.allEdges()) {
2759
+ census.total += 1;
2760
+ if (!isDead({ src: e.src, dst: e.dst, weight: e.weight, lastDay: e.last_day }, day, ASSOCIATE_TUNABLES)) census.conducting += 1;
2761
+ if (dreamed.has(e.src) || dreamed.has(e.dst)) census.gist += 1;
2762
+ else if (dreamPairs.has(pairKey(e.src, e.dst))) census.dream += 1;
2763
+ else census.hebbian += 1;
2764
+ }
2765
+ } catch {
2766
+ return [];
2767
+ }
2768
+ const pct = (n: number): string => (turns === 0 ? "0%" : `${String(Math.round((100 * n) / turns))}%`);
2769
+ const spreadSaid =
2770
+ turns === 0
2771
+ ? `last ${String(ASSOCIATION_WINDOW_DAYS)} lived days — no spreading measured yet`
2772
+ : `last ${String(ASSOCIATION_WINDOW_DAYS)} lived days — spread got past its seeds (depth 2) on ${pct(deep)} of ${String(turns)} turns it ran; stopped at the node limit on ${pct(nodeLimit)}; ${String(landed)} of ${String(computed)} contributions landed on a candidate the cut kept; ${String(pointersShown)} quiet ${pointersShown === 1 ? "pointer" : "pointers"} shown (memories only links reached), ${String(pointersExpanded)} later expanded`;
2773
+ return [
2774
+ finding(
2775
+ "association",
2776
+ "green",
2777
+ "Association",
2778
+ `${spreadSaid}. Edges: ${String(census.total)} rows, ${String(census.conducting)} conducting — ${String(census.hebbian)} learned from use or contiguity, ${String(census.dream)} dream links, ${String(census.gist)} gist ties (derived: a row touching a dream's gist is a gist tie, a pair a dream linked is a dream link, the rest were learned from use or from memories made next to each other)` +
2779
+ `. Temporal contiguity buffered ${String(contiguityPairs)} ${contiguityPairs === 1 ? "pair" : "pairs"} of neighbouring memories at the boundaries, ${String(contiguityLanded)} landed as links; it pushed out ${String(contiguityEvictedOther)} other ${contiguityEvictedOther === 1 ? "link" : "links"} and scaled back ${String(contiguityScaled)} ${contiguityScaled === 1 ? "memory's" : "memories'"} links at full memories; ${String(contiguityExcluded)} ${contiguityExcluded === 1 ? "memory" : "memories"} the nightly run wrote left out` +
2780
+ (contiguityFailed > 0 ? `; the pass failed at ${String(contiguityFailed)} ${contiguityFailed === 1 ? "boundary" : "boundaries"}` : "") +
2781
+ (contiguityLost > 0 ? `; ${String(contiguityLost)} planned ${contiguityLost === 1 ? "pair was" : "pairs were"} lost before a flush recorded them` : "") +
2782
+ (dropped > 0 ? `. The candidate cut left out ${String(dropped)} scored memories, summed over all ${String(allTurns)} recall turns in the window` : "") +
2783
+ (unread ? ". More turns than were read: the counts are a floor" : ""),
2784
+ "",
2785
+ {
2786
+ turns,
2787
+ deep,
2788
+ nodeLimit,
2789
+ landed,
2790
+ computed,
2791
+ dropped,
2792
+ allTurns,
2793
+ pointersShown,
2794
+ pointersExpanded,
2795
+ contiguityPairs,
2796
+ contiguityLanded,
2797
+ contiguityEvictedOther,
2798
+ contiguityScaled,
2799
+ contiguityExcluded,
2800
+ contiguityLost,
2801
+ contiguityFailed,
2802
+ edges: census.total,
2803
+ conducting: census.conducting,
2804
+ hebbian: census.hebbian,
2805
+ dreamLinks: census.dream,
2806
+ gistTies: census.gist,
2807
+ floor: unread,
2808
+ },
2809
+ ),
2810
+ ];
2811
+ }
2812
+
2813
+ /** Turn rows the Association line reads, newest first; a full read is a floor. */
2814
+ const ASSOCIATION_ROWS = 5_000;
2815
+
2592
2816
  /**
2593
2817
  * DREAMING, informational (2026-09-26): the owner's setting (2026-09-28:
2594
2818
  * auto, ask or off), when the counterpart last dreamed, and what today's line
@@ -2609,7 +2833,7 @@ export function dreamingFindings(input: DoctorInput, store: Store): Finding[] {
2609
2833
  const when = last === undefined ? null : (last.date ?? `lived day ${String(last.day)}`);
2610
2834
  const today =
2611
2835
  setting === "off"
2612
- ? "off — no dreams (counterparts dream --setting auto turns it back on)"
2836
+ ? "off — no dreams (counterparts dream --setting ask turns it back on)"
2613
2837
  : ask === undefined
2614
2838
  ? "not started today"
2615
2839
  : ask.state === "declined"
@@ -2630,6 +2854,81 @@ export function dreamingFindings(input: DoctorInput, store: Store): Finding[] {
2630
2854
  ];
2631
2855
  }
2632
2856
 
2857
+ /**
2858
+ * THE NIGHTLY RUN, headless (2026-09-29): what became of the latest run the
2859
+ * host started itself (setting `auto`) — the store's one-row record
2860
+ * (`dream/#nightRunOf`). Silent when no run was ever started and the setting
2861
+ * is not `auto`. AMBER only while the setting is `auto` and the latest run
2862
+ * did not finish (could not start, failed, timed out, or started and never
2863
+ * reported an end past its watchdog): a mechanism the owner chose is not
2864
+ * working. The fix says what to look at.
2865
+ */
2866
+ export function nightRunFindings(input: DoctorInput, store: Store): Finding[] {
2867
+ let setting: DreamingSetting;
2868
+ let run: ReturnType<typeof nightRunOf>;
2869
+ let now: number;
2870
+ try {
2871
+ setting = dreamingSetting(store);
2872
+ run = nightRunOf(store);
2873
+ now = store.now();
2874
+ } catch {
2875
+ return [];
2876
+ }
2877
+ if (run === null) {
2878
+ if (setting !== "auto") return [];
2879
+ return [finding("night-run", "green", "Nightly run", "auto; no headless run yet — the first session of a day with enough new memory starts one", "", { setting, state: null })];
2880
+ }
2881
+ const data = { setting, run: run.run, state: run.state, date: run.date, reason: run.reason, code: run.code, dream: run.dream, reflection: run.reflection };
2882
+ const mins = (ms: number): string => `${String(Math.max(1, Math.round(ms / 60_000)))} min`;
2883
+ const took = run.endedAt === null ? "" : ` after ${mins(run.endedAt - run.startedAt)}`;
2884
+ const what = run.kind === "reflection" ? "the reflection alone" : "the whole night";
2885
+ if (run.state === "done") {
2886
+ const ids = [run.dream, run.reflection].filter((x): x is string => x !== null).join(", ");
2887
+ return [finding("night-run", "green", "Nightly run", `${setting}; last run ${run.date} (${what}) finished${took}${ids.length > 0 ? ` — ${ids}` : ""}`, "", data)];
2888
+ }
2889
+ if (run.state === "partial") {
2890
+ // PART OF THE RUN RAN (2026-09-29, owner): which parts, and — when the
2891
+ // exit said more than "it stopped" — why.
2892
+ const why = run.reason === "unfinished" ? "" : ` (${nightRunWords(run)})`;
2893
+ return [
2894
+ finding(
2895
+ "night-run",
2896
+ setting === "auto" ? "amber" : "green",
2897
+ "Nightly run",
2898
+ `${setting}; the run of ${run.date} (${what}) was partial${took}: ${nightPartsWords(run)}${why}`,
2899
+ "Nothing to do by hand: a later session picks up what did not run — a dream cut off is resumed, a reflection cut off runs alone.",
2900
+ { ...data, parts: (run.parts ?? []).join(",") },
2901
+ ),
2902
+ ];
2903
+ }
2904
+ if (run.state === "started") {
2905
+ const lost = nightRunLost(run, now);
2906
+ return [
2907
+ finding(
2908
+ "night-run",
2909
+ lost && setting === "auto" ? "amber" : "green",
2910
+ "Nightly run",
2911
+ lost
2912
+ ? `${setting}; the run of ${run.date} started ${mins(now - run.startedAt)} ago and never reported an end — its process went away (a sleep, a restart, a kill)`
2913
+ : `${setting}; running now (${what}), started ${mins(now - run.startedAt)} ago`,
2914
+ lost ? "The next session asks instead of starting another headless run. If this repeats, run claude -p once by hand in a terminal to see whether it hangs (a login, an update prompt)." : "",
2915
+ data,
2916
+ ),
2917
+ ];
2918
+ }
2919
+ const words = nightRunWords(run);
2920
+ const ended = run.state === "could-not-start" ? "could not start" : run.state === "timed-out" ? "timed out" : "failed";
2921
+ const fix =
2922
+ run.reason === "no-claude"
2923
+ ? "The headless run starts claude -p: put the claude command on the PATH the hooks see, or set dreaming to ask (counterparts dream --setting ask)."
2924
+ : run.reason === "quick-exit"
2925
+ ? "Run claude -p once by hand in a terminal to see why it stops (a login, an update prompt). Meanwhile the session asks instead."
2926
+ : run.reason === "nothing-ran"
2927
+ ? "The headless run needs the counterparts MCP server registered for claude at user scope (claude mcp list shows it); the server's own mcp.session rows say whether it refused the session."
2928
+ : "A later session starts it again, or asks when it cannot. counterparts dream --setting ask stops the headless runs.";
2929
+ return [finding("night-run", setting === "auto" ? "amber" : "green", "Nightly run", `${setting}; the run of ${run.date} (${what}) ${ended}${took}: ${words}`, fix, data)];
2930
+ }
2931
+
2633
2932
  export function selfPageFindings(store: Store): Finding[] {
2634
2933
  const page = readSelfPage(store);
2635
2934
  if (page === null) {
@@ -3401,9 +3700,15 @@ export function doctorFindings(input: DoctorInput): Finding[] {
3401
3700
  ["upgrade-v8", () => upgradeV8Findings(store)],
3402
3701
  // Dreaming (2026-09-26): informational — last dreamed, and today's ask.
3403
3702
  ["dreaming", () => dreamingFindings(input, store)],
3703
+ // The headless nightly run (2026-09-29): one meta read.
3704
+ ["night-run", () => nightRunFindings(input, store)],
3404
3705
  // v9 (2026-09-27): what the upgrade carried, and the reflection.
3405
3706
  ["upgrade-v9", () => upgradeV9Findings(store)],
3406
3707
  ["reflection", () => reflectionFindings(input, store)],
3708
+ // Build B (2026-09-28): does anyone read what an index offers in part?
3709
+ ["lookups", () => lookupFindings(store)],
3710
+ // Association build 1 (2026-09-28): what spreading did, and the edges.
3711
+ ["association", () => associationFindings(store)],
3407
3712
  // LAST, and deliberately: it is the widest read here — the whole event log,
3408
3713
  // plus a pass over the ids for the table probes — so when the console's
3409
3714
  // reading is cut short this is the group that goes, and the `Budget` finding