counterparts 0.3.2 → 0.3.4

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 (153) hide show
  1. package/CHANGELOG.md +153 -0
  2. package/docs/module-map.md +3 -2
  3. package/package.json +1 -1
  4. package/src/adapters/claude-code/NOTES.md +28 -0
  5. package/src/adapters/claude-code/bin/hook.ts +85 -22
  6. package/src/adapters/claude-code/config.ts +7 -0
  7. package/src/adapters/claude-code/doctor.ts +166 -4
  8. package/src/adapters/claude-code/hooks.ts +185 -6
  9. package/src/adapters/claude-code/index.ts +3 -0
  10. package/src/adapters/claude-code/transcript.ts +7 -0
  11. package/src/adapters/cli/CONTRACT.md +11 -0
  12. package/src/adapters/cli/INTERFACE-GAPS.md +16 -0
  13. package/src/adapters/cli/NOTES.md +25 -0
  14. package/src/adapters/cli/commands.ts +184 -4
  15. package/src/adapters/cli/dream-core.ts +126 -0
  16. package/src/adapters/cli/help.ts +17 -0
  17. package/src/adapters/cli/mechanisms.ts +199 -106
  18. package/src/adapters/dashboard/CONTRACT.md +5 -0
  19. package/src/adapters/dashboard/INTERFACE-GAPS.md +12 -0
  20. package/src/adapters/dashboard/NOTES.md +38 -0
  21. package/src/adapters/dashboard/registries.ts +35 -1
  22. package/src/adapters/dashboard/web/README.md +63 -26
  23. package/src/adapters/dashboard/web/app.html +2 -0
  24. package/src/adapters/dashboard/web/flow.ts +14 -0
  25. package/src/adapters/dashboard/web/lanes.ts +141 -0
  26. package/src/adapters/dashboard/web/mechanisms/association/index.js +1 -2
  27. package/src/adapters/dashboard/web/mechanisms/consolidation/index.js +8 -5
  28. package/src/adapters/dashboard/web/mechanisms/consolidation/panel.js +7 -7
  29. package/src/adapters/dashboard/web/mechanisms/decay/index.js +1 -2
  30. package/src/adapters/dashboard/web/mechanisms/dreaming/index.js +19 -0
  31. package/src/adapters/dashboard/web/mechanisms/emotional/index.js +9 -6
  32. package/src/adapters/dashboard/web/mechanisms/episodic-semantic/index.js +4 -5
  33. package/src/adapters/dashboard/web/mechanisms/index.js +5 -3
  34. package/src/adapters/dashboard/web/mechanisms/interference/index.js +1 -2
  35. package/src/adapters/dashboard/web/mechanisms/prospective/index.js +7 -5
  36. package/src/adapters/dashboard/web/mechanisms/reconsolidation/index.js +1 -2
  37. package/src/adapters/dashboard/web/mechanisms/regions.js +1 -1
  38. package/src/adapters/dashboard/web/mechanisms/retrieval/index.js +1 -2
  39. package/src/adapters/dashboard/web/mechanisms/salience/index.js +1 -2
  40. package/src/adapters/dashboard/web/mechanisms/schema/index.js +1 -2
  41. package/src/adapters/dashboard/web/narrate.ts +76 -13
  42. package/src/adapters/dashboard/web/pages/health/sections/checks.js +17 -1
  43. package/src/adapters/dashboard/web/pages/home/home.css +29 -13
  44. package/src/adapters/dashboard/web/pages/home/index.js +2 -0
  45. package/src/adapters/dashboard/web/pages/home/sections/explorer.js +22 -7
  46. package/src/adapters/dashboard/web/pages/home/sections/hero.js +15 -3
  47. package/src/adapters/dashboard/web/pages/home/sections/live-activity.js +15 -9
  48. package/src/adapters/dashboard/web/pages/home/sections/recent-chapters.js +6 -2
  49. package/src/adapters/dashboard/web/pages/home/sections/tiles.js +35 -18
  50. package/src/adapters/dashboard/web/pages/memories/index.js +30 -36
  51. package/src/adapters/dashboard/web/pages/memories/memories.css +97 -72
  52. package/src/adapters/dashboard/web/pages/memories/row.js +51 -0
  53. package/src/adapters/dashboard/web/pages/memories/sections/feel.js +176 -0
  54. package/src/adapters/dashboard/web/pages/memories/sections/hold.js +67 -0
  55. package/src/adapters/dashboard/web/pages/memories/sections/list.js +65 -43
  56. package/src/adapters/dashboard/web/pages/memories/sections/search.js +26 -23
  57. package/src/adapters/dashboard/web/pages/memories/state.js +12 -5
  58. package/src/adapters/dashboard/web/pages/self/index.js +57 -16
  59. package/src/adapters/dashboard/web/pages/self/sections/dreams.js +76 -0
  60. package/src/adapters/dashboard/web/pages/self/sections/journal.js +75 -19
  61. package/src/adapters/dashboard/web/pages/self/sections/page.js +108 -65
  62. package/src/adapters/dashboard/web/pages/self/sections/settling.js +129 -104
  63. package/src/adapters/dashboard/web/pages/self/sections/wake.js +31 -15
  64. package/src/adapters/dashboard/web/pages/self/self.css +122 -59
  65. package/src/adapters/dashboard/web/pages/self/state.js +21 -0
  66. package/src/adapters/dashboard/web/server.ts +9 -0
  67. package/src/adapters/dashboard/web/shared/memory-marks.css +17 -0
  68. package/src/adapters/dashboard/web/shared/memory-marks.js +81 -0
  69. package/src/adapters/dashboard/web/shared/memory-modal.js +240 -53
  70. package/src/adapters/dashboard/web/shared/modal.css +67 -0
  71. package/src/adapters/dashboard/web/shared/tip.js +1 -1
  72. package/src/adapters/dashboard/web/shared/widgets/feed.css +4 -0
  73. package/src/adapters/dashboard/web/shared/widgets/feed.js +56 -14
  74. package/src/adapters/dashboard/web/shared/widgets/light.css +1 -0
  75. package/src/adapters/dashboard/web/shared/widgets/light.js +7 -5
  76. package/src/adapters/dashboard/web/shared/widgets/tips.css +19 -0
  77. package/src/adapters/dashboard/web/shared/widgets/tips.js +56 -0
  78. package/src/adapters/dashboard/web/views/activity.ts +18 -2
  79. package/src/adapters/dashboard/web/views/archive-words.ts +27 -10
  80. package/src/adapters/dashboard/web/views/dreams.ts +199 -0
  81. package/src/adapters/dashboard/web/views/mechanism-panel.ts +116 -35
  82. package/src/adapters/dashboard/web/views/mechanisms.ts +81 -255
  83. package/src/adapters/dashboard/web/views/memories.ts +245 -43
  84. package/src/adapters/dashboard/web/views/memory-words.ts +133 -0
  85. package/src/adapters/dashboard/web/views/memory.ts +226 -4
  86. package/src/adapters/dashboard/web/views/mind.ts +261 -61
  87. package/src/adapters/dashboard/web/views/overview.ts +80 -42
  88. package/src/adapters/dashboard/web/views/search.ts +35 -1
  89. package/src/adapters/dashboard/web/views/shared.ts +14 -0
  90. package/src/adapters/dashboard/web/views.ts +2 -0
  91. package/src/adapters/feelings-line.ts +74 -0
  92. package/src/adapters/fired.ts +163 -23
  93. package/src/adapters/mcp/CONTRACT.md +8 -0
  94. package/src/adapters/mcp/NOTES.md +56 -0
  95. package/src/adapters/mcp/server.ts +254 -6
  96. package/src/adapters/mcp/tools.ts +180 -5
  97. package/src/adapters/mechanism-evidence.ts +465 -0
  98. package/src/core/bridge.ts +21 -16
  99. package/src/core/counterpart.ts +422 -10
  100. package/src/core/dream/CONTRACT.md +143 -0
  101. package/src/core/dream/INTERFACE-GAPS.md +24 -0
  102. package/src/core/dream/NOTES.md +84 -0
  103. package/src/core/dream/index.ts +1067 -0
  104. package/src/core/dream/mark.ts +14 -0
  105. package/src/core/dream/tunables.ts +56 -0
  106. package/src/core/encode/CONTRACT.md +7 -1
  107. package/src/core/feelings-wheel.ts +171 -13
  108. package/src/core/mint.ts +9 -0
  109. package/src/core/physics/CONTRACT.md +132 -21
  110. package/src/core/physics/NOTES.md +233 -0
  111. package/src/core/physics/index.ts +419 -50
  112. package/src/core/prospective/CONTRACT.md +35 -6
  113. package/src/core/prospective/INTERFACE-GAPS.md +10 -5
  114. package/src/core/prospective/NOTES.md +175 -4
  115. package/src/core/prospective/derive.ts +32 -3
  116. package/src/core/prospective/index.ts +362 -39
  117. package/src/core/prospective/tunables.ts +18 -1
  118. package/src/core/prospective/windows.ts +104 -46
  119. package/src/core/recall/CONTRACT.md +28 -0
  120. package/src/core/recall/NOTES.md +55 -0
  121. package/src/core/recall/activate.ts +32 -5
  122. package/src/core/recall/gate.ts +7 -1
  123. package/src/core/recall/index.ts +28 -2
  124. package/src/core/recall/mood.ts +106 -0
  125. package/src/core/recall/tunables.ts +26 -0
  126. package/src/core/remember/CONTRACT.md +5 -0
  127. package/src/core/remember/index.ts +1 -0
  128. package/src/core/remember/proposals.ts +86 -3
  129. package/src/core/remember/spans.ts +11 -1
  130. package/src/core/self/CONTRACT.md +3 -0
  131. package/src/core/self/INTERFACE-GAPS.md +7 -0
  132. package/src/core/self/NOTES.md +30 -0
  133. package/src/core/self/identity.ts +115 -6
  134. package/src/core/self/index.ts +17 -0
  135. package/src/core/self/tunables.ts +17 -0
  136. package/src/core/sleep/CONTRACT.md +17 -1
  137. package/src/core/sleep/INTERFACE-GAPS.md +19 -0
  138. package/src/core/sleep/NOTES.md +36 -0
  139. package/src/core/sleep/consolidate.ts +149 -96
  140. package/src/core/sleep/decay.ts +11 -0
  141. package/src/core/sleep/index.ts +4 -1
  142. package/src/core/sleep/tunables.ts +9 -0
  143. package/src/core/sleep/types.ts +17 -0
  144. package/src/core/sleep/upgrade.ts +168 -0
  145. package/src/core/store/CONTRACT.md +21 -2
  146. package/src/core/store/NOTES.md +68 -0
  147. package/src/core/store/feelings.ts +23 -6
  148. package/src/core/store/index.ts +716 -17
  149. package/src/core/store/operational.ts +329 -4
  150. package/src/core/store/owner-op-seam.ts +79 -1
  151. package/src/core/types.ts +37 -0
  152. package/src/adapters/dashboard/web/pages/memories/sections/constellation.js +0 -178
  153. package/src/adapters/dashboard/web/pages/memories/sections/kinds.js +0 -42
