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
@@ -55,15 +55,17 @@
55
55
  * No body text, no question text, no note text ever reaches an event.
56
56
  */
57
57
  import { CLAIM_NOTHING_NEW, claimUnwritten } from "../../core/coverage/index.js";
58
- import { MCP_RECALL_EVENT } from "../../core/counterpart.js";
59
- import { CONTRADICTION_TUNABLES, NEIGHBOURS_HINT } from "../../core/contradictions.js";
58
+ import { MCP_OVERSIZE_EVENT, MCP_PART_EVENT, MCP_RECALL_EVENT } from "../../core/counterpart.js";
59
+ import { CONTRADICTION_TUNABLES, HELD_HINT, NEIGHBOURS_HINT } from "../../core/contradictions.js";
60
60
  import type { Neighbour } from "../../core/contradictions.js";
61
- import { localDate, parseCalendarDate, todayIn } from "../../core/time.js";
62
- import type { ChapterResult, Counterpart, DepositResult } from "../../core/counterpart.js";
61
+ import { isRecurrence, localDate, occurrenceOnOrAfter, parseCalendarDate, readableRecurrence, todayIn } from "../../core/time.js";
62
+ import type { Recurrence } from "../../core/time.js";
63
+ import type { ChapterResult, Counterpart, DepositResult, SentFacts } from "../../core/counterpart.js";
64
+ import { loadGateState } from "../../core/recall/index.js";
63
65
  import type { SemanticSource } from "../../core/recall/index.js";
64
66
  import { AUTHOR_DIMENSIONS } from "../../core/remember/index.js";
65
- import { ABOUT_MARKS, CACHE_SCHEMA_VERSION, CORE_ABOUT_MARKS, SCHEMA_VERSION, StoreError, checkFeelings, checkTraits, isStoreError, schemaAhead } from "../../core/store/index.js";
66
- import type { AboutMark, FeelingInput, TraitInput } from "../../core/store/index.js";
67
+ import { ABOUT_MARKS, CACHE_SCHEMA_VERSION, CORE_ABOUT_MARKS, SAID_BY, SCHEMA_VERSION, STATUSES, StoreError, checkFeelings, checkTraits, isStoreError, saidByOf, schemaAhead, statusOf } from "../../core/store/index.js";
68
+ import type { AboutMark, FeelingInput, MemoryStatus, SaidBy, TraitInput } from "../../core/store/index.js";
67
69
  import { isLocked } from "../../core/store/db.js";
68
70
  import type { Band, Kind } from "../../core/types.js";
69
71
  import { UNBOUND_SESSION, isKnownSession } from "../../core/types.js";
@@ -109,21 +111,21 @@ import {
109
111
  sameScope,
110
112
  serverIsNewer,
111
113
  touchDesktopSession,
114
+ versionNewer,
112
115
  } from "../sessions.js";
113
116
  import type { ServerRecord } from "../sessions.js";
114
117
  import {
115
118
  JOURNAL_GLOSS,
116
119
  RECALL_BODY_CHARS,
117
- RECALL_EXCERPT_CHARS,
118
120
  RECALL_MAX_IDS,
119
121
  RECALL_ID_RESULT_CHARS,
120
- RECALL_RESULT_CHARS,
121
122
  boundById,
122
- boundMemories,
123
123
  deliberateRecall,
124
124
  embedQuestion,
125
125
  } from "./deliberate.js";
126
126
  import type { DeliberateResult } from "./deliberate.js";
