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
@@ -3,6 +3,8 @@
3
3
  * conversation of 2026-09-26 ("try it, see how it goes, adjust"); CAL = not
4
4
  * yet measured against real dreams.
5
5
  */
6
+ import { TOOL_RESULT_CEILING } from "../fit/index.js";
7
+
6
8
  export const DREAM_TUNABLES = {
7
9
  // ── when to ask ───────────────────────────────────────────────────────────
8
10
  /** The ask is due only when at least this many memories wait in the queue
@@ -102,11 +104,17 @@ export const DREAM_TUNABLES = {
102
104
  /**
103
105
  * THE BUNDLE IN PARTS (2026-09-28), measured the way the MCP server sends
104
106
  * it (`dreamResultChars`): the begin result under this, each later part
105
- * under `PART_CHARS`. The tool result's ceiling is about 25k tokens, and
106
- * escaped JSON runs near three characters a token. CAL.
107
+ * under `PART_CHARS`.
108
+ *
109
+ * THE HOST'S CEILING, MEASURED (2026-10-02): were 54,000 each, on a guess of
110
+ * three characters a token. Claude Code saves a result past 50,000
111
+ * characters to a file the nightly run cannot open — the begin (51.5 KB)
112
+ * and part 2 (51,306) of the night's bundle never reached the dream. Both
113
+ * now sit at the one ceiling (`fit/TOOL_RESULT_CEILING`, 20% under that
114
+ * line): more parts, each one read.
107
115
  */
108
- RESULT_CHARS: 54_000,
109
- PART_CHARS: 54_000,
116
+ RESULT_CHARS: TOOL_RESULT_CEILING.CHARS,
117
+ PART_CHARS: TOOL_RESULT_CEILING.CHARS,
110
118
 
111
119
  // ── what one dream may change (owner: "start ~10 merges, 20 links, 3 gists") ─
112
120
  LIMITS: {
@@ -146,3 +154,15 @@ export const DREAM_TUNABLES = {
146
154
 
147
155
  export type DreamAction = keyof typeof DREAM_TUNABLES.LIMITS;
148
156
  export const DREAM_ACTIONS = Object.keys(DREAM_TUNABLES.LIMITS) as DreamAction[];
157
+
158
+ /**
159
+ * WHAT A DREAM'S BUNDLE IS READ AS: a guest, always (review of #318, a
160
+ * coordinator default that keeps the behaviour from before it — the owner may
161
+ * revisit). A dream's journal and a nomination's `why` carry no
162
+ * confidentiality mark and are read later by other bundles and the
163
+ * dashboard, so a confidential memory may not reach them. Until #318 every
164
+ * server that built a bundle was a guest; since then a Claude Code server can
165
+ * be the owner's, and the bundle stays as it was. `ctx.owner` still decides
166
+ * the GATE (what counts as new for the ask), which is the session's own.
167
+ */
168
+ export const BUNDLE_OWNER = false;
@@ -144,7 +144,9 @@ raw transcript (`fallback.ts#renderForSweep` → `interpret-client.ts`), and not
144
144
  through this battery before it leaves the machine; only the vector text is redacted
145
145
  (`counterpart.ts#sweepFallback`). With the key-based sweep becoming an opt-in (roadmap C2)
146
146
  it matters less, but a credential spoken in a crashed session is sent to the interpreter
147
- as spoken.
147
+ as spoken. *(Noted 2026-10-09: moot since the keys were removed, #201, 2026-09-24:
148
+ `interpret-client.ts` is gone and the worker passes the sweep no interpreter, so no
149
+ shipped path sends the prompt out. If an interpreter ever returns, this applies again.)*
148
150
 
149
151
  *As filed:*
150
152
 
@@ -222,3 +222,10 @@ window naming what breaks on each side. Two carry a **standing warning**:
222
222
  here forecloses folding it into `remember/`'s pipeline later.
223
223
  - The cross-module half of the universality test (note 2) belongs to the suite,
224
224
  once there are callers to enumerate.
225
+
226
+ ## 2026-10-03 — `wordTokens`
227
+
228
+ `words.ts#wordTokens(text)`: the text's runs of word characters, lower-cased, by the same
229
+ `WORD_CHAR` class the whole-word matcher uses. It is a prefilter's index and never a match:
230
+ `schemas/aliases.ts#AliasIndex.scanner` tries only the terms whose first word is among
231
+ them and confirms each with the one rule, so a second definition of a word cannot drift in.
@@ -37,6 +37,38 @@ export function wholeWordRegex(term: string, flags = "iu"): RegExp {
37
37
  return new RegExp(`(?<!${WORD_CHAR})${t}(?!${WORD_CHAR})`, flags);
38
38
  }
39
39
 
40
+ /**
41
+ * THE NAME RULE (2026-10-03, review of #322): the whole-word rule above, with
42
+ * a trailing possessive read as the name — "Han's", "Han’s", "James'" name
43
+ * Han and James. The apostrophe stays a word character everywhere else, so
44
+ * "Hans", "Oskarsson" and "Han'll" still do not. For what a text NAMES (the
45
+ * alias index's `matchesIn` and `scanner`, and so subject links and the
46
+ * crediting of a card a memory names); birth's name-in-source test and the
47
+ * encoder's preselection keep the strict rule.
48
+ */
49
+ export function nameRegex(term: string, flags = "iu"): RegExp {
50
+ const t = escapeRegExp(term.trim());
51
+ return new RegExp(`(?<!${WORD_CHAR})${t}(?:['’]s?)?(?!${WORD_CHAR})`, flags);
52
+ }
53
+
54
+ /** True when `term` occurs in `haystack` as a name (`nameRegex`). Empty terms never match. */
55
+ export function occursAsName(haystack: string, term: string): boolean {
56
+ const t = term.trim();
57
+ if (t.length === 0) return false;
58
+ return nameRegex(t).test(haystack);
59
+ }
60
+
61
+ /**
62
+ * A whole-word token with a trailing possessive taken off (`han's` → `han`,
63
+ * `james'` → `james`), or the token itself — the prefilter's side of
64
+ * `nameRegex`, so a scanner keyed on a term's first word still tries "Han"
65
+ * on "Han's".
66
+ */
67
+ export function unpossessed(token: string): string {
68
+ const m = /^(.+?)['’]s?$/u.exec(token);
69
+ return m === null ? token : (m[1] as string);
70
+ }
71
+
40
72
  /** True when `term` occurs in `haystack` as a whole word. Empty terms never match. */
41
73
  export function occursAsWholeWord(haystack: string, term: string): boolean {
42
74
  const t = term.trim();
@@ -45,6 +77,19 @@ export function occursAsWholeWord(haystack: string, term: string): boolean {
45
77
  }
46
78
 
47
79
  /** How many whole-word occurrences. Used for per-channel attribution, not counts of text. */
80
+ /**
81
+ * THE TEXT'S WHOLE WORDS, lower-cased: its runs of word characters, by the
82
+ * one class the matcher above uses (v12, 2026-10-03). A PREFILTER'S INDEX,
83
+ * never a match — a term can only occur as a whole word where its first run
84
+ * of word characters is one of these, and every candidate is confirmed with
85
+ * `occursAsWholeWord` (`schemas/aliases.ts#AliasIndex.scanner`).
86
+ */
87
+ export function wordTokens(text: string): string[] {
88
+ return text.toLowerCase().match(WORD_RUN) ?? [];
89
+ }
90
+
91
+ const WORD_RUN = new RegExp(`${WORD_CHAR}+`, "gu");
92
+
48
93
  export function countWholeWord(haystack: string, term: string): number {
49
94
  const t = term.trim();
50
95
  if (t.length === 0) return 0;
@@ -8,9 +8,15 @@ The lookup count is in doctor (`Lookups`). The dashboard does not show it yet, n
8
8
  (`dream.begun`'s `queue`, `waiting`, `agedOut`), nor the fidelity a merge or gist was made at
9
9
  (`dream_changes.detail.fidelity`). Those belong to the dashboard's own session.
10
10
 
11
+ **CLOSED 2026-10-01 by #306 (`a08d20d`), noted 2026-10-09:** the Health page's checks say
12
+ the Lookups line in words, the dream's `dream.begun` row narrates what waited and what aged
13
+ out, and the dreams view says what a merge or a gist was made from (its fidelity).
14
+
11
15
  ## §2. Other mechanisms that could fit this way
12
16
 
13
17
  - The page writer's day (`self/writer.ts`, 8 KB by strength): one long statement can take most
14
18
  of the room; a line per statement would fit more.
15
- - The wake's lanes (`self/identity.ts`): a "N more" pointer per lane.
16
- - One budget per hook envelope (SessionStart, UserPromptSubmit).
19
+ - The wake's lanes (`self/identity.ts`): a "N more" pointer per lane. *(Built 2026-09-29,
20
+ #285: `self/briefing.ts#moreLine`, every lane but Nearby since 10-01; noted 2026-10-09.)*
21
+ - One budget per hook envelope (SessionStart, UserPromptSubmit). *(Built 2026-09-29, #285,
22
+ `b475748`; noted 2026-10-09.)*
@@ -28,10 +28,48 @@ What the build learned. Newest last.
28
28
  three), and cuts go by `clipWire`. Tested with Chinese text at the real limits.
29
29
  - **A result carries its payload twice** (the text, and `structuredContent`). Whether a host
30
30
  counts both is not known here; nothing in this package reads `structuredContent`, so the long
31
- `bundle` text rides only in the text and the structured copy says `bundleChars`.
31
+ `bundle` text rides only in the text and the structured copy says `bundleChars`. (Superseded
32
+ 2026-09-29: Claude Code hands the model `structuredContent` and drops the text, so the whole
33
+ payload rides in both — `mcp/server.ts#result`.)
32
34
  - **A lookup counts as the index's only while its run is open** (the dream not journaled, the
33
35
  reflection not finished) or within `LOOKUP_GRACE_MS` of its end.
34
36
  - **Journal entries the room did not take are carried**: the index keeps each episode's entry
35
37
  count and the entries below it that were not taken (`unread`); the next dream sends them
36
38
  whether or not the episode grew.
37
39
 
40
+
41
+ ## §3. The host's ceiling, measured (2026-10-02)
42
+
43
+ - **What Claude Code does past it.** Read from Claude Code 2.1.287's own code: a tool result
44
+ whose text passes 50,000 characters (the global persist threshold; an MCP tool's own is
45
+ 100,000, and the lower wins) is saved to a file and the model gets a 2 KB preview; an MCP
46
+ result past 25,000 tokens (`MAX_MCP_OUTPUT_TOKENS`, counted for real once the estimate passes
47
+ ~12,500) is saved the same way. The text it measures is `structuredContent` serialized
48
+ compact. The headless nightly run cannot open the file, so the dream of 10-02 read part 3 of
49
+ its bundle only (the begin, 51.5 KB, and part 2, 51,306 characters, were saved), and the
50
+ reflection lost its begin (51.7 KB). The night of 10-01 lost the same three (51.4 KB, 52,066,
51
+ 51.9 KB).
52
+ - **The char line is the one that binds.** The token line is counted for real only when the
53
+ estimate (length / 4) passes 12,500 — past 50,000 characters — so under the char line it never
54
+ applies. Part 2 (51,306 characters, JSON escaped inside JSON) was past both, and counted over
55
+ 25,000 tokens. 54,000 was sized on a guess of three characters a token, over the char line.
56
+ - **One ceiling.** `TOOL_RESULT_CEILING.CHARS` = 40,000, 20% under the 50,000-character line,
57
+ and the dream's and the reflection's rooms derive from it; so does the nightly writer's day
58
+ (`self/writer.ts#fitNightWriter`, which shrinks the day until its block fits beside the page)
59
+ and the write-up parts (`sessions.ts#partCost`, bytes or escaped wire cost, whichever is more).
60
+ - **A turn's budget too.** `HOST_MESSAGE_CHARS` = 200,000 across one assistant turn's results:
61
+ a night model that fetches parts 2 and 3 in one turn shares it. A busy night's whole bundle is
62
+ tested under 80% of it.
63
+ - **Residual risk.** The host can lower either line by a remote flag. The nightly run's child
64
+ pins the token line with `MAX_MCP_OUTPUT_TOKENS=25000` (the env var outranks the flag); nothing
65
+ pins the char line. The server's net (`mcp/server.ts#withinCeiling`) cannot show it — it
66
+ measures against our own ceiling, and the host acts after it answers. Since 2026-10-09 the
67
+ nightly run reads its child's transcript for the host's marker (`claude-code/NOTES.md`,
68
+ 2026-10-09) and writes `mcp.result.spilled`; doctor's Tool results line and the morning
69
+ hand-back say it. Ordinary sessions are not read: a cut there shows only in that session.
70
+ - **New durable event names after all** (§1 said none): `mcp.part` and `mcp.result.oversize`.
71
+ The lookup count measures what a receiver fetched by id, which cannot see a part the host
72
+ never showed; these two say what was handed and what was cut. Every dashboard registry
73
+ learned them in the same change.
74
+ - **Unsure:** carrying the bundle as structured fields rather than a JSON string inside JSON
75
+ would roughly halve its characters for the same content. Not done here.
@@ -185,6 +185,46 @@ export function fit(candidates: readonly FitCandidate[], opts: FitOptions): FitO
185
185
  };
186
186
  }
187
187
 
188
+ // ── the room one tool result has ────────────────────────────────────────────
189
+
190
+ /**
191
+ * THE CEILING ON ONE TOOL RESULT (2026-10-02), the one number every tool
192
+ * result's cap derives from — the dream's and the reflection's parts, the
193
+ * nightly writer's day, and the MCP server's last-resort cut.
194
+ *
195
+ * MEASURED, not guessed: the night of 2026-10-02 (and of 10-01) Claude Code
196
+ * handed the model a 2 KB preview of every result over the line and saved the
197
+ * rest to a file the headless run cannot open, so the dream saw a third of
198
+ * its bundle. Read from Claude Code 2.1.287 itself, there are three lines:
199
+ *
200
+ * - `HOST_CHARS`: a result whose text runs past 50,000 characters (the
201
+ * host's global persist threshold, under the MCP tool's own 100,000) is
202
+ * saved to a file — "Output too large (51.5KB)". The text it measures is
203
+ * `structuredContent` serialized compact, when a result carries one.
204
+ * - `HOST_TOKENS`: an MCP result past 25,000 tokens (`MAX_MCP_OUTPUT_TOKENS`)
205
+ * is saved the same way — "result (51,306 characters) exceeds maximum
206
+ * allowed tokens". It is counted for real only when the estimate
207
+ * (length / 4) passes 12,500, that is past 50,000 characters, so under
208
+ * the char line it never applies.
209
+ * - `HOST_MESSAGE_CHARS`: 200,000 characters across one assistant turn's
210
+ * results together (parts 2 and 3 fetched in parallel are one turn).
211
+ *
212
+ * `CHARS` is the room: 20% under the char line, so a result measured by
213
+ * `wireChars` (a non-ASCII character as three) under it reaches the model
214
+ * whole. RESIDUAL RISK: the host can lower either line by a remote flag
215
+ * (`tengu_velvet_ibis`); the nightly run pins the token line with the env var
216
+ * (`night-run.ts`), and nothing pins the char line. What it does instead
217
+ * (2026-10-09): the nightly run reads its child's transcript for the host's
218
+ * marker on our results (`claude-code/transcript.ts#readToolSpills`), so a
219
+ * lowered line shows up in doctor and in the morning, not in nothing. CAL.
220
+ */
221
+ export const TOOL_RESULT_CEILING = {
222
+ HOST_CHARS: 50_000,
223
+ HOST_TOKENS: 25_000,
224
+ HOST_MESSAGE_CHARS: 200_000,
225
+ CHARS: 40_000,
226
+ } as const;
227
+
188
228
  // ── what a text costs on the wire ───────────────────────────────────────────
189
229
 
190
230
  /**
@@ -72,7 +72,8 @@ this host a directory is what a piece of work *is*.
72
72
  model id (or null), the lived-day clock, and a gate (`bridge.episodeGate`, injected).
73
73
  **Outputs** — one schema row per (directory, session) with `meta.role = "handoff"`; a
74
74
  pointer block for a given directory and day — two lines for one live handoff, a short
75
- newest-first list for several; four durable event names (`written`, `shown`, `cleared`,
75
+ newest-first list for several, and under either a "since" line when a plan was written
76
+ here after the newest (§5 G13); four durable event names (`written`, `shown`, `cleared`,
76
77
  `refused`). And a "Last here" block for a directory where a session wrote a chapter inside
77
78
  the fortnight: one to three lines, no row and no durable event (§5 G11).
78
79
 
@@ -211,6 +212,27 @@ the fortnight: one to three lines, no row and no durable event (§5 G11).
211
212
  The root hands it to `self/`'s render as furniture for the day before the render's
212
213
  date; unlike "Last here" it is in the published bundle, not spliced at delivery.
213
214
 
215
+ 13. **[M] What was planned here since the handoff is named under it** (2026-10-09). A
216
+ session that left a handoff and later changed the plan in a note, without rewriting
217
+ the handoff, left the newer memory quiet. Now the pointer's block ends with one line,
218
+ "Since this handoff:" ("Since the newest handoff here:" beside several), naming the
219
+ memories this directory's sessions wrote by hand after the NEWEST handoff's words
220
+ whose v12 `status` is `planned`, `proposed` or `asked`, or that are still flagged
221
+ `unresolved` (`Handoffs#plansSince`, `PLAN_STATUSES`): up to `SINCE_SHOWN` by title
222
+ (cut to `SINCE_TITLE_BYTES`), word and id, newest first, the rest by count. Its own
223
+ session's memories count, except what it wrote within `SINCE_SAME_ANSWER_MS` of the
224
+ handoff, which is the same answer (the `session_end` call writes its handoff first
225
+ and its memories straight after). Never named: a `done` or unmarked memory, another
226
+ directory's, a dream's or a sweep's (`source = 'authored'` only), one a later memory
227
+ settled over, one the published wake already lists under "Still open:" (one place for
228
+ an open question; `self/index.ts#threadsShown`, review of #332), a journal copy, a
229
+ confidential one outside the owner's session. Read
230
+ at delivery and at the boundary from the columns (`Store#planCandidates`), then the
231
+ prose of what came back; a store that will not answer names nothing. Every rung of
232
+ the ladder is tried WITH the line before the rungs WITHOUT it, which are the blocks as
233
+ they were, byte for byte; a memory the line names is left out of the work lines
234
+ above it. `handoff.shown` counts the line's memories (`plans`).
235
+
214
236
  ## 6. Where it sits in the wake's order — who pays, when, and how much
215
237
 
216
238
  The pointer is **furniture at the foot of the bundle**, above the tail sentinel and below
@@ -263,6 +285,18 @@ true:
263
285
  fallback. The line alone only when no handoff rung fits (`no-room` written as before).
264
286
  With no chapter here the ladder is the handoff's, rung for rung.
265
287
 
288
+ - **The "since" line (2026-10-09)** is part of the handoff's own rungs (§5 G13): each rung
289
+ with it is a candidate in the reserve, sized to the line that exists at the boundary,
290
+ and the share rule still takes the widest that passes. It adds 79 bytes for one plan
291
+ with a 29-byte title, and at most 306 (317 beside several handoffs: three titles at the
292
+ cap, the widest word, a count). With no plan written here since the newest handoff the
293
+ rungs and the block are what they were, and so is the reserve below a 13,168-byte
294
+ budget (above it the raised ceiling no longer clamps the widest block's margin; NOTES
295
+ §11). A plan written after the boundary
296
+ that composed the bundle waits for the next one to be reserved for (`session_end`
297
+ marks the wake behind; a lone `note` does not), and until then is carried only where
298
+ the bundle has the room.
299
+
266
300
  So the order of who gives up bytes, stated plainly: **above the share rule's threshold the
267
301
  pointer is paid for first, out of the compose budget, by whatever lane the trim order
268
302
  reaches — store-wide. Below it the pointer gives up everything and the lanes give up
@@ -292,7 +326,8 @@ does not log its own refusal) · **§13 G3** (one ask at the blocked moment).
292
326
  naming a session and a model (2,400 until 2026-09-30, when the pointer began saying how
293
327
  current it is, then who left it and how to retire it, and the reserve was sized to
294
328
  those words), and roughly 4,400 for one that also says why it may be out of date
295
- (2026-10-01). It is a judgement about
329
+ (2026-10-01); about 5,000 with a one-plan "since" line under that, and 6,900 with the
330
+ widest line (2026-10-09). It is a judgement about
296
331
  what a pointer is worth against a memory, made once, in numbers; the owner's hosts all
297
332
  report far more than that, so nothing he runs is near it today.
298
333
  2. **Does the host's own file memory duplicate this?** The spec names it as the thing to
@@ -16,6 +16,11 @@ rows about places, which is a handful in any store anyone has.
16
16
  rows. Until then: do not put this call on a hot path. It runs at a boundary
17
17
  (`liveBlockBytes`, one walk), at a wake (`pointer`) and at a write, and nowhere else.
18
18
 
19
+ The "since" line (2026-10-09) meets the same gap for `unresolved`, which lives in the
20
+ meta and not in a column: `Store#planCandidates` matches the meta's text loosely
21
+ (`"unresolved":true`) beside the `status` column, and `Handoffs#plansSince` confirms each
22
+ on the prose it reads anyway.
23
+
19
24
  ## 2. `expandHandle` has no scope filter
20
25
 
21
26
  **Owner:** `mcp/deliberate.ts`.
@@ -172,6 +177,11 @@ is in, and `rebuildCache` already reaches it.
172
177
 
173
178
  ## 8. No host but Claude Code passes a scope at wake
174
179
 
180
+ *(Noted 2026-10-09: no longer true. Since 2026-09-30 the host-neutral
181
+ `adapters/lifecycle.ts#composeWake` passes the session's scope to `wake` (#292), and
182
+ Claude Desktop chat's `wake` tool calls it with the server's scope (#294). The ask stands
183
+ for the next host. Kept as written.)*
184
+
175
185
  **Owner:** whoever writes the next adapter.
176
186
  **Needed:** `Counterpart.wake(budget, delivery, here)`'s third argument.
177
187
  **Have:** only `claude-code/hooks.ts#sessionStart` passes it. Every other caller — the CLI,
@@ -399,3 +399,75 @@ choices it left open:
399
399
  (`ChapterHere.confidential`, `aboutMe`). No schema change. The Yesterday line, which is
400
400
  composed once and read by every session, leaves confidential chapters out for all.
401
401
 
402
+
403
+ ## 2026-10-03 — `chaptersOf` returns the heading too
404
+
405
+ Each chapter `chaptersOf` reads now carries its engine heading line (`heading`, null for a
406
+ body with none), so a chapter address (`self/chapter-address.ts`, v12) resolves to it. The
407
+ two fields it had are unchanged.
408
+
409
+ ## 11. What was planned here since the handoff (2026-10-09)
410
+
411
+ From daily use: a session wrote its handoff, worked on, and near its end wrote a note that
412
+ changed the plan, without rewriting the handoff. The next wake in that directory showed the
413
+ older handoff as the place to resume, and the note said nothing. §10's stale words would
414
+ not fire: they look for a chapter by ANOTHER session, or a newer install. What was built
415
+ (CONTRACT §5 G13), and why each piece is the way it is:
416
+
417
+ - **The signal is the writer's v12 `status`, plus `unresolved`.** `planned` (decided, not
418
+ done), `proposed` (put forward, not decided) and `asked` (a question or request still
419
+ open) are a closed vocabulary the writer fills deliberately, a column the SQL can filter
420
+ on, and a revision carries it over by default — so a note that `updates` a planned
421
+ memory to change the plan is still `planned` unless the writer says otherwise. `done` is
422
+ not a next step and an unmarked memory says nothing. `unresolved` is the older flag for
423
+ an open question or a pending promise, and the brief named it; the line prints it as
424
+ "open", the word the "Still open:" lane uses. Not a separate "updates a plan" rule: a
425
+ revision of a fact is not a plan, and a revision of a plan carries its status.
426
+ - **Since the NEWEST handoff, one line for the block.** Per-handoff lines would multiply
427
+ the bytes, and "since the oldest shown" makes "since" mean something different on each
428
+ rung. What this gives up: a plan written between two sessions' handoffs is not named
429
+ once the later handoff exists. Beside several handoffs the lead says "Since the newest
430
+ handoff here:".
431
+ - **The same answer is not news.** `session_end` writes its handoff first and its memories
432
+ straight after, so a planned entry in the same call would be listed "since" a handoff it
433
+ was written with, every wake for a fortnight. The writer's own memories within
434
+ `SINCE_SAME_ANSWER_MS` (five minutes, the chapter span's grace for the same answer) are
435
+ left out; another session's count from the first millisecond. Chosen over "until the
436
+ writer's next turn-end" (`coverage/#workSince`'s rule): a turn in this host can run an
437
+ hour, a plan changed late in the same long turn should be named, and a host with no
438
+ turn-ends (Desktop chat) would never name its own.
439
+ - **Only what a session wrote** (`source = 'authored'`: notes, `session_end` entries, a
440
+ write-up). A dream's gist can carry a status too, and is filed under the directory the
441
+ dream ran in; it is a reading of older memories, not news since the handoff.
442
+ - **Tried before the third handoff.** The ladder is every rung with the line, widest first,
443
+ then every rung as it was. Interleaved (three with, three, two with, …) would keep a
444
+ third, older handoff over the line at the owner's ceiling, where the share rule caps the
445
+ block near 1,077 bytes; the line is newer than any handoff in the block. The rungs
446
+ without it are today's blocks byte for byte, so a ceiling with no room for the line
447
+ carries exactly what it carried before.
448
+ - **Not named twice.** A planned note written in a project is usually a work memory too
449
+ (an unmarked fact with a directory), so the work lines above the pointer leave out the
450
+ ids the chosen rung's line names. And the line leaves out what the published wake
451
+ already lists under "Still open:" (review of #332): the bundle cannot be filtered at
452
+ delivery, so the lane keeps it and the line gives way. Its ids are written beside the
453
+ bundle at each publish (`self/index.ts#THREADS_SHOWN_KEY`, a JSON array) and handed in as
454
+ `listed`, as `settled` is. An open question the lane does not list — opened since the
455
+ last boundary, or past its cap of the oldest — is still named here, which is when the
456
+ line is the only place it shows.
457
+ - **Sized to the line that exists, at the boundary** (`liveBlockBytesByScope` asks
458
+ `plansSince` as delivery does). A `note` does not mark the wake behind, so a plan written
459
+ after the last boundary is carried only where the bundle has room until the next one;
460
+ `session_end` does mark it, and the Stop that follows re-renders. The one-boundary lag
461
+ every handoff fact has.
462
+ - **Cost.** One SQL read per directory with a live handoff, at each delivery and each
463
+ boundary (no index on `origin_scope`, as `workCandidates`), and prose reads only for
464
+ what it returns; `settledOver` only when there is something to name. Timed against the
465
+ continuity suite's busiest ladder test with the read switched off: no difference above
466
+ the noise. Measured in review (#332) on a synthetic store: the SQL read is 0.2 ms at 800
467
+ memories and 1 ms at 5,000; `plansSince` whole, with its 30 prose reads, 5–9 ms per
468
+ directory.
469
+ - **The reserve's ceiling moved, so the widest no-plan block's margin is no longer
470
+ clamped** (review of #332). At 1,646 the ceiling ate the 48-byte margin of a 1,646-byte
471
+ block; at 1,963 it does not. Below a 13,168-byte budget nothing changes (that block fails
472
+ the share rule either way); between 13,168 and 13,552 the reserve takes a narrower rung
473
+ than it did; above, it is up to 48 bytes larger. The owner's hosts report 9,000.