counterparts 0.3.11 → 0.3.13

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 (150) hide show
  1. package/CHANGELOG.md +326 -0
  2. package/docs/QUICKSTART.md +5 -0
  3. package/docs/README.md +2 -2
  4. package/docs/module-map.md +3 -3
  5. package/package.json +1 -1
  6. package/src/adapters/claude-code/CONTRACT.md +36 -10
  7. package/src/adapters/claude-code/INTERFACE-GAPS.md +116 -16
  8. package/src/adapters/claude-code/NOTES.md +182 -0
  9. package/src/adapters/claude-code/bin/hook.ts +46 -12
  10. package/src/adapters/claude-code/bin/runner.ts +7 -1
  11. package/src/adapters/claude-code/doctor.ts +632 -18
  12. package/src/adapters/claude-code/hooks.ts +61 -16
  13. package/src/adapters/claude-code/index.ts +11 -0
  14. package/src/adapters/claude-code/night-run.ts +150 -14
  15. package/src/adapters/claude-code/transcript.ts +268 -1
  16. package/src/adapters/cli/CONTRACT.md +5 -0
  17. package/src/adapters/cli/INTERFACE-GAPS.md +8 -4
  18. package/src/adapters/cli/NOTES.md +111 -0
  19. package/src/adapters/cli/commands.ts +134 -92
  20. package/src/adapters/cli/dream-core.ts +57 -42
  21. package/src/adapters/cli/export.ts +320 -21
  22. package/src/adapters/cli/help.ts +2 -1
  23. package/src/adapters/cli/index.ts +1 -0
  24. package/src/adapters/cli/install.ts +39 -7
  25. package/src/adapters/cli/mechanisms.ts +7 -1
  26. package/src/adapters/cli/uninstall.ts +13 -5
  27. package/src/adapters/cli/wire.ts +189 -63
  28. package/src/adapters/config.ts +2 -0
  29. package/src/adapters/dashboard/INTERFACE-GAPS.md +10 -1
  30. package/src/adapters/dashboard/NOTES.md +79 -0
  31. package/src/adapters/dashboard/registries.ts +34 -2
  32. package/src/adapters/dashboard/web/README.md +19 -14
  33. package/src/adapters/dashboard/web/actions.ts +23 -1
  34. package/src/adapters/dashboard/web/flow.ts +14 -0
  35. package/src/adapters/dashboard/web/lanes.ts +10 -0
  36. package/src/adapters/dashboard/web/narrate.ts +88 -2
  37. package/src/adapters/dashboard/web/pages/flow/sections/fired.js +1 -0
  38. package/src/adapters/dashboard/web/pages/health/sections/checks.js +2 -0
  39. package/src/adapters/dashboard/web/pages/health/sections/wake.js +3 -1
  40. package/src/adapters/dashboard/web/pages/memories/memories.css +17 -4
  41. package/src/adapters/dashboard/web/pages/memories/row.js +37 -21
  42. package/src/adapters/dashboard/web/pages/memories/sections/search.js +279 -60
  43. package/src/adapters/dashboard/web/pages/memories/state.js +2 -1
  44. package/src/adapters/dashboard/web/server.ts +0 -5
  45. package/src/adapters/dashboard/web/shared/memory-marks.css +7 -0
  46. package/src/adapters/dashboard/web/shared/memory-marks.js +33 -0
  47. package/src/adapters/dashboard/web/shared/memory-modal.js +5 -3
  48. package/src/adapters/dashboard/web/views/health.ts +21 -3
  49. package/src/adapters/dashboard/web/views/search.ts +4 -45
  50. package/src/adapters/dashboard/web/views.ts +2 -2
  51. package/src/adapters/fired.ts +430 -28
  52. package/src/adapters/host-wiring.ts +300 -0
  53. package/src/adapters/hosts.ts +11 -0
  54. package/src/adapters/lifecycle.ts +42 -2
  55. package/src/adapters/log/index.ts +9 -0
  56. package/src/adapters/mcp/CONTRACT.md +151 -11
  57. package/src/adapters/mcp/INTERFACE-GAPS.md +24 -2
  58. package/src/adapters/mcp/NOTES.md +313 -1
  59. package/src/adapters/mcp/bin/serve.ts +74 -1
  60. package/src/adapters/mcp/deliberate.ts +169 -651
  61. package/src/adapters/mcp/facts.ts +1094 -0
  62. package/src/adapters/mcp/index.ts +25 -7
  63. package/src/adapters/mcp/meaning.ts +1610 -0
  64. package/src/adapters/mcp/server.ts +835 -150
  65. package/src/adapters/mcp/stdio.ts +3 -1
  66. package/src/adapters/mcp/stood-down.ts +51 -0
  67. package/src/adapters/mcp/tools.ts +167 -41
  68. package/src/adapters/plugin-run.sh +133 -0
  69. package/src/adapters/plugin.ts +329 -0
  70. package/src/adapters/sessions.ts +18 -4
  71. package/src/core/associate/CONTRACT.md +2 -1
  72. package/src/core/associate/INTERFACE-GAPS.md +6 -1
  73. package/src/core/associate/NOTES.md +45 -0
  74. package/src/core/briefing.ts +12 -3
  75. package/src/core/contradictions.ts +184 -0
  76. package/src/core/counterpart.ts +797 -51
  77. package/src/core/dream/CONTRACT.md +36 -4
  78. package/src/core/dream/INTERFACE-GAPS.md +29 -6
  79. package/src/core/dream/NOTES.md +107 -0
  80. package/src/core/dream/feeling-weeks.ts +198 -0
  81. package/src/core/dream/index.ts +109 -18
  82. package/src/core/dream/reflect.ts +346 -87
  83. package/src/core/dream/tunables.ts +24 -4
  84. package/src/core/encode/INTERFACE-GAPS.md +3 -1
  85. package/src/core/encode/NOTES.md +7 -0
  86. package/src/core/encode/words.ts +45 -0
  87. package/src/core/fit/INTERFACE-GAPS.md +8 -2
  88. package/src/core/fit/NOTES.md +39 -1
  89. package/src/core/fit/index.ts +40 -0
  90. package/src/core/handoff/CONTRACT.md +37 -2
  91. package/src/core/handoff/INTERFACE-GAPS.md +10 -0
  92. package/src/core/handoff/NOTES.md +72 -0
  93. package/src/core/handoff/index.ts +214 -12
  94. package/src/core/handoff/last-here.ts +6 -4
  95. package/src/core/mint.ts +12 -2
  96. package/src/core/physics/CONTRACT.md +14 -2
  97. package/src/core/physics/NOTES.md +33 -1
  98. package/src/core/physics/index.ts +28 -5
  99. package/src/core/prospective/CONTRACT.md +45 -6
  100. package/src/core/prospective/INTERFACE-GAPS.md +4 -0
  101. package/src/core/prospective/NOTES.md +138 -0
  102. package/src/core/prospective/derive.ts +33 -5
  103. package/src/core/prospective/index.ts +90 -5
  104. package/src/core/prospective/windows.ts +72 -1
  105. package/src/core/recall/CONTRACT.md +31 -12
  106. package/src/core/recall/INTERFACE-GAPS.md +28 -4
  107. package/src/core/recall/NOTES.md +70 -1
  108. package/src/core/recall/feeling-ask.ts +10 -1
  109. package/src/core/recall/index.ts +3 -1
  110. package/src/core/recall/probe.ts +58 -0
  111. package/src/core/recall/session.ts +46 -2
  112. package/src/core/recall/time-ask.ts +487 -0
  113. package/src/core/remember/CONTRACT.md +4 -1
  114. package/src/core/remember/INTERFACE-GAPS.md +9 -1
  115. package/src/core/remember/NOTES.md +8 -0
  116. package/src/core/remember/proposals.ts +47 -5
  117. package/src/core/revision.ts +18 -1
  118. package/src/core/schemas/CONTRACT.md +21 -1
  119. package/src/core/schemas/INTERFACE-GAPS.md +20 -2
  120. package/src/core/schemas/NOTES.md +144 -0
  121. package/src/core/schemas/aliases.ts +55 -5
  122. package/src/core/schemas/index.ts +93 -1
  123. package/src/core/schemas/types.ts +2 -0
  124. package/src/core/self/CONTRACT.md +32 -5
  125. package/src/core/self/INTERFACE-GAPS.md +7 -2
  126. package/src/core/self/NOTES.md +102 -1
  127. package/src/core/self/behind.ts +43 -3
  128. package/src/core/self/briefing.ts +12 -2
  129. package/src/core/self/chapter-address.ts +254 -0
  130. package/src/core/self/episodes.ts +27 -0
  131. package/src/core/self/index.ts +83 -8
  132. package/src/core/self/page.ts +88 -0
  133. package/src/core/self/tunables.ts +5 -0
  134. package/src/core/self/work.ts +35 -2
  135. package/src/core/self/writer.ts +30 -0
  136. package/src/core/sleep/INTERFACE-GAPS.md +22 -3
  137. package/src/core/sleep/NOTES.md +20 -1
  138. package/src/core/sleep/consolidate.ts +59 -7
  139. package/src/core/sleep/index.ts +3 -0
  140. package/src/core/sleep/prune.ts +6 -2
  141. package/src/core/sleep/types.ts +7 -0
  142. package/src/core/store/CONTRACT.md +16 -0
  143. package/src/core/store/NOTES.md +66 -0
  144. package/src/core/store/feelings.ts +14 -1
  145. package/src/core/store/index.ts +483 -16
  146. package/src/core/store/operational.ts +95 -2
  147. package/src/core/store/owner-op-seam.ts +23 -0
  148. package/src/core/time.ts +152 -0
  149. package/tools/install-loop/run.sh +48 -12
  150. package/src/adapters/dashboard/web/pages/memories/fold.js +0 -53
