counterparts 0.3.4 → 0.3.6

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 (156) hide show
  1. package/CHANGELOG.md +205 -0
  2. package/docs/module-map.md +2 -2
  3. package/package.json +1 -1
  4. package/src/adapters/claude-code/CONTRACT.md +48 -30
  5. package/src/adapters/claude-code/NOTES.md +38 -0
  6. package/src/adapters/claude-code/doctor.ts +202 -20
  7. package/src/adapters/claude-code/hooks.ts +39 -294
  8. package/src/adapters/claude-code/index.ts +2 -2
  9. package/src/adapters/cli/NOTES.md +12 -0
  10. package/src/adapters/cli/commands.ts +84 -20
  11. package/src/adapters/cli/dream-core.ts +105 -11
  12. package/src/adapters/cli/export.ts +21 -2
  13. package/src/adapters/cli/help.ts +13 -9
  14. package/src/adapters/cli/mechanisms.ts +7 -1
  15. package/src/adapters/cli/self-page.ts +5 -2
  16. package/src/adapters/dashboard/activity.ts +18 -5
  17. package/src/adapters/dashboard/registries.ts +1 -1
  18. package/src/adapters/dashboard/source.ts +8 -0
  19. package/src/adapters/dashboard/stories.ts +3 -1
  20. package/src/adapters/dashboard/web/README.md +131 -54
  21. package/src/adapters/dashboard/web/actions.ts +45 -3
  22. package/src/adapters/dashboard/web/app.html +1 -4
  23. package/src/adapters/dashboard/web/app.js +3 -7
  24. package/src/adapters/dashboard/web/ask-voice.ts +364 -0
  25. package/src/adapters/dashboard/web/lanes.ts +32 -2
  26. package/src/adapters/dashboard/web/mechanisms/association/index.js +1 -0
  27. package/src/adapters/dashboard/web/mechanisms/association/panel.js +1 -3
  28. package/src/adapters/dashboard/web/mechanisms/consolidation/index.js +1 -0
  29. package/src/adapters/dashboard/web/mechanisms/consolidation/panel.js +31 -17
  30. package/src/adapters/dashboard/web/mechanisms/decay/index.js +1 -0
  31. package/src/adapters/dashboard/web/mechanisms/decay/panel.js +1 -3
  32. package/src/adapters/dashboard/web/mechanisms/dreaming/index.js +3 -2
  33. package/src/adapters/dashboard/web/mechanisms/dreaming/panel.js +20 -0
  34. package/src/adapters/dashboard/web/mechanisms/emotional/index.js +1 -0
  35. package/src/adapters/dashboard/web/mechanisms/emotional/panel.js +24 -0
  36. package/src/adapters/dashboard/web/mechanisms/episodic-semantic/index.js +1 -0
  37. package/src/adapters/dashboard/web/mechanisms/episodic-semantic/panel.js +11 -0
  38. package/src/adapters/dashboard/web/mechanisms/index.js +15 -4
  39. package/src/adapters/dashboard/web/mechanisms/interference/index.js +1 -0
  40. package/src/adapters/dashboard/web/mechanisms/prospective/index.js +1 -0
  41. package/src/adapters/dashboard/web/mechanisms/prospective/panel.js +27 -0
  42. package/src/adapters/dashboard/web/mechanisms/reconsolidation/index.js +1 -0
  43. package/src/adapters/dashboard/web/mechanisms/reconsolidation/panel.js +1 -3
  44. package/src/adapters/dashboard/web/mechanisms/retrieval/index.js +1 -0
  45. package/src/adapters/dashboard/web/mechanisms/retrieval/panel.js +54 -15
  46. package/src/adapters/dashboard/web/mechanisms/salience/index.js +1 -0
  47. package/src/adapters/dashboard/web/mechanisms/salience/panel.js +16 -5
  48. package/src/adapters/dashboard/web/mechanisms/schema/index.js +1 -0
  49. package/src/adapters/dashboard/web/narrate.ts +78 -9
  50. package/src/adapters/dashboard/web/pages/health/health.css +151 -0
  51. package/src/adapters/dashboard/web/pages/health/index.js +28 -13
  52. package/src/adapters/dashboard/web/pages/health/sections/archive.js +5 -2
  53. package/src/adapters/dashboard/web/pages/health/sections/checks.js +31 -24
  54. package/src/adapters/dashboard/web/pages/health/sections/cycle.js +8 -5
  55. package/src/adapters/dashboard/web/pages/health/sections/mechanisms.js +251 -0
  56. package/src/adapters/dashboard/web/pages/health/sections/wake.js +49 -0
  57. package/src/adapters/dashboard/web/pages/home/brain.js +17 -36
  58. package/src/adapters/dashboard/web/pages/home/go.js +7 -0
  59. package/src/adapters/dashboard/web/pages/home/home.css +54 -123
  60. package/src/adapters/dashboard/web/pages/home/index.js +47 -56
  61. package/src/adapters/dashboard/web/pages/home/sections/brain.js +84 -0
  62. package/src/adapters/dashboard/web/pages/home/sections/feel.js +37 -0
  63. package/src/adapters/dashboard/web/pages/home/sections/hero.js +43 -16
  64. package/src/adapters/dashboard/web/pages/home/sections/map.js +25 -0
  65. package/src/adapters/dashboard/web/pages/home/sections/today.js +41 -0
  66. package/src/adapters/dashboard/web/pages/memories/fold.js +48 -0
  67. package/src/adapters/dashboard/web/pages/memories/index.js +9 -3
  68. package/src/adapters/dashboard/web/pages/memories/memories.css +5 -0
  69. package/src/adapters/dashboard/web/pages/memories/row.js +8 -2
  70. package/src/adapters/dashboard/web/pages/memories/sections/feel.js +33 -14
  71. package/src/adapters/dashboard/web/pages/memories/sections/hold.js +9 -4
  72. package/src/adapters/dashboard/web/pages/memories/sections/search.js +59 -11
  73. package/src/adapters/dashboard/web/pages/self/index.js +15 -11
  74. package/src/adapters/dashboard/web/pages/self/sections/dreams.js +6 -2
  75. package/src/adapters/dashboard/web/pages/self/sections/journal.js +31 -12
  76. package/src/adapters/dashboard/web/pages/self/sections/map.js +273 -0
  77. package/src/adapters/dashboard/web/pages/self/sections/page.js +121 -62
  78. package/src/adapters/dashboard/web/pages/self/sections/settling.js +31 -41
  79. package/src/adapters/dashboard/web/pages/self/sections/traits.js +102 -0
  80. package/src/adapters/dashboard/web/pages/self/sections/wake.js +45 -52
  81. package/src/adapters/dashboard/web/pages/self/self.css +110 -72
  82. package/src/adapters/dashboard/web/pages/self/state.js +4 -0
  83. package/src/adapters/dashboard/web/server.ts +20 -1
  84. package/src/adapters/dashboard/web/shared/absence.js +1 -3
  85. package/src/adapters/dashboard/web/shared/base.css +0 -1
  86. package/src/adapters/dashboard/web/shared/doctor.js +68 -0
  87. package/src/adapters/dashboard/web/shared/layout.css +0 -1
  88. package/src/adapters/dashboard/web/shared/memory-card-words.js +96 -0
  89. package/src/adapters/dashboard/web/shared/memory-modal.js +13 -22
  90. package/src/adapters/dashboard/web/shared/widgets/feed.js +22 -15
  91. package/src/adapters/dashboard/web/shell/pulse.js +1 -16
  92. package/src/adapters/dashboard/web/views/activity.ts +43 -7
  93. package/src/adapters/dashboard/web/views/archive-words.ts +6 -0
  94. package/src/adapters/dashboard/web/views/core-road.ts +56 -0
  95. package/src/adapters/dashboard/web/views/dreams.ts +8 -5
  96. package/src/adapters/dashboard/web/views/flow-view.ts +9 -5
  97. package/src/adapters/dashboard/web/views/health.ts +74 -13
  98. package/src/adapters/dashboard/web/views/mechanism-panel.ts +395 -93
  99. package/src/adapters/dashboard/web/views/mechanisms.ts +106 -5
  100. package/src/adapters/dashboard/web/views/memories.ts +33 -22
  101. package/src/adapters/dashboard/web/views/memory.ts +99 -32
  102. package/src/adapters/dashboard/web/views/mind.ts +590 -53
  103. package/src/adapters/dashboard/web/views/overview.ts +57 -99
  104. package/src/adapters/dashboard/web/views/search.ts +58 -7
  105. package/src/adapters/dashboard/web/views/self-map.ts +124 -0
  106. package/src/adapters/dashboard/web/views/today.ts +181 -0
  107. package/src/adapters/dashboard/web/views/traits.ts +296 -0
  108. package/src/adapters/dashboard/web/views.ts +7 -5
  109. package/src/adapters/fired.ts +32 -11
  110. package/src/adapters/mcp/CONTRACT.md +3 -0
  111. package/src/adapters/mcp/NOTES.md +40 -0
  112. package/src/adapters/mcp/bin/serve.ts +6 -1
  113. package/src/adapters/mcp/index.ts +4 -0
  114. package/src/adapters/mcp/server.ts +471 -21
  115. package/src/adapters/mcp/tools.ts +237 -18
  116. package/src/adapters/mechanism-evidence.ts +26 -3
  117. package/src/adapters/sessions.ts +5 -0
  118. package/src/core/counterpart.ts +210 -2
  119. package/src/core/dream/CONTRACT.md +180 -27
  120. package/src/core/dream/INTERFACE-GAPS.md +25 -0
  121. package/src/core/dream/NOTES.md +265 -0
  122. package/src/core/dream/index.ts +745 -139
  123. package/src/core/dream/mind.ts +110 -0
  124. package/src/core/dream/reflect.ts +1734 -0
  125. package/src/core/dream/tunables.ts +33 -4
  126. package/src/core/physics/CONTRACT.md +23 -1
  127. package/src/core/physics/NOTES.md +48 -0
  128. package/src/core/physics/index.ts +100 -7
  129. package/src/core/remember/owes.ts +4 -1
  130. package/src/core/schemas/index.ts +8 -1
  131. package/src/core/self/CONTRACT.md +41 -19
  132. package/src/core/self/INTERFACE-GAPS.md +4 -0
  133. package/src/core/self/NOTES.md +41 -0
  134. package/src/core/self/index.ts +22 -3
  135. package/src/core/self/journal-file.ts +5 -2
  136. package/src/core/self/page.ts +60 -30
  137. package/src/core/self/writer.ts +114 -19
  138. package/src/core/sleep/CONTRACT.md +2 -1
  139. package/src/core/sleep/NOTES.md +51 -0
  140. package/src/core/sleep/consolidate.ts +146 -25
  141. package/src/core/sleep/index.ts +12 -2
  142. package/src/core/sleep/types.ts +17 -0
  143. package/src/core/store/CONTRACT.md +15 -0
  144. package/src/core/store/NOTES.md +92 -1
  145. package/src/core/store/errors.ts +16 -3
  146. package/src/core/store/feelings.ts +159 -22
  147. package/src/core/store/index.ts +572 -29
  148. package/src/core/store/operational.ts +351 -7
  149. package/src/core/store/owner-op-seam.ts +110 -1
  150. package/src/core/store/traits.ts +179 -0
  151. package/src/core/types.ts +17 -2
  152. package/src/adapters/dashboard/web/pages/home/sections/explorer.js +0 -221
  153. package/src/adapters/dashboard/web/pages/home/sections/live-activity.js +0 -31
  154. package/src/adapters/dashboard/web/pages/home/sections/recent-chapters.js +0 -17
  155. package/src/adapters/dashboard/web/pages/home/sections/tiles.js +0 -69
  156. package/src/adapters/dashboard/web/shared/widgets/chapters.js +0 -15
