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
@@ -41,12 +41,14 @@ import { Associate, appendPendingDeltas, claimPending, releasePending } from "./
41
41
  import type { CoactivateResult, Credited, FlushReport, PairDelta, PendingClaim } from "./associate/index.js";
42
42
  import { selfRenderer } from "./briefing.js";
43
43
  import { batteryGate, episodeGate, gateSweepChunk } from "./bridge.js";
44
+ import { Dreams } from "./dream/index.js";
44
45
  import type { VectorSource } from "./bridge.js";
45
46
  import { mintProposal } from "./mint.js";
46
47
  import type { MintResult } from "./mint.js";
47
48
  import { isObserver } from "./observer.js";
48
49
  import type { Stance } from "./observer.js";
49
- import { Prospective } from "./prospective/index.js";
50
+ import { Prospective, DATE_LINEAGE_MAX, DATE_MOVED_TO_META, cueModeOf } from "./prospective/index.js";
51
+ import type { PlainDue } from "./prospective/index.js";
50
52
  import {
51
53
  Recall,
52
54
  isConfidential,
@@ -121,6 +123,7 @@ import {
121
123
  } from "./handoff/index.js";
122
124
  import type { Handoff, HandoffRefusal, HandoffWrite } from "./handoff/index.js";
123
125
  import {
126
+ BRIEFING_KEY,
124
127
  BRIEFING_TRIM_LOG_CAP,
125
128
  LANE_ORDER,
126
129
  PREFACE_RESERVE_BYTES,
@@ -152,7 +155,7 @@ import { Store, assertSafeDataDir, hashText, indexTextOf } from "./store/index.j
152
155
  import type {
153
156
  AddFeelingsResult,
154
157
  FeelingInput, Embedder, StoreEvent } from "./store/index.js";
155
- import { TUNABLES as PHYSICS } from "./physics/index.js";
158
+ import { TUNABLES as PHYSICS, band as bandOf } from "./physics/index.js";
156
159
  import type { UseTier } from "./physics/index.js";
157
160
  import type { Kind } from "./types.js";
158
161
 
@@ -764,6 +767,16 @@ export type DepositReason =
764
767
  | "gate-failed"
765
768
  | "io-failed";
766
769
 
770
+ /**
771
+ * One plain reminder, claimed and due to be told (`Counterpart.plainReminders`).
772
+ * The record `prospective/` hands out, plus `what`: the memory's title or its
773
+ * first line, which is the one piece of the memory's own words a host needs to
774
+ * say it. The sentence around it is the host's.
775
+ */
776
+ export interface PlainReminder extends PlainDue {
777
+ readonly what: string;
778
+ }
779
+
767
780
  export interface DepositResult {
768
781
  readonly deposited: boolean;
769
782
  readonly reason: DepositReason;
@@ -778,6 +791,35 @@ export interface DepositResult {
778
791
  * …), when that is why it was refused. A bare "malformed" told the author
779
792
  * nothing to fix (IMPROVEMENTS U11). */
780
793
  readonly malformed?: MalformedReason | null;
794
+ /**
795
+ * Present when this deposit REVISED a dated memory (`updates:`, declared and
796
+ * resolved): the reminder the new memory carries after the carry-over, and
797
+ * where it came from (`Counterpart#carryReminder`, review N7).
798
+ */
799
+ readonly reminder?: DepositReminder;
800
+ }
801
+
802
+ /** A revision's reminder: carried over, replaced, or dropped — and moved. */
803
+ export interface DepositReminder {
804
+ /** The memory the reminder came from — the one revised, or, when its reminder
805
+ * had already moved on, the memory holding it now. Its own date was cleared
806
+ * (kept in its version) when `moved`. */
807
+ readonly from: string;
808
+ /** The date the new memory carries, or null when the revision dropped it. */
809
+ readonly eventDate: string | null;
810
+ readonly remind: "plain" | "quiet" | null;
811
+ /** Which fields came from `from` because the author left them out. */
812
+ readonly inherited: readonly ("eventDate" | "remind")[];
813
+ /** False only when clearing `from`'s date failed (evented). */
814
+ readonly moved: boolean;
815
+ }
816
+
817
+ /** `carryReminder`'s answer: the proposal to mint, and what it took from where. */
818
+ interface ReminderCarryPlan {
819
+ readonly proposal: Proposal;
820
+ /** The dated memory being revised, or null when there is nothing to carry. */
821
+ readonly from: string | null;
822
+ readonly inherited: readonly ("eventDate" | "remind")[];
781
823
  }
782
824
 
783
825
  export interface SweepEntry {
@@ -1184,6 +1226,8 @@ export const RECALL_DECISION_FIELDS = [
1184
1226
  "footnoteCount",
1185
1227
  "affectFlag",
1186
1228
  "affectReason",
1229
+ // Emotion part A (2026-09-26): admitted memories the current mood lifted.
1230
+ "moodMatched",
1187
1231
  "sentinelRendered",
1188
1232
  "surfaced",
1189
1233
  "footnotes",
@@ -1254,6 +1298,7 @@ function recallDecisionRecord(
1254
1298
  footnoteCount: d.footnotes.length,
1255
1299
  affectFlag: d.affectFlag,
1256
1300
  affectReason: d.affectReason,
1301
+ moodMatched: d.moodMatched,
1257
1302
  sentinelRendered: d.sentinel !== null,
1258
1303
  surfaced: tierRows(d.surfaced, d.verdicts),
1259
1304
  footnotes: tierRows(d.footnotes, d.verdicts),
@@ -1277,11 +1322,16 @@ export class Counterpart {
1277
1322
  readonly prospective: Prospective;
1278
1323
  /** Working context per directory (E1) — never memory. See `handoff/`. */
1279
1324
  readonly handoffs: Handoffs;
1325
+ /** Dreaming (2026-09-26, `dream/`): the ask, the bundle, the changes, the journal, undo. */
1326
+ readonly dreams: Dreams;
1280
1327
  /** One predicate, one definition: the store's. Never re-derived here. */
1281
1328
  readonly observer: boolean;
1282
1329
 
1283
1330
  /** Undefined when no embedder was wired, and under observer. See below. */
1284
1331
  private readonly vectors: VectorSource | undefined;
1332
+ /** The owner's own session? Recall's rule, kept for the plain lane: a
1333
+ * confidential memory is said only to its owner (recall §9.1 G5). */
1334
+ private readonly owner: boolean;
1285
1335
  private reportedBudget: number | null;
1286
1336
  private readonly onEvent: ((e: CounterpartEvent) => void) | undefined;
1287
1337
  private readonly nowFn: () => number;
@@ -1312,6 +1362,7 @@ export class Counterpart {
1312
1362
  // belongs in `Store.open` too, and this is not a substitute for that.
1313
1363
  if (opts.dir !== undefined) assertSafeDataDir(opts.dir);
1314
1364
  this.observer = isObserver(opts);
1365
+ this.owner = opts.owner === true && !this.observer;
1315
1366
  this.onEvent = opts.onEvent;
1316
1367
  this.nowFn = opts.now ?? ((): number => Date.now());
1317
1368
  this.reportedBudget = opts.budgetBytes ?? null;
@@ -1422,6 +1473,33 @@ export class Counterpart {
1422
1473
  onEvent: (e) => this.relay("remember", e),
1423
1474
  });
1424
1475
 
1476
+ // DREAMING. Every word a dream writes is REDACTED of credentials before it
1477
+ // is stored — the secrets scan the battery runs, without the battery's
1478
+ // length and shape gates: a dream's words are a rewording of memories that
1479
+ // already crossed the full battery, and a one-line journal, a nomination's
1480
+ // reason or a merged sentence is short by nature (the full gate refused
1481
+ // them `content-too-short`). Text that was nothing but a credential is
1482
+ // refused. A merge hands its originals' links to the merged memory through
1483
+ // `associate/`'s retarget, which had no caller until now.
1484
+ this.dreams = new Dreams({
1485
+ store: this.store,
1486
+ observer: this.observer,
1487
+ owner: this.owner,
1488
+ gate: (text) => {
1489
+ const redacted = redactSecrets(text);
1490
+ return redacted.replace(/\[REDACTED[^\]]*\]/g, "").trim().length === 0
1491
+ ? { ok: false, reason: "only-a-credential" }
1492
+ : { ok: true, text: redacted };
1493
+ },
1494
+ page: () => this.self.page()?.body ?? null,
1495
+ wake: () => this.store.getMeta(BRIEFING_KEY) ?? null,
1496
+ today: () => this.store.today(),
1497
+ retarget: (oldId, newId, day) => {
1498
+ this.associate.retargetOnSupersede(oldId, newId, day);
1499
+ },
1500
+ emit: (name, ref, data) => this.emit(name, ref, data),
1501
+ });
1502
+
1425
1503
  if (opts.identity !== undefined) this.self.ensureIdentityCore(opts.identity);
1426
1504
  }
1427
1505
 
@@ -1644,17 +1722,148 @@ export class Counterpart {
1644
1722
  * temporal cues from `prospective/`, the hop function from `associate/`. A
1645
1723
  * missing `at` means no temporal channel — a lived day is not a date.
1646
1724
  */
1647
- recallForTurn(turn: RecallTurn, opts: { at?: string } = {}): RecallResult {
1648
- const result = recallTurn(this.recall, this.withSemantic(turn), {
1725
+ recallForTurn(
1726
+ turn: RecallTurn,
1727
+ opts: {
1728
+ at?: string;
1729
+ /** Memory ids whose temporal cue is held back THIS turn: plain items the
1730
+ * host is saying outright in the same breath (2026-09-26 review), so the
1731
+ * model is not handed the same date twice in one turn. */
1732
+ withhold?: ReadonlySet<string>;
1733
+ } = {},
1734
+ ): RecallResult {
1735
+ // THE TEMPORAL CUES ARE COMPUTED HERE, not inside `composeTurn`, for one
1736
+ // reason: the window each one came from has to survive the turn, so the
1737
+ // arrivals the gate actually admitted can SPEND their fire budget below.
1738
+ // `composeTurn` skips its own read when `turn.temporal` is already set, so
1739
+ // this is the same channel and the same ceiling (§12 G1, G5) — one read of
1740
+ // `arrivals()`, never two.
1741
+ const arrived =
1742
+ opts.at === undefined || turn.temporal !== undefined
1743
+ ? null
1744
+ : this.prospective.arrivals({
1745
+ at: opts.at,
1746
+ ...(turn.day === undefined ? {} : { day: turn.day }),
1747
+ sessionId: turn.sessionId,
1748
+ }).arrivals.filter((a) => opts.withhold?.has(a.memoryId) !== true);
1749
+ const withCues: RecallTurn =
1750
+ arrived === null ? turn : { ...turn, temporal: arrived.map((a) => ({ id: a.memoryId, weight: a.cueWeight })) };
1751
+ const result = recallTurn(this.recall, this.withSemantic(withCues), {
1649
1752
  schemas: this.schemas,
1650
1753
  prospective: this.prospective,
1651
1754
  associate: this.associate,
1652
1755
  ...(opts.at === undefined ? {} : { at: opts.at }),
1653
1756
  });
1654
1757
  this.recordDecision(result.decision, opts.at ?? null);
1758
+ if (arrived !== null && opts.at !== undefined) this.spendArrivals(arrived, result.decision, opts.at);
1655
1759
  return result;
1656
1760
  }
1657
1761
 
1762
+ /**
1763
+ * `Prospective.fire()`'s LIVE CALLER (2026-09-26; until today the only one was
1764
+ * `tools/demo/seed.ts`, so a dated memory would have been re-offered every
1765
+ * turn of its window). A fire is a surfacing that HAPPENED (prospective NOTES
1766
+ * §6): an arrival is spent only when the gate put its memory in this turn's
1767
+ * surfaced or footnoted set — which is what makes brake 1 (once per lived
1768
+ * day) and brake 2 (`FIRES_PER_WINDOW`) real. An aborted turn surfaced
1769
+ * nothing and spends nothing (recall §5 G2); an observer's `fire()` stands
1770
+ * down on its own (§5 G9). Never throws into the turn: a lost fire row costs
1771
+ * one extra polite mention, never the recall (§12 G12).
1772
+ */
1773
+ private spendArrivals(
1774
+ arrived: readonly { memoryId: string; windowKey: string }[],
1775
+ decision: RecallDecision,
1776
+ at: string,
1777
+ ): void {
1778
+ if (decision.aborted || arrived.length === 0) return;
1779
+ const shown = new Set<string>([...decision.surfaced, ...decision.footnotes]);
1780
+ for (const a of arrived) {
1781
+ if (!shown.has(a.memoryId)) continue;
1782
+ try {
1783
+ this.prospective.fire({
1784
+ memoryId: a.memoryId,
1785
+ windowKey: a.windowKey,
1786
+ at,
1787
+ day: decision.day,
1788
+ sessionId: decision.sessionId,
1789
+ });
1790
+ } catch (err) {
1791
+ this.emit("counterpart.prospective.fire.failed", a.memoryId, { code: errCode(err) });
1792
+ }
1793
+ }
1794
+ }
1795
+
1796
+ /**
1797
+ * PLAIN REMINDERS DUE TODAY, NOT YET CLAIMED — a read. The owner-decided
1798
+ * exception to "a cue, not a command" (prospective CONTRACT §3): an item its
1799
+ * author marked plain is SAID on its day, to the person and to the model,
1800
+ * once per beat. A host that can tell whether its line will actually reach
1801
+ * the person reads here and claims (`claimPlainReminder`) only what it is
1802
+ * certainly about to show — "mark only what is certainly leaving", the
1803
+ * update notice's rule (2026-09-26 review). `plainReminders` is the two in
1804
+ * one, for a host with no such question.
1805
+ *
1806
+ * `what` is the memory's title, else the first line of its body, with its
1807
+ * whitespace folded — the handle a person recognizes. How long a line may be
1808
+ * and the sentence around it are the host adapter's to decide. Never throws:
1809
+ * any failure is an empty list.
1810
+ */
1811
+ plainDueToday(input: { at: string }): PlainReminder[] {
1812
+ if (this.observer) return [];
1813
+ const out: PlainReminder[] = [];
1814
+ try {
1815
+ for (const due of this.prospective.plainDue({ at: input.at })) {
1816
+ let what = "";
1817
+ try {
1818
+ const read = this.store.read(due.memoryId);
1819
+ // Confidential is said only in the owner's own session — recall's
1820
+ // boundary gate 1, which a line outside recall must keep by hand.
1821
+ if (read.confidential && !this.owner) continue;
1822
+ const doc = read.doc;
1823
+ const title = doc.title?.trim() ?? "";
1824
+ const line = doc.body.split("\n").map((l) => l.trim()).find((l) => l.length > 0) ?? "";
1825
+ what = (title.length > 0 ? title : line).replace(/\s+/g, " ").trim();
1826
+ } catch {
1827
+ continue;
1828
+ }
1829
+ if (what.length === 0) continue;
1830
+ out.push({ ...due, what });
1831
+ }
1832
+ } catch (err) {
1833
+ this.emit("counterpart.prospective.plain.failed", undefined, { code: errCode(err) });
1834
+ }
1835
+ return out;
1836
+ }
1837
+
1838
+ /**
1839
+ * Claim one plain beat: TRUE only when this call wrote the latch
1840
+ * (`Prospective.claimPlain`), so two processes racing for the same beat
1841
+ * cannot both show it. Show the line only on true. Never throws.
1842
+ */
1843
+ claimPlainReminder(reminder: PlainDue, input: { at: string; day?: number }): boolean {
1844
+ if (this.observer) return false;
1845
+ try {
1846
+ return this.prospective.claimPlain(reminder, {
1847
+ at: input.at,
1848
+ ...(input.day === undefined ? {} : { day: input.day }),
1849
+ });
1850
+ } catch (err) {
1851
+ this.emit("counterpart.prospective.plain.failed", reminder.memoryId, { code: errCode(err) });
1852
+ return false;
1853
+ }
1854
+ }
1855
+
1856
+ /**
1857
+ * PLAIN REMINDERS DUE TODAY, each already CLAIMED (`plainDueToday`, then
1858
+ * `claimPlainReminder` on each) — so the caller shows every one it gets
1859
+ * back, and a second process asking the same morning gets none. For a host
1860
+ * that shows whatever it reads; the Claude Code hooks instead claim only
1861
+ * what their envelope will carry (`bin/hook.ts#deliverTurn`).
1862
+ */
1863
+ plainReminders(input: { at: string; day?: number }): PlainReminder[] {
1864
+ return this.plainDueToday({ at: input.at }).filter((r) => this.claimPlainReminder(r, input));
1865
+ }
1866
+
1658
1867
  /**
1659
1868
  * THE FOURTH BORROWED CHANNEL, and the one that had no wiring: the lagged
1660
1869
  * semantic cue.
@@ -1789,8 +1998,8 @@ export class Counterpart {
1789
1998
  }
1790
1999
 
1791
2000
  /** Retrospective reinforcement for ONE memory the reply actually used. */
1792
- resolveUse(sessionId: string, memoryId: string, tier: UseTier): CreditResult {
1793
- return this.recall.resolveUse(sessionId, memoryId, tier);
2001
+ resolveUse(sessionId: string, memoryId: string, tier: UseTier, opts: { cued?: boolean } = {}): CreditResult {
2002
+ return this.recall.resolveUse(sessionId, memoryId, tier, opts);
1794
2003
  }
1795
2004
 
1796
2005
  /**
@@ -1883,7 +2092,11 @@ export class Counterpart {
1883
2092
  let credited = 0;
1884
2093
  for (const u of uses) {
1885
2094
  try {
1886
- const r = this.resolveUse(sessionId, u.memoryId, "referenced");
2095
+ // A QUOTED use was a loud candidate recall surfaced on a turn's own cue
2096
+ // this session: organic, whatever the wake's hints lane was showing. An
2097
+ // EXPANDED id may have been read off the wake — the display decides
2098
+ // whether it is a return (physics §5.11).
2099
+ const r = this.resolveUse(sessionId, u.memoryId, "referenced", u.how === "quoted" ? { cued: true } : {});
1887
2100
  if (r.credited) {
1888
2101
  credited += 1;
1889
2102
  ids.push(u.memoryId);
@@ -2178,8 +2391,9 @@ export class Counterpart {
2178
2391
  * Feelings on a memory (schema v7, `store/feelings.ts`), through the SECRETS
2179
2392
  * half of the battery: `carried_by` and an `other` word are words about the
2180
2393
  * moment, and a credential must not land in them any more than in a body.
2181
- * Nothing else here reads them — salience, decay and recall are untouched
2182
- * until the emotion build. Throws what the store throws (`FEELING_INVALID`).
2394
+ * Once stored they weigh (emotion part A): physics reads the strongest one
2395
+ * beside the row (§5.10) and recall reads recent ones as the mood (G18).
2396
+ * Throws what the store throws (`FEELING_INVALID`).
2183
2397
  */
2184
2398
  addFeelings(memoryId: string, inputs: readonly FeelingInput[], opts: { model?: string } = {}): AddFeelingsResult {
2185
2399
  const clean = inputs.map((f) => ({
@@ -2266,6 +2480,80 @@ export class Counterpart {
2266
2480
  return this.self.ingestEpisode(input);
2267
2481
  }
2268
2482
 
2483
+ // ── the core: what it holds, and the owner's door out of it ────────────────
2484
+
2485
+ /**
2486
+ * THE CORE, as the owner reads it (2026-09-26): every identity-band memory,
2487
+ * with the lane that carried it there (when a promotion recorded one) and
2488
+ * whether it is on the page's row; plus the recent nominations dreams made.
2489
+ * A read.
2490
+ */
2491
+ coreList(): {
2492
+ core: { id: string; kind: string; lane: string | null; day: number | null; body: string | null; confidential: boolean }[];
2493
+ nominated: { id: string; day: number; reason: string | null; dream: string | null }[];
2494
+ demoted: { id: string; day: number; reason: string | null }[];
2495
+ } {
2496
+ const core: ReturnType<Counterpart["coreList"]>["core"] = [];
2497
+ for (const id of this.store.list({ archived: false })) {
2498
+ const row = this.store.row(id);
2499
+ if (row === undefined || row.promoted_identity !== 1) continue;
2500
+ const promoted = this.store.coreEvents({ memoryId: id, action: "promoted", limit: 1 })[0];
2501
+ let body: string | null = null;
2502
+ try {
2503
+ const doc = this.store.readProse(id);
2504
+ body = row.confidential === 1 && !this.owner ? null : (doc.title ?? doc.body).split("\n")[0] ?? "";
2505
+ } catch {
2506
+ body = null;
2507
+ }
2508
+ core.push({
2509
+ id,
2510
+ kind: row.kind,
2511
+ lane: promoted?.lane ?? null,
2512
+ day: promoted?.day ?? null,
2513
+ body,
2514
+ confidential: row.confidential === 1,
2515
+ });
2516
+ }
2517
+ const nominated = this.store
2518
+ .coreEvents({ action: "nominated" })
2519
+ .map((e) => ({ id: e.memory_id, day: e.day, reason: e.reason, dream: e.dream_id }));
2520
+ const demoted = this.store
2521
+ .coreEvents({ action: "demoted" })
2522
+ .map((e) => ({ id: e.memory_id, day: e.day, reason: e.reason }));
2523
+ return { core, nominated, demoted };
2524
+ }
2525
+
2526
+ /**
2527
+ * THE DEMOTE DOOR (owner decision 2026-09-26): send a core memory back to
2528
+ * ordinary fading, and record why. Its fading restarts TODAY — it was held at
2529
+ * full strength until now, and "back to normal fading" should not mean a
2530
+ * collapse to whatever months of decay would have left. The demotion is
2531
+ * sticky: the core lanes do not promote it again (`coreDemoted`). The row
2532
+ * says who and why; a `band.demoted` event is the durable crossing record,
2533
+ * the mirror of `band.promoted`.
2534
+ */
2535
+ demoteCore(id: string, opts: { reason: string; actor?: string }): { ok: boolean; reason: string } {
2536
+ if (this.observer) return { ok: false, reason: "observer" };
2537
+ const reason = opts.reason.trim();
2538
+ if (reason.length === 0) return { ok: false, reason: "reason-required" };
2539
+ const row = this.store.row(id);
2540
+ if (row === undefined) return { ok: false, reason: "unknown-id" };
2541
+ if (row.promoted_identity !== 1) return { ok: false, reason: "not-core" };
2542
+ const day = this.store.livedDay();
2543
+ this.store.appendCoreEvent({ memoryId: id, action: "demoted", day, reason, actor: opts.actor ?? "owner" });
2544
+ this.store.updatePhysics(id, { promotedIdentity: false, lastUsedDay: Math.max(row.last_used_day, day) });
2545
+ const after = this.store.physicsOf(id);
2546
+ this.store.setBand(id, bandOf(after, day), day);
2547
+ this.store.appendEvent({
2548
+ name: "band.demoted",
2549
+ day,
2550
+ ref: id,
2551
+ payload: { kind: row.kind, day, actor: opts.actor ?? "owner" },
2552
+ });
2553
+ this.emit("counterpart.core.demoted", id, { day });
2554
+ return { ok: true, reason: "demoted" };
2555
+ }
2556
+
2269
2557
  // ── the self page ──────────────────────────────────────────────────────────
2270
2558
 
2271
2559
  /** The written page, or null while none has been written. A pure read. */
@@ -3543,13 +3831,17 @@ export class Counterpart {
3543
3831
  return { ...none(reason, result.gate), malformed: result.malformed };
3544
3832
  }
3545
3833
 
3546
- const proposal = result.proposal;
3834
+ const carry = this.carryReminder(result.proposal);
3835
+ const proposal = carry.proposal;
3547
3836
  const mint = mintProposal(this.store, proposal, {
3548
3837
  self: this.self,
3549
3838
  channel: "authored",
3550
3839
  ...(ctx.model === undefined ? {} : { model: ctx.model }),
3551
3840
  onEvent: (name, data) => this.emit(name, undefined, data),
3552
3841
  });
3842
+ // BEFORE the revision dispatch: a current-state target is superseded there,
3843
+ // and the date must leave the row while it is still the live one.
3844
+ const reminder = carry.from === null ? null : this.moveReminder(carry, mint.id);
3553
3845
  this.emit("counterpart.deposit", mint.id, {
3554
3846
  source,
3555
3847
  kind: proposal.kind,
@@ -3574,6 +3866,121 @@ export class Counterpart {
3574
3866
  mint,
3575
3867
  gate: null,
3576
3868
  covers: proposal.covers,
3869
+ ...(reminder === null ? {} : { reminder }),
3870
+ };
3871
+ }
3872
+
3873
+ /**
3874
+ * A REVISION OWNS THE REMINDER (review N7, 2026-09-26). A `note` or a
3875
+ * `session_end` entry that revises a DATED memory (`updates:`) and leaves the
3876
+ * date out would otherwise mint an undated successor — and because a revision
3877
+ * of an ordinary memory is link-only (`revision.ts`), the old row would keep
3878
+ * its date and keep coming back beside the new one; a reschedule would leave
3879
+ * the old day firing too. So, field by field: what the author sent wins,
3880
+ * `eventDate: null` drops the date, and anything left out is carried over from
3881
+ * the memory being revised. `moveReminder` then clears the old row's date.
3882
+ *
3883
+ * Only for an address the AUTHOR declared and the store resolved (`declared`).
3884
+ * A content match is the engine's guess, and moving a date off a guessed row
3885
+ * would be a wrong write; leaving it where it is loses nothing. The sweep
3886
+ * builds its proposals without a `dateIntent`, so it carries nothing either
3887
+ * (it never dates a memory — `applySweep`).
3888
+ *
3889
+ * The reminder is found where it NOW lives (`reminderHolder`): the old id
3890
+ * stays live after a move, so "cancel it" or "it moved to the 20th" sent
3891
+ * against the id the model first saw must reach the memory holding the date,
3892
+ * not answer from a row whose date already left (review of #247). An
3893
+ * ARCHIVED holder carries nothing, as `revision.ts` refuses `target-archived`:
3894
+ * a reminder that faded or was put away is not revived onto a live row by a
3895
+ * revision that did not ask for it.
3896
+ */
3897
+ private carryReminder(p: Proposal): ReminderCarryPlan {
3898
+ const intent = p.dateIntent;
3899
+ const target = p.updates?.method === "declared" ? p.updates.resolved : null;
3900
+ const none: ReminderCarryPlan = { proposal: p, from: null, inherited: [] };
3901
+ if (intent === undefined || target === null) return none;
3902
+ const from = this.reminderHolder(target);
3903
+ // Nothing dated to carry or to move: the author's own fields stand as sent.
3904
+ if (from === null) return none;
3905
+ const priorDate = this.store.row(from)?.event_date ?? null;
3906
+ if (priorDate === null) return none;
3907
+ let priorMode: "plain" | "quiet" = "quiet";
3908
+ try {
3909
+ priorMode = cueModeOf(this.store.readProse(from));
3910
+ } catch {
3911
+ // Unreadable prose: the date still carries, at the default mode.
3912
+ }
3913
+ const eventDate =
3914
+ intent.eventDate === "set" ? p.eventDate : intent.eventDate === "cleared" ? null : priorDate;
3915
+ const remind = eventDate === null ? null : intent.remind ?? priorMode;
3916
+ const inherited: ("eventDate" | "remind")[] = [];
3917
+ if (eventDate !== null && intent.eventDate === "absent") inherited.push("eventDate");
3918
+ if (eventDate !== null && intent.remind === null) inherited.push("remind");
3919
+ return { proposal: { ...p, eventDate, remind, reminderFrom: from }, from, inherited };
3920
+ }
3921
+
3922
+ /**
3923
+ * The live memory holding the reminder `target` had: `target` itself when it
3924
+ * is dated, else the end of its `meta.reminderMovedTo` chain (each hop through
3925
+ * `Store#resolve`, since a holder can itself be superseded). Null when there
3926
+ * is none, when the chain reaches an archived or removed row, or when it runs
3927
+ * past `DATE_LINEAGE_MAX`.
3928
+ */
3929
+ private reminderHolder(target: string): string | null {
3930
+ let current = target;
3931
+ const seen = new Set<string>();
3932
+ for (let hop = 0; hop <= DATE_LINEAGE_MAX; hop++) {
3933
+ if (seen.has(current)) return null;
3934
+ seen.add(current);
3935
+ const row = this.store.row(current);
3936
+ if (row === undefined || row.archived === 1) return null;
3937
+ if (row.event_date !== null) return current;
3938
+ let next: unknown;
3939
+ try {
3940
+ next = this.store.readProse(current).meta[DATE_MOVED_TO_META];
3941
+ if (typeof next !== "string") return null;
3942
+ current = this.store.resolve(next);
3943
+ } catch {
3944
+ return null;
3945
+ }
3946
+ }
3947
+ return null;
3948
+ }
3949
+
3950
+ /**
3951
+ * The other half of `carryReminder`: the revised row's date is cleared, so the
3952
+ * reminder lives on exactly one memory — the newest. `Store#revise` keeps the
3953
+ * old date in the version it writes (constitution 7). A failed clear does not
3954
+ * fail a deposit that is already on disk; it is emitted and reported.
3955
+ */
3956
+ private moveReminder(carry: ReminderCarryPlan, successor: string): DepositReminder {
3957
+ const from = carry.from as string;
3958
+ let moved = false;
3959
+ try {
3960
+ // The forward pointer rides the same revise, so the clear and the address
3961
+ // it leaves behind land in one transaction or not at all.
3962
+ this.store.revise(from, {
3963
+ eventDate: null,
3964
+ meta: { [DATE_MOVED_TO_META]: successor },
3965
+ reason: "reminder-moved",
3966
+ });
3967
+ moved = true;
3968
+ } catch (err) {
3969
+ this.emit("counterpart.reminder.move.failed", from, { successor, error: errCode(err) });
3970
+ }
3971
+ this.emit("counterpart.reminder.moved", successor, {
3972
+ from,
3973
+ moved,
3974
+ eventDate: carry.proposal.eventDate,
3975
+ remind: carry.proposal.remind,
3976
+ inherited: carry.inherited.join(",") || null,
3977
+ });
3978
+ return {
3979
+ from,
3980
+ eventDate: carry.proposal.eventDate,
3981
+ remind: carry.proposal.remind,
3982
+ inherited: carry.inherited,
3983
+ moved,
3577
3984
  };
3578
3985
  }
3579
3986
 
@@ -3736,6 +4143,11 @@ export class Counterpart {
3736
4143
  aliases: [...accepted.aliases],
3737
4144
  updates,
3738
4145
  unresolved: accepted.unresolved,
4146
+ // The sweep never dates a memory: a reminder date is an explicit field
4147
+ // an AUTHOR writes, and the interpreter's retelling is not one (owner
4148
+ // decision 2026-09-25/26 — never infer a date from text).
4149
+ eventDate: null,
4150
+ remind: null,
3739
4151
  at: this.nowFn(),
3740
4152
  day,
3741
4153
  contentHash: accepted.contentHash,