@@ -51,7 +51,7 @@ import {
51
51
  WAKE_DELIVERED_EVENT,
52
52
  WAKE_INJECTED_EVENT,
53
53
  } from "../../core/counterpart.js";
54
- import type { AdapterDurableEventName } from "../../core/counterpart.js";
54
+ import type { AdapterDurableEventName, PlainReminder } from "../../core/counterpart.js";
55
55
  import type {
56
56
  BoundaryKind,
57
57
  CaptureResult,
@@ -98,7 +98,7 @@ import {
98
98
  writerInstruction,
99
99
  writerInstructionOverhead,
100
100
  } from "../../core/self/index.js";
101
- import { localClock, localDate } from "../../core/time.js";
101
+ import { localClock, localDate, readableDate } from "../../core/time.js";
102
102
  import { capabilities, pageWriterMode } from "./config.js";
103
103
  import { TUNABLES } from "./config.js";
104
104
  import type { AdapterConfig, CapabilityReport } from "./config.js";
@@ -167,6 +167,13 @@ export interface HookInput {
167
167
  readonly model?: string;
168
168
  /** Today's calendar date, for the temporal channel and the horizon lane. */
169
169
  readonly at?: string;
170
+ /**
171
+ * This session is the host-mode NIGHTLY PAGE WRITER this package started
172
+ * (`page-writer.ts`, `COUNTERPARTS_PAGE_WRITER` in its environment): a
173
+ * headless `claude -p` nobody watches. A plain reminder is never claimed in
174
+ * it — its beat would be spent on a terminal no one reads (2026-09-26 review).
175
+ */
176
+ readonly pageWriter?: boolean;
170
177
  /**
171
178
  * THE HOST'S RE-FIRE. A blocked Stop comes back with `stop_hook_active`, and
172
179
  * that pass must ask nothing — v1's anti-loop, kept for the same reason. It is
@@ -220,6 +227,21 @@ export interface HookResult {
220
227
  readonly spansAppended: number;
221
228
  readonly spawn: SpawnOutcome | null;
222
229
  readonly observer: boolean;
230
+ /**
231
+ * Lines for the PERSON — the host's `systemMessage`, which their terminal
232
+ * shows (`bin/hook.ts#hostDelivery`). Today only plain reminders
233
+ * (`Counterpart.plainDueToday`, 2026-09-26), at SessionStart and at a
234
+ * prompt; absent when there are none. The same lines also ride in
235
+ * `injection` (`plainContextLine`), for the model, so it can raise them.
236
+ *
237
+ * NOT YET CLAIMED (2026-09-26 review): `plain` is the records behind these
238
+ * lines, in the same order, and the delivery claims them only once it knows
239
+ * the envelope carries them (`bin/hook.ts#deliverTurn` → `claimPlain`); what
240
+ * it cannot carry, or loses the race for, is stripped (`withoutPlain`) and
241
+ * waits for the next prompt.
242
+ */
243
+ readonly notices?: readonly string[];
244
+ readonly plain?: readonly PlainReminder[];
223
245
  }
224
246
 
225
247
  export interface AdapterEvent {
@@ -698,7 +720,13 @@ export class ClaudeCodeAdapter {
698
720
  // the delivery check finds its sentinels by prefix, not by line number.
699
721
  // It is counted wherever the host's ceiling is: the over-budget event
700
722
  // and the room an ask may take both measure `sent`, not `woke.bytes`.
701
- const lead = woke.text.length === 0 ? "" : `${this.nowLine()}\n`;
723
+ // PLAIN REMINDERS DUE TODAY (2026-09-26) ride right under the clock, outside
724
+ // the wake block like the clock itself, and go to the person too
725
+ // (`notices`). NOT claimed here: the delivery claims them once it knows
726
+ // the envelope carries them, and a full wake that leaves no room sends
727
+ // them to the first prompt instead (`bin/hook.ts#deliverTurn`).
728
+ const plain = this.plainFor(input);
729
+ const lead = `${woke.text.length === 0 && plain.context.length === 0 ? "" : `${this.nowLine()}\n`}${plain.context}`;
702
730
  const sent = woke.bytes + Buffer.byteLength(lead, "utf8");
703
731
  if (budget !== undefined && sent > budget) {
704
732
  // Exceeding a reported limit is an EVENT, never silent degradation. The
@@ -767,6 +795,7 @@ export class ClaudeCodeAdapter {
767
795
  bytes: woke.bytes,
768
796
  sentinel: woke.sentinel,
769
797
  ask: asks.length === 0 ? null : asks,
798
+ ...(plain.due.length === 0 ? {} : { notices: plain.notices, plain: plain.due }),
770
799
  };
771
800
  });
772
801
  }
@@ -1208,9 +1237,17 @@ export class ClaudeCodeAdapter {
1208
1237
  return { ...out, ok: true, reason: "primacy-standdown" };
1209
1238
  }
1210
1239
  this.checkWakeArrival(input);
1240
+ // A plain reminder whose day began while this session was already open —
1241
+ // the session that runs past midnight — or that SessionStart had no room
1242
+ // for, is said at the next prompt, once (claimed at delivery).
1243
+ const plain = this.plainFor(input);
1244
+ const told = plain.due.length === 0 ? {} : { notices: plain.notices, plain: plain.due };
1245
+ // The DREAM lines (2026-09-26): the once-a-day ask, and any contradiction
1246
+ // a dream flagged that is still unraised — for the model, quietly.
1247
+ const context = `${plain.context}${this.dreamLines(input)}`;
1211
1248
  const text = input.prompt ?? "";
1212
1249
  if (text.trim().length === 0) {
1213
- return { ...out, ok: true, reason: "empty-prompt", injection: this.nowLine() };
1250
+ return { ...out, ok: true, reason: "empty-prompt", injection: `${this.nowLine()}${context.length === 0 ? "" : `\n${context.trimEnd()}`}`, ...told };
1214
1251
  }
1215
1252
  const result = this.counterpart.recallForTurn(
1216
1253
  {
@@ -1220,7 +1257,11 @@ export class ClaudeCodeAdapter {
1220
1257
  ? {}
1221
1258
  : { budgetBytes: this.config.injectionBudgetBytes }),
1222
1259
  },
1223
- { ...(input.at === undefined ? {} : { at: input.at }) },
1260
+ {
1261
+ ...(input.at === undefined ? {} : { at: input.at }),
1262
+ // Said outright this turn, so not ALSO handed over as a quiet cue.
1263
+ ...(plain.due.length === 0 ? {} : { withhold: new Set(plain.due.map((r) => r.memoryId)) }),
1264
+ },
1224
1265
  );
1225
1266
  const decision = result.decision;
1226
1267
  // The recall block states its own sentinel too, and nothing checks it: the
@@ -1251,22 +1292,103 @@ export class ClaudeCodeAdapter {
1251
1292
  // session can run for hours. One line ABOVE the recall note when there
1252
1293
  // is one, outside it like the wake's, so the note's byte count and
1253
1294
  // sentinel stand; alone when recall surfaced nothing.
1254
- injection: result.injection.length === 0 ? this.nowLine() : `${this.nowLine()}\n${result.injection}`,
1295
+ injection:
1296
+ result.injection.length === 0
1297
+ ? `${this.nowLine()}${context.length === 0 ? "" : `\n${context.trimEnd()}`}`
1298
+ : `${this.nowLine()}\n${context}${result.injection}`,
1255
1299
  bytes: decision.bytes,
1256
1300
  sentinel: decision.sentinel,
1257
1301
  // The footnote tier is carried SEPARATELY from the loud one, because the
1258
1302
  // two mean different things to reinforcement: a footnote trains nothing.
1259
1303
  surfaced: decision.surfaced,
1260
1304
  footnotes: decision.footnotes,
1305
+ ...told,
1261
1306
  };
1262
1307
  });