@@ -68,6 +68,8 @@ import type { EventRow } from "../../core/store/index.js";
68
68
  // The ask allowance the amber hint names, read rather than retyped: a number in
69
69
  // a diagnostic's prose is a number that goes stale silently.
70
70
  import { SELF_TUNABLES } from "../../core/self/tunables.js";
71
+ import { dreamingSetting } from "../../core/dream/index.js";
72
+ import type { DreamingSetting } from "../../core/dream/index.js";
71
73
  // The page's own reader, so this line cannot drift from what the wake prints.
72
74
  import { clearedMarker, findPageRow, readSelfPage } from "../../core/self/page.js";
73
75
  import {
@@ -170,9 +172,10 @@ export const SESSION_NOTICE_BUDGET_MS = 150;
170
172
  /**
171
173
  * How many lived days back the newest-row search widens through.
172
174
  *
173
- * `Store.eventLog` orders ASCENDING and takes a LIMIT, so "the newest row of
174
- * this name" is not a query it offers (filed as an ask in `cli/INTERFACE-GAPS`).
175
- * The reading below is exact rather than approximate: a window whose result is
175
+ * Written when `Store.eventLog` read only ASCENDING with a LIMIT, so "the
176
+ * newest row of this name" was not a query it offered. Since #272 it is
177
+ * (`order: "desc", limit: 1`); this ladder predates that and is left as it
178
+ * is, because it is exact either way: a window whose result is
176
179
  * SHORTER than the limit was not truncated, so its last row is provably the
177
180
  * newest in that window. The ladder starts at today so the common case reads
178
181
  * the fewest rows, and widens only when a window is empty.
@@ -1712,6 +1715,7 @@ function rowsInWindow(
1712
1715
  const all = store.eventLog({
1713
1716
  name,
1714
1717
  sinceDay: Math.max(0, livedDay - AUTHORSHIP_DAYS),
1718
+ order: "desc",
1715
1719
  limit: AUTHORSHIP_LIMIT,
1716
1720
  });
1717
1721
  return {
@@ -1719,10 +1723,9 @@ function rowsInWindow(
1719
1723
  const date = rowDate(r);
1720
1724
  return date !== null && date >= from;
1721
1725
  }),
1722
- // `eventLog` orders ASCENDING, so a full read is the OLDEST rows of the
1723
- // window and the newest days are the ones missing. The counts are a floor
1724
- // and the line says so; a confident wrong number is the one thing a
1725
- // diagnostic may never produce.
1726
+ // Read newest first, so a full read is missing the window's OLDEST rows
1727
+ // rather than today's. The counts are still a floor and the line says so;
1728
+ // a confident wrong number is the one thing a diagnostic may never produce.
1726
1729
  truncated: all.length >= AUTHORSHIP_LIMIT,
1727
1730
  };
1728
1731
  }
@@ -2450,31 +2453,179 @@ export function upgradeV8Findings(store: Store): Finding[] {
2450
2453
  ];
2451
2454
  }
2452
2455
 
2456
+ /** The meta row the v9 upgrade writes (`store/operational.ts#V9_UPGRADE_KEY`). */
2457
+ const V9_UPGRADE_META = "physics.v9.upgrade";
2458
+
2453
2459
  /**
2454
- * DREAMING, informational (2026-09-26): when the counterpart last dreamed, and
2455
- * whether today's ask went out or was declined. Never amber: not dreaming is
2456
- * the owner's choice, and a quiet week is not a fault.
2460
+ * WHAT THE v9 UPGRADE CARRIED (2026-09-27, reflection + core by meaning),
2461
+ * informational. The core's first question moved from a kind label to a mark
2462
+ * set by meaning; the upgrade carried the old rule onto the rows it found, so
2463
+ * the candidates did not change overnight — this line says so, and how many
2464
+ * marks have been set by meaning since. Silent on a store born at v9.
2465
+ */
2466
+ export function upgradeV9Findings(store: Store): Finding[] {
2467
+ const upgrade = metaJson(store, V9_UPGRADE_META);
2468
+ if (upgrade === null) return [];
2469
+ const me = metaNum(upgrade["markedMe"]);
2470
+ const owner = metaNum(upgrade["markedOwner"]);
2471
+ const candidates = metaNum(upgrade["candidates"]);
2472
+ let since = 0;
2473
+ let work = 0;
2474
+ try {
2475
+ for (const e of store.coreEvents({ action: "about", limit: 10_000 })) {
2476
+ since += 1;
2477
+ if ((e.reason ?? "").startsWith("work")) work += 1;
2478
+ }
2479
+ } catch {
2480
+ since = 0;
2481
+ }
2482
+ return [
2483
+ finding(
2484
+ "upgrade-v9",
2485
+ "green",
2486
+ "Upgrade",
2487
+ `Upgrade to v9: what a memory is about is now marked by meaning; the old rule was carried so nothing changed overnight — ${String(me)} self ${me === 1 ? "memory" : "memories"} marked about me, ${String(owner)} about the owner (${String(candidates)} core ${candidates === 1 ? "candidate" : "candidates"}); ${String(since)} ${since === 1 ? "mark" : "marks"} set by the writer or a reflection since${work > 0 ? `, ${String(work)} of them "work" (out of the candidates)` : ""}`,
2488
+ "",
2489
+ { markedMe: me, markedOwner: owner, candidates, marksSince: since, work },
2490
+ ),
2491
+ ];
2492
+ }
2493
+
2494
+ /** How many `band.promoted` rows the reflection finding reads, newest first. */
2495
+ export const PROMOTED_ROWS = 5000;
2496
+
2497
+ /**
2498
+ * REFLECTION, informational (2026-09-27): when the waking self last
2499
+ * reflected, what it did, what became of the morning share; the week's
2500
+ * returns by source; and how many memories became core on reflection alone.
2501
+ * Never amber: a quiet week is not a fault.
2502
+ */
2503
+ export function reflectionFindings(input: DoctorInput, store: Store): Finding[] {
2504
+ let last: ReturnType<Store["reflections"]>[number] | undefined;
2505
+ let returns: ReturnType<Store["returnCounts"]>;
2506
+ let alone = 0;
2507
+ // RE-LABELS BY A REFLECTION (owner ruling D2 on #256): every mark a
2508
+ // reflection changed, and apart, those that moved a memory INTO me, us or
2509
+ // the owner (a core candidate it was not before).
2510
+ let relabeled = 0;
2511
+ let movedIn = 0;
2512
+ // A promotion the fast lane made only on a feeling a reflection recorded
2513
+ // later — the half of "on reflection" the open door lets through (review
2514
+ // of #256, S4). Counted apart from `alone`; one memory can be both.
2515
+ let later = 0;
2516
+ let promotionsUnread = false;
2517
+ try {
2518
+ last = store.reflections({ limit: 5 }).find((r) => r.state === "reflected");
2519
+ returns = store.returnCounts({ sinceAt: Date.parse(`${input.today}T00:00:00Z`) - 6 * 86_400_000 });
2520
+ // Newest first with a named ceiling. The default read was the OLDEST 500
2521
+ // promotions, so the newest were the ones never counted; a read that comes
2522
+ // back full has not seen them all, and then the two counts are unknown
2523
+ // rather than a floor dressed as a total (as `newestRows` does).
2524
+ const promotions = store.eventLog({ name: "band.promoted", order: "desc", limit: PROMOTED_ROWS });
2525
+ promotionsUnread = promotions.length >= PROMOTED_ROWS;
2526
+ for (const row of promotions) {
2527
+ try {
2528
+ const p = JSON.parse(row.payload ?? "{}") as { reflectionOnly?: unknown; feelingRecordedLater?: unknown };
2529
+ if (p.reflectionOnly === true) alone += 1;
2530
+ if (p.feelingRecordedLater === true) later += 1;
2531
+ } catch {
2532
+ continue;
2533
+ }
2534
+ }
2535
+ for (const e of store.coreEvents({ action: "about", limit: 10_000 })) {
2536
+ if (e.actor !== "reflection") continue;
2537
+ const m = /^(\w+) \(was (\w+)\)/.exec(e.reason ?? "");
2538
+ if (m === null || m[1] === m[2]) continue;
2539
+ relabeled += 1;
2540
+ const core = (x: string | undefined): boolean => x === "me" || x === "us" || x === "owner";
2541
+ if (core(m[1]) && !core(m[2])) movedIn += 1;
2542
+ }
2543
+ } catch {
2544
+ return [];
2545
+ }
2546
+ const share: Record<string, string> = {
2547
+ none: "no share",
2548
+ offered: "its morning share not told yet",
2549
+ carried: "its morning share carried to a later session",
2550
+ told: "its morning share told",
2551
+ };
2552
+ const what =
2553
+ last === undefined
2554
+ ? "has not reflected yet"
2555
+ : `last reflected ${last.date ?? `lived day ${String(last.day)}`} (${last.dream_id === null ? "on its own" : "after a dream"}): ${
2556
+ last.entry_id === null ? "nothing much" : "an entry"
2557
+ }${last.page_version === null ? "" : ", the self page rewritten"}, ${share[last.share_state] ?? last.share_state}`;
2558
+ const byHow = `returns this week — awake ${String(returns.awake)}, reflection ${String(returns.reflection)}, dream ${String(returns.dream)}`;
2559
+ const aloneLine =
2560
+ (promotionsUnread
2561
+ ? `; how many became core on reflection alone is unknown: more than ${String(PROMOTED_ROWS)} promotions in the log, and only the newest ${String(PROMOTED_ROWS)} were read`
2562
+ : "") +
2563
+ (!promotionsUnread && alone > 0 ? `; ${String(alone)} ${alone === 1 ? "memory" : "memories"} became core on reflection alone` : "") +
2564
+ (!promotionsUnread && later > 0 ? `; ${String(later)} ${later === 1 ? "memory" : "memories"} became core on a feeling a reflection recorded later` : "") +
2565
+ (relabeled > 0
2566
+ ? `; ${String(relabeled)} ${relabeled === 1 ? "mark" : "marks"} changed by a reflection, ${String(movedIn)} of them into me, us or the owner`
2567
+ : "");
2568
+ return [
2569
+ finding(
2570
+ "reflection",
2571
+ "green",
2572
+ "Reflection",
2573
+ `${what}; ${byHow}${aloneLine}`,
2574
+ "",
2575
+ {
2576
+ last: last?.date ?? null,
2577
+ reflection: last?.id ?? null,
2578
+ page: last?.page_version !== null && last?.page_version !== undefined,
2579
+ share: last?.share_state ?? null,
2580
+ returnsAwake: returns.awake,
2581
+ returnsReflection: returns.reflection,
2582
+ returnsDream: returns.dream,
2583
+ promotedOnReflectionAlone: promotionsUnread ? null : alone,
2584
+ promotedOnFeelingRecordedLater: promotionsUnread ? null : later,
2585
+ relabeledByReflection: relabeled,
2586
+ relabeledIntoCore: movedIn,
2587
+ },
2588
+ ),
2589
+ ];
2590
+ }
2591
+
2592
+ /**
2593
+ * DREAMING, informational (2026-09-26): the owner's setting (2026-09-28:
2594
+ * auto, ask or off), when the counterpart last dreamed, and what today's line
2595
+ * did — started the nightly run, asked, or was declined. Never amber: not
2596
+ * dreaming is the owner's choice, and a quiet week is not a fault.
2457
2597
  */
2458
2598
  export function dreamingFindings(input: DoctorInput, store: Store): Finding[] {
2459
2599
  let last: ReturnType<Store["dreams"]>[number] | undefined;
2460
2600
  let ask: ReturnType<Store["dreamAsk"]>;
2601
+ let setting: DreamingSetting;
2461
2602
  try {
2462
2603
  last = store.dreams({ limit: 5 }).find((d) => d.state !== "undone");
2463
2604
  ask = store.dreamAsk(input.today);
2605
+ setting = dreamingSetting(store);
2464
2606
  } catch {
2465
2607
  return [];
2466
2608
  }
2467
2609
  const when = last === undefined ? null : (last.date ?? `lived day ${String(last.day)}`);
2468
2610
  const today =
2469
- ask === undefined ? "not asked today" : ask.state === "declined" ? "asked today; the owner said not today" : "asked today";
2611
+ setting === "off"
2612
+ ? "off — no dreams (counterparts dream --setting auto turns it back on)"
2613
+ : ask === undefined
2614
+ ? "not started today"
2615
+ : ask.state === "declined"
2616
+ ? "asked today; the owner said not today"
2617
+ : ask.state === "launched"
2618
+ ? "started today, in the background"
2619
+ : "asked today";
2620
+ const unfinished = last !== undefined && last.state === "begun" ? `; dream ${last.id} is begun and not yet journaled` : "";
2470
2621
  return [
2471
2622
  finding(
2472
2623
  "dreaming",
2473
2624
  "green",
2474
2625
  "Dreaming",
2475
- `${when === null ? "has not dreamed yet" : `last dreamed ${when}${last?.title ? ` — "${last.title}"` : ""}`}; ${today}`,
2626
+ `${setting}; ${when === null ? "has not dreamed yet" : `last dreamed ${when}${last?.title ? ` — "${last.title}"` : ""}`}; ${today}${unfinished}`,
2476
2627
  "",
2477
- { last: when, dream: last?.id ?? null, ask: ask?.state ?? null },
2628
+ { setting, last: when, dream: last?.id ?? null, ask: ask?.state ?? null },
2478
2629
  ),
2479
2630
  ];
2480
2631
  }
@@ -2556,10 +2707,18 @@ export function selfPageFindings(store: Store): Finding[] {
2556
2707
  * Green also for a night that read the day and had nothing to say: that is the
2557
2708
  * mechanism working, and it is stated in words rather than left as a silence.
2558
2709
  *
2559
- * AMBER, with a fix, on the two readings that mean something has stopped: the
2560
- * writer is switched off while a page exists (somebody turned it off and the
2561
- * page will now only move by hand), and a run that failed or was refused. Never
2562
- * red: nothing here can cost a session its memory.
2710
+ * Green when it is OFF, too — a deliberate choice is not a fault — with the
2711
+ * line saying what off means. (This comment and the adapter CONTRACT used to
2712
+ * say "amber while a page stands"; the code has said green since the S2
2713
+ * review, and the words now follow the code, 2026-09-28.)
2714
+ *
2715
+ * AMBER, with a fix, on the readings that mean something has stopped: a run
2716
+ * that failed or was refused, a pageWriter block that could not be read, and
2717
+ * — since the writer moved into the nightly run (2026-09-28) — a night owed
2718
+ * for days while nightly runs went on without it. A night owed because no run
2719
+ * started (fewer than three new memories, dreaming off or declined) is the
2720
+ * ordinary state of a quiet week and stays green. Never red: nothing here can
2721
+ * cost a session its memory.
2563
2722
  */
2564
2723
  export function pageWriterFindings(store: Store, config: AdapterConfig): Finding[] {
2565
2724
  const mode = pageWriterMode(config);
@@ -2623,7 +2782,9 @@ export function pageWriterFindings(store: Store, config: AdapterConfig): Finding
2623
2782
  "Page writer",
2624
2783
  young
2625
2784
  ? `${mode} mode; never run — this store has no day before ${today} yet`
2626
- : `${mode} mode; never run — the next session start is its first turn (${about})`,
2785
+ : mode === "session"
2786
+ ? `${mode} mode; never run — it is the first part of the next nightly run, before the dream (${about})${dreamingSetting(store) === "off" ? "; dreaming is off, so the nightly run does not start" : ""}`
2787
+ : `${mode} mode; never run — the next boundary's worker starts it (${about})`,
2627
2788
  "",
2628
2789
  { ...data, young },
2629
2790
  ),
@@ -2645,7 +2806,14 @@ export function pageWriterFindings(store: Store, config: AdapterConfig): Finding
2645
2806
  asksPerDay: SELF_TUNABLES.PAGE_WRITER_ASKS_PER_DAY,
2646
2807
  });
