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
@@ -407,8 +407,27 @@ store property is the `VACUUM INTO`, and that is G19. The code's numbering wins.
407
407
  `feelings` row names `whose`, one of six cores, a wheel emotion or `other` with the
408
408
  word kept, a strength recorded once, and optionally the feeling on the same memory it
409
409
  sits beneath. A write is all-or-none and refused by name (`FEELING_INVALID`) rather
410
- than guessed; an unknown emotion is kept as `other`, never mapped. The owner's
411
- removal deletes them with the memory. They move no physics.
410
+ than guessed; an unknown emotion is kept as `other`, never mapped (a small ALIAS list
411
+ — `exposed` → `vulnerable` — reads as its wheel word and says so; a blend is stored
412
+ under its primary core). The owner's removal deletes them with the memory. *Since
413
+ 2026-09-26 (emotion part A) they move physics:* `row()` reads the strongest recorded
414
+ strength beside the row (`feeling_peak`, not a column), which physics folds into the
415
+ memory's emotional intensity (§5.10 there). The recorded strength is still never
416
+ rewritten. Reads for the rest: `feelingsSince(ms)` (recall's mood), `feelingsOn(ids)`
417
+ (one query for recall's candidates), `emotionCensus()` (counts for the mechanisms
418
+ views).
419
+ 23. **[M] Returns, what the wake showed, dreams and the core's history** (schema v8,
420
+ 2026-09-26). A credited use is also asked whether it is a RETURN (physics §5.11), in
421
+ the same transaction, with the one fact only the store holds — whether the memory was
422
+ showing in the wake's hints lane (`wake_display`); a return is a `returns` row, and
423
+ the aggregate columns on `memories` are recomputed FROM that table, never written
424
+ another way, so an undone dream's replays leave no trace. `legacy` marks every row
425
+ the v8 migration found (the old consolidation path stays theirs). A dream's rows
426
+ (`dreams`, `dream_changes`, `dream_asks`) hold ids and numbers, except the journal
427
+ and a reason, which are words. The owner's removal deletes a memory's returns,
428
+ display rows and core history, and blanks its address in a dream's change log. The
429
+ undo helpers are named for what they do (`restoreEdge`, `restoreSuperseded`,
430
+ `retract*`) — there is still no deletion verb on `Store`.
412
431
 
413
432
  ## 6. Scars honored
414
433
 
@@ -1556,6 +1556,26 @@ migration transaction and a fresh store has it from birth.
1556
1556
  - **Nothing reads them.** Salience, decay and recall are untouched; the `emotional`
1557
1557
  dimension and `meta.feeling` are exactly as before. `Counterpart#addFeelings` runs
1558
1558
  `carried_by` and an `other` word through `redactSecrets` first.
1559
+ *(Superseded 2026-09-26, emotion part A — see the next section.)*
1560
+
1561
+ ### Feelings are read (2026-09-26, emotion part A)
1562
+
1563
+ - **`row()` carries `feeling_peak`** — `(SELECT MAX(strength) FROM feelings WHERE
1564
+ memory_id = m.id)`, one probe of the `feelings_memory` index. Not a column and not on
1565
+ `MemoryRow` (the `Row` index type would reject an optional member); it is the
1566
+ `FeelingPeak` intersection on `row()`'s return, and `rowToPhysics` reads it as
1567
+ `feelingPeak`, null or absent reading as "no feeling". Every physics read goes through
1568
+ `row()` — `read`, `physicsOf`, sleep's phases, recall's scoring, the dashboard — so a
1569
+ feeling weighs the same everywhere. `rebuildCache`'s bare `SELECT *` reads no feeling,
1570
+ and needs none: it computes no strength.
1571
+ - **Suggestions** (`notices[].closest`) are now offered only for a near misspelling under
1572
+ the same core (`feelings-wheel.ts#closestKeys`), never the five nearest by raw edit
1573
+ distance — which offered "tender" bored, despair and lonely. An alias read is a notice
1574
+ with `readAs`; the `store.feelings` ring event's `other` count excludes it.
1575
+ - **Three reads added**: `feelingsSince(ms)` (feelings on LIVE memories recorded at or
1576
+ after a moment — recall's mood), `feelingsOn(ids)` (one query, chunked at 500 ids, with
1577
+ each memory's `birth_day` for softening), `emotionCensus({ sinceDay })` (live memories
1578
+ with feelings, and with intensity above 0 — counts only).
1559
1579
 