1263
1308
  }
1264
1309
 
1310
+ /**
1311
+ * THE DREAM LINES (2026-09-26, `core/dream/`), for the MODEL only, each
1312
+ * ending in a newline: a contradiction a dream flagged, raised once awake,
1313
+ * and the day's ask — "I haven't dreamed since …" — which the model is to put
1314
+ * to the owner at a natural moment. The ask is at most once a CALENDAR day
1315
+ * across every session (the store's `dream_asks` latch decides, so of two
1316
+ * sessions racing one gets it); a "no" is the dream tool's `decline`. Never in
1317
+ * the host-mode page writer's headless child, never under observer, never
1318
+ * without a date. Only what could surface here anyway is counted or raised
1319
+ * (the dream module applies recall's gates). Never throws.
1320
+ */
1321
+ private dreamLines(input: HookInput): string {
1322
+ if (this.observer || input.at === undefined || input.pageWriter === true || input.sessionId.length === 0) return "";
1323
+ try {
1324
+ const dreams = this.counterpart.dreams;
1325
+ const lines = [...dreams.raiseLines({ session: input.sessionId })];
1326
+ const ask = dreams.askLine({ at: input.at, session: input.sessionId });
1327
+ if (ask !== null) lines.push(ask);
1328
+ if (lines.length > 0) this.emit("adapter.dream.lines", { asked: ask !== null, raised: lines.length - (ask === null ? 0 : 1) });
1329
+ return lines.map((l) => `${l}\n`).join("");
1330
+ } catch {
1331
+ return "";
1332
+ }
1333
+ }
1334
+
1265
1335
  /** `Now: Fri 25 Sep 2026, 1:40 pm MDT` — this adapter's clock, in the store's zone. */