@@ -32,7 +32,7 @@
32
32
  * nobody needed).
33
33
  */
34
34
  import { spawnSync } from "node:child_process";
35
- import { addDays, isDay, localDate, resolveZone } from "../../core/time.js";
35
+ import { addDays, isDay, localDate, resolveZone, startOfLocalDay } from "../../core/time.js";
36
36
  import { existsSync, mkdirSync, rmSync, statSync } from "node:fs";
37
37
  import { homedir } from "node:os";
38
38
  import { dirname, join } from "node:path";
@@ -42,8 +42,15 @@ import {
42
42
  ADAPTER_ASK_EVENT,
43
43
  BOUNDARY_EVENT,
44
44
  EMBED_BACKFILL_EVENT,
45
+ ENVELOPE_GAVE_WAY_EVENT,
46
+ ENVELOPE_OVERCAP_EVENT,
47
+ INJECTION_OVERBUDGET_EVENT,
48
+ NOTICE_DROPPED_EVENT,
45
49
  GATE_CHUNK_EVENT,
46
50
  GATE_DEPOSIT_EVENT,
51
+ MCP_OVERSIZE_EVENT,
52
+ MCP_PART_EVENT,
53
+ MCP_SPILLED_EVENT,
47
54
  RECALL_CREDIT_EVENT,
48
55
  RUNNER_FAILED_EVENT,
49
56
  SLEEP_CYCLE_EVENT,
@@ -51,7 +58,9 @@ import {
51
58
  SNAPSHOT_TAKEN_EVENT,
52
59
  SPAWN_FAILED_EVENT,
53
60
  SPAWN_REFUSED_EVENT,
61
+ SPAWN_STARTED_EVENT,
54
62
  SWEEP_GATE_EVENT,
63
+ WAKE_DELIVERED_EVENT,
55
64
  } from "../../core/counterpart.js";
56
65
  import { Counterpart } from "../../core/counterpart.js";
57
66
  import {
@@ -66,13 +75,17 @@ import {
66
75
  } from "../../core/store/index.js";
67
76
  import { BUSY_TIMEOUT_MS, journalModeOf } from "../../core/store/db.js";
68
77
  import { CLI_SCRIPT, NODE_HOOKS } from "../runtime.js";
69
- import { acceptsReflectedFeeling, selfRelevantFeeling } from "../../core/sleep/index.js";
78
+ import { acceptsReflectedFeeling, laterFeelingWasAwake, laterFeelingWasReflections, selfRelevantFeeling } from "../../core/sleep/index.js";
70
79
  import { TUNABLES as ASSOCIATE_TUNABLES, isDead, pairKey } from "../../core/associate/index.js";
71
80
  import type { EventRow } from "../../core/store/index.js";
72
81
  // The ask allowance the amber hint names, read rather than retyped: a number in
73
82
  // a diagnostic's prose is a number that goes stale silently.
74
83
  import { SELF_TUNABLES } from "../../core/self/tunables.js";
75
- import { dreamingSetting, nightPartsWords, nightRunLost, nightRunOf, nightRunWords } from "../../core/dream/index.js";
84
+ import { WORK_OVERFLOW_EVENT } from "../../core/self/work.js";
85
+ import { HANDOFF_REFUSED_EVENT } from "../../core/handoff/index.js";
86
+ import { LAST_HERE_NOROOM_EVENT } from "../../core/handoff/last-here.js";
87
+ import { TOOL_RESULT_CEILING } from "../../core/fit/index.js";
88
+ import { awakeFeelingCounts, dreamingSetting, nightPartsWords, nightRunLost, nightRunOf, nightRunWords } from "../../core/dream/index.js";
76
89
  import type { DreamingSetting } from "../../core/dream/index.js";
77
90
  // The page's own reader, so this line cannot drift from what the wake prints.
78
91
  import { clearedMarker, findPageRow, readSelfPage } from "../../core/self/page.js";
@@ -127,6 +140,7 @@ import {
127
140
  writeUpPlan,
128
141
  } from "../sessions.js";
129
142
  import { DESKTOP_HOST } from "../hosts.js";
143
+ import type { PluginInstallRead } from "../host-wiring.js";
130
144
  import { localStamp } from "../../core/time.js";
131
145
  import { catchUpOf, catchUpWords } from "./night-catch-up.js";
132
146
  import type { AdapterConfig } from "../config.js";
@@ -1004,7 +1018,22 @@ function configFindings(input: DoctorInput): Finding[] {
1004
1018
  }),
1005
1019
  );
1006
1020
  } else {
1007
- out.push(finding("stance", "green", "Mode", "remembering", "", { observer: false }));
1021
+ // WHOSE SESSIONS ARE THE OWNER'S, said plainly (2026-10-02): with the
1022
+ // install's `owner: true`, the hooks, the worker and — since that day —
1023
+ // the memory server Claude Code starts (`mcp/bin/serve.ts#ownerStance`).
1024
+ const owner = input.config.owner === true;
1025
+ out.push(
1026
+ finding(
1027
+ "stance",
1028
+ "green",
1029
+ "Mode",
1030
+ owner
1031
+ ? "remembering; your Claude Code sessions are the owner's (confidential memories are said in them, and an open question can be closed from any directory); a Claude Desktop chat is not; COUNTERPARTS_OWNER=0 on the memory server's launch turns it off for the memory server, and the hooks follow this configuration"
1032
+ : "remembering; no session is the owner's (the configuration has no \"owner\": true), so confidential memories stay out of the tools' answers",
1033
+ "",
1034
+ { observer: false, owner },
1035
+ ),
1036
+ );
1008
1037
  }
1009
1038
  return out;
1010
1039
  }