127
+ import { factsRecall, renderFacts } from "./facts.js";
128
+ import { meaningRecall, renderMeaning } from "./meaning.js";
127
129
  import {
128
130
  ERROR_CODES,
129
131
  failure,
@@ -133,9 +135,9 @@ import {
133
135
  import type { Id, Request, Response } from "./protocol.js";
134
136
  import { DREAMING_SETTINGS, NIGHT_RUN_FINISHES, nightNext, nightOrder } from "../../core/dream/index.js";
135
137
  import type { DreamBundle, DreamingSetting, NightPart } from "../../core/dream/index.js";
136
- import { noteLookups } from "../../core/fit/index.js";
138
+ import { TOOL_RESULT_CEILING, clipWire, noteLookups, wireChars } from "../../core/fit/index.js";
137
139
  import type { FitMechanism } from "../../core/fit/index.js";
138
- import { NO_PAGE_VERSION, pageSections } from "../../core/self/index.js";
140
+ import { NIGHT_WRITER_TOOL, NO_PAGE_VERSION, WAKE_BUILD_KEY, pageSections } from "../../core/self/index.js";
139
141
  import type { PageWriterMode } from "../../core/self/index.js";
140
142
  import { toolDefinitions, toolSpec } from "./tools.js";
141
143
  import { writeUpDoor } from "./write-up.js";
@@ -151,7 +153,7 @@ export const SERVER_NAME = "counterparts";
151
153
  * host decides whether to trust what follows. Read from a constant rather than
152
154
  * from disk so the server opens no file to answer its first message.
153
155
  */
154
- export const SERVER_VERSION = "0.3.11";
156
+ export const SERVER_VERSION = "0.3.13";
155
157
 
156
158
  /**
157
159
  * THE ONE LINE EVERY TOOL ANSWERS WITH when the store on disk is a schema AHEAD
@@ -230,6 +232,23 @@ export interface McpServerOptions {
230
232
  scope?: string;
231
233
  /** Is this the owner's own session? Withholding is the safe direction. */
232
234
  owner?: boolean;
235
+ /**
236
+ * WHAT DECIDED `owner` (2026-10-02), for `status` to say plainly: `env` —
237
+ * `COUNTERPARTS_OWNER` or `--owner`; `config` — nothing said, so the installed
238
+ * configuration's `owner: true` made a Claude Code launch the owner's;
239
+ * `off` — `COUNTERPARTS_OWNER` said no (`0`, or a value it could not
240
+ * read); `default` — nothing said and nothing made it so. Absent: `env`
241
+ * when `owner` is true, else `default`.
242
+ */
243
+ ownerFrom?: "env" | "config" | "default" | "off";
244
+ /**
245
+ * DESKTOP'S CODE TAB IS THE OWNER'S TOO (owner ruling 2026-10-02). Desktop's
246
+ * server opens as a guest for its chats; a call it serves as a Claude Code
247
+ * session (`callAs`) is that session, so with this set the call is the
248
+ * owner's — its reads and its thread close. Set by the entry point from the
249
+ * configuration's `owner: true` when `COUNTERPARTS_OWNER` said nothing.
250
+ */
251
+ codeTabOwner?: boolean;
233
252
  /**
234
253
  * The embedder, for ONE purpose: embedding a deliberate question in line.
235
254
  *
@@ -249,6 +268,12 @@ export interface McpServerOptions {
249
268
  registryDir?: string;
250
269
  /** **CAL.** Liveness window for a lazily-bound claim (`adapters/sessions.ts`). */
251
270
  sessionTtlMs?: number;
271
+ /**
272
+ * The most one tool result may measure, by `wireChars` of its serialized
273
+ * `structuredContent` (`withinCeiling`). Default `TOOL_RESULT_CEILING.CHARS`;
274
+ * a test passes a small one to reach the cut without a 40,000-character page.
275
+ */
276
+ resultCeilingChars?: number;
252
277
  /**
253
278
  * THE SCOPE REGISTRY this server consults — `<config dir>/scopes.json`,
254
279
  * resolved by the entry point from the same `--config` rule everything else
@@ -322,7 +347,7 @@ export interface McpServerOptions {
322
347
  * a host that reads it learns the one thing it needs to.
323
348
  */
324
349
  export const DESKTOP_INSTRUCTIONS =
325
- "Counterparts is your memory. At the start of each chat, before answering, call its wake tool once: it returns this chat's briefing and a session id to pass on session_end, chapter, dream and reflect. In a Claude Code session (Desktop's Code tab) the hook already woke you: do not call wake — pass your own session id, the one your wake or Stop ask names, as `session` on every call.";
350
+ "Counterparts is your memory. In every new chat, call its wake tool first — before answering anything about the person, the past, or work in progress — and once: it returns this chat's briefing, including what happened yesterday across every session, and a session id to pass on session_end, chapter, dream and reflect. Without a wake, what recall returns is a slice, not the whole record: never present it as complete. In a Claude Code session (Desktop's Code tab) the hook already woke you: do not call wake — pass your own session id, the one your wake or Stop ask names, as `session` on every call.";
326
351
 
327
352
  /** The MCP prompt a Desktop person can pick (brief item 6). */
328
353
  export const START_PROMPT = {
@@ -361,7 +386,10 @@ export function desktopWriteUpAsk(session: string): string {
361
386
 
362
387
  /** What `status` says `owner: false` means — the confused Desktop chats' question (2026-09-30). */
363
388
  export const OWNER_FALSE_NOTE =
364
- "owner: false is the ordinary setting — confidential memories are left out of this server's answers; nothing is wrong.";
389
+ "owner: false — confidential memories are left out of this server's answers, and an open question written in another directory cannot be closed from here. It is the ordinary setting for a Claude Desktop chat; your Claude Code sessions run as the owner unless COUNTERPARTS_OWNER=0. Nothing is wrong.";
390
+
391
+ /** The owner variable's name, for `status` (the entry point reads it, `stance-env.ts`). */
392
+ const OWNER_ENV_NAME = "COUNTERPARTS_OWNER";
365
393
 
366
394
  /** The narrow face of `claude-code/embed-client.ts`'s `LiveEmbedder` this
367
395
  * adapter needs — structural, so the server library imports no other adapter.
@@ -474,6 +502,9 @@ const PAGE_REFUSAL_DETAIL: Record<string, string> = {
474
502
  const KIND_SET: Record<Kind, true> = { self: true, person: true, entity: true, skill: true, place: true, fact: true };
475
503
  const MEMORY_KINDS = Object.keys(KIND_SET) as readonly Kind[];
476
504
 
505
+ /** Sessions whose "shown" a server keeps in memory for `feelingsNow` (Desktop serves many). */
506
+ export const SEEN_SESSIONS = 32;
507
+
477
508
  export class McpServer {
478
509
  readonly counterpart: Counterpart;
479
510
  /** The session the HOST named at launch, if it could. Never changes. */
@@ -486,6 +517,8 @@ export class McpServer {
486
517
  scopeSource: ScopeSource;
487
518
  /** Did the host say this is the owner's session? Read through `owner`. */
488
519
  private readonly ownerClaimed: boolean;
520
+ private readonly ownerFrom: "env" | "config" | "default" | "off";
521
+ private readonly codeTabOwner: boolean;
489
522
  /** The store's own observer bit (observer-mode G7): set at open, never lifted. */
490
523
  private readonly storeObserver: boolean;
491
524
  /**
@@ -507,9 +540,20 @@ export class McpServer {
507
540
  private readonly registryDir: string;
508
541
  private readonly scopesFile: string | null;
509
542
  private readonly sessionTtlMs: number;
543
+ private readonly resultCeilingChars: number;
510
544
  private readonly onEvent: ((e: McpEvent) => void) | undefined;
511
545
  private readonly nowFn: () => number;
512
546
  private readonly ring: McpEvent[] = [];
547
+ /**
548
+ * WHAT EACH SESSION WAS SHOWN through this server (2026-10-02, lane B): the
549
+ * memories `recall` DELIVERED (not the ids left waiting) and the neighbours
550
+ * a write showed. With the ambient recall's record for the session, it is
551
+ * what `note`'s `feelingsNow` may feel again. KEYED BY SESSION (review of
552
+ * #316): Desktop's one server serves many sessions, and a Claude Code
553
+ * process starts a new session on /clear. In memory only, the newest
554
+ * `SEEN_SESSIONS` sessions.
555
+ */
556
+ private readonly seenBySession = new Map<string, Set<string>>();
513
557
  private initialized = false;
514
558
  /** The lazy bind's result: null until a claim is corroborated, then frozen. */
515
559
  private lazySession: string | null = null;
@@ -522,6 +566,8 @@ export class McpServer {
522
566
  private launchOff = false;
523
567
  /** Set by the write guard when it refused a write in the current call. */
524
568
  private writeTripped: SchemaVerdict | null = null;
569
+ /** The part this call handed, written after the net (`writePart`). */
570
+ private partHanded: { mechanism: FitMechanism; ref: string; part: number; of: number } | null = null;
525
571
  /**
526
572
  * CLAUDE DESKTOP'S BINDING IS PER CALL (2026-09-30). One server serves every
527
573
  * Desktop chat, so the lazy bind — once, for the life of the process — would
@@ -561,6 +607,7 @@ export class McpServer {
561
607
  this.scopesFile =
562
608
  opts.scopesFile !== undefined && opts.scopesFile.length > 0 ? opts.scopesFile : null;
563
609
  this.sessionTtlMs = opts.sessionTtlMs ?? SESSION_TTL_MS;
610
+ this.resultCeilingChars = opts.resultCeilingChars ?? TOOL_RESULT_CEILING.CHARS;
564
611
  this.host = opts.host ?? DEFAULT_HOST;
565
612
  this.lifecycleOpts = opts.lifecycle ?? {};
566
613
  this.wakeNotice = opts.wakeNotice;
@@ -575,6 +622,8 @@ export class McpServer {
575
622
  this.storeObserver = opts.counterpart.observer;
576
623
  this.launchObserver = opts.launchObserver === true;
577
624
  this.ownerClaimed = opts.owner === true;
625
+ this.ownerFrom = opts.ownerFrom ?? (opts.owner === true ? "env" : "default");
626
+ this.codeTabOwner = opts.codeTabOwner === true;
578
627
  this.embedderGiven = opts.embedder ?? null;
579
628
  this.onEvent = opts.onEvent;
580
629
  this.nowFn = opts.now ?? ((): number => Date.now());
@@ -658,7 +707,22 @@ export class McpServer {
658
707
  /** An observer is a non-owner regardless of what the host claimed
659
708
  * (observer-mode G7): an instrument reading somebody's store is not them. */
660
709
  get owner(): boolean {
661
- return this.ownerClaimed && !this.observer;
710
+ return (this.ownerClaimed || (this.callAs !== null && this.codeTabOwner)) && !this.observer;
711
+ }
712
+
713
+ /** What `status` says decided the stance (2026-10-02), in words. */
714
+ private ownerStance(): Record<string, unknown> {
715
+ const from =
716
+ this.callAs !== null && this.codeTabOwner && !this.ownerClaimed
717
+ ? "a Claude Code session from Desktop's Code tab, which the installed configuration (owner: true) makes the owner's"
718
+ : this.ownerFrom === "config"
719
+ ? "the installed configuration (owner: true): this is your own Claude Code session"
720
+ : this.ownerFrom === "env"
721
+ ? `--owner or ${OWNER_ENV_NAME}, set on this launch`
722
+ : this.ownerFrom === "off"
723
+ ? `${OWNER_ENV_NAME} on this launch says not the owner's (0, off or false, or a value it could not read): the opt-out`
724
+ : "nothing made this launch the owner's";
725
+ return { owner: this.owner, ownerFrom: from, ...(this.owner ? {} : { ownerMeans: OWNER_FALSE_NOTE }) };
662
726
  }
663
727
 
664
728
  /** An instrument opens no sockets, whatever the host handed it (scar E7). */
@@ -822,6 +886,7 @@ export class McpServer {
822
886
  // the gate's refusal, whatever the tool made of the error on its way out.
823
887
  // Calls arrive one at a time over stdio, so one slot is enough.
824
888
  this.writeTripped = null;
889
+ this.partHanded = null;
825
890
  // CLAUDE DESKTOP: WHICH SESSION IS THIS CALL (2026-09-30) — bound per call,
826
891
  // before anything reads `this.session`, and let go when the call ends.
827
892
  // `wake` binds nothing: it makes the session. Nothing here writes in a place
@@ -849,7 +914,13 @@ export class McpServer {
849
914
  const tripped = this.writeTripped;
850
915
  this.writeTripped = null;
851
916
  if (tripped !== null) return this.refusalFor(name, tripped, "write");
852
- return desktopCall ? this.afterDesktopCall(name, result as ToolResult) : (result as ToolResult);
917
+ // THE NET LAST (2026-10-02): after the Desktop extras, which rebuild the
918
+ // result, so nothing leaves past it; a part's row after the net. The
919
+ // update notice before the net, so the net measures what leaves.
920
+ const served = desktopCall ? this.afterDesktopCall(name, result as ToolResult) : (result as ToolResult);
921
+ const out = this.withinCeiling(name, args, this.withUpdateNotice(name, served));
922
+ this.writePart(out);
923
+ return out;
853
924
  } finally {
854
925
  this.callSession = null;
855
926
  this.callBoundBy = null;
@@ -1493,7 +1564,19 @@ export class McpServer {
1493
1564
  });
1494
1565
  }
1495
1566
  const hasText = typeof text === "string" && text.trim().length > 0;
1496
- if (!hasText && settleArg !== undefined) return this.settleOnly(settleArg as Record<string, unknown>);
1567
+ // FEELINGS NOW (2026-10-02, lane B): how a memory this session was shown
1568
+ // feels now, recorded beside the first. With `text` too, both happen.
1569
+ const nowArg = args["feelingsNow"];
1570
+ if (nowArg !== undefined && !Array.isArray(nowArg)) {
1571
+ return this.refuse("note", "feelings-now-malformed", {
1572
+ detail: "feelingsNow is a list: one object each, {id, emotion, core?, strength?, carried_by?, whose?}.",
1573
+ });
1574
+ }
1575
+ if (!hasText && settleArg === undefined && nowArg !== undefined) return this.feelingsNowOnly(nowArg as unknown[]);
1576
+ if (!hasText && settleArg !== undefined) {
1577
+ const settled = this.settleOnly(settleArg as Record<string, unknown>);
1578
+ return nowArg === undefined ? settled : this.withFeelingsNow(settled, nowArg as unknown[]);
1579
+ }
1497
1580
  if (typeof text !== "string" || text.trim().length === 0) {
1498
1581
  return this.refuse("note", "text-required", {});
1499
1582
  }
@@ -1549,13 +1632,22 @@ export class McpServer {
1549
1632
  if ("refused" in about) return this.refuse("note", "about-malformed", { detail: about.refused });
1550
1633
  const traits = readTraits(args["traits"]);
1551
1634
  if ("refused" in traits) return this.refuse("note", "traits-malformed", { detail: traits.refused });
1635
+ // v12: when it happened, who said it, what kind — never a refusal: what
1636
+ // cannot be read is dropped and said beside the memory that landed.
1637
+ const facts = readWriteFacts(args, this.today());
1552
1638
  const deposit = await this.counterpart.submitJot(draft, {
1553
1639
  session,
1554
1640
  scope: this.scope,
1555
1641
  ownSpanHash,
1642
+ facts: facts.sent,
1556
1643
  ...(model === undefined ? {} : { model }),
1644
+ // This call's stance, which a Code-tab call on Desktop's server can hold
1645
+ // when the store opened as a guest (2026-10-02).
1646
+ owner: this.owner,
1557
1647
  });
1558
1648
  const neighbours = this.neighboursOf(deposit);
1649
+ this.markSeen(neighbours.map((n) => n.id));
1650
+ const feltNow = nowArg === undefined ? null : this.feelingsNowOutcome(nowArg as unknown[]);
1559
1651
  // WITH A SETTLE TOO (review of #284, M2): the call is an error only when
1560
1652
  // NOTHING landed — a refused note beside a settle that landed is not one,
1561
1653
  // so a retry does not run into `already-settled`.
@@ -1565,13 +1657,105 @@ export class McpServer {
1565
1657
  ...this.recordAbout(deposit, about.mark),
1566
1658
  ...this.recordTraits(deposit, traits.inputs, model),
1567
1659
  ...reminderEcho(deposit, dated, this.today()),
1660
+ ...factsEcho(deposit, facts),
1568
1661
  ...this.settledOf(deposit, args["how"] !== undefined),
1569
1662
  ...threadOf(deposit),
1570
1663
  // IN THE PAYLOAD, so it rides in `structuredContent` — which is what
1571
1664
  // Claude Code hands the model (the #282 lesson, f387f55).
1572
1665
  ...(neighbours.length === 0 ? {} : { neighbours, neighboursHint: NEIGHBOURS_HINT }),
1573
1666
  ...(settle === null ? {} : { settle }),
1574
- }, settle === null ? undefined : !deposit.deposited && settle["ok"] !== true);
1667
+ ...(feltNow === null ? {} : { feelingsNow: feltNow }),
1668
+ // AN ERROR ONLY WHEN NOTHING LANDED (review of #316): a refused note
1669
+ // beside a feeling that was recorded is not one, or the resend meets
1670
+ // `once-a-day`.
1671
+ }, settle === null && feltNow === null ? undefined : !deposit.deposited && settle?.["ok"] !== true && Number(feltNow?.["recorded"] ?? 0) === 0);
1672
+ }
1673
+
1674
+ /**
1675
+ * `note` with `feelingsNow` and no `text` (2026-10-02, lane B): record how
1676
+ * memories this session was shown feel now, and write nothing else. The
1677
+ * path is the reflection's (`Reflections#feelAgain`); an error only when
1678
+ * nothing was recorded.
1679
+ */
1680
+ private feelingsNowOnly(list: readonly unknown[]): ToolResult {
1681
+ const out = this.feelingsNowOutcome(list);
1682
+ return this.result({ stored: false, reason: "feelings-now-only", feelingsNow: out }, out["recorded"] === 0);
1683
+ }
1684
+
1685
+ /**
1686
+ * WHOSE "shown" A CALL IS (review of #316): on Desktop, the session the call
1687
+ * is served as; in Claude Code, the session its host is running now (a
1688
+ * /clear starts a new one in the same process), else the bound one.
1689
+ */
1690
+ private seenKey(): string {
1691
+ if (this.desktop) return this.session ?? UNBOUND_SESSION;
1692
+ return this.hostSession() ?? this.session ?? UNBOUND_SESSION;
1693
+ }
1694
+
1695
+ /** Remember that the calling session was shown these memories. */
1696
+ private markSeen(ids: readonly string[]): void {
1697
+ if (ids.length === 0) return;
1698
+ const key = this.seenKey();
1699
+ const set = this.seenBySession.get(key) ?? new Set<string>();
1700
+ for (const id of ids) set.add(id);
1701
+ // Newest last; the oldest session is let go past the bound.
1702
+ this.seenBySession.delete(key);
1703
+ this.seenBySession.set(key, set);
1704
+ while (this.seenBySession.size > SEEN_SESSIONS) {
1705
+ const oldest = this.seenBySession.keys().next().value;
1706
+ if (oldest === undefined) break;
1707
+ this.seenBySession.delete(oldest);
1708
+ }
1709
+ }
1710
+
1711
+ /** A settle-only result with the feelings now beside it. */
1712
+ private withFeelingsNow(settled: ToolResult, list: readonly unknown[]): ToolResult {
1713
+ const out = this.feelingsNowOutcome(list);
1714
+ const body = (settled as { structuredContent?: Record<string, unknown> }).structuredContent;
1715
+ if (body === undefined) return settled;
1716
+ const ok = body["settle"] !== undefined && (body["settle"] as Record<string, unknown>)["ok"] === true;
1717
+ return this.result({ ...body, feelingsNow: out }, !ok && out["recorded"] === 0);
1718
+ }
1719
+
1720
+ /**
1721
+ * One `feelingsNow` list through the core, as the result carries it. What
1722
+ * this session was shown: what this server handed it (`seenHere`) and what
1723
+ * ambient recall surfaced for its session, when the session is known.
1724
+ * Never throws.
1725
+ */
1726
+ private feelingsNowOutcome(list: readonly unknown[]): Record<string, unknown> {
1727
+ try {
1728
+ const session = this.seenKey();
1729
+ const shown = new Set(this.seenBySession.get(session) ?? []);
1730
+ if (session !== UNBOUND_SESSION) {
1731
+ try {
1732
+ // SURFACED, not footnoted (review of #316): a title in a footnote or
1733
+ // a link's pointer is not being shown the memory.
1734
+ for (const [id, rec] of Object.entries(loadGateState(this.counterpart.store, session).state.surfaced)) {
1735
+ if (rec.tier === "surfaced") shown.add(id);
1736
+ }
1737
+ } catch {
1738
+ // The ambient record unreadable: what this server showed still counts.
1739
+ }
1740
+ }
1741
+ const model = this.sessionModel(session);
1742
+ const items = list.map((x) => (x !== null && typeof x === "object" && !Array.isArray(x) ? (x as Record<string, unknown>) : {}));
1743
+ const done = this.counterpart.reflections.feelAgain({
1744
+ session,
1745
+ shown,
1746
+ feelings: items,
1747
+ ...(model === undefined ? {} : { model }),
1748
+ // This call's stance (#317 × #318): a Code-tab call on Desktop's
1749
+ // server may feel again what its recall showed it.
1750
+ owner: this.owner,
1751
+ });
1752
+ if (!done.ok) return { recorded: 0, reason: done.reason };
1753
+ const recorded = done.feelings.filter((f) => f.ok && f.reason === "recorded-later").length;
1754
+ this.emit("mcp.note.feelingsNow", undefined, { sent: list.length, recorded });
1755
+ return { recorded, results: done.feelings };
1756
+ } catch (err) {
1757
+ return { recorded: 0, reason: "threw", detail: String((err as Error).message ?? err) };
1758
+ }
1575
1759
  }
1576
1760
 
1577
1761
  /**
@@ -1619,6 +1803,25 @@ export class McpServer {
1619
1803
  * declared.
1620
1804
  */
1621
1805
  private settledOf(deposit: DepositResult, sentHow: boolean): Record<string, unknown> {
1806
+ // HELD (2026-10-09, the update guard): the memory named in `updates`
1807
+ // looked unrelated, so nothing was settled or linked. Its own words come
1808
+ // back with the ask the neighbours carry, and the two ids to settle with.
1809
+ const h = deposit.held;
1810
+ if (h !== undefined) {
1811
+ return {
1812
+ settled: {
1813
+ ok: false,
1814
+ held: true,
1815
+ reason: "looks-unrelated",
1816
+ how: h.how,
1817
+ holds: deposit.memoryId,
1818
+ over: h.over,
1819
+ ...(h.title === null ? {} : { title: h.title }),
1820
+ ...(h.text === null ? {} : { text: h.text }),
1821
+ detail: HELD_HINT,
1822
+ },
1823
+ };
1824
+ }
1622
1825
  const r = deposit.revision;
1623
1826
  if (r === undefined) return {};
1624
1827
  const o = r.settle;
@@ -1662,16 +1865,30 @@ export class McpServer {
1662
1865
  if (!deposit.deposited || deposit.memoryId === null || room <= 0) return [];
1663
1866
  // Not the memory it updates, and not a sibling written by the same call
1664
1867
  // (review of #284, M1): those are this writer's own words, not existing ones.
1665
- const exclude = [deposit.revision?.targetId, deposit.mint?.updates, ...siblings].filter((x): x is string => typeof x === "string");
1868
+ // A held one (2026-10-09) is already shown whole, beside its own ask.
1869
+ const exclude = [deposit.revision?.targetId, deposit.mint?.updates, deposit.held?.over, ...siblings].filter((x): x is string => typeof x === "string");
1666
1870
  return this.counterpart.writeNeighbours(deposit.memoryId, { exclude, owner: this.owner }).slice(0, room);
1667
1871
  }
1668
1872
 
1669
1873
  /**
1670
- * `recall` — the deeper look. Deposits no memory and touches no physics; see
1671
- * `deliberate.ts`. The ONE thing it writes is host state: a handle path that
1672
- * was answered leaves a line in `adapters/expansions.ts`'s resolution log, so
1673
- * the boundary's credit pass can tell which memory a TITLE reached
1674
- * (`noteHandleResolution`, and `mcp/INTERFACE-GAPS` §9).
1874
+ * `recall` — the deeper look. Deposits no memory and touches no physics.
1875
+ * Three kinds of ask, exactly one per call:
1876
+ *
1877
+ * - a QUESTION, with a REQUIRED `mode` (Release B, 2026-10-03): `facts`
1878
+ * (`facts.ts`) or `meaning` (`meaning.ts`), each its own path with its
1879
+ * own ranking and its own answer — labeled lines, shipped as `answer`;
1880
+ * - `ids` or a `handle`: an exact address, read whole (`deliberate.ts`).
1881
+ * They take no mode: opening a memory is not a search. A `mode` sent
1882
+ * beside one is ignored, and the result says so.
1883
+ *
1884
+ * What it writes is host state and bookkeeping, never a memory: a handle
1885
+ * path that was answered leaves a line in `adapters/expansions.ts`'s
1886
+ * resolution log, so the boundary's credit pass can tell which memory a
1887
+ * TITLE reached (`noteHandleResolution`, `mcp/INTERFACE-GAPS` §9); a
1888
+ * question's shown memories are recorded for this session as QUOTABLE
1889
+ * (`noteAsked`), so quoting one's words in a reply credits it at the
1890
+ * boundary as quoting a loud surfacing does; and one durable `mcp.recall`
1891
+ * row (`noteRecall`).
1675
1892
  */
1676
1893
  private async recallTool(args: Record<string, unknown>): Promise<ToolResult> {
1677
1894
  if (this.observer) return this.standDown("recall");
@@ -1692,23 +1909,25 @@ export class McpServer {
1692
1909
  if (part !== undefined && (typeof part !== "number" || !Number.isInteger(part) || part < 1)) {
1693
1910
  return this.refuse("recall", "part-not-a-positive-integer", {});
1694
1911
  }
1912
+ // PAGES (2026-10-03): which page of a question's answer.
1913
+ const page = args["page"];
1914
+ if (page !== undefined && (typeof page !== "number" || !Number.isInteger(page) || page < 1)) {
1915
+ return this.refuse("recall", "page-not-a-positive-integer", {});
1916
+ }
1917
+ const mode = args["mode"];
1918
+ if (mode !== undefined && mode !== "facts" && mode !== "meaning") {
1919
+ return this.refuse("recall", "mode-unknown", { modes: RECALL_MODE_WORDS });
1920
+ }
1695
1921
  const askedIds = ((ids as string[] | undefined) ?? []).map((s) => s.trim()).filter((s) => s.length > 0);
1696
- // IN LINE, and only for a question: the handle and `ids` paths are exact
1697
- // addresses and embedding them would buy nothing but a round trip. A refusal
1698
- // is a NAME, not a narrower answer — `deliberateRecall` degrades to lexical
1699
- // and says which.
1700
1922
  const asked = typeof question === "string" && question.trim().length > 0;
1701
- // One embedding call, and every way it can decline, by name
1702
- // (`deliberate.ts#embedQuestion`, which the console's `ask` shares).
1703
- const embedded = asked ? await embedQuestion(this.embedder, question) : { vector: null, semantic: "none" as SemanticSource };
1704
- // THE GATE AGAIN, after this tool's wait: a migration that committed
1705
- // during the embedding's round-trip must not be recalled past. The store's
1706
- // write guard would stop `noteRecall`'s row anyway; this also stops the
1707
- // read and the handle log before them.
1708
- if (asked) {
1709
- const moved = this.schemaGate("recall");
1710
- if (moved !== null) return moved;
1923
+ const addressed = (typeof handle === "string" && handle.trim().length > 0) || askedIds.length > 0;
1924
+
1925
+ // A QUESTION, alone: a mode answers it.
1926
+ if (asked && !addressed) {
1927
+ if (mode === undefined) return this.refuse("recall", "mode-required", { modes: RECALL_MODE_WORDS });
1928
+ return this.askQuestion(question, mode, typeof page === "number" ? page : 1);
1711
1929
  }
1930
+
1712
1931
  const result = deliberateRecall(
1713
1932
  this.counterpart,
1714
1933
  {
@@ -1716,20 +1935,15 @@ export class McpServer {
1716
1935
  ...(typeof question === "string" ? { question } : {}),
1717
1936
  ...(askedIds.length > 0 ? { ids: askedIds } : {}),
1718
1937
  },
1719
- {
1720
- sessionId: this.session ?? this.hostSession() ?? UNBOUND_SESSION,
1721
- owner: this.owner,
1722
- vector: embedded.vector,
1723
- semantic: embedded.semantic,
1724
- // A question about time leads with THIS directory's most recent
1725
- // session (2026-09-30, `recall/recency-ask.ts`).
1726
- scope: this.scope,
1727
- },
1938
+ { sessionId: this.session ?? this.hostSession() ?? UNBOUND_SESSION, owner: this.owner },
1728
1939
  );
1729
1940
  const resolved = this.noteHandleResolution(handle, result);
1730
1941
  // THE MEASUREMENT (2026-09-28): did this lookup fetch what a mechanism's
1731
1942
  // index offered only in part? Counted per mechanism, never the ids.
1732
- const payload = this.recallPayload(result, typeof part === "number" ? part : 1);
1943
+ const payload: Record<string, unknown> = {
1944
+ ...this.recallPayload(result, typeof part === "number" ? part : 1),
1945
+ ...(mode !== undefined && addressed ? { modeIgnored: "ids and handle are exact addresses; mode applies to a question only." } : {}),
1946
+ };
1733
1947
  // Counted from what was DELIVERED (review of #278), not what was asked:
1734
1948
  // an id that waited is not a lookup yet, and one is fetched whole only
1735
1949
  // when its last part went out.
@@ -1750,9 +1964,27 @@ export class McpServer {
1750
1964
  // it blows. The three overflowed calls of 2026-09-04 emitted nothing.
1751
1965
  chars: payload["chars"] as number,
1752
1966
  truncated: payload["truncated"] === true,
1753
- droppedForBudget: (payload["droppedForBudget"] as number | undefined) ?? 0,
1967
+ droppedForBudget: 0,
1754
1968
  });
1755
- this.noteRecall(result, askedIds.length, question, resolved, payload, fromIndex);
1969
+ this.noteRecall(
1970
+ {
1971
+ path: result.path,
1972
+ reason: result.reason,
1973
+ semantic: result.semantic,
1974
+ considered: result.considered,
1975
+ storeSize: result.storeSize,
1976
+ expanded: result.path === "handle" ? result.memories.length : 0,
1977
+ blockedBy: addressBlocked(result),
1978
+ },
1979
+ askedIds.length,
1980
+ question,
1981
+ resolved,
1982
+ payload,
1983
+ fromIndex,
1984
+ );
1985
+ // Only what was DELIVERED (review of #316): an id left `waiting` was not shown.
1986
+ const deliveredIds = ((payload["memories"] as { id?: unknown }[] | undefined) ?? []).map((m) => m.id).filter((x): x is string => typeof x === "string");
1987
+ this.markSeen(deliveredIds);
1756
1988
  const bad =
1757
1989
  result.reason === "no-argument" ||
1758
1990
  result.reason === "both-arguments" ||
@@ -1762,6 +1994,126 @@ export class McpServer {
1762
1994
  return this.result(payload, bad);
1763
1995
  }
1764
1996
 
1997
+ /**
1998
+ * A QUESTION, answered by its mode (Release B, 2026-10-03). Embedded in
1999
+ * line first — the one deliberate path allowed to (the ruling of
2000
+ * 2026-09-04) — with every way the embedding can decline said by name
2001
+ * (`deliberate.ts#embedQuestion`, which the console's `ask` shares). The
2002
+ * answer is the mode's own rendering, shipped whole as `answer`; the ids it
2003
+ * showed go to the seen set and the quotable record.
2004
+ */
2005
+ private async askQuestion(question: string, mode: "facts" | "meaning", page: number): Promise<ToolResult> {
2006
+ const embedded = await embedQuestion(this.embedder, question);
2007
+ // THE GATE AGAIN, after this tool's wait: a migration that committed
2008
+ // during the embedding's round-trip must not be recalled past.
2009
+ const moved = this.schemaGate("recall");
2010
+ if (moved !== null) return moved;
2011
+ const ctx = {
2012
+ counterpart: this.counterpart,
2013
+ sessionId: this.session ?? this.hostSession() ?? UNBOUND_SESSION,
2014
+ owner: this.owner,
2015
+ ...(this.scope === undefined ? {} : { scope: this.scope }),
2016
+ vector: embedded.vector,
2017
+ semantic: embedded.semantic,
2018
+ asker: "self" as const,
2019
+ };
2020
+ let answer: string;
2021
+ let ids: readonly string[];
2022
+ let body: Record<string, unknown>;
2023
+ let row: RecallRowFields;
2024
+ if (mode === "facts") {
2025
+ const r = factsRecall(ctx, question, { page });
2026
+ answer = renderFacts(r);
2027
+ ids = r.memories.map((m) => m.id);
2028
+ body = {
2029
+ matched: r.matched,
2030
+ page: r.page,
2031
+ pages: r.pages,
2032
+ ...(r.fadedTotal > 0 ? { faded: r.fadedTotal } : {}),
2033
+ };
2034
+ row = {
2035
+ path: "question",
2036
+ reason: r.reason,
2037
+ semantic: r.semantic,
2038
+ considered: r.considered,
2039
+ storeSize: r.storeSize,
2040
+ expanded: 0,
2041
+ blockedBy: r.blockedBy,
2042
+ mode,
2043
+ matched: r.matched,
2044
+ shown: r.memories.length,
2045
+ faded: r.fadedTotal,
2046
+ page: r.page,
2047
+ ...(r.time === null ? {} : { time: r.time.anchor?.kind ?? "window" }),
2048
+ };
2049
+ } else {
2050
+ const r = meaningRecall(ctx, question, { page });
2051
+ answer = renderMeaning(r);
2052
+ ids = r.shown;
2053
+ body = { page: r.page, pages: r.pages, counts: { ...r.counts } };
2054
+ row = {
2055
+ path: "question",
2056
+ reason: r.reason,
2057
+ semantic: r.semantic,
2058
+ considered: r.counts.moments + r.counts.faded,
2059
+ storeSize: 0,
2060
+ expanded: 0,
2061
+ blockedBy: {},
2062
+ mode,
2063
+ matched: r.counts.moments,
2064
+ shown: ids.length,
2065
+ faded: r.counts.faded,
2066
+ page: r.page,
2067
+ counts: { ...r.counts },
2068
+ };
2069
+ }
2070
+ const payload: Record<string, unknown> = {
2071
+ path: "question",
2072
+ mode,
2073
+ reason: row.reason,
2074
+ semantic: row.semantic,
2075
+ ...body,
2076
+ chars: answer.length,
2077
+ answer,
2078
+ ids: [...ids],
2079
+ };
2080
+ this.emit("mcp.recall", undefined, {
2081
+ path: "question",
2082
+ mode,
2083
+ reason: row.reason,
2084
+ semantic: row.semantic,
2085
+ returned: ids.length,
2086
+ considered: row.considered,
2087
+ owner: this.owner,
2088
+ chars: answer.length,
2089
+ truncated: false,
2090
+ droppedForBudget: 0,
2091
+ });
2092
+ this.noteRecall(row, 0, question, false, payload);
2093
+ this.markSeen(ids);
2094
+ this.noteAsked(ids);
2095
+ return this.result(payload, false);
2096
+ }
2097
+
2098
+ /**
2099
+ * THE QUOTABLE RECORD (Release B, 2026-10-03): the memories a question's
2100
+ * answer showed with their words, recorded for the asking session so the
2101
+ * boundary's credit pass may count a QUOTE of one (`Counterpart#
2102
+ * creditReferences`, `reference.ts`'s verbatim window) — the owner's 09-14
2103
+ * rule, opening or quoting credits, extended to deliberate results. A list
2104
+ * shown does not credit; only a quote of its words in a reply does. Keyed
2105
+ * like the seen set (`seenKey`); nothing for a session nobody identified.
2106
+ * Never throws.
2107
+ */
2108
+ private noteAsked(ids: readonly string[]): void {
2109
+ if (ids.length === 0) return;
2110
+ const session = this.seenKey();
2111
+ if (session === UNBOUND_SESSION) return;
2112
+ this.telemetry(() => {
2113
+ this.counterpart.noteAsked(session, ids);
2114
+ });
2115
+ }
2116
+
1765
2117
  /**
1766
2118
  * THE DURABLE ROW for one deliberate recall (2026-09-20, E2).
1767
2119
  *
@@ -1786,61 +2138,55 @@ export class McpServer {
1786
2138
  * unreadable as the inventory found it — a withholding that happened and one
1787
2139
  * that never had to, the same absence.
1788
2140
  *
2141
+ * A question's row (2026-10-03) carries its `mode`, how many matched, how
2142
+ * many were shown and how many listed faded, and the page — still counts.
2143
+ *
1789
2144
  * Never throws: a tool answer may not fail because its telemetry did.
1790
2145
  */
1791
2146
  private noteRecall(
1792
- result: DeliberateResult,
2147
+ row: RecallRowFields,
1793
2148
  askedIds: number,
1794
2149
  question: unknown,
1795
2150
  handleResolved: boolean,
1796
2151
  payload: Record<string, unknown>,
1797
2152
  fromIndex: Partial<Record<FitMechanism, number>> = {},
1798
2153
  ): void {
1799
- const byAddress = result.path === "handle";
1800
- const blockedBy: Record<string, number> = { ...(result.blockedBy ?? {}) };
1801
- // The address paths' refusals are their own `reason` — one per id on the
1802
- // `ids` path, so three unknown ids read as three and not as one.
1803
- if (byAddress) {
1804
- const reasons =
1805
- result.perId === undefined
1806
- ? result.reason === "expanded"
1807
- ? []
1808
- : [result.reason]
1809
- : result.perId.filter((p) => p.reason !== "expanded").map((p) => p.reason);
1810
- for (const r of reasons) blockedBy[r] = (blockedBy[r] ?? 0) + 1;
1811
- } else if (result.path === "none") {
1812
- blockedBy[result.reason] = (blockedBy[result.reason] ?? 0) + 1;
1813
- }
1814
- try {
2154
+ const byAddress = row.path === "handle";
2155
+ const shown = row.shown ?? 0;
2156
+ this.telemetry(() => {
1815
2157
  this.counterpart.noteAdapterEvent(MCP_RECALL_EVENT, {
1816
- path: result.path,
1817
- reason: result.reason,
2158
+ path: row.path,
2159
+ reason: row.reason,
2160
+ ...(row.mode === undefined ? {} : { mode: row.mode }),
1818
2161
  // WHAT WAS ASKED, as shapes and sizes. Never the words.
1819
2162
  queryChars: typeof question === "string" ? question.trim().length : 0,
1820
2163
  askedIds,
1821
2164
  handleResolved,
1822
- semantic: result.semantic,
2165
+ semantic: row.semantic,
1823
2166
  // What came back, split the way the reader's question splits: an
1824
- // expansion answered an address, a surfacing answered a question.
1825
- surfaced: byAddress ? 0 : result.memories.filter((m) => m.tier !== "dim").length,
1826
- dim: byAddress ? 0 : result.memories.filter((m) => m.tier === "dim").length,
1827
- expanded: byAddress ? result.memories.length : 0,
1828
- considered: result.considered,
1829
- storeSize: result.storeSize,
2167
+ // expansion answered an address, a question's answer showed results.
2168
+ surfaced: byAddress ? 0 : shown,
2169
+ expanded: byAddress ? row.expanded : 0,
2170
+ ...(row.matched === undefined ? {} : { matched: row.matched }),
2171
+ ...(row.faded === undefined ? {} : { faded: row.faded }),
2172
+ ...(row.page === undefined ? {} : { page: row.page }),
2173
+ ...(row.time === undefined ? {} : { time: row.time }),
2174
+ ...(row.counts === undefined ? {} : { counts: row.counts }),
2175
+ considered: row.considered,
2176
+ storeSize: row.storeSize,
1830
2177
  owner: this.owner,
1831
2178
  chars: payload["chars"] ?? 0,
1832
2179
  truncated: payload["truncated"] === true,
1833
- droppedForBudget: payload["droppedForBudget"] ?? 0,
2180
+ droppedForBudget: 0,
1834
2181
  // THE POINT OF THE ROW: what kept the rest out, by name.
1835
- blockedBy,
2182
+ blockedBy: row.blockedBy,
1836
2183
  // How many of the expanded ids a mechanism's index had offered only
1837
2184
  // in part (2026-09-28) — the lookup's use, per mechanism. Counts only.
1838
2185
  ...(Object.keys(fromIndex).length > 0 ? { fromIndex } : {}),
1839
2186
  });
1840
- } catch {
1841
2187
  // The ring emit above already carries this call; a telemetry write that
1842
- // failed must not become the answer the model receives.
1843
- }
2188
+ // failed must not become the answer the model receives (`telemetry`).
2189
+ });
1844
2190
  }
1845
2191
 
1846
2192
  /**
@@ -1915,56 +2261,36 @@ export class McpServer {
1915
2261
  * measurement did.
1916
2262
  */
1917
2263
  private lookupsFromIndex(delivered: readonly { id: string; whole: boolean }[]): Partial<Record<FitMechanism, number>> {
1918
- try {
1919
- return noteLookups(this.counterpart.store, delivered);
1920
- } catch {
1921
- return {};
1922
- }
2264
+ let counted: Partial<Record<FitMechanism, number>> = {};
2265
+ this.telemetry(() => {
2266
+ counted = noteLookups(this.counterpart.store, delivered);
2267
+ });
2268
+ return counted;
1923
2269
  }
1924
2270
 
1925
2271
  /**
1926
- * The payload, BOUNDED. A list answers "which memories" and ships excerpts;
1927
- * an address (`handle`, or `ids`) answers "what did it say" and ships as much
1928
- * body as the total budget allows. See `deliberate.ts`'s size constants for
1929
- * the measurement that set them.
2272
+ * The ADDRESS payload, BOUNDED: `handle` or `ids` answers "what did it
2273
+ * say" and ships as much body as the total budget allows, in parts. See
2274
+ * `deliberate.ts`'s size constants for the measurement that set them. (A
2275
+ * question's answer is its mode's rendering — `askQuestion`.)
1930
2276
  */
1931
2277
  private recallPayload(result: DeliberateResult, part = 1): Record<string, unknown> {
1932
- const byAddress = result.path === "handle";
1933
2278
  // By address, IN PARTS (2026-09-28): each body a part at a time, the ids
1934
- // past the total waiting by name; a list, excerpts.
1935
- const bounded = byAddress ? boundById(result.memories, part) : boundMemories(result.memories, RECALL_EXCERPT_CHARS);
2279
+ // past the total waiting by name.
2280
+ const bounded = boundById(result.memories, part);
1936
2281
  const lastPart = Math.max(1, ...bounded.memories.map((m) => m.parts ?? 1));
1937
2282
  return {
1938
2283
  path: result.path,
1939
2284
  reason: result.reason,
1940
- /** Said out loud, never inferred from a thinner answer: when the semantic
1941
- * channel could not run, the asker is told which channel answered. */
1942
2285
  semantic: result.semantic,
1943
- /** The two numbers §9.1 G3 exists for: a count here is never a top-K. */
1944
2286
  considered: result.considered,
1945
- /** `considered` is `MAX_CANDIDATES`, and saying so is the difference
1946
- * between a bound and a census (§9.1 G3). Read from the recall instance
1947
- * in force, not the module default, or a calibration override would be
1948
- * invisible in the one place the number is explained. */
1949
- consideredCap: this.counterpart.recall.tunables.MAX_CANDIDATES,
1950
- /** The cap bounds what the words and the meaning reached; a memory the
1951
- * links or a feeling brought has its own bound, so `considered` can pass
1952
- * it (2026-10-01: "considered 30, consideredCap 24" read as a broken cap). */
1953
- ...(result.considered > this.counterpart.recall.tunables.MAX_CANDIDATES && result.path === "question"
1954
- ? {
1955
- consideredNote: `${String(result.considered - this.counterpart.recall.tunables.MAX_CANDIDATES)} past the cap came in through links between memories or a feeling the question named; consideredCap bounds only what its words and meaning reached.`,
1956
- }
1957
- : {}),
1958
2287
  storeSize: result.storeSize,
1959
2288
  returned: bounded.memories.length,
1960
2289
  chars: bounded.chars,
1961
2290
  truncated: bounded.truncated,
1962
- ...(bounded.droppedForBudget > 0 ? { droppedForBudget: bounded.droppedForBudget } : {}),
1963
- ...(bounded.truncated || bounded.droppedForBudget > 0
2291
+ ...(bounded.truncated
1964
2292
  ? {
1965
- budget: byAddress
1966
- ? `By id, a body comes in parts of ${RECALL_BODY_CHARS} characters ("part" of "parts" on each; bodyChars is the whole length).${part < lastPart ? ` Ask again with the same ids and part: ${String(part + 1)} for the next.` : " That was the last part."}`
1967
- : `A list is bounded to ${RECALL_RESULT_CHARS} characters, ${RECALL_EXCERPT_CHARS} per memory. To read any whole, ask again with ids: [...] — up to ${RECALL_MAX_IDS} at once; a long body comes in parts (part: 2, 3, …).`,
2293
+ budget: `By id, a body comes in parts of ${RECALL_BODY_CHARS} characters ("part" of "parts" on each; bodyChars is the whole length).${part < lastPart ? ` Ask again with the same ids and part: ${String(part + 1)} for the next.` : " That was the last part."}`,
1968
2294
  }
1969
2295
  : {}),
1970
2296
  ...(bounded.waiting !== undefined
@@ -1984,6 +2310,12 @@ export class McpServer {
1984
2310
  "That memory is marked confidential and this is not the owner's own session. It exists; it is not being shown.",
1985
2311
  }
1986
2312
  : {}),
2313
+ ...(result.reason === "both-arguments"
2314
+ ? { refused: "One kind of ask per call: a question (with a mode), ids, or a handle." }
2315
+ : {}),
2316
+ ...(result.reason === "no-argument"
2317
+ ? { refused: `Send a question with mode (${RECALL_MODE_WORDS}), or ids, or a handle.` }
2318
+ : {}),
1987
2319
  memories: bounded.memories.map((m) => ({ ...m })),
1988
2320
  /** The label the ruling of 2026-09-04 put on every delivered chapter,
1989
2321
  * glossed once here so `journal: true` on a row is not a bare boolean the
@@ -1992,21 +2324,6 @@ export class McpServer {
1992
2324
  * bytes explaining a flag that is not on any row is the wire budget spent
1993
2325
  * on a word nobody read. */
1994
2326
  ...(bounded.memories.some((m) => m.journal) ? { journal: JOURNAL_GLOSS } : {}),
1995
- /** A question about time (2026-09-30): which session's rows lead, and
1996
- * why. CONDITIONAL, like `journal`. */
1997
- ...(result.recent === undefined
1998
- ? {}
1999
- : {
2000
- recent: `Rows marked recent: true come first because the question asked about time ("${result.recent.cue}"): they are what the session it means here (${result.recent.session}) wrote — its latest episode, shown from its first chapter (what its title names; the id fetches every chapter), then its memories, newest first. A quiet one among them was put there by the question, not reached by the search. Everything after them is ranked as usual.`,
2001
- }),
2002
- tiers: {
2003
- vivid: "came clearly to mind",
2004
- quiet:
2005
- result.recent === undefined
2006
- ? "quietly available — the ambient path would have footnoted this"
2007
- : "quietly available — the ambient path would have footnoted this; or, marked recent: true, put first by a question about time without the search reaching it",
2008
- dim: "reached only because you asked deliberately; lower confidence, and labeled so",
2009
- },
2010
2327
  };
2011
2328
  }
2012
2329
 
@@ -2140,20 +2457,70 @@ export class McpServer {
2140
2457
  * loaded against the package on disk now. Desktop's server is started with
2141
2458
  * the app and there is no per-turn hook running the installed build beside
2142
2459
  * it, so this process has to look for itself (`manifestVersionOnDisk`).
2460
+ *
2461
+ * AND A NEWER BUILD THAT WROTE THE STORE (2026-10-02): the build stamp on
2462
+ * the published wake (`self/behind.ts#WAKE_BUILD_KEY`) newer than this
2463
+ * process says the same, for a store shared with an install this process
2464
+ * cannot see on its own disk.
2143
2465
  */
2144
2466
  private wakeUpdateLine(): string | null {
2467
+ return this.updateReading()?.line ?? null;
2468
+ }
2469
+
2470
+ /**
2471
+ * What the two checks say, or null when neither moved. `reconnect` is
2472
+ * whether reconnecting would load something newer: only when the package
2473
+ * on THIS process's disk moved. A newer stamp with this disk unchanged is
2474
+ * another install (another path, `npx`) writing the same store (review of
2475
+ * #318): reconnecting would load this same version again, so the line says
2476
+ * what happened and offers no remedy that does not work.
2477
+ */
2478
+ private updateReading(): { line: string; reconnect: boolean } | null {
2145
2479
  try {
2146
2480
  const loaded = this.identity?.build.version ?? installedVersion();
2481
+ if (loaded === null) return null;
2147
2482
  const onDisk = this.manifestVersion();
2148
- if (loaded === null || onDisk === null || loaded === onDisk) return null;
2149
- const stamp = (version: string): ReturnType<typeof installedBuild> => ({ ...installedBuild(), version });
2150
- const older = serverIsNewer(stamp(loaded), stamp(onDisk));
2151
- return `Counterparts was ${older ? "changed to an older version" : "updated"}. ${wordingFor(this.host).reconnect}`;
2483
+ if (onDisk !== null && loaded !== onDisk) {
2484
+ const stamp = (version: string): ReturnType<typeof installedBuild> => ({ ...installedBuild(), version });
2485
+ const older = serverIsNewer(stamp(loaded), stamp(onDisk));
2486
+ return { line: `Counterparts was ${older ? "changed to an older version" : "updated"}. ${wordingFor(this.host).reconnect}`, reconnect: true };
2487
+ }
2488
+ let wrote: string | null = null;
2489
+ try {
2490
+ wrote = this.counterpart.store.getMeta(WAKE_BUILD_KEY) ?? null;
2491
+ } catch {
2492
+ return null;
2493
+ }
2494
+ if (!versionNewer(wrote, loaded)) return null;
2495
+ return {
2496
+ line: `A newer Counterparts (${String(wrote)}), installed somewhere else, has written this memory store; this server is ${loaded}.`,
2497
+ reconnect: false,
2498
+ };
2152
2499
  } catch {
2153
2500
  return null;
2154
2501
  }
2155
2502
  }
2156
2503
 
2504
+ /**
2505
+ * THE SAME LINE ON EVERY OTHER RESULT (2026-10-02). A server left open
2506
+ * across an install keeps the tool list it loaded, so an argument the new
2507
+ * version added — `note`'s `about`, `unresolved` — is dropped without a
2508
+ * word until the host reconnects, and Desktop had no notice at all outside
2509
+ * `wake`. Now every result says it, in `updated`, while the two builds
2510
+ * differ: one manifest read and one meta read per call. The line names what
2511
+ * may be lost. Never throws, never refuses: the call already ran.
2512
+ */
2513
+ private withUpdateNotice(name: string, result: ToolResult): ToolResult {
2514
+ if (name === "wake") return result;
2515
+ const reading = this.updateReading();
2516
+ if (reading === null) return result;
2517
+ this.emit("mcp.update.noticed", undefined, { tool: name, reconnect: reading.reconnect });
2518
+ const said = reading.reconnect
2519
+ ? `${reading.line} Until then this server runs the version it started with, and it ignores anything newer, such as a field added to a tool since.`
2520
+ : `${reading.line} It ignores anything newer, such as a field added to a tool since; updating this install is what brings it level.`;
2521
+ return this.result({ ...result.structuredContent, updated: said }, result.isError === true);
2522
+ }
2523
+
2157
2524
  /** The doctor's red-only notice, from the entry point's closure. Never throws. */
2158
2525
  private wakeDoctorLine(): string | null {
2159
2526
  try {
@@ -2267,7 +2634,7 @@ export class McpServer {
2267
2634
  livedDay: store.livedDay(),
2268
2635
  lastActiveDate: store.getMeta("lastActiveDate") ?? null,
2269
2636
  },
2270
- stance: { observer: this.observer, owner: this.owner, ...(this.owner ? {} : { ownerMeans: OWNER_FALSE_NOTE }) },
2637
+ stance: { observer: this.observer, ...this.ownerStance() },
2271
2638
  };
2272
2639
  }
2273
2640
 
@@ -2462,6 +2829,8 @@ export class McpServer {
2462
2829
  const datedOf: ReminderRead[] = [];
2463
2830
  const aboutOf: AboutRead[] = [];
2464
2831
  const traitsOf: TraitsRead[] = [];
2832
+ const factsOf: FactsRead[] = [];
2833
+ const today = this.today();
2465
2834
  for (const item of raw) {
2466
2835
  if (item === null || typeof item !== "object" || Array.isArray(item)) {
2467
2836
  entries.push({ content: "" });
@@ -2469,6 +2838,7 @@ export class McpServer {
2469
2838
  datedOf.push({ fields: {}, remindIgnored: false });
2470
2839
  aboutOf.push({ mark: null });
2471
2840
  traitsOf.push({ inputs: [] });
2841
+ factsOf.push({ sent: {}, dropped: [], notes: [] });
2472
2842
  continue;
2473
2843
  }
2474
2844
  const rec = item as Record<string, unknown>;
@@ -2493,6 +2863,7 @@ export class McpServer {
2493
2863
  feelingsOf.push(readFeelings(rec["feelings"]));
2494
2864
  aboutOf.push(readAbout(rec["about"]));
2495
2865
  traitsOf.push(readTraits(rec["traits"]));
2866
+ factsOf.push(readWriteFacts(rec, today));
2496
2867
  }
2497
2868
 
2498
2869
  const outcomes: Record<string, unknown>[] = [];
@@ -2526,11 +2897,14 @@ export class McpServer {
2526
2897
  outcomes.push({ stored: false, reason: "traits-malformed", detail: traits.refused });
2527
2898
  continue;
2528
2899
  }
2900
+ const facts = factsOf[n] ?? { sent: {}, dropped: [], notes: [] };
2529
2901
  let result: DepositResult;
2530
2902
  try {
2531
2903
  result = await this.counterpart.submitSessionEnd(draft, {
2532
2904
  session,
2533
2905
  scope: scope ?? this.scope,
2906
+ owner: this.owner,
2907
+ facts: facts.sent,
2534
2908
  ...(cover === undefined ? {} : { cover }),
2535
2909
  ...(model === undefined ? {} : { model }),
2536
2910
  ...(writeUp === undefined ? {} : { writeUp }),
@@ -2562,6 +2936,7 @@ export class McpServer {
2562
2936
  ...this.recordAbout(result, about.mark),
2563
2937
  ...this.recordTraits(result, traits.inputs, model),
2564
2938
  ...reminderEcho(result, dated, this.today()),
2939
+ ...factsEcho(result, facts),
2565
2940
  ...this.settledOf(result, draft["how"] !== undefined),
2566
2941
  ...threadOf(result),
2567
2942
  ...(neighbours.length === 0 ? {} : { neighbours }),
@@ -2889,7 +3264,7 @@ export class McpServer {
2889
3264
  shown: Object.keys(out.bundle.memories).length,
2890
3265
  resumed: out.resumed,
2891
3266
  });
2892
- return this.result(
3267
+ const handed = this.result(
2893
3268
  {
2894
3269
  phase,
2895
3270
  session,
@@ -2902,6 +3277,9 @@ export class McpServer {
2902
3277
  },
2903
3278
  false,
2904
3279
  );
3280
+ // Part 1 is the begin: its row says how many parts the run owes.
3281
+ this.notePart("dream", out.bundle.dream, 1, out.bundle.parts?.of ?? 1);
3282
+ return handed;
2905
3283
  }
2906
3284
  case "part": {
2907
3285
  const dream = args["dream"];
@@ -2912,7 +3290,7 @@ export class McpServer {
2912
3290
  const out = dreams.part({ dream, session, part: n });
2913
3291
  if (!out.ok) return refused(out.reason, out.detail ?? "That dream is not open for this session.");
2914
3292
  this.emit("mcp.dream", dream, { phase: "part", part: out.part, of: out.of });
2915
- return this.result(
3293
+ const handed = this.result(
2916
3294
  {
2917
3295
  phase,
2918
3296
  dream,
@@ -2925,6 +3303,8 @@ export class McpServer {
2925
3303
  },
2926
3304
  false,
2927
3305
  );
3306
+ this.notePart("dream", dream, out.part, out.of);
3307
+ return handed;
2928
3308
  }
2929
3309
  case "propose": {
2930
3310
  const dream = args["dream"];
@@ -2980,7 +3360,7 @@ export class McpServer {
2980
3360
  // reused (a run started again the same day claims nothing twice).
2981
3361
  const dreamArg = typeof args["dream"] === "string" ? args["dream"] : null;
2982
3362
  const claim = this.counterpart.claimNightWriter({ session, run: dreamArg ?? `night of ${at}` });
2983
- const out = this.counterpart.nightWriter({ session, tool: "counterparts self_page" });
3363
+ const out = this.counterpart.nightWriter({ session, tool: NIGHT_WRITER_TOOL });
2984
3364
  const next = nextAfter("writer", dreamArg);
2985
3365
  if (!out.ok) {
2986
3366
  this.emit("mcp.dream", dreamArg ?? undefined, { phase: "writer", writer: claim.reason });
@@ -3074,7 +3454,7 @@ export class McpServer {
3074
3454
  );
3075
3455
  }
3076
3456
  this.emit("mcp.reflect", out.bundle.reflection, { phase: "begin", session, shown: Object.keys(out.bundle.memories).length });
3077
- return this.result(
3457
+ const handed = this.result(
3078
3458
  {
3079
3459
  phase,
3080
3460
  session,
@@ -3088,6 +3468,8 @@ export class McpServer {
3088
3468
  },
3089
3469
  false,
3090
3470
  );
3471
+ this.notePart("reflection", out.bundle.reflection, 1, out.bundle.parts?.of ?? 1);
3472
+ return handed;
3091
3473
  }
3092
3474
  case "part": {
3093
3475
  const reflection = args["reflection"];
@@ -3098,7 +3480,7 @@ export class McpServer {
3098
3480
  const out = reflections.part({ reflection, session, part: n });
3099
3481
  if (!out.ok) return refused(out.reason, out.detail ?? "That reflection is not open for this session.");
3100
3482
  this.emit("mcp.reflect", reflection, { phase: "part", part: out.part, of: out.of });
3101
- return this.result(
3483
+ const handed = this.result(
3102
3484
  {
3103
3485
  phase,
3104
3486
  reflection,
@@ -3109,6 +3491,8 @@ export class McpServer {
3109
3491
  },
3110
3492
  false,
3111
3493
  );
3494
+ this.notePart("reflection", reflection, out.part, out.of);
3495
+ return handed;
3112
3496
  }
3113
3497
  case "finish": {
3114
3498
  const reflection = args["reflection"];
@@ -3795,6 +4179,133 @@ export class McpServer {
3795
4179
  return this.result({ stored: false, tool, reason, ...extra }, true);
3796
4180
  }
3797
4181
 
4182
+ /**
4183
+ * THE LAST WORD ON SIZE (2026-10-02). Every result leaves through here, the
4184
+ * last step of `call`. The caps upstream (the dream's and the reflection's
4185
+ * parts, the writer's day, recall's rooms) all derive from one ceiling
4186
+ * (`fit/TOOL_RESULT_CEILING`) and should keep every result under it; this is
4187
+ * the net for the one that does not. Measured the way Claude Code measures —
4188
+ * `structuredContent` serialized, which is what it hands the model — by
4189
+ * `wireChars`, so a non-ASCII character counts toward the token line too.
4190
+ *
4191
+ * Over it, the result is NOT shipped to be spilled: its longest top-level
4192
+ * string (a bundle, the writer's block, the wake) is cut to fit, a `cut`
4193
+ * field says so in words, and one durable `mcp.result.oversize` row records
4194
+ * the tool, the phase and the sizes — never the text — so doctor goes amber.
4195
+ * A result with no long string to cut (a list) is shipped as it is, and
4196
+ * recorded the same way. A guard by a margin and a stated cut, never a
4197
+ * refusal: the part that fits still reaches the model.
4198
+ */
4199
+ private withinCeiling(name: string, args: Record<string, unknown>, result: ToolResult): ToolResult {
4200
+ const ceiling = this.resultCeilingChars;
4201
+ const sc = result.structuredContent;
4202
+ const measured = wireChars(JSON.stringify(sc));
4203
+ if (measured <= ceiling) return result;
4204
+ let field: string | null = null;
4205
+ for (const [k, v] of Object.entries(sc)) {
4206
+ if (typeof v === "string" && (field === null || v.length > (sc[field] as string).length)) field = k;
4207
+ }
4208
+ const phase = typeof args["phase"] === "string" ? args["phase"] : null;
4209
+ const noteFor = (f: string): string =>
4210
+ `This answer came to ${String(measured)} characters, more than the ${String(ceiling)} one tool answer carries whole, ` +
4211
+ `so the server cut \`${f}\` to fit: what is shown is its beginning, and the rest did not reach you. ` +
4212
+ `Work with what is here and say so; nothing was refused.`;
4213
+ // The rest of the result, measured with the note beside it. When the bulk
4214
+ // is not that string (a list), cutting it cannot bring the result under:
4215
+ // it ships as it is, recorded, rather than losing an instruction for nothing.
4216
+ const rest = field === null ? measured : wireChars(JSON.stringify({ ...sc, [field]: "", cut: noteFor(field) }));
4217
+ if (rest > ceiling) field = null;
4218
+ let out = result;
4219
+ let cutTo = measured;
4220
+ if (field !== null) {
4221
+ const value = sc[field] as string;
4222
+ const note = noteFor(field);
4223
+ // The field gets what is left — a FIXED target (review of #315: the first
4224
+ // version shrank its target each try and kept about (2−r)⁶ of what fits
4225
+ // for escaped text). The longest cut whose ESCAPED cost fits is found by
4226
+ // halving: `clipWire` keeps more as its limit grows, so the search is exact.
4227
+ const target = Math.max(0, ceiling - rest);
4228
+ const escaped = (s: string): number => wireChars(JSON.stringify(s)) - 2;
4229
+ let lo = 0;
4230
+ let hi = target;
4231
+ let kept = clipWire(value, 0);
4232
+ while (lo <= hi) {
4233
+ const mid = Math.floor((lo + hi) / 2);
4234
+ const tried = clipWire(value, mid);
4235
+ if (escaped(tried) <= target) {
4236
+ kept = tried;
4237
+ lo = mid + 1;
4238
+ } else hi = mid - 1;
4239
+ }
4240
+ if (escaped(kept) > target) kept = "";
4241
+ const payload: Record<string, unknown> = { ...sc, [field]: kept, cut: note };
4242
+ // The text copy follows the shape it had: the wake rides as its own text,
4243
+ // everything else as the payload's JSON.
4244
+ const asText = result.content.length === 1 && result.content[0]?.text === value;
4245
+ out = {
4246
+ content: [{ type: "text", text: asText ? `${kept}\n\n${note}` : JSON.stringify(payload, null, 2) }],
4247
+ structuredContent: payload,
4248
+ ...(result.isError === true ? { isError: true } : {}),
4249
+ };
4250
+ cutTo = wireChars(JSON.stringify(payload));
4251
+ }
4252
+ this.emit("mcp.result.oversize", undefined, { tool: name, phase, chars: measured, cutTo });
4253
+ // The cut already happened; a lost row costs doctor's amber, never the answer.
4254
+ this.telemetry(() => {
4255
+ this.counterpart.noteAdapterEvent(MCP_OVERSIZE_EVENT, {
4256
+ tool: name,
4257
+ phase,
4258
+ chars: measured,
4259
+ ceiling,
4260
+ field,
4261
+ cut: field !== null,
4262
+ cutTo,
4263
+ });
4264
+ });
4265
+ return out;
4266
+ }
4267
+
4268
+ /**
4269
+ * A TELEMETRY WRITE, never the answer (review of #315). The store's write
4270
+ * guard records a `busy` or `ahead` verdict in `writeTripped`, and `call`
4271
+ * turns any tripped verdict into the tool's refusal — right for a tool's own
4272
+ * write, wrong for the row a READ leaves behind (a part handed, a recall
4273
+ * counted): a lock held for a moment would turn the part into a refusal.
4274
+ * So the verdict is put back as it was, and the row is simply lost.
4275
+ */
4276
+ private telemetry(write: () => void): void {
4277
+ const before = this.writeTripped;
4278
+ try {
4279
+ write();
4280
+ } catch {
4281
+ /* evidence, never a reason to fail the call */
4282
+ } finally {
4283
+ this.writeTripped = before;
4284
+ }
4285
+ }
4286
+
4287
+ /**
4288
+ * A PART HANDED (2026-10-02): one durable `mcp.part` row per part — part 1
4289
+ * being the begin — so doctor can hold the parts a begin promised against
4290
+ * the parts that were fetched. The handler only marks it (`notePart`); the
4291
+ * row is written by `call` AFTER the net (`writePart`), so `chars` is what
4292
+ * left the server and `cut` says whether the net had to act (review of
4293
+ * #315: it recorded the size from before the cut). Counts and ids only.
4294
+ */
4295
+ private notePart(mechanism: FitMechanism, ref: string, part: number, of: number): void {
4296
+ this.partHanded = { mechanism, ref, part, of };
4297
+ }
4298
+
4299
+ private writePart(result: ToolResult): void {
4300
+ const p = this.partHanded;
4301
+ this.partHanded = null;
4302
+ if (p === null) return;
4303
+ const cut = typeof result.structuredContent["cut"] === "string";
4304
+ this.telemetry(() => {
4305
+ this.counterpart.noteAdapterEvent(MCP_PART_EVENT, { ...p, chars: wireChars(JSON.stringify(result.structuredContent)), cut });
4306
+ });
4307
+ }
4308
+
3798
4309
  private result(payload: Record<string, unknown>, isError: boolean): ToolResult {
3799
4310
  // THE WHOLE PAYLOAD IN BOTH (2026-09-29, the first real headless run).
3800
4311
  // From 2026-09-28 the long `bundle` rode only in the text, with
@@ -3859,6 +4370,52 @@ export function dreamHow(bundle: Pick<DreamBundle, "queue" | "shownAs">): string
3859
4370
  );
3860
4371
  }
3861
4372
 
4373
+ /**
4374
+ * THE TWO MODES, in the words a refusal teaches them with (Release B,
4375
+ * 2026-10-03). There is no default: the caller says which question it is
4376
+ * asking.
4377
+ */
4378
+ export const RECALL_MODE_WORDS =
4379
+ 'A question needs mode: "facts" — what happened, who said it, when, and whether it still holds (every match, ranked, with dates and speaker); or "meaning" — how something went, felt, and what it adds up to (a person, a project, us).';
4380
+
4381
+ /** What one recall call's durable row says (`noteRecall`). Counts only. */
4382
+ interface RecallRowFields {
4383
+ readonly path: "handle" | "question" | "none";
4384
+ readonly reason: string;
4385
+ readonly semantic: string;
4386
+ readonly considered: number;
4387
+ readonly storeSize: number;
4388
+ readonly expanded: number;
4389
+ readonly blockedBy: Readonly<Record<string, number>>;
4390
+ readonly mode?: "facts" | "meaning";
4391
+ readonly matched?: number;
4392
+ readonly shown?: number;
4393
+ readonly faded?: number;
4394
+ readonly page?: number;
4395
+ /** A question that named a time: `window`, `event` or `session`. */
4396
+ readonly time?: string;
4397
+ /** Meaning mode's own counts (`MeaningResult.counts`). */
4398
+ readonly counts?: Readonly<Record<string, number>>;
4399
+ }
4400
+
4401
+ /**
4402
+ * The address paths' refusals are their own `reason` — one per id on the
4403
+ * `ids` path, so three unknown ids read as three and not as one.
4404
+ */
4405
+ function addressBlocked(result: DeliberateResult): Record<string, number> {
4406
+ const out: Record<string, number> = {};
4407
+ const reasons =
4408
+ result.path === "none"
4409
+ ? [result.reason]
4410
+ : result.perId === undefined
4411
+ ? result.reason === "expanded"
4412
+ ? []
4413
+ : [result.reason]
4414
+ : result.perId.filter((p) => p.reason !== "expanded").map((p) => p.reason);
4415
+ for (const r of reasons) out[r] = (out[r] ?? 0) + 1;
4416
+ return out;
4417
+ }
4418
+
3862
4419
  function resolvedIdOf(result: DeliberateResult): string | null | undefined {
3863
4420
  switch (result.reason) {
3864
4421
  case "expanded":
@@ -3911,12 +4468,18 @@ type ReminderRead =
3911
4468
  /** `eventDate: null` is the explicit drop (a revision's cancel); `remind`
3912
4469
  * rides only when it was SENT, so a revision can tell a left-out mode
3913
4470
  * from a stated one (review N7). */
3914
- readonly fields: { eventDate?: string | null; remind?: "plain" | "quiet" };
4471
+ readonly fields: { eventDate?: string | null; remind?: "plain" | "quiet"; recurring?: Recurrence | null };
3915
4472
  /** `remind` was sent with no `eventDate`: there is nothing for it to shape
3916
4473
  * — unless the memory it revises carries a date (`DepositResult.reminder`). */
3917
4474
  readonly remindIgnored: boolean;
4475
+ /** `recurring` was sent with no `eventDate` (2026-10-09): nothing to repeat
4476
+ * — unless the memory it revises carries a date. */
4477
+ readonly recurringIgnored?: boolean;
3918
4478
  }
3919
- | { readonly refused: "event-date-unreadable" | "remind-unknown"; readonly detail: string };
4479
+ | {
4480
+ readonly refused: "event-date-unreadable" | "remind-unknown" | "recurring-unknown" | "recurring-needs-day";
4481
+ readonly detail: string;
4482
+ };
3920
4483
 
3921
4484
  const EVENT_DATE_SHAPES =
3922
4485
  'A day "2026-10-15", a month "2026-10", a year "2026", or a range of two days "2026-10-20..2026-10-31" (first day first). Convert "late October" or "before the 15th" into one of those yourself.';
@@ -3937,15 +4500,24 @@ const DATE_PASSED_NOTE = "That date has already passed — it won't come back as
3937
4500
  function readReminder(rec: Record<string, unknown>): ReminderRead {
3938
4501
  const rawDate = rec["eventDate"];
3939
4502
  const rawRemind = rec["remind"];
4503
+ const rawRule = rec["recurring"];
3940
4504
  if (rawRemind !== undefined && rawRemind !== null && rawRemind !== "plain" && rawRemind !== "quiet") {
3941
4505
  return { refused: "remind-unknown", detail: '`remind` is "plain" or "quiet".' };
3942
4506
  }
3943
- const sent: { remind?: "plain" | "quiet" } =
3944
- rawRemind === "plain" || rawRemind === "quiet" ? { remind: rawRemind } : {};
4507
+ // HOW OFTEN (2026-10-09): one of four words, refused by name like a date.
4508
+ if (rawRule !== undefined && rawRule !== null && !isRecurrence(rawRule)) {
4509
+ return { refused: "recurring-unknown", detail: RECURRING_WORDS };
4510
+ }
4511
+ const sent: { remind?: "plain" | "quiet"; recurring?: Recurrence | null } = {
4512
+ ...(rawRemind === "plain" || rawRemind === "quiet" ? { remind: rawRemind } : {}),
4513
+ // `null` rides as sent: a revision's "it no longer repeats".
4514
+ ...(isRecurrence(rawRule) ? { recurring: rawRule } : rawRule === null ? { recurring: null } : {}),
4515
+ };
3945
4516
  if (rawDate === undefined || rawDate === null) {
3946
4517
  return {
3947
4518
  fields: { ...(rawDate === null ? { eventDate: null } : {}), ...sent },
3948
4519
  remindIgnored: sent.remind !== undefined,
4520
+ recurringIgnored: isRecurrence(sent.recurring),
3949
4521
  };
3950
4522
  }
3951
4523
  const read = typeof rawDate === "string" ? parseCalendarDate(rawDate) : null;
@@ -3955,13 +4527,33 @@ function readReminder(rec: Record<string, unknown>): ReminderRead {
3955
4527
  detail: `\`eventDate\` ${typeof rawDate === "string" ? `"${rawDate.slice(0, 64)}"` : "(not text)"} is not a date this can read. ${EVENT_DATE_SHAPES}`,
3956
4528
  };
3957
4529
  }
4530
+ if (isRecurrence(sent.recurring) && read.precision !== "day") {
4531
+ return { refused: "recurring-needs-day", detail: RECURRING_NEEDS_DAY };
4532
+ }
3958
4533
  return { fields: { eventDate: read.text, ...sent }, remindIgnored: false };
3959
4534
  }
3960
4535
 
4536
+ const RECURRING_WORDS =
4537
+ '`recurring` is "daily", "weekly", "monthly" or "yearly", anchored on eventDate. Every other week, "the first Monday" and the like are not kept: leave it out.';
4538
+
4539
+ const RECURRING_NEEDS_DAY =
4540
+ '`recurring` repeats one day, so eventDate must be a day: the first one ("1990-05-14" for a birthday, any Monday for "every Monday").';
4541
+
4542
+ const RECURRING_IGNORED_NOTE = "`recurring` repeats a date; with no `eventDate` there was nothing to repeat.";
4543
+
4544
+ const RECURRING_DROPPED_NOTE = "Not repeating any more: only a day repeats, and this date is not one, so it comes once.";
4545
+
3961
4546
  /** What to say about a recorded date: that it has already passed (its last day
3962
4547
  * is before the person's today — `time.ts#todayIn` in the store's zone), or
3963
4548
  * that a year alone never comes back. One note, the passed one first. */
3964
- function dateNote(eventDate: string, today: string): Record<string, unknown> {
4549
+ function dateNote(eventDate: string, today: string, recurring: Recurrence | null = null): Record<string, unknown> {
4550
+ // A REPEATING date never "has passed" (2026-10-09): a birthday anchored in
4551
+ // 1990 comes round every year. Said instead: how often, and when next.
4552
+ if (recurring !== null) {
4553
+ const every = readableRecurrence(eventDate, recurring);
4554
+ const next = occurrenceOnOrAfter(eventDate, recurring, today);
4555
+ return { ...(every === "" ? {} : { every }), ...(next === null ? {} : { next: next.date }) };
4556
+ }
3965
4557
  const read = parseCalendarDate(eventDate);
3966
4558
  if (read === null) return {};
3967
4559
  if (read.last < today) return { note: DATE_PASSED_NOTE };
@@ -3986,20 +4578,33 @@ function reminderEcho(deposit: DepositResult, dated: ReminderRead, today: string
3986
4578
  },
3987
4579
  };
3988
4580
  }
4581
+ // A repeat — sent or carried — that the new date cannot take (a month or a
4582
+ // range does not repeat) is SAID, never silently lost.
4583
+ const ruleDropped = carried.recurringDropped === true;
3989
4584
  return {
3990
4585
  reminder: {
3991
4586
  eventDate: carried.eventDate,
3992
4587
  remind: carried.remind ?? "quiet",
4588
+ ...(carried.recurring === null ? {} : { recurring: carried.recurring }),
3993
4589
  from: carried.from,
3994
4590
  ...(carried.inherited.length > 0 ? { carriedOver: [...carried.inherited] } : {}),
3995
4591
  ...unmoved,
3996
- ...dateNote(carried.eventDate, today),
4592
+ ...dateNote(carried.eventDate, today, carried.recurring),
4593
+ ...(ruleDropped ? { note: RECURRING_DROPPED_NOTE } : {}),
3997
4594
  },
3998
4595
  };
3999
4596
  }
4000
- const { eventDate, remind } = dated.fields;
4597
+ const { eventDate, remind, recurring } = dated.fields;
4001
4598
  if (typeof eventDate === "string") {
4002
- return { reminder: { eventDate, remind: remind ?? "quiet", ...dateNote(eventDate, today) } };
4599
+ const rule = isRecurrence(recurring) ? recurring : null;
4600
+ return {
4601
+ reminder: {
4602
+ eventDate,
4603
+ remind: remind ?? "quiet",
4604
+ ...(rule === null ? {} : { recurring: rule }),
4605
+ ...dateNote(eventDate, today, rule),
4606
+ },
4607
+ };
4003
4608
  }
4004
4609
  // A cancel that found nothing to cancel is SAID (review of #247): silence
4005
4610
  // here read as success while a reminder the model meant to drop kept coming.
@@ -4011,9 +4616,12 @@ function reminderEcho(deposit: DepositResult, dated: ReminderRead, today: string
4011
4616
  },
4012
4617
  };
4013
4618
  }
4014
- return dated.remindIgnored
4015
- ? { reminder: { ignored: "remind", note: "`remind` shapes how a date comes back; with no `eventDate` there was nothing to shape." } }
4016
- : {};
4619
+ const remindNote = "`remind` shapes how a date comes back; with no `eventDate` there was nothing to shape.";
4620
+ if (dated.remindIgnored && dated.recurringIgnored === true) {
4621
+ return { reminder: { ignored: "remind, recurring", note: `${remindNote} ${RECURRING_IGNORED_NOTE}` } };
4622
+ }
4623
+ if (dated.recurringIgnored === true) return { reminder: { ignored: "recurring", note: RECURRING_IGNORED_NOTE } };
4624
+ return dated.remindIgnored ? { reminder: { ignored: "remind", note: remindNote } } : {};
4017
4625
  }
4018
4626
 
4019
4627
  // ── feelings on a tool call (schema v7) ─────────────────────────────────────
@@ -4082,6 +4690,83 @@ function threadOf(deposit: DepositResult): Record<string, unknown> {
4082
4690
  return { thread: t.closed ? { closed: t.from } : { closed: null, from: t.from, reason: t.refused ?? "not-recorded" } };
4083
4691
  }
4084
4692
 
4693
+ /**
4694
+ * v12 (2026-10-03): THE WRITER'S THREE FIELDS off a `note` or a
4695
+ * `session_end` entry — `occurredOn` (when it happened: read by `time.ts`,
4696
+ * the one module that reads dates), `saidBy` and `status` (against their
4697
+ * words). LOOSE FIRST: nothing here refuses the memory. What cannot be read
4698
+ * is dropped and said (`dropped`, with what to send instead); null is sent
4699
+ * as none (a revision carries nothing over for it); absent is not sent.
4700
+ * A date in the future is kept, and a note says that a date to be reminded
4701
+ * on is `eventDate`.
4702
+ */
4703
+ interface FactsRead {
4704
+ readonly sent: SentFacts;
4705
+ readonly dropped: readonly { readonly field: string; readonly note: string }[];
4706
+ readonly notes: readonly string[];
4707
+ }
4708
+
4709
+ const OCCURRED_ON_SHAPES =
4710
+ 'Send it as a day "2026-09-24", a month "2026-09", a year "2026" or a range "2026-09-21..2026-09-27" — resolve "last week" or "yesterday" to one of those while you know the date.';
4711
+
4712
+ const OCCURRED_ON_FUTURE_NOTE =
4713
+ "occurredOn is in the future. It is kept, but it means when this happened; a date to be reminded on is eventDate.";
4714
+
4715
+ function readWriteFacts(rec: Record<string, unknown>, today: string): FactsRead {
4716
+ const sent: { occurredOn?: string | null; saidBy?: SaidBy | null; status?: MemoryStatus | null } = {};
4717
+ const dropped: { field: string; note: string }[] = [];
4718
+ const notes: string[] = [];
4719
+ const said = (v: unknown): string => (typeof v === "string" ? `"${v.slice(0, 64)}"` : "(not text)");
4720
+ const date = rec["occurredOn"];
4721
+ if (date === null) sent.occurredOn = null;
4722
+ else if (date !== undefined) {
4723
+ const read = parseCalendarDate(date);
4724
+ if (read === null) {
4725
+ dropped.push({ field: "occurredOn", note: `occurredOn ${said(date)} is not a date this can read, so the memory was kept without it. ${OCCURRED_ON_SHAPES}` });
4726
+ } else {
4727
+ sent.occurredOn = read.text;
4728
+ if (read.first > today) notes.push(OCCURRED_ON_FUTURE_NOTE);
4729
+ }
4730
+ }
4731
+ const by = rec["saidBy"];
4732
+ if (by === null) sent.saidBy = null;
4733
+ else if (by !== undefined) {
4734
+ const v = saidByOf(by);
4735
+ if (v === null) dropped.push({ field: "saidBy", note: `saidBy ${said(by)} is not one of ${SAID_BY.join(", ")}, so the memory was kept without it.` });
4736
+ else sent.saidBy = v;
4737
+ }
4738
+ const st = rec["status"];
4739
+ if (st === null) sent.status = null;
4740
+ else if (st !== undefined) {
4741
+ const v = statusOf(st);
4742
+ if (v === null) dropped.push({ field: "status", note: `status ${said(st)} is not one of ${STATUSES.join(", ")}, so the memory was kept without it.` });
4743
+ else sent.status = v;
4744
+ }
4745
+ return { sent, dropped, notes };
4746
+ }
4747
+
4748
+ /** The three fields' half of a deposit's answer (v12): what was RECORDED —
4749
+ * after a revision's carry-over — what was carried and from where, and what
4750
+ * was dropped and why. Nothing when nothing was sent, dropped or carried. */
4751
+ function factsEcho(deposit: DepositResult, read: FactsRead): Record<string, unknown> {
4752
+ const sentAny = Object.keys(read.sent).length > 0;
4753
+ if (!sentAny && read.dropped.length === 0 && deposit.facts === undefined) return {};
4754
+ const dropped = read.dropped.length === 0 ? {} : { dropped: read.dropped.map((d) => ({ field: d.field, note: d.note })) };
4755
+ if (!deposit.deposited) return { facts: { stored: false, reason: "memory-not-stored", ...dropped } };
4756
+ const f = deposit.facts;
4757
+ return {
4758
+ facts: {
4759
+ stored: true,
4760
+ ...((f?.occurredOn ?? null) === null || f === undefined ? {} : { occurredOn: f.occurredOn }),
4761
+ ...((f?.saidBy ?? null) === null || f === undefined ? {} : { saidBy: f.saidBy }),
4762
+ ...((f?.status ?? null) === null || f === undefined ? {} : { status: f.status }),
4763
+ ...(f === undefined || f.inherited.length === 0 ? {} : { carriedOver: [...f.inherited], from: f.from }),
4764
+ ...dropped,
4765
+ ...(read.notes.length === 0 ? {} : { note: read.notes.join(" ") }),
4766
+ },
4767
+ };
4768
+ }
4769
+
4085
4770
  function readAbout(raw: unknown): AboutRead {
4086
4771
  if (raw === undefined || raw === null) return { mark: null };
4087
4772
  if (typeof raw !== "string" || !(ABOUT_MARKS as readonly string[]).includes(raw)) {