2647
2808
  const staleFor = last.on === "" ? 0 : daysBetween(last.on, today);
2648
- const overdue = owed.due && staleFor > PAGE_WRITER_STALE_DAYS;
2809
+ // OWED IS NOT OVERDUE on its own any more (2026-09-28). The writer runs
2810
+ // inside the nightly run, and a night with fewer than three new memories
2811
+ // runs nothing — the day carries over — so "owed for days" is the ordinary
2812
+ // state of a quiet week. It is amber only when nightly runs HAPPENED since
2813
+ // (a dream dated after the writer's last row, before today) and the writer
2814
+ // still left nothing: the run is going without it.
2815
+ const ranSince = mode === "session" && last.on !== "" ? dreamsBetween(store, last.on, today) : 0;
2816
+ const overdue = owed.due && staleFor > PAGE_WRITER_STALE_DAYS && (mode !== "session" || ranSince > 0);
2649
2817
  const bad = status.outcome === "failed" || status.outcome === "refused";
2650
2818
  const detail =
2651
2819
  `${mode} mode; ${when} — ${status.outcome}` +
@@ -2662,7 +2830,9 @@ export function pageWriterFindings(store: Store, config: AdapterConfig): Finding
2662
2830
  "Page writer",
2663
2831
  detail,
2664
2832
  bad || overdue