@@ -1868,6 +1897,15 @@ function authorshipFindings(input: DoctorInput, store: Store, owedReading: OwedS
1868
1897
  * a standing fact about the build, and ambering on it every morning would train
1869
1898
  * its reader to ignore the line that matters.
1870
1899
  *
1900
+ * NOT EVERY SILENCE IS ONE (2026-10-09). A one-time job that ran is `done` and
1901
+ * an occasion-driven one whose occasion has not come is `waiting`
1902
+ * (`fired.ts#Cadence`); neither can go quiet, so neither turns this line amber —
1903
+ * the owner's store went amber on a plain reminder that had not fallen due and
1904
+ * on the v8 census, which runs once. The `never` count never fed the colour,
1905
+ * only the words, and the owner-action and failure rows have left it for
1906
+ * `waiting`. The one occasion the store can SEE — a plain reminder due on a day
1907
+ * a session ran — is graded instead: due and not said is amber.
1908
+ *
1871
1909
  * THE SESSION-START READING DOES NOT TAKE IT. This is the only group here whose
1872
1910
  * SQL is not bounded by a lived day — the roll-call is a question about the
1873
1911
  * whole log, and the five table probes cost a query per memory on top — and a
@@ -1906,6 +1944,8 @@ function firedFindings(input: DoctorInput, store: Store): Finding[] {
1906
1944
  `${shown === report.from ? "this week" : "in that time"}${blocked}, ` +
1907
1945
  `${String(c.quiet)} ${c.quiet === 1 ? "has" : "have"} gone quiet, ` +
1908
1946
  `${String(c.never)} ${c.never === 1 ? "has" : "have"} never fired, ` +
1947
+ `${String(c.waiting)} ${c.waiting === 1 ? "is" : "are"} waiting for an occasion (an owner's action, a failure, a reminder falling due), ` +
1948
+ `${String(c.done)} one-time ${c.done === 1 ? "job is" : "jobs are"} done, ` +
1909
1949
  `${String(c.new)} ${c.new === 1 ? "is" : "are"} too new to grade, ` +
1910
1950
  `${String(c.blind)} ${c.blind === 1 ? "records" : "record"} nothing durable at all` +
1911
1951
  `${c.disabled + c.retired === 0 ? "" : ` (${String(c.disabled)} stood down, ${String(c.retired)} retired)`}` +
@@ -1919,6 +1959,8 @@ function firedFindings(input: DoctorInput, store: Store): Finding[] {
1919
1959
  quiet: c.quiet,
1920
1960
  never: c.never,
1921
1961
  new: c.new,
1962
+ waiting: c.waiting,
1963
+ done: c.done,
1922
1964
  blind: c.blind,
1923
1965
  disabled: c.disabled,
1924
1966
  retired: c.retired,
@@ -1926,6 +1968,7 @@ function firedFindings(input: DoctorInput, store: Store): Finding[] {
1926
1968
  truncated: report.truncated,
1927
1969
  wentQuiet: report.wentQuiet.join("; "),
1928
1970
  wentBlocked: report.wentBlocked.join("; "),
1971
+ missedOccasion: report.missedOccasion.join("; "),
1929
1972
  young: report.young,
1930
1973
  livedDay: report.livedDay,
1931
1974
  };
@@ -1953,7 +1996,7 @@ function firedFindings(input: DoctorInput, store: Store): Finding[] {
1953
1996
  // leaves `wentQuiet` — and without `wentBlocked` this finding would have gone
1954
1997
  // GREEN for it. A state that says MORE must never make a diagnostic read
1955
1998
  // safer than it did before that state existed.
1956
- if (report.wentQuiet.length === 0 && report.wentBlocked.length === 0) {
1999
+ if (report.wentQuiet.length === 0 && report.wentBlocked.length === 0 && report.missedOccasion.length === 0) {
1957
2000
  return [
1958
2001
  finding(
1959
2002
  "fired",
@@ -1969,6 +2012,9 @@ function firedFindings(input: DoctorInput, store: Store): Finding[] {
1969
2012
  report.wentBlocked.length === 0
1970
2013
  ? ""
1971
2014
  : `Fired last week and STOPPED this week: ${report.wentBlocked.join("; ")}`,
2015
+ report.missedOccasion.length === 0
2016
+ ? ""
2017
+ : `Its occasion came this week and it did not fire: ${report.missedOccasion.join("; ")}`,
1972
2018
  report.wentQuiet.length === 0
1973
2019
  ? ""
1974
2020
  : `Fired last week and not once this week: ${report.wentQuiet.join("; ")}`,
@@ -1981,7 +2027,9 @@ function firedFindings(input: DoctorInput, store: Store): Finding[] {
1981
2027
  `${roll}. ${changed.join(". ")}`,
1982
2028
  report.wentBlocked.length > 0
1983
2029
  ? `Run: counterparts mechanisms --all — ${STATE_MEANING.blocked}, and the reason on the row names what to fix.`
1984
- : `Run: counterparts mechanisms --all — ${STATE_MEANING.quiet}, which is a wiring fault more often than a verdict.`,
2030
+ : report.missedOccasion.length > 0
2031
+ ? "Run: counterparts mechanisms --all — the row says what was due and not said; its occasion came, so this silence is the mechanism failing, not resting."
2032
+ : `Run: counterparts mechanisms --all — ${STATE_MEANING.quiet}, which is a wiring fault more often than a verdict.`,
1985
2033
  data,
1986
2034
  ),
1987
2035
  ];
@@ -2039,6 +2087,51 @@ function spawnFindings(input: DoctorInput, store: Store): Finding[] {
2039
2087
  finding("spawn", "amber", "Spawn", `spawn refusals standing: ${counts}${rowClause === "" ? "" : ` — ${rowClause}`}`, "A spawn that starts clears every counter.", data),
2040
2088
  ];
2041
2089
  }
2090
+ // STARTED, THEN FAILED (2026-10-02, the "nobody saw it" review). The
2091
+ // counters clear on a start, so a worker that starts every boundary and then
2092
+ // throws — the wake not refreshed, the session-end pass not run — read green
2093
+ // here with its failure only named in passing. STANDING (review of #315: one
2094
+ // transient SQLITE_BUSY must not hold it amber for two days) means either
2095
+ // the same step failed on both today and yesterday, or the newest failure is
2096
+ // newer than the newest recorded start. Both rows are latched once a
2097
+ // calendar date (a step's failure, and the first start; "newer" is the
2098
+ // log's own order, `seq`), so the second reads
2099
+ // "it failed after today's first start" and clears at the next day's first
2100
+ // start unless the step fails again. Older is history, named in the clause.
2101
+ // THE LAST THREE LIVED DAYS, read as one window (2026-10-02): `newestRows`
2102
+ // stops at the first window with rows — today's — so yesterday's failure was
2103
+ // never read and "the same step, today and yesterday" could not fire on a
2104
+ // store whose days had moved. Newest first under the ceiling, then oldest
2105
+ // first, so the last row is the newest.
2106
+ let failures: EventRow[] = [];
2107
+ try {
2108
+ failures = store
2109
+ .eventLog({ name: RUNNER_FAILED_EVENT, sinceDay: Math.max(0, livedDay - 2), order: "desc", limit: RUNNER_FAILED_ROWS })
2110
+ .reverse();
2111
+ } catch {
2112
+ failures = [];
2113
+ }
2114
+ const failed = failures[failures.length - 1];
2115
+ const failedOn = rowDate(failed);
2116
+ const started = newestRows(store, SPAWN_STARTED_EVENT, 1, livedDay).rows[0];
2117
+ const yesterday = addDays(input.today, -1);
2118
+ const stepOn = (step: string | null, date: string): boolean =>
2119
+ failures.some((r) => str(payloadOf(r), "step") === step && rowDate(r) === date);
2120
+ const repeated = failed !== undefined && stepOn(str(payloadOf(failed), "step"), input.today) && stepOn(str(payloadOf(failed), "step"), yesterday);
2121
+ const sinceStart = failed !== undefined && (failedOn === input.today || failedOn === yesterday) && (started === undefined || failed.seq > started.seq);
2122
+ if (failed !== undefined && failedOn !== null && (repeated || sinceStart)) {
2123
+ const fp = payloadOf(failed);
2124
+ return [
2125
+ finding(
2126
+ "spawn",
2127
+ "amber",
2128
+ "Spawn",
2129
+ `the background worker started${startClause === "" ? "" : ` (${startClause.slice(2)})`} but failed at its ${str(fp, "step") ?? "?"} step on ${failedOn} (${str(fp, "code") ?? "?"})${rowClause === "" ? "" : ` — ${rowClause}`}`,
2130
+ "Nothing to do by hand: the next boundary runs the worker again. If it repeats, the process log (the Log line) has the error.",
2131
+ { ...data, startsToday: starts, failedStep: str(fp, "step"), failedOn },
2132
+ ),
2133
+ ];
2134
+ }
2042
2135
  return [
2043
2136
  finding(
2044
2137
  "spawn",
@@ -2515,8 +2608,12 @@ export function upgradeV9Findings(store: Store): Finding[] {
2515
2608
  const candidates = metaNum(upgrade["candidates"]);
2516
2609
  let since = 0;
2517
2610
  let work = 0;
2611
+ let floor = false;
2518
2612
  try {
2519
- for (const e of store.coreEvents({ action: "about", limit: 10_000 })) {
2613
+ const marks = store.coreEvents({ action: "about", limit: MARK_ROWS });
2614
+ // A FULL READ IS A FLOOR (2026-10-02), as the Reflection line's is.
2615
+ floor = marks.length >= MARK_ROWS;
2616
+ for (const e of marks) {
2520
2617
  since += 1;
2521
2618
  if ((e.reason ?? "").startsWith("work")) work += 1;
2522
2619
  }
@@ -2528,9 +2625,9 @@ export function upgradeV9Findings(store: Store): Finding[] {
2528
2625
  "upgrade-v9",
2529
2626
  "green",
2530
2627
  "Upgrade",
2531
- `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)` : ""}`,
2628
+ `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"}); ${floor ? "at least " : ""}${String(since)} ${since === 1 ? "mark" : "marks"} set by the writer or a reflection since${work > 0 ? `, ${floor ? "at least " : ""}${String(work)} of them "work" (out of the candidates)` : ""}${floor ? ` (only the newest ${String(MARK_ROWS)} were read)` : ""}`,
2532
2629
  "",
2533
- { markedMe: me, markedOwner: owner, candidates, marksSince: since, work },
2630
+ { markedMe: me, markedOwner: owner, candidates, marksSince: since, work, marksFloor: floor },
2534
2631
  ),
2535
2632
  ];
2536
2633
  }
@@ -2597,6 +2694,55 @@ export function upgradeV11Findings(store: Store): Finding[] {
2597
2694
  ];
2598
2695
  }
2599
2696
 
2697
+ /** The meta row the v12 upgrade writes (`store/operational.ts#V12_UPGRADE_KEY`). */
2698
+ const V12_UPGRADE_META = "recall.v12.upgrade";
2699
+
2700
+ /**
2701
+ * WRITE FIELDS (v12, 2026-10-03), informational, never amber or red: of the
2702
+ * memories written since the v12 upgrade by a door that takes the writer's
2703
+ * three fields — `note`, `session_end` (write-ups included) and a dream's
2704
+ * gist — how many say when it happened, who said it and what kind of thing
2705
+ * it is; and how many subject links there are. What the revisit a few days
2706
+ * after the upgrade reads, before recall reads the fields (Release B). A
2707
+ * store born at v12 counts every such memory; one upgraded counts from the
2708
+ * upgrade's moment. Silent on a file without the columns.
2709
+ */
2710
+ export function writeFieldFindings(store: Store): Finding[] {
2711
+ let share: ReturnType<Store["writeFieldShare"]> = null;
2712
+ let links: ReturnType<Store["subjectLinkCount"]> = null;
2713
+ const upgrade = metaJson(store, V12_UPGRADE_META);
2714
+ const since = upgrade === null ? null : metaNum(upgrade["at"]) || null;
2715
+ try {
2716
+ share = store.writeFieldShare(since);
2717
+ links = store.subjectLinkCount();
2718
+ } catch {
2719
+ return [];
2720
+ }
2721
+ if (share === null) return [];
2722
+ const pct = (n: number): string => (share === null || share.written === 0 ? "0%" : `${String(Math.round((100 * n) / share.written))}%`);
2723
+ const when = since === null ? "" : ` since the v12 upgrade (${localDate(since, readingZone)})`;
2724
+ const linked =
2725
+ links === null
2726
+ ? ""
2727
+ : `; subject links: ${String(links.links)} on ${String(links.memories)} ${links.memories === 1 ? "memory" : "memories"}`;
2728
+ const detail =
2729
+ share.written === 0
2730
+ ? `no memory written${when} by note, session_end or a dream gist yet${linked}`
2731
+ : `of ${String(share.written)} ${share.written === 1 ? "memory" : "memories"} written${when} by note, session_end or a dream gist — when it happened ${pct(share.occurredOn)}, who said it ${pct(share.saidBy)}, what kind ${pct(share.status)}, all three ${pct(share.all)}${linked}`;
2732
+ return [
2733
+ finding("write-fields", "green", "Write fields", detail, "", {
2734
+ written: share.written,
2735
+ occurredOn: share.occurredOn,
2736
+ saidBy: share.saidBy,
2737
+ status: share.status,
2738
+ all: share.all,
2739
+ since: since ?? 0,
2740
+ links: links?.links ?? 0,
2741
+ linkedMemories: links?.memories ?? 0,
2742
+ }),
2743
+ ];
2744
+ }
2745
+
2600
2746
  /**
2601
2747
  * THE RECOGNITION LANE, informational (wheel v2, the review of #301): how
2602
2748
  * many memories nobody marked are on the core's fast lane only because I
@@ -2728,10 +2874,24 @@ export function reflectionFindings(input: DoctorInput, store: Store): Finding[]
2728
2874
  // later — the half of "on reflection" the open door lets through (review
2729
2875
  // of #256, S4). Counted apart from `alone`; one memory can be both.
2730
2876
  let later = 0;
2877
+ // ...and one an ordinary session's feeling-now carried through the same
2878
+ // door (`feelingRecordedLaterBy` names `awake`, review of #317): said apart,
2879
+ // never credited to a reflection. A memory both could have carried is said
2880
+ // once, as both (review of #319).
2881
+ let laterAwake = 0;
2882
+ let laterBoth = 0;
2731
2883
  let promotionsUnread = false;
2884
+ let marksUnread = false;
2885
+ // Feelings recorded looking back while AWAKE (lane B, 2026-10-02): loose on purpose, so said.
2886
+ let awake = { total: 0, fast: 0, owner: 0 };
2732
2887
  try {
2888
+ awake = awakeFeelingCounts(store);
2733
2889
  last = store.reflections({ limit: 5 }).find((r) => r.state === "reflected");
2734
- returns = store.returnCounts({ sinceAt: Date.parse(`${input.today}T00:00:00Z`) - 6 * 86_400_000 });
2890
+ // THE PERSON'S WEEK, not the UTC one (2026-10-09): today and the six local
2891
+ // days before it, from local midnight in the reading's zone. It began at
2892
+ // UTC midnight, so in Denver a return from the evening before the week
2893
+ // counted and in Kiritimati the week's first fourteen hours did not.
2894
+ returns = store.returnCounts({ sinceAt: startOfLocalDay(addDays(input.today, -6), readingZone) });
2735
2895
  // Newest first with a named ceiling. The default read was the OLDEST 500
2736
2896
  // promotions, so the newest were the ones never counted; a read that comes
2737
2897
  // back full has not seen them all, and then the two counts are unknown
@@ -2740,14 +2900,21 @@ export function reflectionFindings(input: DoctorInput, store: Store): Finding[]
2740
2900
  promotionsUnread = promotions.length >= PROMOTED_ROWS;
2741
2901
  for (const row of promotions) {
2742
2902
  try {
2743
- const p = JSON.parse(row.payload ?? "{}") as { reflectionOnly?: unknown; feelingRecordedLater?: unknown };
2903
+ const p = JSON.parse(row.payload ?? "{}") as { reflectionOnly?: unknown; feelingRecordedLater?: unknown; feelingRecordedLaterBy?: unknown };
2744
2904
  if (p.reflectionOnly === true) alone += 1;
2745
- if (p.feelingRecordedLater === true) later += 1;
2905
+ const byReflection = laterFeelingWasReflections(p);
2906
+ const byAwake = laterFeelingWasAwake(p);
2907
+ if (byReflection && byAwake) laterBoth += 1;
2908
+ else if (byReflection) later += 1;
2909
+ else if (byAwake) laterAwake += 1;
2746
2910
  } catch {
2747
2911
  continue;
2748
2912
  }
2749
2913
  }
2750
- for (const e of store.coreEvents({ action: "about", limit: 10_000 })) {
2914
+ // A FULL READ IS A FLOOR (2026-10-02), said as one, as the promotions are.
2915
+ const marks = store.coreEvents({ action: "about", limit: MARK_ROWS });
2916
+ marksUnread = marks.length >= MARK_ROWS;
2917
+ for (const e of marks) {
2751
2918
  if (e.actor !== "reflection") continue;
2752
2919
  const m = /^(\w+) \(was (\w+)\)/.exec(e.reason ?? "");
2753
2920
  if (m === null || m[1] === m[2]) continue;
@@ -2764,6 +2931,20 @@ export function reflectionFindings(input: DoctorInput, store: Store): Finding[]
2764
2931
  carried: "its morning share carried to a later session",
2765
2932
  told: "its morning share told",
2766
2933
  };
2934
+ // A SHARE STUCK AT `carried` (2026-10-02): `told` was never called, so the
2935
+ // line said "carried to a later session" forever. Now it says since when:
2936
+ // the day it was carried (`share_at`), else the reflection's own date.
2937
+ const carriedOn =
2938
+ last?.share_state !== "carried"
2939
+ ? null
2940
+ : typeof last.share_at === "number"
2941
+ ? localDate(last.share_at, readingZone)
2942
+ : (last.date ?? null);
2943
+ const carriedDays =
2944
+ carriedOn !== null && isDay(carriedOn) && isDay(input.today) ? Math.max(0, daysBetween(carriedOn, input.today)) : null;
2945
+ if (carriedDays !== null && carriedDays > 0) {
2946
+ share["carried"] = `its morning share carried to a later session ${String(carriedDays)} ${carriedDays === 1 ? "day" : "days"} ago and never told`;
2947
+ }
2767
2948
  const what =
2768
2949
  last === undefined
2769
2950
  ? "has not reflected yet"
@@ -2777,8 +2958,18 @@ export function reflectionFindings(input: DoctorInput, store: Store): Finding[]
2777
2958
  : "") +
2778
2959
  (!promotionsUnread && alone > 0 ? `; ${String(alone)} ${alone === 1 ? "memory" : "memories"} became core on reflection alone` : "") +
2779
2960
  (!promotionsUnread && later > 0 ? `; ${String(later)} ${later === 1 ? "memory" : "memories"} became core on a feeling a reflection recorded later` : "") +
2961
+ (!promotionsUnread && laterAwake > 0
2962
+ ? `; ${String(laterAwake)} ${laterAwake === 1 ? "memory" : "memories"} became core on a feeling recorded looking back in a session`
2963
+ : "") +
2964
+ (!promotionsUnread && laterBoth > 0
2965
+ ? `; ${String(laterBoth)} ${laterBoth === 1 ? "memory" : "memories"} became core on a feeling recorded later, both a reflection's and a session's`
2966
+ : "") +
2780
2967
  (relabeled > 0
2781
- ? `; ${String(relabeled)} ${relabeled === 1 ? "mark" : "marks"} changed by a reflection, ${String(movedIn)} of them into me, us or the owner`
2968
+ ? `; ${marksUnread ? "at least " : ""}${String(relabeled)} ${relabeled === 1 ? "mark" : "marks"} changed by a reflection, ${String(movedIn)} of them into me, us or the owner${marksUnread ? ` (only the newest ${String(MARK_ROWS)} mark changes were read)` : ""}`
2969
+ : "") +
2970
+ // A lifetime count beside the week's returns, so it says "in all" (review of #317).
2971
+ (awake.total > 0
2972
+ ? `; in all, ${String(awake.total)} ${awake.total === 1 ? "feeling" : "feelings"} recorded looking back in a session, ${String(awake.fast)} at the core's fast-lane strength, ${String(awake.owner)} the owner's`
2782
2973
  : "");
2783
2974
  return [
2784
2975
  finding(
@@ -2792,18 +2983,34 @@ export function reflectionFindings(input: DoctorInput, store: Store): Finding[]
2792
2983
  reflection: last?.id ?? null,
2793
2984
  page: last?.page_version !== null && last?.page_version !== undefined,
2794
2985
  share: last?.share_state ?? null,
2986
+ carriedDays,
2795
2987
  returnsAwake: returns.awake,
2796
2988
  returnsReflection: returns.reflection,
2797
2989
  returnsDream: returns.dream,
2798
2990
  promotedOnReflectionAlone: promotionsUnread ? null : alone,
2799
2991
  promotedOnFeelingRecordedLater: promotionsUnread ? null : later,
2992
+ promotedOnAwakeFeeling: promotionsUnread ? null : laterAwake,
2993
+ promotedOnBothLaterFeelings: promotionsUnread ? null : laterBoth,
2800
2994
  relabeledByReflection: relabeled,
2801
2995
  relabeledIntoCore: movedIn,
2996
+ relabeledFloor: marksUnread,
2997
+ awakeFeelings: awake.total,
2998
+ awakeFeelingsFast: awake.fast,
2999
+ awakeFeelingsOwner: awake.owner,
2802
3000
  },
2803
3001
  ),
2804
3002
  ];
2805
3003
  }
2806
3004
 
3005
+ /** Mark changes the Reflection line reads, newest first; a read that comes back full is a floor. */
3006
+ const MARK_ROWS = 10_000;
3007
+
3008
+ /** The newest `adapter.runner.failed` rows the Spawn line reads (one per step per date). */
3009
+ const RUNNER_FAILED_ROWS = 20;
3010
+
3011
+ /** How many dreams the Dreaming line reads, newest first, to find the last one that stands. */
3012
+ const DREAM_ROWS = 200;
3013
+
2807
3014
  /** How far back the lookup count reads, in lived days. */
2808
3015
  const LOOKUP_WINDOW_DAYS = 14;
2809
3016
 
@@ -2886,6 +3093,360 @@ export function lookupFindings(store: Store): Finding[] {
2886
3093
  /** Rows each lookup read takes, newest first; a read that comes back full is a floor. */
2887
3094
  const LOOKUP_ROWS = 2_000;
2888
3095
 
3096
+ /** How far back the Wake line reads, in lived days. */
3097
+ const WAKE_WINDOW_DAYS = 7;
3098
+
3099
+ /**
3100
+ * DID THE WAKE ARRIVE (2026-10-02, the "nobody saw it" review). At each
3101
+ * session's first prompt (or, since 2026-10-08, its first Stop when the host
3102
+ * had not yet written the file) the hook reads the transcript for the wake's tail
3103
+ * mark and writes one `adapter.wake.delivered` row with the outcome
3104
+ * (`hooks.ts#wakeOutcome`) — and until now no line read it: a wake the host
3105
+ * cut short, or that arrived as something else, was green everywhere, along
3106
+ * with the write-up and handoff pointers that ride at its end. AMBER on any
3107
+ * `truncated` in the window. `mismatch` is counted, not graded (review of
3108
+ * #315): a session resumed after its record was pruned finds the earlier
3109
+ * wake's mark, which is not a cut. `printed-unverified` (a host build that
3110
+ * does not record what it injected) and `not-found` are counted too. Silent
3111
+ * with no rows.
3112
+ *
3113
+ * AND WHAT THE WAKE COULD NOT CARRY (2026-10-02, the gaps #315 listed), as
3114
+ * clauses on the same line: a hook past the host's 10,000-character cap
3115
+ * (AMBER: the host previewed it), and, counted only, a session start over the
3116
+ * reported ceiling (the clock, Code-tab and reminder lines ride above the
3117
+ * composed wake unreserved, so a full wake does it daily — review of #318), a
3118
+ * notice dropped to keep the envelope under the cap, parts that waited for room (`adapter.envelope.gave-way`), a handoff
3119
+ * or "Last here" line with no room, and "Work here" lines that did not fit.
3120
+ */
3121
+ export function wakeArrivalFindings(store: Store): Finding[] {
3122
+ const since = Math.max(0, store.livedDay() - WAKE_WINDOW_DAYS);
3123
+ let wakes: EventRow[];
3124
+ let room: WakeRoom;
3125
+ try {
3126
+ wakes = store.eventLog({ name: WAKE_DELIVERED_EVENT, sinceDay: since, order: "desc", limit: RESULTS_ROWS });
3127
+ room = wakeRoom(store, since);
3128
+ } catch {
3129
+ return [];
3130
+ }
3131
+ const counts: Record<string, number> = {};
3132
+ // A `not-found` splits three ways by what the check could read (2026-10-08).
3133
+ // ABSENT AT THE FIRST PROMPT is not a wake that failed to arrive: since about
3134
+ // 09-25 the host writes the file only after that prompt, so the rows written
3135
+ // before the check learned to wait for the Stop say this. Counted apart, and
3136
+ // out of the "N of M" — those wakes were never checked. ABSENT AT THE STOP
3137
+ // (`checkedAt: "stop"`) is different: no transcript by the end of a turn
3138
+ // means the host did not write one where it said. And UNREADABLE is a file
3139
+ // that was there and could not be opened. Both stay in the "N of M", each
3140
+ // with its own clause; counted, not graded, like `not-found` itself.
3141
+ let unread = 0;
3142
+ let noFile = 0;
3143
+ let unreadable = 0;
3144
+ for (const row of wakes) {
3145
+ const p = payloadOf(row);
3146
+ const o = str(p, "outcome") ?? "unknown";
3147
+ const transcript = str(p, "transcript");
3148
+ if (o === "not-found" && transcript === "absent") {
3149
+ if (str(p, "checkedAt") === "stop") noFile += 1;
3150
+ else unread += 1;
3151
+ } else if (o === "not-found" && transcript === "unreadable") {
3152
+ unreadable += 1;
3153
+ } else {
3154
+ counts[o] = (counts[o] ?? 0) + 1;
3155
+ }
3156
+ }
3157
+ const expected = wakes.length - (counts["no-wake-expected"] ?? 0) - unread;
3158
+ if (expected <= 0 && unread === 0 && !room.any) return [];
3159
+ const whole = counts["delivered"] ?? 0;
3160
+ const cut = counts["truncated"] ?? 0;
3161
+ const mismatched = counts["mismatch"] ?? 0;
3162
+ const unverified = counts["printed-unverified"] ?? 0;
3163
+ const missing = counts["not-found"] ?? 0;
3164
+ const window = `last ${String(WAKE_WINDOW_DAYS)} lived days`;
3165
+ const floor = wakes.length >= RESULTS_ROWS || room.floor;
3166
+ const rest =
3167
+ (mismatched > 0 ? `; ${String(mismatched)} carried another wake's mark (a session resumed after its record was let go)` : "") +
3168
+ (unverified > 0 ? `; ${String(unverified)} printed but not verifiable on this host build` : "") +
3169
+ (missing > 0 ? `; ${String(missing)} not found in the transcript` : "") +
3170
+ (noFile > 0 ? `; ${String(noFile)} had no transcript even at the end of the first turn` : "") +
3171
+ (unreadable > 0 ? `; ${String(unreadable)} ${unreadable === 1 ? "transcript" : "transcripts"} could not be read` : "") +
3172
+ (unread > 0 ? `; ${String(unread)} not checked (no transcript to read)` : "") +
3173
+ room.clauses +
3174
+ (floor ? ". More rows than were read: the counts are a floor" : "");
3175
+ const data = {
3176
+ wakes: expected,
3177
+ delivered: whole,
3178
+ cut,
3179
+ mismatch: mismatched,
3180
+ unverified,
3181
+ notFound: missing,
3182
+ noTranscriptAtStop: noFile,
3183
+ unreadable,
3184
+ notChecked: unread,
3185
+ overBudget: room.overBudget,
3186
+ overCap: room.overCap,
3187
+ noticeDropped: room.noticeDropped,
3188
+ gaveWay: Object.values(room.gaveWay).reduce((n, k) => n + k, 0),
3189
+ handoffNoRoom: room.handoffNoRoom,
3190
+ lastHereNoRoom: room.lastHereNoRoom,
3191
+ workNoRoom: room.workNoRoom,
3192
+ floor,
3193
+ };
3194
+ const head =
3195
+ expected <= 0
3196
+ ? `${window} — no wake checked on arrival`
3197
+ : `${window} — ${String(whole)} of ${String(expected)} ${expected === 1 ? "wake" : "wakes"} arrived whole`;
3198
+ if (cut === 0 && room.amber !== null) {
3199
+ return [
3200
+ finding(
3201
+ "wake",
3202
+ "amber",
3203
+ "Wake",
3204
+ `${head}${rest}`,
3205
+ room.amber,
3206
+ data,
3207
+ ),
3208
+ ];
3209
+ }
3210
+ if (cut > 0) {
3211
+ const newest = wakes.find((r) => str(payloadOf(r), "outcome") === "truncated");
3212
+ return [
3213
+ finding(
3214
+ "wake",
3215
+ "amber",
3216
+ "Wake",
3217
+ `${window} — ${String(cut)} of ${String(expected)} ${expected === 1 ? "wake" : "wakes"} reached the session cut short (newest ${rowDate(newest) ?? "?"}); ${String(whole)} arrived whole${rest}`,
3218
+ "A wake cut short loses its end, and the write-up and handoff pointers ride there. Nothing to do by hand; if it repeats, the wake is over what the host takes in one — worth reporting with this line.",
3219
+ data,
3220
+ ),
3221
+ ];
3222
+ }
3223
+ return [finding("wake", "green", "Wake", `${head}${rest}`, "", data)];
3224
+ }
3225
+
3226
+ /** What the Wake line reads beside the arrivals: what a delivery could not carry. */
3227
+ interface WakeRoom {
3228
+ readonly overBudget: number;
3229
+ readonly overCap: number;
3230
+ readonly noticeDropped: number;
3231
+ readonly gaveWay: Readonly<Record<string, number>>;
3232
+ readonly handoffNoRoom: number;
3233
+ readonly lastHereNoRoom: number;
3234
+ readonly workNoRoom: number;
3235
+ /** The clauses, each led by "; ", or "". */
3236
+ readonly clauses: string;
3237
+ /** The amber's remedy, or null when nothing here is amber. */
3238
+ readonly amber: string | null;
3239
+ readonly any: boolean;
3240
+ readonly floor: boolean;
3241
+ }
3242
+
3243
+ /** The rows since `since`, read newest first under the line's ceiling. Throws what the store throws. */
3244
+ function wakeRoom(store: Store, since: number): WakeRoom {
3245
+ let floor = false;
3246
+ const read = (name: string): EventRow[] => {
3247
+ const rows = store.eventLog({ name, sinceDay: since, order: "desc", limit: RESULTS_ROWS });
3248
+ if (rows.length >= RESULTS_ROWS) floor = true;
3249
+ return rows;
3250
+ };
3251
+ const overBudget = read(INJECTION_OVERBUDGET_EVENT).length;
3252
+ const overCap = read(ENVELOPE_OVERCAP_EVENT).length;
3253
+ const noticeDropped = read(NOTICE_DROPPED_EVENT).length;
3254
+ const gaveWay: Record<string, number> = {};
3255
+ for (const row of read(ENVELOPE_GAVE_WAY_EVENT)) {
3256
+ const part = str(payloadOf(row), "part") ?? "?";
3257
+ gaveWay[part] = (gaveWay[part] ?? 0) + 1;
3258
+ }
3259
+ const handoffNoRoom = read(HANDOFF_REFUSED_EVENT).filter((r) => str(payloadOf(r), "reason") === "no-room").length;
3260
+ const lastHereNoRoom = read(LAST_HERE_NOROOM_EVENT).length;
3261
+ const workNoRoom = read(WORK_OVERFLOW_EVENT).filter((r) => str(payloadOf(r), "cause") === "room").length;
3262
+ const parts = Object.entries(gaveWay)
3263
+ .sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1))
3264
+ .map(([part, n]) => `${part} ${String(n)}`);
3265
+ const times = (n: number): string => `${String(n)} ${n === 1 ? "time" : "times"}`;
3266
+ const clauses =
3267
+ // Counted, never amber (review of #318): the ceiling bounds the composed
3268
+ // wake, and the clock, Code-tab and reminder lines ride above it unreserved,
3269
+ // so a full wake goes a little over every day by design.
3270
+ (overBudget > 0 ? `; a session start sent a little more than the reported ceiling (the lines above the wake) ${times(overBudget)}` : "") +
3271
+ (overCap > 0 ? `; a hook's output passed the host's cap and was shown only as a preview ${times(overCap)}` : "") +
3272
+ (noticeDropped > 0 ? `; a notice for you was left off to keep the wake under the cap ${times(noticeDropped)}` : "") +
3273
+ (parts.length > 0 ? `; waited for room: ${parts.join(", ")}` : "") +
3274
+ (handoffNoRoom + lastHereNoRoom > 0
3275
+ ? `; no room for ${[
3276
+ handoffNoRoom > 0 ? `the handoff pointer ${times(handoffNoRoom)}` : "",
3277
+ lastHereNoRoom > 0 ? `the "Last here" line ${times(lastHereNoRoom)}` : "",
3278
+ ]
3279
+ .filter((s) => s.length > 0)
3280
+ .join(" and ")}`
3281
+ : "") +
3282
+ (workNoRoom > 0 ? `; "Work here" lines that did not fit, in ${String(workNoRoom)} ${workNoRoom === 1 ? "directory-day" : "directory-days"}` : "");
3283
+ const amber =
3284
+ overCap > 0
3285
+ ? "Claude Code shows a hook's output past 10,000 characters only as a preview, so that output did not reach the session whole. Nothing to do by hand; if it repeats, worth reporting with this line."
3286
+ : null;
3287
+ const any = clauses.length > 0;
3288
+ return { overBudget, overCap, noticeDropped, gaveWay, handoffNoRoom, lastHereNoRoom, workNoRoom, clauses, amber, any, floor };
3289
+ }
3290
+
3291
+ /** How far back the Tool results line reads, in lived days. */
3292
+ const RESULTS_WINDOW_DAYS = 14;
3293
+ /** Rows each of its reads takes, newest first; a read that comes back full is a floor. */
3294
+ const RESULTS_ROWS = 2_000;
3295
+
3296
+ /**
3297
+ * WHAT REACHED THE MODEL (2026-10-02). The night of 10-02 every line here was
3298
+ * green while the dream read a third of its bundle: Claude Code saved the
3299
+ * begin and part 2 — each past its 50,000-character ceiling — to a file the
3300
+ * headless run cannot open, and the Lookups line counts look-ups, the Nightly
3301
+ * run line a run that finished. Two readings close that:
3302
+ *
3303
+ * - an `mcp.result.oversize` row: a result came to more than the ceiling
3304
+ * (`fit/TOOL_RESULT_CEILING`) and the server cut it there. AMBER — a cap
3305
+ * upstream is too loose, and the model saw only the start of something.
3306
+ * - a dream or a reflection handed in parts (its `mcp.part` row for part 1
3307
+ * says how many) and finished without fetching every later part. AMBER —
3308
+ * it acted on a bundle it had not read. A run still open is not judged;
3309
+ * a run begun before parts were logged has no part-1 row and is not
3310
+ * judged either.
3311
+ * - an `mcp.result.spilled` row (2026-10-09, U14 item 3): the nightly run's
3312
+ * own transcript showed a result of ours that Claude Code replaced with a
3313
+ * short preview — its line is lower than the ceiling now (a remote flag
3314
+ * can lower it), and the server could not see it. AMBER, like the two
3315
+ * above: nothing to do by hand, and the night has already happened.
3316
+ *
3317
+ * Green says how many runs came in parts, the largest result handed, and
3318
+ * whether the last night's transcript was read for the host's cut. Silent on a
3319
+ * store whose window holds none of the three rows.
3320
+ */
3321
+ export function resultFindings(store: Store): Finding[] {
3322
+ const since = Math.max(0, store.livedDay() - RESULTS_WINDOW_DAYS);
3323
+ let oversize: EventRow[];
3324
+ let spilled: EventRow[];
3325
+ const runs = new Map<string, { mechanism: string; of: number; fetched: Set<number>; date: string | null }>();
3326
+ let largest = 0;
3327
+ let floor = false;
3328
+ const open = new Set<string>();
3329
+ try {
3330
+ oversize = store.eventLog({ name: MCP_OVERSIZE_EVENT, sinceDay: since, order: "desc", limit: RESULTS_ROWS });
3331
+ spilled = store.eventLog({ name: MCP_SPILLED_EVENT, sinceDay: since, order: "desc", limit: RESULTS_ROWS });
3332
+ const parts = store.eventLog({ name: MCP_PART_EVENT, sinceDay: since, order: "asc", limit: RESULTS_ROWS });
3333
+ floor = oversize.length >= RESULTS_ROWS || parts.length >= RESULTS_ROWS || spilled.length >= RESULTS_ROWS;
3334
+ for (const row of parts) {
3335
+ const p = payloadOf(row);
3336
+ const ref = str(p, "ref");
3337
+ const part = num(p, "part");
3338
+ const of = num(p, "of");
3339
+ if (ref === null || part === null || of === null) continue;
3340
+ largest = Math.max(largest, num(p, "chars") ?? 0);
3341
+ // A part-1 row opens the run's count (a resumed dream's begin opens it again).
3342
+ if (part === 1) runs.set(ref, { mechanism: str(p, "mechanism") ?? "dream", of, fetched: new Set([1]), date: rowDate(row) });
3343
+ else runs.get(ref)?.fetched.add(part);
3344
+ }
3345
+ for (const d of store.dreams({ limit: RESULTS_ROWS })) if (d.state === "begun") open.add(d.id);
3346
+ for (const r of store.reflections({ limit: RESULTS_ROWS })) if (r.state !== "reflected") open.add(r.id);
3347
+ } catch {
3348
+ return [];
3349
+ }
3350
+ if (oversize.length === 0 && runs.size === 0 && spilled.length === 0) return [];
3351
+ const ceiling = TOOL_RESULT_CEILING.CHARS;
3352
+ const inParts = [...runs.entries()].filter(([, r]) => r.of > 1);
3353
+ const unread = inParts
3354
+ .filter(([ref]) => !open.has(ref))
3355
+ .map(([ref, r]) => {
3356
+ const missing: number[] = [];
3357
+ for (let k = 2; k <= r.of; k += 1) if (!r.fetched.has(k)) missing.push(k);
3358
+ return { ref, ...r, missing };
3359
+ })
3360
+ .filter((r) => r.missing.length > 0);
3361
+ const window = `last ${String(RESULTS_WINDOW_DAYS)} lived days`;
3362
+ const newest = oversize[0];
3363
+ const np = payloadOf(newest);
3364
+ const overSaid =
3365
+ newest === undefined
3366
+ ? ""
3367
+ : `${String(oversize.length)} ${oversize.length === 1 ? "result" : "results"} came to more than the ${String(ceiling)} characters one answer carries — the newest, ${str(np, "tool") ?? "a tool"}${str(np, "phase") === null ? "" : ` ${str(np, "phase") as string}`} on ${rowDate(newest) ?? "an unknown day"}, at ${String(num(np, "chars") ?? 0)}, ${np["cut"] === true ? `cut to ${String(num(np, "cutTo") ?? 0)} with a note saying so` : "shipped whole (nothing in it to cut)"}`;
3368
+ const unreadSaid =
3369
+ unread.length === 0
3370
+ ? ""
3371
+ : unread
3372
+ .map((r) => `${r.mechanism === "reflection" ? "reflection" : "dream"} ${r.ref}${r.date === null ? "" : ` (${r.date})`} was handed in ${String(r.of)} parts and finished without part${r.missing.length === 1 ? "" : "s"} ${r.missing.join(", ")}`)
3373
+ .join("; ");
3374
+ const newestSpill = spilled[0];
3375
+ const sp = payloadOf(newestSpill);
3376
+ const spillTool = (str(sp, "tool") ?? "a tool").replace(/^mcp__counterparts__/, "");
3377
+ const spillRuns = new Set(spilled.map((r) => str(payloadOf(r), "run") ?? "")).size;
3378
+ const spillSaid =
3379
+ newestSpill === undefined
3380
+ ? ""
3381
+ : `${String(spilled.length)} ${spilled.length === 1 ? "result" : "results"} of the nightly run${spillRuns > 1 ? ` (${String(spillRuns)} runs)` : ""} reached the model only as Claude Code's short preview — the newest, ${spillTool}${str(sp, "phase") === null ? "" : ` ${str(sp, "phase") as string}`} on ${rowDate(newestSpill) ?? "an unknown day"}${str(sp, "said") === null ? "" : `, at ${str(sp, "said") as string}`}`;
3382
+ // WAS THE LAST NIGHT CHECKED AT ALL (2026-10-09)? Said on the line, green or
3383
+ // amber, so a transcript the host stopped writing where it is looked for is
3384
+ // not silence that reads as "nothing cut". A last run whose own cuts the
3385
+ // amber text already names adds nothing here.
3386
+ let checked = "";
3387
+ let lastTranscript: string | null = null;
3388
+ try {
3389
+ const last = nightRunOf(store);
3390
+ lastTranscript = last?.transcript ?? null;
3391
+ if (last !== null && last.transcript !== undefined && !(last.transcript === "read" && (last.spills ?? 0) > 0)) {
3392
+ checked =
3393
+ last.transcript === "read"
3394
+ ? `; the ${last.date} run's transcript showed none of our results cut by Claude Code`
3395
+ : `; the ${last.date} run's transcript ${last.transcript === "absent" ? "was not found where Claude Code keeps sessions" : "could not be read"}, so Claude Code's cut was not checked`;
3396
+ }
3397
+ } catch {
3398
+ /* the line stands without it */
3399
+ }
3400
+ // WHY THE HOST CUT, by the newest cut's shape (review of #330): the
3401
+ // character line, the token line the run pins, or the budget for one turn.
3402
+ const spillShape = str(sp, "shape");
3403
+ const spillFix =
3404
+ spillShape === "turn-budget"
3405
+ ? "Nothing to do by hand: the run fetched several results in one turn, and together they passed Claude Code's budget for one turn, so it cut the largest to a preview. Worth reporting with this line."
3406
+ : spillShape === "tokens" || spillShape === "token-cut"
3407
+ ? `Nothing to do by hand: Claude Code's token limit on one tool result came out lower than the ${String(TOOL_RESULT_CEILING.HOST_TOKENS)} tokens the nightly run sets it to, so the night read through a keyhole. Worth reporting with this line.`
3408
+ : `Nothing to do by hand: Claude Code's limit on one tool result is lower than the ${String(ceiling)} characters Counterparts keeps them under, so the night read through a keyhole. Worth reporting with this line — the ceiling has to come down to meet it.`;
3409
+ const data = {
3410
+ ceiling,
3411
+ oversize: oversize.length,
3412
+ newestOversizeTool: str(np, "tool"),
3413
+ newestOversizeChars: num(np, "chars"),
3414
+ runsInParts: inParts.length,
3415
+ runsUnread: unread.length,
3416
+ largestPart: largest,
3417
+ spilled: spilled.length,
3418
+ newestSpillTool: str(sp, "tool"),
3419
+ lastTranscript,
3420
+ floor,
3421
+ };
3422
+ if (spillSaid.length > 0 || overSaid.length > 0 || unreadSaid.length > 0) {
3423
+ return [
3424
+ finding(
3425
+ "results",
3426
+ "amber",
3427
+ "Tool results",
3428
+ `${window} — ${[spillSaid, overSaid, unreadSaid].filter((x) => x.length > 0).join("; ")}${checked}${floor ? ". More rows than were read: the counts are a floor" : ""}`,
3429
+ spillSaid.length > 0
3430
+ ? spillFix
3431
+ : overSaid.length > 0
3432
+ ? "Nothing to do by hand: the model was told the answer was cut. It means a cap upstream lets a result grow past the ceiling — worth reporting with this line."
3433
+ : "Nothing to do by hand: the next night reads its own bundle. If it repeats, the run is skipping parts — worth reporting with this line.",
3434
+ data,
3435
+ ),
3436
+ ];
3437
+ }
3438
+ return [
3439
+ finding(
3440
+ "results",
3441
+ "green",
3442
+ "Tool results",
3443
+ `${window} — every result under ${String(ceiling)} characters; ${inParts.length === 0 ? "no bundle came in parts" : `${String(inParts.length)} ${inParts.length === 1 ? "bundle" : "bundles"} came in parts, every part read`}; the largest part handed was ${String(largest)} characters${checked}${floor ? ". More rows than were read: the counts are a floor" : ""}`,
3444
+ "",
3445
+ data,
3446
+ ),
3447
+ ];
3448
+ }
3449
+
2889
3450
  /** How far back the Association line reads turns, in lived days. */
2890
3451
  const ASSOCIATION_WINDOW_DAYS = 7;
2891
3452
 
@@ -3038,7 +3599,9 @@ export function dreamingFindings(input: DoctorInput, store: Store): Finding[] {
3038
3599
  let ask: ReturnType<Store["dreamAsk"]>;
3039
3600
  let setting: DreamingSetting;
3040
3601
  try {
3041
- last = store.dreams({ limit: 5 }).find((d) => d.state !== "undone");
3602
+ // Past any run of undone dreams (2026-10-02): five newest undone read as
3603
+ // "has not dreamed yet" when the read stopped at five.
3604
+ last = store.dreams({ limit: DREAM_ROWS }).find((d) => d.state !== "undone");
3042
3605
  ask = store.dreamAsk(input.today);
3043
3606
  setting = dreamingSetting(store);
3044
3607
  } catch {
@@ -3191,9 +3754,16 @@ export function selfPageFindings(store: Store): Finding[] {
3191
3754
  ];
3192
3755
  }
3193
3756
  const stale = pageStaleOn(page.revisedOn, store.today(), SELF_TUNABLES.PAGE_STALE_DAYS);
3757
+ // WHAT THE WAKE SHOWS OF IT (2026-10-02, the "nobody saw it" review): a page
3758
+ // past `PAGE_WAKE_BYTES` is kept whole but the wake carries only its start,
3759
+ // so a session never reads the rest unless it asks. A chosen state, said.
3760
+ const wakeShows =
3761
+ page.bytes > SELF_TUNABLES.PAGE_WAKE_BYTES
3762
+ ? `; the wake shows its first ${String(SELF_TUNABLES.PAGE_WAKE_BYTES)} bytes (the self_page tool reads it whole)`
3763
+ : "";
3194
3764
  const detail =
3195
3765
  `${page.bytes} bytes, version ${page.version}, last revised ${page.revisedOn === "" ? "(unrecorded)" : page.revisedOn}` +
3196
- `${page.by === null ? "" : ` by ${page.by}`}`;
3766
+ `${page.by === null ? "" : ` by ${page.by}`}${wakeShows}`;
3197
3767
  // The day count and the limit ride along so a surface can say it in words
3198
3768
  // ("not rewritten in 16 days") without re-deriving either (dashboard health).
3199
3769
  const data = {
@@ -3202,6 +3772,7 @@ export function selfPageFindings(store: Store): Finding[] {
3202
3772
  version: page.version,
3203
3773
  revisedOn: page.revisedOn,
3204
3774
  stale,
3775
+ wakeShowsAll: page.bytes <= SELF_TUNABLES.PAGE_WAKE_BYTES,
3205
3776
  daysSince: calendarDaysSince(page.revisedOn, store.today()),
3206
3777
  staleAfter: SELF_TUNABLES.PAGE_STALE_DAYS,
3207
3778
  };
@@ -3685,6 +4256,9 @@ export interface HostReading {
3685
4256
  }[];
3686
4257
  /** The runtime this console is running under (`runtime.ts#runtimeLabel`). */
3687
4258
  readonly consoleRuntime?: string;
4259
+ /** The Counterparts Claude Code plugin, when Claude Code records it
4260
+ * installed (`host-wiring.ts#pluginInstall`); absent or null when not. */
4261
+ readonly plugin?: PluginInstallRead | null;
3688
4262
  }
3689
4263
 
3690
4264
  /**
@@ -3815,6 +4389,10 @@ function desktopFindings(reading: DesktopReading, store: Store | null, dir: stri
3815
4389
  // server, which serves a Code-tab session when the call names its id.
3816
4390
  ...(reading.codeTab ? ["its Code tab's counterparts tools come from this entry's server, which shadows ~/.claude.json's — both name this store, and Code-tab sessions pass their session id"] : []),
3817
4391
  ];
4392
+ // SAID, NOT MEASURED (2026-10-02): Desktop asks before each tool until its
4393
+ // tools are set to Always allow, and a chat whose tools still ask never
4394
+ // called `wake`. Nothing on disk says which, so the line says it every time.
4395
+ parts.push("set its counterparts tools to Always allow, or a chat cannot wake on its own (not measurable from here)");
3818
4396
  return [finding("desktop", "green", "Claude Desktop", parts.join("; "), "", data)];
3819
4397
  }
3820
4398
 
@@ -3844,6 +4422,33 @@ function hostFindings(reading: HostReading): Finding[] {
3844
4422
  mcp: reading.mcp,
3845
4423
  mcpFile: reading.mcpFile,
3846
4424
  };
4425
+ // THE PLUGIN (prototype, 2026-10-09). A plugin install wires nothing in
4426
+ // these files — Claude Code loads its hooks and server from the plugin — so
4427
+ // without this the line told a plugin user "no hook of ours is connected,
4428
+ // run counterparts connect", which would wire the host twice. Enabled and
4429
+ // alone: connected. Enabled beside live npm wiring: the plugin stands down
4430
+ // (`adapters/plugin.ts`), which works, and is said, with both ways out.
4431
+ const plugin = reading.plugin !== undefined && reading.plugin !== null && reading.plugin.enabled ? reading.plugin : null;
4432
+ data["plugin"] = plugin === null ? null : plugin.id;
4433
+ const npmAny = reading.events.length > 0 || reading.mcp;
4434
+ if (plugin !== null && !npmAny) {
4435
+ return [
4436
+ finding(
4437
+ "host",
4438
+ "green",
4439
+ "Claude Code",
4440
+ `connected as the Claude Code plugin (${plugin.id}${plugin.version === null ? "" : ` ${plugin.version}`}): its ${String(total)} hooks and the memory tools load from the plugin`,
4441
+ "",
4442
+ data,
4443
+ ),
4444
+ ];
4445
+ }
4446
+ const twiceClause =
4447
+ plugin === null ? "" : `ALSO installed as the Claude Code plugin (${plugin.id}), which stands down while this wiring is live`;
4448
+ const twiceFix =
4449
+ plugin === null
4450
+ ? ""
4451
+ : `Installed twice: to keep only the plugin, run \`counterparts disconnect\` and restart Claude Code; to keep only this install, run \`claude plugin uninstall ${plugin.id}\`. Same memory either way.`;
3847
4452
  const mcpClause = reading.mcp
3848
4453
  ? `the MCP server is registered in ${reading.mcpFile}`
3849
4454
  : reading.mcpUnreadable
@@ -3851,6 +4456,9 @@ function hostFindings(reading: HostReading): Finding[] {
3851
4456
  : `no MCP server named "${reading.mcpName}" in ${reading.mcpFile}`;
3852
4457
 
3853
4458
  if (missing.length === 0 && stale.length === 0 && reading.mcp) {
4459
+ if (plugin !== null) {
4460
+ return [finding("host", "amber", "Claude Code", `connected: ${String(total)} hooks and the memory tools; ${twiceClause}`, twiceFix, data)];
4461
+ }
3854
4462
  // THE ONE LINE THE PERSON CAME FOR: is my assistant joined up to this
3855
4463
  // memory? It says `connected` because that is the verb the command has
3856
4464
  // (`counterparts connect`), and it names the two halves — the hooks and the
@@ -3922,11 +4530,11 @@ function hostFindings(reading: HostReading): Finding[] {
3922
4530
  : missing.length > 0
3923
4531
  ? `connected on ${reading.events.join(", ")} but NOT on ${missing.join(", ")}`
3924
4532
  : `all ${String(total)} hook events are connected`;
3925
- const detail = [staleClause, connected, `(${where})`, mcpClause]
4533
+ const detail = [staleClause, connected, `(${where})`, mcpClause, twiceClause]
3926
4534
  .filter((s) => s.length > 0)
3927
4535
  .join("; ")
3928
4536
  .replace("; (", " (");
3929
- return [finding("host", "amber", "Claude Code", detail, fixes.join(" "), data)];
4537
+ return [finding("host", "amber", "Claude Code", detail, [...fixes, ...(twiceFix.length === 0 ? [] : [twiceFix])].join(" "), data)];
3930
4538
  }
3931
4539
 
3932
4540
  // ── the reading ─────────────────────────────────────────────────────────────
@@ -4079,10 +4687,16 @@ export function doctorFindings(input: DoctorInput): Finding[] {
4079
4687
  // v10 (2026-09-29): what the upgrade carried, and the week's contradictions.
4080
4688
  ["upgrade-v10", () => upgradeV10Findings(store)],
4081
4689
  ["upgrade-v11", () => upgradeV11Findings(store)],
4690
+ // v12 (2026-10-03): the writer's three fields, and the subject links. Two aggregates.
4691
+ ["write-fields", () => writeFieldFindings(store)],
4082
4692
  ["recognition-lane", () => recognitionLaneFindings(store)],
4083
4693
  ["contradictions", () => contradictionFindings(store)],
4084
4694
  // Build B (2026-09-28): does anyone read what an index offers in part?
4085
4695
  ["lookups", () => lookupFindings(store)],
4696
+ // 2026-10-02: what reached the model — results past the ceiling, parts never read.
4697
+ ["results", () => resultFindings(store)],
4698
+ // 2026-10-02: whether the wake reached the session whole (`adapter.wake.delivered`).
4699
+ ["wake", () => wakeArrivalFindings(store)],
4086
4700
  // Association build 1 (2026-09-28): what spreading did, and the edges.
4087
4701
  ["association", () => associationFindings(store)],
4088
4702
  // LAST, and deliberately: it is the widest read here — the whole event log,