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
@@ -30,20 +30,71 @@ export const TUNABLES = {
30
30
  // --- §5.2 strength ---
31
31
  /** Repetition credit per use [v0, verbatim]. */
32
32
  REP_PER_USE: 0.12,
33
- /** Repetition cap. With CONS_BONUS this tops out at 0.70, structurally below
34
- * THETA_ID = 0.85 — guarantee 4 is arithmetic, not a check [v0; v1 §10 G11]. */
33
+ /** Repetition cap [v0; v1 §10 G11]. Repetition is also no road to the
34
+ * identity band for any kind but `self`/`person` — guarantee 4, now a rule of
35
+ * `promotionEligibility` rather than a threshold (§5.3, 2026-09-26). */
35
36
  REP_CAP: 0.5,
36
- /** Consolidation bonus [v0, verbatim]. */
37
+ /**
38
+ * The one-time consolidation bonus [v0, verbatim] — now a LEGACY path
39
+ * (2026-09-26): only a memory born before schema v8 (`legacy`) can still be
40
+ * marked consolidated and carry it, so the upgrade moves nothing down. Every
41
+ * memory made since earns its durability from RETURNS (§5.11) instead.
42
+ */
37
43
  CONS_BONUS: 0.2,
38
44
 
39
45
  // --- §5.3 bands ---
40
46
  /** Semantic floor, evaluated on DECAYED strength (§5.3 rewrite). */
41
47
  THETA_SEM: 0.5,
42
- /** Identity floor, evaluated on `base` — one half of promotion eligibility. */
43
- THETA_ID: 0.85,
44
- /** Distinct lived days of reinforcement required to promote (owner ruling N = 3).
45
- * Same number, same ancestry, as the slow-kind revision pace (Amendment 15). */
46
- N_PROMOTION_DAYS: 3,
48
+
49
+ // --- §5.11 returns (owner decisions 2026-09-26 — WORKING DEFAULTS) ---
50
+ /**
51
+ * How spacing weighs a return: `1 - exp(-gap / RETURN_SPACING_DAYS)`, `gap`
52
+ * the lived days since the memory's previous counted return (or its birth).
53
+ * 7 gives 0.13 the next day, 0.35 after three, 0.63 after a week and 0.95
54
+ * after three weeks — full weight once forgetting has visibly started (a fact
55
+ * with S = 60 has lost ~11% by day 7). Harvested from #238's spacing credit,
56
+ * with its penalty DROPPED: this scales what a return adds to durability and
57
+ * nothing else — `uses`, `lastUsedDay` and the rep arm credit exactly as
58
+ * before, so close-together use never counts against a memory. CAL.
59
+ */
60
+ RETURN_SPACING_DAYS: 7,
61
+ /**
62
+ * How much the returns lengthen stability: `x (1 + RETURN_GAIN x ln(1 +
63
+ * returns))`. One full-weight return x1.69, three x2.39, ten x3.40 — each
64
+ * spaced return slows fading, with diminishing returns (the log), and never
65
+ * makes a memory immortal. 1 at zero returns, so no memory's curve moves at
66
+ * the upgrade. NOTES "Returns" has the 60-day simulation. CAL.
67
+ */
68
+ RETURN_GAIN: 1.0,
69
+ /** A dream replay counts as a return worth this fraction of an awake one
70
+ * (owner: "start ~0.5"), at most once per dream per memory. CAL. */
71
+ DREAM_RETURN_WEIGHT: 0.5,
72
+ /**
73
+ * The claimed-salience ceiling for a DREAMED memory (a dream's gist or
74
+ * pattern, source `dreamed`): below the semantic floor, so what a dream
75
+ * concludes starts lower than anything lived and rises only by proving true
76
+ * awake — used (the rep arm, returns) or confirmed. Above the
77
+ * `AUTHORED_DEFAULT_CLAIM` a silent note gets, so a gist is not prunable
78
+ * from birth, and below `THETA_SEM`. CAL.
79
+ */
80
+ DREAMED_CLAIM_CEILING: 0.3,
81
+
82
+ // --- §5.3 core lanes (owner decisions 2026-09-26 — WORKING DEFAULTS) ---
83
+ /** Fast lane: strongly felt — `emotionalIntensity` at or above this, his
84
+ * feeling or mine. CAL. */
85
+ CORE_FAST_FEELING: 0.6,
86
+ /** Fast lane: "and it has come back at least once after a gap" — an awake
87
+ * return at least this many lived days after the memory was made (2 = not
88
+ * the very next day). CAL. */
89
+ CORE_FAST_GAP_DAYS: 2,
90
+ /** Slow lane: awake returns on at least this many distinct lived days… CAL. */
91
+ CORE_SLOW_DAYS: 5,
92
+ /** …spanning at least this many lived days, first return to last. CAL. */
93
+ CORE_SLOW_SPAN_DAYS: 21,
94
+ /** …and standing at least this strong (decayed) on the day it is promoted:
95
+ * the semantic floor, so a faint memory does not become core on repetition
96
+ * alone (working default 2026-09-26, review of #251). CAL. */
97
+ CORE_SLOW_FLOOR: 0.5,
47
98
  /**
48
99
  * The salience-claim ceiling for a FALLBACK-minted memory (owner ruling
49
100
  * 2026-08-29, the authorship doctrine's salience half): the experiencer's own
@@ -53,8 +104,9 @@ export const TUNABLES = {
53
104
  * claim is CAPPED. The first blind replay showed why: 97.9% of sweep mints
54
105
  * self-claimed importance (mode 0.8), parking ~75% of the store above
55
106
  * THETA_SEM with no independent check (review F5). 0.6 clears the semantic
56
- * floor (a crashed day still matters) and sits structurally below THETA_ID.
57
- * WORKING DEFAULT — to be revisited against the re-run's watch metrics.
107
+ * floor (a crashed day still matters); identity is reached only through the
108
+ * core lanes (§5.3), never by a claim. WORKING DEFAULT — to be revisited
109
+ * against the re-run's watch metrics.
58
110
  */
59
111
  SWEEP_CLAIM_CEILING: 0.6,
60
112
  /**
@@ -105,6 +157,40 @@ export const TUNABLES = {
105
157
  /** CAL. Size of the nearest-neighbour slice in E(m) for novelty (v1's top-M). */
106
158
  K_NEAREST: 8,
107
159
 
160
+ // --- §5.10 emotion (owner decisions 2026-09-25/26 — WORKING DEFAULTS) ---
161
+ /**
162
+ * How much a memory's emotional intensity ADDS to its salience arm (§5.2):
163
+ * `clamp01(sal + EMO_LIFT x I)`. Before this, a 0.9 `emotional` on a note
164
+ * with no other dimensions read as mean 0.3 — the feeling averaged away by
165
+ * the claimed floor. 0.15 is chosen so the lift is felt but cannot on its
166
+ * own carry a silent note across a band: `AUTHORED_DEFAULT_CLAIM + EMO_LIFT
167
+ * = 0.40 < THETA_SEM` (a strong feeling alone does not make a silent note
168
+ * semantic at birth; use still has to). The lift is height only: identity
169
+ * reads the FEELING itself, in the core fast lane (§5.3, 2026-09-26), and
170
+ * only for memories about me or about us. NOTES.md "Emotion, part A" has
171
+ * the simulation. CAL.
172
+ */
173
+ EMO_LIFT: 0.15,
174
+ /**
175
+ * How much the same intensity slows decay: stability x (1 + EMO_SLOPE x I).
176
+ * At I = 0.9 that is x1.45 — a fact with S = 60 lived days gets S = 87. It
177
+ * changes decay on EXISTING stores (every row with an `emotional` score or a
178
+ * feeling), which is why it is modest: a strongly felt, never-used note
179
+ * reaches the prune floor after ~255 lived days instead of ~150. CAL.
180
+ */
181
+ EMO_SLOPE: 0.5,
182
+ /**
183
+ * How fast a recorded FEELING softens, in lived days: `strength x
184
+ * exp(-age / S_FEELING)`, age counted from the memory's birth day. 20 < 60 =
185
+ * S_BASE is the owner's "the feeling softens faster than the fact" as
186
+ * arithmetic: half the feeling is gone in ~14 lived days, while the fact
187
+ * itself is still at ~0.8 of its height. Softening is READ-SIDE ONLY — the
188
+ * table keeps the strength as recorded, and height and slope use that
189
+ * recorded peak; the softened value is what mood-matching and the displays
190
+ * read. CAL.
191
+ */
192
+ S_FEELING: 20,
193
+
108
194
  // --- §5.5 reinforcement ---
109
195
  /** Retrospective credit weights by tier. The ignorable tier never trains. */
110
196
  W_REFERENCED: 1.0,
@@ -402,17 +488,73 @@ export function cons(m: Pick<MemoryPhysics, "consolidated">): number {
402
488
  */
403
489
  export function base(m: MemoryPhysics): number {
404
490
  const k = kindPhysics(m.kind);
405
- return Math.max(k.wSal * sal(m.salience), k.wRep * rep(m)) + cons(m);
491
+ return Math.max(k.wSal * salArm(m), k.wRep * rep(m)) + cons(m);
406
492
  }
407
493
 
408
- /** Stability S, in lived days. kappa DIVIDES (§5.4). */
409
- export function stability(m: Pick<MemoryPhysics, "kind" | "uses">): number {
494
+ // ---------------------------------------------------------------------------
495
+ // §5.10 Emotion — height, slope, and the feeling that softens
496
+ // ---------------------------------------------------------------------------
497
+
498
+ /**
499
+ * I(m) — a memory's emotional intensity: the STRONGEST of its numeric
500
+ * `emotional` score and the recorded strengths of the feelings on it, whoever's
501
+ * they are (owner decision 2026-09-25/26: "how long a memory lasts follows the
502
+ * strongest feeling on it, his or mine"). A MAX, like `base`, so a lone strong
503
+ * feeling is never averaged down by quieter ones. 0 when there is neither.
504
+ */
505
+ export function emotionalIntensity(m: { salience: Salience; feelingPeak?: number | null | undefined }): number {
506
+ const peak = m.feelingPeak;
507
+ return Math.max(
508
+ clamp01(m.salience.emotional),
509
+ typeof peak === "number" && Number.isFinite(peak) ? clamp01(peak) : 0,
510
+ );
511
+ }
512
+
513
+ /**
514
+ * The salience ARM of `base`: `sal(m)` with the emotion ADDED on top of it.
515
+ * `sal()` itself stays v0's verbatim mean-with-floor — it is also what recall's
516
+ * turn gate (§9 G10) and `challengeForce` read, and neither may see this lift.
517
+ * The repetition arm gets no lift at all, so "repetition is capped below
518
+ * identity" (§3) is untouched.
519
+ */
520
+ export function salArm(m: Pick<MemoryPhysics, "salience" | "feelingPeak">): number {
521
+ return clamp01(sal(m.salience) + TUNABLES.EMO_LIFT * emotionalIntensity(m));
522
+ }
523
+
524
+ /**
525
+ * How a recorded feeling reads NOW — softened over the lived days since it was
526
+ * recorded. `ageDays` is lived days (the one clock); a negative or non-finite
527
+ * age reads as fresh. Never written back: the table keeps the strength as felt.
528
+ */
529
+ export function softenedFeeling(strength: number, ageDays: number): number {
530
+ const age = Number.isFinite(ageDays) ? Math.max(0, ageDays) : 0;
531
+ return clamp01(strength) * Math.exp(-age / TUNABLES.S_FEELING);
532
+ }
533
+
534
+ /**
535
+ * Stability S, in lived days. kappa DIVIDES (§5.4); emotion lengthens it
536
+ * (§5.10); spaced RETURNS lengthen it (§5.11) — a factor of exactly 1 at zero
537
+ * returns, so a memory that has never returned fades exactly as before.
538
+ */
539
+ export function stability(
540
+ m: Pick<MemoryPhysics, "kind" | "uses"> & Partial<Pick<MemoryPhysics, "salience" | "feelingPeak" | "returns">>,
541
+ ): number {
542
+ const felt = m.salience === undefined ? 0 : emotionalIntensity({ salience: m.salience, feelingPeak: m.feelingPeak });
410
543
  return (
411
- (TUNABLES.S_BASE * (1 + TUNABLES.BETA * Math.log(1 + Math.max(0, m.uses)))) /
544
+ (TUNABLES.S_BASE *
545
+ (1 + TUNABLES.BETA * Math.log(1 + Math.max(0, m.uses))) *
546
+ (1 + TUNABLES.EMO_SLOPE * felt) *
547
+ returnFactor(m.returns ?? 0)) /
412
548
  kindPhysics(m.kind).kappa
413
549
  );
414
550
  }
415
551
 
552
+ /** The returns' share of stability: `1 + RETURN_GAIN x ln(1 + returns)`. */
553
+ export function returnFactor(returns: number): number {
554
+ const r = Number.isFinite(returns) ? Math.max(0, returns) : 0;
555
+ return 1 + TUNABLES.RETURN_GAIN * Math.log(1 + r);
556
+ }
557
+
416
558
  /** The decay curve itself, over an elapsed lived-day interval. */
417
559
  export function decayCurve(
418
560
  elapsedDays: number,
@@ -467,50 +609,143 @@ export function band(m: MemoryPhysics, d: number, shape: DecayShape = TUNABLES.D
467
609
  return strength(m, d, shape) >= TUNABLES.THETA_SEM ? "semantic" : "episodic";
468
610
  }
469
611
 
612
+ // ---------------------------------------------------------------------------
613
+ // §5.3 Core — the two lanes into the identity band (2026-09-26)
614
+ // ---------------------------------------------------------------------------
615
+
616
+ /** Which lane carried a memory into the core. */
617
+ export type CoreLane = "fast" | "slow";
618
+
470
619
  export type PromotionReason =
471
620
  | "eligible"
472
621
  | "already-identity"
473
- | "base-below-identity-threshold"
474
- | "insufficient-distinct-days";
622
+ /** Not a memory about me or about us: only `self`, and `person` memories
623
+ * about the owner, may become core. Repetition alone makes nothing else
624
+ * identity, however often it returns (guarantee 4). */
625
+ | "not-about-me"
626
+ /** The owner sent it back to ordinary fading; the lanes do not re-promote it. */
627
+ | "demoted-by-owner"
628
+ /** About me, but neither lane is met yet (`fast` / `slow` say which part). */
629
+ | "no-lane-yet";
475
630
 
476
631
  export interface PromotionVerdict {
477
632
  eligible: boolean;
478
633
  /** The first blocking reason, or "eligible". */
479
634
  reason: PromotionReason;
480
- /** Every blocking reason — promotion needs ALL conditions, so all are reported. */
635
+ /** Every blocking reason. */
481
636
  blockedBy: PromotionReason[];
637
+ /** The lane that is met (fast first), or null. */
638
+ lane: CoreLane | null;
639
+ /** Fast lane: strongly felt AND it came back at least once after a gap. */
640
+ fast: {
641
+ readonly met: boolean;
642
+ readonly intensity: number;
643
+ readonly needIntensity: number;
644
+ /** Lived days from birth to the latest awake return; null when none. */
645
+ readonly gap: number | null;
646
+ readonly needGap: number;
647
+ };
648
+ /** Slow lane: awake returns on several distinct lived days over weeks. */
649
+ slow: {
650
+ readonly met: boolean;
651
+ readonly days: number;
652
+ readonly needDays: number;
653
+ /** Lived days from the first awake return to the last. */
654
+ readonly span: number;
655
+ readonly needSpan: number;
656
+ /** Decayed strength on `ctx.day` (null when no day was given) and the floor it must reach. */
657
+ readonly strength: number | null;
658
+ readonly needStrength: number;
659
+ };
660
+ /** `base` as it stands — carried for the record, never a threshold. */
482
661
  base: number;
483
- reinforcedDays: number;
484
- requiredDays: number;
485
- threshold: number;
662
+ /** Distinct lived days with a counted awake return. */
663
+ returnDays: number;
664
+ }
665
+
666
+ /** Who a memory is about, as the core lanes need it — decided by the caller,
667
+ * which can read the words and the owner's names (sleep's consolidate phase). */
668
+ export interface CoreContext {
669
+ /** Kind `self`, or a `person` memory about the owner. */
670
+ readonly aboutMe: boolean;
671
+ /** The owner demoted it (`counterparts core --demote`). */
672
+ readonly demoted?: boolean;
673
+ /**
674
+ * The lived day the verdict is for. With it, the SLOW lane also asks the
675
+ * memory to stand in the semantic band on that day (decayed strength at or
676
+ * above `THETA_SEM`): coming back on many days is not by itself a reason to
677
+ * be part of who I am when the memory is faint (working default, 2026-09-26,
678
+ * after the review of #251 saw six zero-salience `self` rows cross on
679
+ * repetition alone). `promote` always passes it; a reader that only wants
680
+ * the lane progress may leave it out.
681
+ */
682
+ readonly day?: number;
486
683
  }
487
684
 
488
685
  /**
489
- * Promotion eligibility (§5.3): `base >= THETA_ID` AND reinforcement on
490
- * >= N = 3 DISTINCT lived days. Evaluated at consolidation by `sleep/`.
491
- * Note it is `base`, not decayed strength: promotion is about what the memory
492
- * earned, not about how recently it was touched.
686
+ * Core eligibility (§5.3, owner decisions 2026-09-26). Only for memories about
687
+ * me or about us (`ctx.aboutMe`), and then by one of two lanes:
688
+ *
689
+ * - FAST: strongly felt (`emotionalIntensity >= CORE_FAST_FEELING`, either
690
+ * person's feeling) AND it has come back awake at least once, at least
691
+ * `CORE_FAST_GAP_DAYS` after it was made;
692
+ * - SLOW: not strongly felt, but it kept coming back organically — awake
693
+ * returns on `>= CORE_SLOW_DAYS` distinct lived days spanning
694
+ * `>= CORE_SLOW_SPAN_DAYS`.
695
+ *
696
+ * `base` is no longer read (the `promotionBase` stopgap of #244 is retired):
697
+ * emotion counts toward core ON PURPOSE, through the fast lane, and a dream's
698
+ * replays do not count toward either lane — a dream can nominate, only a lane
699
+ * promotes. Evaluated at consolidation by `sleep/`, which executes the crossing
700
+ * (and caps how many cross per night).
493
701
  */
494
- export function promotionEligibility(m: MemoryPhysics): PromotionVerdict {
495
- const b = base(m);
496
- const days = reinforcedDays(m);
702
+ export function promotionEligibility(m: MemoryPhysics, ctx: CoreContext): PromotionVerdict {
703
+ const intensity = emotionalIntensity(m);
704
+ const days = m.returnDays ?? 0;
705
+ const first = m.firstReturnDay ?? null;
706
+ const last = m.lastReturnDay ?? null;
707
+ const gap = last === null ? null : last - m.birthDay;
708
+ const span = first === null || last === null ? 0 : last - first;
709
+ const fastMet = intensity >= TUNABLES.CORE_FAST_FEELING && gap !== null && gap >= TUNABLES.CORE_FAST_GAP_DAYS;
710
+ const now = ctx.day === undefined ? null : strength(m, ctx.day);
711
+ const slowMet =
712
+ days >= TUNABLES.CORE_SLOW_DAYS &&
713
+ span >= TUNABLES.CORE_SLOW_SPAN_DAYS &&
714
+ (now === null || now >= TUNABLES.CORE_SLOW_FLOOR);
497
715
  const blockedBy: PromotionReason[] = [];
498
716
  if (m.promotedIdentity) blockedBy.push("already-identity");
499
- if (b < TUNABLES.THETA_ID) blockedBy.push("base-below-identity-threshold");
500
- if (days < TUNABLES.N_PROMOTION_DAYS) blockedBy.push("insufficient-distinct-days");
717
+ if (!ctx.aboutMe) blockedBy.push("not-about-me");
718
+ if (ctx.demoted === true) blockedBy.push("demoted-by-owner");
719
+ if (!fastMet && !slowMet) blockedBy.push("no-lane-yet");
501
720
  return {
502
721
  eligible: blockedBy.length === 0,
503
722
  reason: blockedBy[0] ?? "eligible",
504
723
  blockedBy,
505
- base: b,
506
- reinforcedDays: days,
507
- requiredDays: TUNABLES.N_PROMOTION_DAYS,
508
- threshold: TUNABLES.THETA_ID,
724
+ lane: fastMet ? "fast" : slowMet ? "slow" : null,
725
+ fast: {
726
+ met: fastMet,
727
+ intensity,
728
+ needIntensity: TUNABLES.CORE_FAST_FEELING,
729
+ gap,
730
+ needGap: TUNABLES.CORE_FAST_GAP_DAYS,
731
+ },
732
+ slow: {
733
+ met: slowMet,
734
+ days,
735
+ needDays: TUNABLES.CORE_SLOW_DAYS,
736
+ span,
737
+ needSpan: TUNABLES.CORE_SLOW_SPAN_DAYS,
738
+ strength: now,
739
+ needStrength: TUNABLES.CORE_SLOW_FLOOR,
740
+ },
741
+ base: base(m),
742
+ returnDays: days,
509
743
  };
510
744
  }
511
745
 
512
746
  export type ConsolidationReason =
513
747
  | "eligible"
748
+ | "not-legacy"
514
749
  | "already-consolidated"
515
750
  | "archived"
516
751
  | "born-today"
@@ -527,20 +762,18 @@ export interface ConsolidationVerdict {
527
762
  }
528
763
 
529
764
  /**
530
- * Consolidation eligibility (SEAMS item M), mirroring `promotionEligibility`:
531
- * a memory that has survived at least one lived day past its birth and now sits
532
- * at or above the semantic floor is eligible. `consolidated` is worth
533
- * `+CONS_BONUS` to `base` for the rest of the memory's life (§5.2), so deciding
534
- * WHEN it turns on is arithmetic and belongs here — `sleep/` executes a crossing
535
- * it does not define, exactly as it does for promotion.
765
+ * THE LEGACY consolidation marking (SEAMS item M), kept for memories born
766
+ * before schema v8 and for them alone (`legacy`, 2026-09-26): a memory that
767
+ * survived at least one lived day past its birth and sits at or above the
768
+ * semantic floor is marked, worth `+CONS_BONUS` for the rest of its life. The
769
+ * upgrade leaves this path open for exactly the rows that had it, so no memory
770
+ * is marked later than it would have been — nothing drops a band or prunes
771
+ * sooner because of the upgrade. A memory made since the upgrade is refused
772
+ * `not-legacy`: returns (§5.11) are its road to staying strong.
536
773
  *
537
- * **There is deliberately NO reinforcement requirement.** "A formative one-shot
538
- * consolidates without repetition" is a property `base` protects with a `max`,
539
- * and a repetition gate here would quietly repeal it.
540
- *
541
- * Nothing consolidates on the day it was encoded, whatever it claims for itself:
542
- * sleep consolidates yesterday's experience. A memory already in the identity
543
- * band is past the semantic floor by definition and is not blocked by it.
774
+ * There is still deliberately NO reinforcement requirement on the legacy path
775
+ * ("a formative one-shot consolidates without repetition"). Nothing
776
+ * consolidates on the day it was encoded.
544
777
  */
545
778
  export function consolidationEligibility(
546
779
  m: MemoryPhysics,
@@ -550,6 +783,7 @@ export function consolidationEligibility(
550
783
  ): ConsolidationVerdict {
551
784
  const b = band(m, d, shape);
552
785
  const blockedBy: ConsolidationReason[] = [];
786
+ if (m.legacy !== true) blockedBy.push("not-legacy");
553
787
  if (opts.archived === true) blockedBy.push("archived");
554
788
  if (m.consolidated) blockedBy.push("already-consolidated");
555
789
  if (d <= m.birthDay) blockedBy.push("born-today");
@@ -567,7 +801,11 @@ export interface PromotionCrossing {
567
801
  readonly event: "band.promoted";
568
802
  readonly day: number;
569
803
  readonly kind: Kind;
804
+ readonly lane: CoreLane;
570
805
  readonly base: number;
806
+ readonly intensity: number;
807
+ readonly returnDays: number;
808
+ /** Kept on the record for the readers that print it; now equals `returnDays`. */
571
809
  readonly reinforcedDays: number;
572
810
  }
573
811
 
@@ -580,9 +818,9 @@ export interface PromotionOutcome {
580
818
  next: Pick<MemoryPhysics, "promotedIdentity"> | null;
581
819
  }
582
820
 
583
- export function promote(m: MemoryPhysics, d: number): PromotionOutcome {
584
- const verdict = promotionEligibility(m);
585
- if (!verdict.eligible) return { promoted: false, verdict, crossing: null, next: null };
821
+ export function promote(m: MemoryPhysics, d: number, ctx: CoreContext): PromotionOutcome {
822
+ const verdict = promotionEligibility(m, { ...ctx, day: d });
823
+ if (!verdict.eligible || verdict.lane === null) return { promoted: false, verdict, crossing: null, next: null };
586
824
  return {
587
825
  promoted: true,
588
826
  verdict,
@@ -590,13 +828,144 @@ export function promote(m: MemoryPhysics, d: number): PromotionOutcome {
590
828
  event: "band.promoted",
591
829
  day: d,
592
830
  kind: m.kind,
831
+ lane: verdict.lane,
593
832
  base: verdict.base,
594
- reinforcedDays: verdict.reinforcedDays,
833
+ intensity: verdict.fast.intensity,
834
+ returnDays: verdict.returnDays,
835
+ reinforcedDays: verdict.returnDays,
595
836
  },
596
837
  next: { promotedIdentity: true },
597
838
  };
598
839
  }
599
840
 
841
+ // ---------------------------------------------------------------------------
842
+ // §5.11 Returns — durability from coming back
843
+ // ---------------------------------------------------------------------------
844
+
845
+ export type ReturnSource = "awake" | "dream";
846
+
847
+ export type ReturnReason =
848
+ | "counted"
849
+ /** Shown in the wake's hints lane when it was used: the display may have
850
+ * prompted the use, and counting it is the rich-get-richer loop (#238). */
851
+ | "on-display"
852
+ | "birth-day"
853
+ /** An awake credit below full weight (surfaced, not used): not a return. */
854
+ | "not-referenced"
855
+ /** An awake return already counted this lived day (or later); for a dream
856
+ * replay, a return of either kind. */
857
+ | "already-returned-today"
858
+ /** A dream replay within `RETURN_SPACING_DAYS` of the memory's last one. */
859
+ | "dream-spaced"
860
+ | "ignorable-tier";
861
+
862
+ export interface ReturnOutcome {
863
+ counted: boolean;
864
+ reason: ReturnReason;
865
+ source: ReturnSource;
866
+ /** Lived days since the previous counted return (or birth). */
867
+ gap: number;
868
+ /** What it added to `returns`: the source's weight x `spacingWeight(gap)`. */
869
+ weight: number;
870
+ next: {
871
+ returns: number;
872
+ returnDays: number;
873
+ firstReturnDay: number | null;
874
+ lastReturnDay: number | null;
875
+ lastDreamDay: number | null;
876
+ };
877
+ }
878
+
879
+ /** How spacing weighs a return: `1 - exp(-gap / RETURN_SPACING_DAYS)`, 0 for no gap. */
880
+ export function spacingWeight(gap: number): number {
881
+ if (!Number.isFinite(gap) || gap <= 0) return 0;
882
+ return 1 - Math.exp(-gap / TUNABLES.RETURN_SPACING_DAYS);
883
+ }
884
+
885
+ /** The lived day spacing is measured from: the last counted return of either
886
+ * kind, or the birth day when there has been none. */
887
+ export function lastReturnAnchor(m: Pick<MemoryPhysics, "birthDay" | "lastReturnDay" | "lastDreamDay">): number {
888
+ return Math.max(m.birthDay, m.lastReturnDay ?? -Infinity, m.lastDreamDay ?? -Infinity);
889
+ }
890
+
891
+ /**
892
+ * One RETURN (§5.11, owner decisions 2026-09-26): a credited organic use on a
893
+ * lived day after the memory's previous counted return (awake), or a dream
894
+ * replay (at `DREAM_RETURN_WEIGHT`). Its weight is spacing-scaled, so returns
895
+ * close together count less — and NEVER against: this adds to `returns` and
896
+ * nothing else, and it is computed BESIDE `creditUse`, which is unchanged.
897
+ *
898
+ * An awake return is refused `on-display` when the memory was showing in the
899
+ * wake's hints lane: the use still credits (`creditUse`), but it buys no
900
+ * durability and no lane day, because the display may have prompted it.
901
+ * `tierWeight` is the credited use's §5.5 weight; only a full-weight
902
+ * (referenced) use is a return at all — a memory surfaced and left unused did
903
+ * not come back, it was offered.
904
+ */
905
+ export function creditReturn(
906
+ m: MemoryPhysics,
907
+ d: number,
908
+ opts: {
909
+ source: ReturnSource;
910
+ tierWeight?: number;
911
+ onDisplay?: boolean;
912
+ /**
913
+ * The last lived day of a return the physics fields do not carry — the
914
+ * LEGACY returns the v8 upgrade credited for a memory's pre-upgrade
915
+ * reinforcement days (`store/operational.ts`). Spacing is measured from it
916
+ * too; the lanes never read it.
917
+ */
918
+ since?: number | null;
919
+ },
920
+ ): ReturnOutcome {
921
+ const unchanged = {
922
+ returns: m.returns ?? 0,
923
+ returnDays: m.returnDays ?? 0,
924
+ firstReturnDay: m.firstReturnDay ?? null,
925
+ lastReturnDay: m.lastReturnDay ?? null,
926
+ lastDreamDay: m.lastDreamDay ?? null,
927
+ };
928
+ const gap = d - Math.max(lastReturnAnchor(m), opts.since ?? -Infinity);
929
+ const refuse = (reason: ReturnReason): ReturnOutcome => ({
930
+ counted: false,
931
+ reason,
932
+ source: opts.source,
933
+ gap,
934
+ weight: 0,
935
+ next: unchanged,
936
+ });
937
+ const tier = opts.source === "dream" ? TUNABLES.DREAM_RETURN_WEIGHT : (opts.tierWeight ?? TUNABLES.W_REFERENCED);
938
+ if (tier <= 0) return refuse("ignorable-tier");
939
+ if (opts.source === "awake" && tier < TUNABLES.W_REFERENCED) return refuse("not-referenced");
940
+ if (d <= m.birthDay) return refuse("birth-day");
941
+ if (opts.source === "awake" && opts.onDisplay === true) return refuse("on-display");
942
+ // "Already today" is asked of the SAME kind of return for an awake one: a
943
+ // dream that replayed the memory earlier this lived day (the ask comes
944
+ // mid-session, and the day goes on) takes the spacing — the awake return
945
+ // adds nothing to `returns` — but it must not take the lane day an organic
946
+ // return earns. A dream is refused against either kind, as before.
947
+ // (Adversarial review of #251, 2026-09-26.)
948
+ const sameKindGap = opts.source === "awake" ? d - Math.max(m.birthDay, m.lastReturnDay ?? -Infinity) : gap;
949
+ if (sameKindGap <= 0) return refuse("already-returned-today");
950
+ // A DREAM FOLLOWS SPACING (working default 2026-09-26, review of #251): a
951
+ // replay counts at most once every `RETURN_SPACING_DAYS` per memory, so a
952
+ // memory that sits in every night's bundle cannot outgrow one that comes
953
+ // back awake every week.
954
+ if (opts.source === "dream" && m.lastDreamDay !== null && m.lastDreamDay !== undefined && d - m.lastDreamDay < TUNABLES.RETURN_SPACING_DAYS) {
955
+ return refuse("dream-spaced");
956
+ }
957
+ const weight = (opts.source === "dream" ? tier : 1) * spacingWeight(gap);
958
+ const next = { ...unchanged, returns: unchanged.returns + weight };
959
+ if (opts.source === "dream") {
960
+ next.lastDreamDay = d;
961
+ } else {
962
+ next.lastReturnDay = d;
963
+ next.returnDays = unchanged.returnDays + 1;
964
+ if (next.firstReturnDay === null) next.firstReturnDay = d;
965
+ }
966
+ return { counted: true, reason: "counted", source: opts.source, gap, weight, next };
967
+ }
968
+
600
969
  // ---------------------------------------------------------------------------
601
970
  // Guarantee 12 — the symmetry counter (scar §2.10)
602
971
  // ---------------------------------------------------------------------------
@@ -21,6 +21,19 @@ clothes. **Hold debts, lose deadlines.**
21
21
  turning to June is treated exactly like the user saying "Portland": one more cue into the
22
22
  same activation → gate → tier competition, under the same floors, refractory, dedup, and
23
23
  footnote-first tiering as everything else.
24
+ **One named exception, by the owner's decision (2026-09-25/26, a working default, not a
25
+ rule): a PLAIN item.** When the author of a dated memory marks it `remind: "plain"` —
26
+ because the person said "don't let me forget", or it is a real deadline — it is *also*
27
+ said outright on its day: one line to the person (the host's terminal) and the same line
28
+ to the model, at most once per beat (a day item on its day; a month or range the first
29
+ day it is seen open and again on its last day). That is a bypass lane on purpose, and it
30
+ is bounded like one: no salience floor (it was asked for), but never under observer,
31
+ never for an archived, superseded, removed or journal row, never for a year, and never
32
+ twice for the same beat (`Prospective.plainDue` / `claimPlain`), and a beat is claimed
33
+ only by a host about to show it (the Claude Code hooks claim after the envelope is known
34
+ to carry the line, 2026-09-26 review). Quiet — the default —
35
+ is everything above, unchanged. A plain item told today is not also offered as a quiet
36
+ cue that day (`told-plainly-today`).
24
37
  - **Prospectivity is DERIVED, never stored.** [v1] §12 G2 — eligibility is a predicate over
25
38
  the event date, the encode date, salience, and flags, so the property expires by itself
26
39
  when the window passes: no cleanup pass, no second source of truth, nothing for decay to
@@ -33,8 +46,18 @@ clothes. **Hold debts, lose deadlines.**
33
46
  `derive`'s seven call sites. Found by adversarial review when a dated chapter rendered
34
47
  in the wake's horizon lane as a thing about to happen.
35
48
  **A missing encode date fails conservatively.** [v1] §12 G3.
49
+ **An explicit date is its own importance signal** (owner decision 2026-09-26, a working
50
+ default): a memory whose author wrote its `eventDate` is exempt from the salience floor,
51
+ which now gates only a date a caller extracted. Decay is not exempted — a dated memory
52
+ faded to `FADED_STRENGTH` refuses as `faded` (G10) — and archived, skill and journal
53
+ still refuse.
36
54
  - **Precision is carried by the date's own format**, never rounded, and the ramp differs by
37
- precision — a stated month *means* early month more than the 29th. [v1] §12 G4.
55
+ precision — a stated month *means* early month more than the 29th. [v1] §12 G4. Since
56
+ 2026-09-26 there are four shapes (`core/time.ts`): a day, a month, a year (no window), and
57
+ a RANGE `a..b` — the author saying exactly which days, so it is at full intensity for the
58
+ whole span. The date is the `memories.event_date` column (schema v7), written by `note`
59
+ and `session_end` as an explicit field; nothing in this module or upstream of it reads a
60
+ date out of prose.
38
61
  - **A temporal cue alone reaches the footnote tier at most.** [v1] §12 G5.
39
62
  - **Once-ness has four independent brakes**: one ambient fire per occasion per lived day;
40
63
  a cap per window; session dedup; and — decisive — **once the assistant is observed to
@@ -85,14 +108,17 @@ clothes. **Hold debts, lose deadlines.**
85
108
  the cue and gate machinery of `recall/`; per-occasion firing history; the previous
86
109
  session's affect summary; the observer predicate.
87
110
  **Outputs** — at most a line or two on the session's horizon, framed *"remembered, not
88
- tasks"*, and/or a temporal cue fed into the ordinary turn-time pass; firing-state
89
- transitions; telemetry by reference.
111
+ tasks"* (day-dated items only, since 2026-09-26), and/or a temporal cue fed into the
112
+ ordinary turn-time pass; for a PLAIN item, a claimed record the host turns into one line on
113
+ its day (§3's named exception) — records, never words; firing-state transitions;
114
+ telemetry by reference.
90
115
 
91
116
  **Guarantees** — **[M]** mechanized, **[A]** advisory:
92
117
 
93
- 1. **[M] There is no bypass lane.** A temporal cue enters `recall/` through the same
94
- activation and gate path as any other cue; a test asserts no second injection path
95
- exists.
118
+ 1. **[M] There is no bypass lane for a quiet item.** A temporal cue enters `recall/`
119
+ through the same activation and gate path as any other cue; a test asserts no second
120
+ injection path exists. The plain lane (§3) is the one named exception, and this module
121
+ still holds no words for it — it hands out records, and a test asserts the exports.
96
122
  2. **[M] Eligibility is a pure predicate, computed at read time.** Nothing stores
97
123
  "prospective"; nothing has to clean it up.
98
124
  3. **[M] A missing or year-only encode date fails closed.**
@@ -135,3 +161,6 @@ admission criterion, with a named negative example) · **§2.17** (exit paths ar
135
161
  lane would be simpler and more brain-faithful.
136
162
  3. **What replaces `session dedup` if `recall/`'s per-session gate state is not persisted?**
137
163
  One of the four brakes depends on it — see `recall/` open question 1.
164
+ 4. **Is "plain" the right amount of loud?** (2026-09-26.) Once on the day, twice for a
165
+ month or range, only on the stated span — no lead-day warning, no nag when the day is
166
+ missed. The owner's first weeks of use answer it; nothing here measured it.