2665
- ? "counterparts mechanisms --all --dir <store> --observer shows the run's own row. A night that is owed but never delivered is usually the host's injection ceiling: the block is deferred rather than truncated, so raise injectionBudgetBytes or run the writer in host mode. counterparts self-page --write amends the page by hand meanwhile."
2833
+ ? mode === "session"
2834
+ ? "counterparts mechanisms --all --dir <store> --observer shows the run's own row. The page writer is the first part of the nightly run, before the dream: counterparts dream shows whether the runs are happening and how each ended. counterparts self-page --write amends the page by hand meanwhile."
2835
+ : "counterparts mechanisms --all --dir <store> --observer shows the run's own row. In host mode the boundary's worker starts a windowless session for the writer; a night that is owed but never delivered usually means that session could not start. counterparts self-page --write amends the page by hand meanwhile."
2666
2836
  : "",
2667
2837
  {
2668
2838
  ...data,
@@ -2687,6 +2857,15 @@ export function pageWriterFindings(store: Store, config: AdapterConfig): Finding
2687
2857
  * missed last night has not failed; one that has missed three has. */
2688
2858
  export const PAGE_WRITER_STALE_DAYS = 2;
2689
2859
 
2860
+ /** Dreams begun on a calendar date after `after` and before `before` (not undone). Never throws. */
2861
+ function dreamsBetween(store: Store, after: string, before: string): number {
2862
+ try {
2863
+ return store.dreams({ limit: 50 }).filter((d) => d.state !== "undone" && d.date !== null && d.date > after && d.date < before).length;
2864
+ } catch {
2865
+ return 0;
2866
+ }
2867
+ }
2868
+
2690
2869
  /** A page that was written and then cleared: when, why, and what is restorable.
2691
2870
  * Null when no page row exists at all. */
2692
2871
  function clearedPage(
@@ -3222,6 +3401,9 @@ export function doctorFindings(input: DoctorInput): Finding[] {
3222
3401
  ["upgrade-v8", () => upgradeV8Findings(store)],
3223
3402
  // Dreaming (2026-09-26): informational — last dreamed, and today's ask.
3224
3403
  ["dreaming", () => dreamingFindings(input, store)],
3404
+ // v9 (2026-09-27): what the upgrade carried, and the reflection.
3405
+ ["upgrade-v9", () => upgradeV9Findings(store)],
3406
+ ["reflection", () => reflectionFindings(input, store)],
3225
3407
  // LAST, and deliberately: it is the widest read here — the whole event log,
3226
3408
  // plus a pass over the ids for the table probes — so when the console's
3227
3409
  // reading is cut short this is the group that goes, and the `Budget` finding