1560
1580
  ### What the adversarial review of #231 changed (2026-09-25)
1561
1581
 
@@ -1580,3 +1600,51 @@ The review is `docs/adversarial-review-v7-2026-09-25.md`.
1580
1600
  - **N9, accepted.** A 0.3.1 worker already mid-run during the upgrade keeps writing
1581
1601
  v6-shaped SQL until its watchdog ends it. Its `INSERT OR REPLACE` on edges leaves
1582
1602
  `created_at` NULL on the edges it touches. That is harmless and bounded.
1603
+
1604
+ ## 2026-09-26 — schema v8: returns, the wake's display, dreams, the core's history
1605
+
1606
+ *Owner decisions of 2026-09-26 (dreaming + consolidation). Additive, through the same
1607
+ copy-first seam as v7; an upgrade test (`test/store-v8.test.ts`) migrates a real v7 file
1608
+ (this build's store with every v8 column and table taken off, stamp 7) and checks nothing
1609
+ is lost and the schema equals a fresh v8's.*
1610
+
1611
+ - **`memories` gains six columns** through `ADDED_COLUMNS`, all with defaults that are the
1612
+ pre-v8 arithmetic exactly: `legacy` (0; the migration sets 1 on every row it finds),
1613
+ `returns` (0), `return_days` (0), `first_return_day`, `last_return_day`,
1614
+ `last_dream_day` (NULL). No SQL comment precedes the last column (v7's DROP COLUMN
1615
+ trap).
1616
+ - **Six tables**: `returns` (one row per counted return, PK memory × day × source; the
1617
+ history the aggregate is recomputed from), `wake_display` (the hints lane's current and
1618
+ first-ever showing per memory, and its habituation load), `dreams` (a dream, its state,
1619
+ the ids it was shown, its journal), `dream_changes` (every change, in order, with what
1620
+ undo needs), `dream_asks` (one row per calendar date: offered / declined), and
1621
+ `core_events` (promotions with their lane, demotions with the owner's reason, dream
1622
+ nominations with the dream's).
1623
+ - **The migration records what it found** in meta `physics.v8.upgrade` (from, lived day,
1624
+ rows, consolidated, identity) inside the same transaction; `sleep/upgrade.ts` measures
1625
+ the rest on the first decay pass. `OBSERVER_READ_FLOOR` rises to 8, as v7's did: on a
1626
+ v7 store doctor and the dashboard read "not initialized" until the next hook migrates.
1627
+ - **Why the aggregate is recomputed, not incremented**: a dream's replays can be undone
1628
+ and a merged memory carries its originals' return rows; an incremented column would
1629
+ drift from its own history the first time either happened.
1630
+ - **`reinforce` takes `{ cued }`**: a use recall surfaced on the turn's own cue is organic
1631
+ even while the memory shows in the hints lane (physics NOTES "Returns"). Every other
1632
+ caller lets the display decide.
1633
+ - **`vectorOf(id)`** reads one stored embedding (box 3), for a dream's neighbours.
1634
+
1635
+
1636
+ ### After the review of #251 (2026-09-26)
1637
+
1638
+ - **`creditLegacyReturns`**, in the v8 migrating transaction, turns each legacy row's
1639
+ reinforced days into `returns` rows of source `legacy` (physics NOTES).
1640
+ - `recomputeReturns` sums every source into `returns`, but counts lane days and
1641
+ first/last from `awake` rows only, so legacy credit never feeds a lane.
1642
+ - `returnCounts` and `fired` leave `legacy` out: it is history, not a firing.
1643
+ - The upgrade record carries `legacyReturns` (how many memories were credited), and
1644
+ its counts are of live memories.
1645
+ - **Removal redacts dream journals (Q6).** `chaseRemoved` redacts the title and entry of
1646
+ any dream that was shown the memory, changed it, or quotes it (its title, or a
1647
+ six-word run of its words).
1648
+ - The dream row, its date, state and change list stay.
1649
+ - The chase reports `operational.dreams` as neutralized when there were any.
1650
+ - The seam's exports stay pinned.
@@ -12,9 +12,16 @@
12
12
  * `carried_by` says briefly what in the moment carried it — the words, what
13
13
  * happened — and need not be a statement of feeling.
14
14
  *
15
- * Nothing reads these yet: salience, decay and recall are untouched (the
16
- * emotion build comes later), and the existing `emotional` dimension and the
17
- * `meta.feeling` label stay exactly as they were.
15
+ * READ SINCE 2026-09-26 (emotion part A). The strongest recorded strength on
16
+ * a memory joins its numeric `emotional` score as its emotional intensity,
17
+ * which lifts its height and slows its decay (physics §5.10, read beside the row
18
+ * by `Store.row()`); a feeling recorded in the last few hours sets the mood
19
+ * that recall matches against (recall G18). The `meta.feeling` label is still
20
+ * only a label.
21
+ *
22
+ * A BLEND (`tender`: sad + happy) may be named under either of its cores and is
23
+ * stored under its PRIMARY core — `core` holds one value, and anything that
24
+ * matches by core reads the blend as both (`feelings-wheel.ts#coresOfFeeling`).
18
25
  */
19
26
  import { CORE_EMOTIONS, OTHER_EMOTION, closestKeys, isCoreEmotion, resolveEmotion } from "../feelings-wheel.js";
20
27
  import type { CoreEmotion } from "../feelings-wheel.js";
@@ -64,12 +71,18 @@ export interface FeelingRow extends Row {
64
71
  updated_at: number;
65
72
  }
66
73
 
67
- /** A feeling stored as `other`: the word as given, and the wheel keys nearest it. */
74
+ /**
75
+ * What the caller should hear about one input: either it was stored as `other`
76
+ * (the word as given, and the wheel keys GENUINELY close to it — usually none),
77
+ * or, with `readAs`, the word was an alias and was stored as that wheel key.
78
+ */
68
79
  export interface FeelingNotice {
69
80
  readonly index: number;
70
81
  readonly word: string;
71
82
  readonly core: CoreEmotion;
72
83
  readonly closest: readonly string[];
84
+ /** Set when `word` was read as this wheel key (`exposed` → `vulnerable`). */
85
+ readonly readAs?: string;
73
86
  }
74
87
 
75
88
  export interface AddFeelingsResult {
@@ -129,6 +142,7 @@ export function checkFeelings(inputs: readonly FeelingInput[]): { rows: CheckedF
129
142
  }
130
143
  let emotion: string;
131
144
  let otherWord: string | null = null;
145
+ let storedCore: CoreEmotion = core;
132
146
  if (f.emotion.trim().toLowerCase() === OTHER_EMOTION) {
133
147
  const word = (f.otherWord ?? "").trim();
134
148
  if (word.length === 0) invalid(i, "other-word-missing");
@@ -142,9 +156,12 @@ export function checkFeelings(inputs: readonly FeelingInput[]): { rows: CheckedF
142
156
  }
143
157
  if (read.kind === "wheel") {
144
158
  emotion = read.entry.key;
159
+ // A blend named under its second core is stored under its primary.
160
+ storedCore = read.entry.core;
161
+ if (read.alias !== undefined) notices.push({ index: i, word: read.alias, core: storedCore, closest: [], readAs: read.entry.key });
145
162
  } else {
146
163
  // Not on the wheel: kept, as `other`, with the word — and the caller is
147
- // told the nearest keys so it can rewrite if it meant one of them.
164
+ // told of a wheel word only when one is genuinely close (a misspelling).
148
165
  emotion = OTHER_EMOTION;
149
166
  otherWord = read.kind === "other" ? read.word : f.emotion.trim();
150
167
  notices.push({ index: i, word: otherWord, core, closest: read.kind === "other" ? read.closest : [] });
@@ -160,7 +177,7 @@ export function checkFeelings(inputs: readonly FeelingInput[]): { rows: CheckedF
160
177
  }
161
178
  rows.push({
162
179
  whose: f.whose as FeelingWhose,
163
- core,
180
+ core: storedCore,
164
181
  emotion,
165
182
  otherWord,
166
183
  strength: f.strength,