1266
1336
  private nowLine(): string {
1267
1337
  return `Now: ${localClock(this.nowFn(), this.counterpart.store.zone())}`;
1268
1338
  }
1269
1339
 
1340
+ /**
1341
+ * PLAIN REMINDERS, in words (owner decision 2026-09-25/26): "Today: pay your
1342
+ * taxes". Two renderings of each, from the same record —
1343
+ *
1344
+ * - `notices`, for the PERSON, bare: the host shows them as the hook's
1345
+ * `systemMessage` in the terminal (`bin/hook.ts#hostDelivery`);
1346
+ * - `context`, for the MODEL, one line each ending in a newline, saying it
1347
+ * was asked for and naming the memory, so it can raise it and look it up.
1348
+ *
1349
+ * A READ (2026-09-26 review): nothing is claimed here. The delivery claims
1350
+ * what its envelope will certainly carry (`claimPlain`, from
1351
+ * `bin/hook.ts#deliverTurn`) and strips the rest, so a beat is never spent
1352
+ * on a line the person did not get. No date (`input.at` absent) means no
1353
+ * calendar, and so nothing; the host-mode page writer's headless child is
1354
+ * told nothing (`HookInput.pageWriter`). Never throws.
1355
+ */
1356
+ private plainFor(input: HookInput): { context: string; notices: string[]; due: PlainReminder[] } {
1357
+ const none = { context: "", notices: [], due: [] };
1358
+ if (input.at === undefined || input.pageWriter === true) return none;
1359
+ try {
1360
+ const due = this.counterpart.plainDueToday({ at: input.at });
1361
+ return {
1362
+ context: due.map((r) => `${plainContextLine(r)}\n`).join(""),
1363
+ notices: due.map(plainLine),
1364
+ due,
1365
+ };
1366
+ } catch {
1367
+ return none;
1368
+ }
1369
+ }
1370
+
1371
+ /**
1372
+ * CLAIM plain reminders the delivery is certainly about to show — the latch
1373
+ * (`Counterpart.claimPlainReminder`) decides, so of two processes racing for
1374
+ * one beat exactly one gets it back. Returns the ones this call claimed, in
1375
+ * order; the caller shows only those. Never throws.
1376
+ */
1377
+ claimPlain(input: HookInput, due: readonly PlainReminder[]): PlainReminder[] {
1378
+ if (input.at === undefined || due.length === 0) return [];
1379
+ const at = input.at;
1380
+ const claimed = due.filter((r) => {
1381
+ try {
1382
+ return this.counterpart.claimPlainReminder(r, { at });
1383
+ } catch {
1384
+ return false;
1385
+ }
1386
+ });
1387
+ if (claimed.length > 0) this.emit("adapter.plain.told", { count: claimed.length });
1388
+ if (claimed.length < due.length) this.emit("adapter.plain.lost", { count: due.length - claimed.length });
1389
+ return claimed;
1390
+ }
1391
+
1270
1392
  /**
1271
1393
  * "COUNTERPARTS WAS UPDATED" — the line this session's terminal gets, once,
1272
1394
  * when the MCP server it is talking to runs an older build than the one
@@ -2547,6 +2669,63 @@ export function wakeOutcome(expected: string | null, arrival: WakeArrival): Wake
2547
2669
  return "truncated";
2548
2670
  }
2549
2671
 
2672
+ /**
2673
+ * ONE PLAIN REMINDER, AS A PERSON READS IT (2026-09-26). The owner's example is
2674
+ * the whole spec — "Today: pay your taxes" — so each beat is the shortest
2675
+ * sentence that says when:
2676
+ *
2677
+ * day `Today: pay your taxes`
2678
+ * opens `This month: launch the beta` / `Until Sat 31 Oct 2026: book flights`
2679
+ * last-day `Last day today: file the extension`
2680
+ *
2681
+ * `what` is the memory's title or first line (`Counterpart.plainReminders`).
2682
+ */
2683
+ export function plainLine(r: Pick<PlainReminder, "beat" | "precision" | "lastDay" | "what">): string {
2684
+ const max = TUNABLES.PLAIN_WHAT_MAX_CHARS;
2685
+ const what = r.what.length <= max ? r.what : `${r.what.slice(0, max - 1).trimEnd()}…`;
2686
+ if (r.beat === "day") return `Today: ${what}`;
2687
+ if (r.beat === "last-day") return `Last day today: ${what}`;
2688
+ if (r.precision === "month") return `This month: ${what}`;
2689
+ return `Until ${readableDate(r.lastDay)}: ${what}`;
2690
+ }
2691
+
2692
+ /**
2693
+ * The MODEL's copy of one plain reminder: says it was asked for, and names the
2694
+ * memory so it can be looked up. One line, no newline — `what` is folded to
2695
+ * single spaces upstream — so `withoutPlain` can take it back out by line.
2696
+ */
2697
+ export function plainContextLine(r: Pick<PlainReminder, "beat" | "precision" | "lastDay" | "what" | "memoryId">): string {
2698
+ return `Plain reminder (they asked to be told) — ${plainLine(r)} [${r.memoryId}]`;
2699
+ }
2700
+
2701
+ /**
2702
+ * A hook result WITHOUT the given plain reminders — their terminal lines, their
2703
+ * records and their context lines — for a delivery that could not carry them or
2704
+ * lost the race to claim them (`bin/hook.ts#deliverTurn`). They are not spent:
2705
+ * the next prompt reads them again. Everything else is untouched.
2706
+ */
2707
+ export function withoutPlain<R extends { injection: string | null; notices?: readonly string[]; plain?: readonly PlainReminder[] }>(
2708
+ result: R,
2709
+ drop: readonly PlainReminder[],
2710
+ ): R {
2711
+ if (drop.length === 0) return result;
2712
+ const keyOf = (r: PlainReminder): string => `${r.memoryId} ${r.windowKey} ${r.beat}`;
2713
+ const gone = new Set(drop.map(keyOf));
2714
+ const lines = new Set(drop.map(plainContextLine));
2715
+ const plain = (result.plain ?? []).filter((r) => !gone.has(keyOf(r)));
2716
+ const injection =
2717
+ result.injection === null
2718
+ ? null
2719
+ : result.injection
2720
+ .split("\n")
2721
+ .filter((l) => !lines.has(l))
2722
+ .join("\n");
2723
+ const rest: R = { ...result, injection };
2724
+ delete (rest as { notices?: unknown }).notices;
2725
+ delete (rest as { plain?: unknown }).plain;
2726
+ return plain.length === 0 ? rest : { ...rest, notices: plain.map(plainLine), plain };
2727
+ }
2728
+
2550
2729
  function codeOf(err: unknown): string {
2551
2730
  if (err !== null && typeof err === "object") {
2552
2731
  const code = (err as { code?: unknown }).code;
@@ -59,8 +59,11 @@ export {
59
59
  SPAWN_REFUSAL_PREFIX,
60
60
  SPAWN_START_COUNT_KEY,
61
61
  SPAWN_START_DATE_KEY,
62
+ plainContextLine,
63
+ plainLine,
62
64
  substanceOf,
63
65
  wakeOutcome,
66
+ withoutPlain,
64
67
  } from "./hooks.js";
65
68
  export type {
66
69
  AdapterEvent,
@@ -90,6 +90,7 @@ import {
90
90
  statSync,
91
91
  } from "node:fs";
92
92
 
93
+ import { carriesDreamMark } from "../../core/dream/mark.js";
93
94
  import type { Turn, TurnSource } from "../../core/remember/index.js";
94
95
 
95
96
  /**
@@ -547,6 +548,12 @@ function pieceOf(text: string, role: "user" | "assistant", author: EntryAuthor):
547
548
  // metadata says: an `isMeta` Stop-hook block read as `injected` would ENTER
548
549
  // capture, which is G11 broken by a step meant only to keep it out of pacing.
549
550
  if (source === "foreign" || source === "ritual") return { text, source };
551
+ // A DREAM'S WORDS (2026-09-26): the bundle a dreamer was shown, or the
552
+ // hand-back its background agent sends home — which this host delivers into
553
+ // the parent's transcript user-role (`isMeta`, origin `peer`) and would read
554
+ // as `injected`, kept. Refused by the mark, whoever wrote the entry and in
555
+ // either role, so a dream never reaches the sweep (`core/dream/mark.ts`).
556
+ if (carriesDreamMark(text)) return { text, source: "dream" };
550
557
  // THE ASSISTANT'S TEXT IS NEVER RECLASSIFIED BY A MARKER (review m2): its own
551
558
  // replies add pacing bytes and earn recall credit exactly as on master. The one change is
552
559
  // an entry the host SYNTHESISED as the assistant (an API error), which the
@@ -581,6 +581,17 @@ The standalone verb does not ask either: typing it is the yes.*
581
581
  treats it as foreign (never moved, never deleted, and named with one sentence saying
582
582
  what it is), and `start-fresh` leaves it byte for byte. `doctor` has no Credentials
583
583
  line; the configuration's retired settings are one green `Old settings` note.
584
+ 43. **[M] The owner's windows onto dreaming and the core (2026-09-26).** `counterparts
585
+ dream` lists the dreams, `--show <id>` prints one dream's journal and every change it
586
+ made (undone rows marked), and `--undo <id>` reverses its whole batch through
587
+ `Counterpart.dreams.undo` — the console decides nothing about what an undo does.
588
+ `counterparts core` lists the core with the lane that carried each memory there, the
589
+ dreams' nominations and the owner's demotions, and `--demote <id> --reason "…"` sends
590
+ one back to ordinary fading through `Counterpart.demoteCore`, which requires the
591
+ reason, records it, restarts fading from today and keeps the lanes from promoting it
592
+ again. Neither command is on `OWNER_OPS`: like `self-page`, reading works from an
593
+ instrument, and the write refuses at the core's own seam under observer. Confidential
594
+ rows print as `[confidential]`.
584
595
 
585
596
  ## 6. Scars honored
586
597
 
@@ -395,3 +395,19 @@ and says how much of the number is log (NOTES, 2026-09-23), which is this module
395
395
  SQL string and finalize the cache in `close()` — so a clean close is a real close. Worth
396
396
  measuring the hooks' per-turn cost before and after, since they open and close the store
397
397
  on every turn.
398
+
399
+ ## Dreaming and the core (2026-09-26)
400
+
401
+ - **`counterparts mechanisms` does not yet say "became core by the fast/slow lane"
402
+ or count a dream's changes.** The short view reads only `fired.ts`'s rows, which
403
+ count rows, not payloads; the lane is on each `band.promoted` row's payload and a
404
+ dream's change count is on `dream.changed`'s. The builder is moving the lights into
405
+ the shared `adapters/mechanism-evidence.ts` (master ef37eb1); that is where the
406
+ Consolidation / Dreaming / Gist lines belong.
407
+ - **A dream's journal cannot be removed from the console.** `remove` takes memory ids,
408
+ and a journal is not a memory (it lives in the `dreams` table). An owner who wants a
409
+ journal gone has `dream --undo`, which keeps it marked undone. A `dream --forget <id>`
410
+ would need a store write that blanks the journal text; not built.
411
+ - **`export --markdown` does not carry the dreams table** (the journals, the change
412
+ logs): it walks memories. The database export and `backup` copy the whole file, so
413
+ they do.
@@ -1800,6 +1800,31 @@ tier is primary while Voyage is frozen (ROADMAP §"Amendments"). What the build
1800
1800
  binding in `bin/counterparts.ts`. Its only caller was `credentials set`; it is a small,
1801
1801
  tested primitive, and removing it was not part of this round.
1802
1802
 
1803
+ ## `dream` and `core` (2026-09-26, dreaming + consolidation)
1804
+
1805
+ Two small commands over the core's own answers (`cli/dream-core.ts` renders, the core
1806
+ decides). Choices made here:
1807
+
1808
+ - **`--undo` is a boolean with the id after it** (`dream --undo drm_…`), because
1809
+ `start-fresh --undo` already declares `undo` as a boolean and the parser's option table
1810
+ is shared by every command; `--undo=<id>` works too. `--show` and `--demote` are new
1811
+ and are valued flags.
1812
+ - **Both are on the advanced page, not the first one.** The first page is what a person
1813
+ reads thirty seconds after installing; dreams and the core are what they look at a week
1814
+ later. `counterparts help dream` / `help core` are the full pages.
1815
+ - **A demotion needs `--reason`**, and `--reason` without `--demote` is refused rather
1816
+ than ignored: the reason is the one thing the record keeps that the store cannot
1817
+ reconstruct.
1818
+ - **`fired` gained eight rows** (`returns`, `dream`, `dream-changes`, `dream-ask`,
1819
+ `dream-replays`, `core-demote`, `upgrade-census`, and `gist` now backed by dreamed
1820
+ memories instead of "not built"). `returns` and `dream-replays` are table probes over
1821
+ the new `returns` table (dated by each row's moment); `gist` is a probe over live
1822
+ memories of source `dreamed`.
1823
+ - **Doctor gained two lines**: `Upgrade` (the v8 upgrade's census — green when nothing
1824
+ moved down, amber until the first sleep measures it, red if anything did; no line on a
1825
+ store born at v8) and `Dreaming` (informational: last dreamed, and today's ask). Both
1826
+ fold into `Background` while green.
1827
+
1803
1828
  ## `ask` by meaning, and short (2026-09-24)
1804
1829
 
1805
1830
  **By meaning.** `ask` passed `vector: null, semantic: "embedder-off"` since the days