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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,158 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.4 — 2026-09-26
4
+
5
+ Memories stay strong by coming back, the core is for what is about the two of you, and
6
+ Counterparts can dream. **The store's format changes (v7 → v8).** The first Claude Code
7
+ session after installing copies the store (as every upgrade since 0.3.1 has) and upgrades
8
+ it; until then `counterparts doctor` says (amber) that the next session will upgrade it,
9
+ and the dashboard asks you to open a session. Close every session before installing, and
10
+ run `/mcp` → Reconnect in any you missed.
11
+
12
+ Staying strong.
13
+
14
+ - **A memory that comes back fades more slowly.** Each time a memory is used again on a
15
+ later day, it gets harder to lose — a lot after a week or more, a little the next day,
16
+ and never less than before. This replaces the one-time bonus a memory used to get for
17
+ surviving its first day.
18
+ - **Nothing you already have moves down.** Every memory in your store keeps the old
19
+ bonus path exactly, so no memory drops a band or will be let go sooner because of the
20
+ upgrade. The first sleep after the upgrade checks this on every memory, and `doctor`
21
+ prints what it found (an "Upgrade" line).
22
+ - **The days a memory was already used count as coming back.** At the upgrade, every
23
+ day a memory was used before counts toward fading more slowly. A memory the old rules
24
+ were about to make core but the new ones do not (a well-used fact, say) stays strong
25
+ that way instead, and `doctor`'s Upgrade line says how many there were.
26
+ - **"Nearby, if it helps" takes turns.** The wake's "Nearby" lane no longer shows the
27
+ same strong memory every day. A memory Claude uses because it was showing there still
28
+ counts as a use, but not as coming back; one shown a lot gives way for a while, and
29
+ returns to the lane over a few days.
30
+
31
+ The core.
32
+
33
+ - **Only memories about Claude, or about the two of you, become core** — kind `self`, and
34
+ memories about a person that name you. Facts, skills and places never do, however often
35
+ they come back.
36
+ - **Two ways in.** Strongly felt (by you or by Claude) and it came back at least once, a
37
+ couple of days later. Or it kept coming back — on five separate days over three weeks.
38
+ - **At most three a night**, strongest first; the rest wait for the next sleep.
39
+ - **You can send one back.** `counterparts core` lists the core (with how each got
40
+ there), what dreams nominated, and what you sent back; `counterparts core --demote <id>
41
+ --reason "..."` returns a memory to ordinary fading from today and keeps it out.
42
+
43
+ Dreaming.
44
+
45
+ - **Once a day, when there is something new, Claude may ask you "I haven't dreamed since
46
+ … — OK if I dream for a few minutes?"** at a natural moment. Say no and it will not
47
+ ask again that day. Say yes and a background agent replays what you lived since the
48
+ last dream beside what it resembles.
49
+ - **What a dream can do**: merge near-copies into one memory in better words (the
50
+ originals are kept), link memories that belong together, replay what matters (it
51
+ strengthens them a little), write down a pattern it notices (labelled "Dreamed", and
52
+ it starts weak until it proves true), flag two memories that disagree (Claude raises
53
+ them with you next session), record how an old feeling sits now, and nominate a
54
+ memory for the core. It cannot delete anything, change the self page, make anything
55
+ core, or rewrite a memory in place.
56
+ - **A dream journal.** Every dream keeps a journal entry, apart from your memories — a
57
+ dream is never remembered as something that happened. `counterparts dream` lists
58
+ them, `--show <id>` shows the journal and every change, and `--undo <id>` reverses a
59
+ whole dream. The dashboard's self page shows the journal and what each dream changed.
60
+
61
+ Seeing it.
62
+
63
+ - `counterparts mechanisms` and the dashboard: Consolidation now lights up on real
64
+ evidence (memories coming back, merges, memories becoming core); **Dreaming** is a new
65
+ light beside it; Gist is partly built (a dream's pattern). The self page shows what
66
+ became core lately and by which way, what you sent back, and what dreams nominated.
67
+ - `counterparts fired` has rows for returns, dream replays, dreams, dream changes, the
68
+ daily ask, demotions and the upgrade check.
69
+
70
+ **The dashboard's Memories tab, round 2.** One idea across the tab: brighter means held
71
+ more firmly. The map of everything held plots strength against age, marks the core with a
72
+ ★ and turns amber what would be let go within two weeks if it isn't used. Kinds are chips
73
+ in the list's filter row; each row shows a title, its date, the kind and its feelings, and
74
+ sorts newest or oldest first. A memory's card shows its strength curve, why it mattered,
75
+ the days it was used, its versions as one timeline, and the raw numbers under "details".
76
+
77
+ **The dashboard's Home tab, round 2.** One headline count, four small tiles (memories,
78
+ core with the closest candidate's progress, chapters, replaced), and the mechanism lights
79
+ as built, partly built or not built, with a new "waiting" ring for a mechanism that ran on
80
+ schedule with nothing to do. The dashboard and `counterparts mechanisms` now read the same
81
+ evidence for each light, so the two agree. Home's feed shows memory events only; the
82
+ housekeeping stays in the flow feed.
83
+
84
+ ## 0.3.3 — 2026-09-26
85
+
86
+ Reminders with dates, and feelings start to matter. The store's format is unchanged (still
87
+ v7), so there is no upgrade step; close every Claude Code session before installing, and
88
+ run `/mcp` → Reconnect in any you missed.
89
+
90
+ Reminders work.
91
+
92
+ - **A memory can carry a date, and it comes back around then.** `note` and each
93
+ `session_end` memory take an optional `eventDate`: a day `2026-10-15`, a month
94
+ `2026-10`, or a range `2026-10-20..2026-10-31` (how to say "late October"). Claude writes
95
+ the date itself; nothing is read out of the text, and a date that cannot be read is
96
+ refused with the shapes that can. A year alone is kept but never comes back on its own.
97
+ - **Plain or quiet.** Beside the date, `remind: "plain"` for something that really has to
98
+ happen — a deadline, an important day, or anything you say not to forget. On its day
99
+ you see it in the terminal (`Today: pay your taxes`) and Claude has it in context, once;
100
+ a month or a range is said on its first day and again on its last. Everything else is
101
+ quiet, the default: it can come back as a footnote around the date, at most twice.
102
+ Giving a memory a date is what makes it eligible, however ordinary the memory; one that
103
+ has faded away or been archived still never comes back.
104
+ - **A plain line is spent only when you can see it.** If the morning's wake is too full
105
+ for the terminal line, it waits for your first prompt instead of being used up unseen,
106
+ and the update notice never pushes it out.
107
+ - **A quiet reminder is not repeated every turn.** A footnote that came back spends one of
108
+ its two mentions, at most one a day. Month and range dates spread their warmth over the
109
+ first week instead of all landing on the 1st, keep their second mention for after the
110
+ dates pass, and never take one of the wake's two "Arriving" lines — those are for
111
+ day-dated things, and a tie goes to the one happening sooner.
112
+ - **The gauge shows it.** `counterparts mechanisms` and the dashboard's Prospective light
113
+ count dated memories held and reminders that came back this week, plain and quiet apart
114
+ (the dashboard adds today's). Grey only when nothing is dated.
115
+ - **Revising a dated memory keeps its date.** A revision (`updates:`) that leaves the date
116
+ or `remind` out carries them over, and the older memory stops coming back, so one
117
+ reminder is never said twice; `eventDate: null` drops the date. The reminder is found
118
+ where it moved even when a later revision names the older memory, and what was already
119
+ said or used for the same window still counts after the move.
120
+ - **A date that has already passed is kept, and the reply says it won't come back**, so a
121
+ wrong year can be caught when it is written.
122
+
123
+ **Feelings start to matter.** No change to the store's format.
124
+
125
+ - **A memory's strongest feeling holds it higher and makes it fade more slowly** — yours or
126
+ Claude's, or its emotional score if that is stronger. This changes how existing memories
127
+ fade too: the ones that carry feeling now last longer (a strongly felt note about 1.7
128
+ times as long before it is let go). The first nightly cleanup after upgrading may move a
129
+ few felt memories up a band. Feeling does not count toward becoming core: what it takes
130
+ to reach identity is unchanged.
131
+ - **A recorded feeling softens faster than the memory it sits on.** The feeling is kept as
132
+ it was recorded; the softened strength is what recall and the displays read.
133
+ - **Mood-matching.** When a feeling was recorded in the last few hours, memories that
134
+ carried the same feeling for the same person come to mind more easily, and the other
135
+ person's matching feelings help a little. It only helps a memory the conversation
136
+ already reached — it never brings up one on its own.
137
+ - **An emotional score given on its own is no longer ignored by the memory gate.**
138
+ - **More words on the feelings wheel**, from real use: grateful, curious, tender,
139
+ sheepish, relieved, moved, wistful, bittersweet, fond and intrigued (marked as
140
+ additions, not the poster's), and "exposed" reads as vulnerable. Blends count under
141
+ both their feelings (tender: sad and happy). A word that is not on the wheel is kept as
142
+ your own, and the reply suggests a wheel word only for a near misspelling — "tender" is
143
+ no longer offered "despair".
144
+ - **Showing it.** The dashboard's memory view and `counterparts ask --full` / `--id` show a
145
+ memory's feelings as `you: … · me: …`. The Emotion light on the dashboard and in
146
+ `counterparts mechanisms` now counts memories carrying feeling and turns where a mood
147
+ brought memories closer.
148
+
149
+ **The dashboard's Self tab, round 2.** Lighter: one line on top, with the explanations
150
+ behind a small `?`. Beside the page, a side column says when it was last rewritten, what
151
+ the page writer did on its last night, the version dots and how much of the wake it
152
+ takes. A version's changes open on a click, settling is one compact chart, the journal is
153
+ a strip of days, and the tab refreshes itself while it is open. The Health row says how
154
+ many days since the page was rewritten.
155
+
3
156
  ## 0.3.2 — 2026-09-25
4
157
 
5
158
  Dates and times follow your clock, and the store's format moves to v7.
@@ -22,7 +22,8 @@ code and the `NOTES.md` / `INTERFACE-GAPS.md` next to it.*
22
22
  | `self/` | autobiographical self | Identity documents, episodes, the wake briefing (v0's briefing, grown up). Governed: frozen self-reinforcement rules. |
23
23
  | `prospective/` | prospective memory | Future intentions, cued by time or context; fire / suppress / reference telemetry. |
24
24
  | `handoff/` | working context for a place | The per-directory handoff: where the work here stands, written as a field on the end-of-session ask, shown as a two-line pointer at the next wake in that directory, expiring in lived days. **Never a memory** — out of recall, out of credit, out of consolidation, out of identity. **Added 2026-09-20 (E1, spec §6.4 / §15 item 6).** |
25
- | `sleep/` | systems consolidation | Pure math on a cycle: decay tick (active-day clock), floor-pruning (real forgetting), re-render of the wake briefing. Zero standing model calls. |
25
+ | `sleep/` | systems consolidation | Pure math on a cycle: decay tick (active-day clock), floor-pruning (real forgetting), the core's two lanes (at most three a night), re-render of the wake briefing. Zero standing model calls. |
26
+ | `dream/` | sleep replay + REM | Dreaming: once a day, if the owner says yes, a background agent (the same model) replays what was lived since the last dream beside what it resembles — merges, links, replays, a pattern, a flagged contradiction, a softened feeling, a core nomination — each recorded for undo, with a dream journal kept apart from lived memory. The module holds the bookkeeping and the rules; the dreamer is the model. **Added 2026-09-26.** |
26
27
  | *(`time.ts`)* | — (a clock, not a memory) | The one module that converts: a moment (UTC ms from `store.now()`) to a person's local date or clock line, "today" in a zone, and calendar dates as said (day, month, year, range). A file, not a module; a test keeps hand-built dates out of `src/`. **Added 2026-09-25 (`docs/time.md`).** |
27
28
  | *(`feelings-wheel.ts`)* | — (a vocabulary) | The feelings wheel as a typed list: six cores, the middle and outer rings, valence, and the key scheme (`<core>.<word>` only for a word printed under two cores). Read by `store/` to validate the `feelings` table. **Added 2026-09-25.** |
28
29
  | *(observer)* | — (instrument stance) | **RESOLVED (owner, 2026-08-25): a MODE, not a module** — one predicate threaded through the core API, checked at the store seam. Spec moved to `docs/observer-mode.md`. |
@@ -36,7 +37,7 @@ input — does `encode` shrink to gates-and-tagging inside `remember`'s pipeline
36
37
  | adapter | job |
37
38
  |---|---|
38
39
  | `claude-code/` | Hooks: wake injection at session start, end-of-session remember, crash detection. The launch adapter. |
39
- | `mcp/` | Deliberate tools: note, recall, status — plus the Stop ask's two return channels, `session_end` (memories) and `chapter` (the episode's own journal, **added 2026-09-04**, because the ask named a door no adapter had built). |
40
+ | `mcp/` | Deliberate tools: note, recall, status — plus the Stop ask's two return channels, `session_end` (memories) and `chapter` (the episode's own journal, **added 2026-09-04**, because the ask named a door no adapter had built) — and `dream`, the dreamer's phases (**added 2026-09-26**). |
40
41
  | `cli/` | `counterparts` command: status, install, owner operations (delete, export, backup). |
41
42
  | `dashboard/` | The owner's window (constitution line 16): brain-view, revision stories, band/protected lists. Observer-mode by construction; minimal version ships DURING the parallel run. **Added 2026-08-25 (owner elevation).** |
42
43
  | `sessions.ts` | Not an adapter — a leaf both may import: the live-session registry a host's hooks write (`<dataDir>/sessions/`) and its tools read, so a tool launched without a session can bind to one that is real, live and in its project. Adapters stay leaves; this is the sibling they share instead of importing each other. **Added 2026-09-04**, because this host's MCP servers are launched from a static config and cannot be told which session they serve. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "counterparts",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "license": "MIT",
5
5
  "description": "Memory that turns AI tools into counterparts - a local-first, human-memory-modeled memory layer for AI.",
6
6
  "repository": {
@@ -1593,3 +1593,31 @@ What the build settled, beyond the CONTRACT section:
1593
1593
  - **Review of #231, S1 (2026-09-25):** the evening of the upgrade no longer turns doctor
1594
1594
  RED. The store holds a one-day-back date as the same lived day, and the migration
1595
1595
  clamps `lastActiveDate`; details are in store NOTES.
1596
+
1597
+ ## 2026-09-26 — plain reminders are claimed only once the envelope carries them (PR #243 review)
1598
+
1599
+ Plain reminder lines ("Today: pay your taxes") now go FIRST among the terminal notices,
1600
+ ahead of the doctor's red line, and are claimed only after `bin/hook.ts#deliverTurn` has
1601
+ probed the envelope and found room for them — the update notice's "mark only what is
1602
+ certainly leaving". The priority order above still holds for the notices that follow them.
1603
+ The reason for going first: the doctor's line returns at the next start, while a plain
1604
+ beat is spent once. A full wake (the ~9 KB case above) therefore defers the plain lines —
1605
+ unclaimed, and stripped from the model's copy too (`hooks.ts#withoutPlain`) — to the first
1606
+ prompt, whose envelope is small. When a plain line and the update notice do not fit
1607
+ together at a prompt, the update notice waits. Details: `docs/adversarial-review-pr243-2026-09-26.md`.
1608
+
1609
+ ## 2026-09-26 — the dream ask, and dream words tagged `dream`
1610
+
1611
+ - **The ask** rides `user-prompt-submit`'s context (the model's channel, like the quiet
1612
+ Stop ask), after the plain reminders: one line, at most once per calendar day across
1613
+ sessions (the store's `dream_asks` latch), never in the page writer's headless child,
1614
+ never under observer, never without a date. It asks the model to ask the owner at a
1615
+ natural moment. A contradiction a dream flagged is raised on the same channel, once.
1616
+ The line is claimed when composed; if the envelope ever dropped it, that day's ask is
1617
+ spent (dream INTERFACE-GAPS §2).
1618
+ - **The reader tags a block carrying `DREAM_MARK` as `dream`**, in either role and
1619
+ whoever wrote the entry — after the foreign and ritual refusals, before everything
1620
+ else. The case it exists for: a background agent's hand-back arrives in the PARENT's
1621
+ transcript as `isMeta`, origin `peer`, "Another Claude session sent a message:", which
1622
+ the reader otherwise keeps as `injected`. `test/dream.test.ts` drives that exact shape
1623
+ through parse, capture and the sweep: zero rows minted from the dream's words.
@@ -34,12 +34,13 @@ import {
34
34
  stanceOfMode,
35
35
  } from "../../scopes.js";
36
36
  import type { ScopeRead, ScopeVerdict } from "../../scopes.js";
37
- import { canonicalScope, readSession } from "../../sessions.js";
37
+ import { PAGE_WRITER_ENV, canonicalScope, readSession } from "../../sessions.js";
38
38
  import { resolveZone, todayIn } from "../../../core/time.js";
39
39
  import { loadConfig, withEmbedderDefault } from "../config.js";
40
40
  import type { AdapterConfig } from "../config.js";
41
41
  import { HOOKS, openAdapter } from "../index.js";
42
- import { STOP_HUMAN_LINE } from "../hooks.js";
42
+ import { STOP_HUMAN_LINE, plainLine, withoutPlain } from "../hooks.js";
43
+ import type { PlainReminder } from "../../../core/counterpart.js";
43
44
  import type { HookInput, HookName } from "../hooks.js";
44
45
  import {
45
46
  CONFIG_REFUSED,
@@ -393,6 +394,9 @@ export function toHookInput(
393
394
  // nothing (`hooks.ts#askAtStop`).
394
395
  ...(payload["stop_hook_active"] === true ? { reFired: true } : {}),
395
396
  ...(typeof payload["prompt"] === "string" ? { prompt: payload["prompt"] } : {}),
397
+ // The host-mode page writer's headless child (`page-writer.ts` sets this):
398
+ // no one reads its terminal, so it must not spend a plain reminder's beat.
399
+ ...(((opts.env ?? process.env)[PAGE_WRITER_ENV] ?? "").trim().length > 0 ? { pageWriter: true } : {}),
396
400
  // THE PERSON'S DAY (docs/time.md, 2026-09-25; UTC before). It dates the
397
401
  // hook's rows, the wake preface, the prospective "today" and the date the
398
402
  // boundary hands the lived clock — which is why the lived clock can see a
@@ -739,6 +743,11 @@ async function runHook(
739
743
  // AND THE UPDATE NOTICE AT A PROMPT (roadmap E, 2026-09-23), fail-open
740
744
  // (`deliverTurn`): once per session, when the MCP server this session talks
741
745
  // to runs an older build than this installed one.
746
+ //
747
+ // AND PLAIN REMINDERS (2026-09-26), at both events, FIRST — `deliverTurn`
748
+ // adds them from `result.plain` and claims them only once the envelope is
749
+ // known to carry them (2026-09-26 review): a plain beat is spent once and
750
+ // never comes back, while the doctor's line returns at the next start.
742
751
  const delivery = deliverTurn(
743
752
  name,
744
753
  result,
@@ -783,38 +792,92 @@ async function runHook(
783
792
  export interface UpdateNoticeDoors {
784
793
  updateNotice(input: HookInput): string | null;
785
794
  markUpdateNotice(input: HookInput): boolean;
795
+ /**
796
+ * Claim plain reminders this delivery is certainly about to show, returning
797
+ * the ones claimed (`ClaudeCodeAdapter#claimPlain`). Absent: nothing can be
798
+ * claimed, so nothing is shown and every one waits for a later turn.
799
+ */
800
+ claimPlain?(input: HookInput, due: readonly PlainReminder[]): readonly PlainReminder[];
786
801
  }
787
802
 
788
803
  /**
789
- * THIS EVENT'S OUTPUT, WITH THE UPDATE NOTICE FOLDED IN FAIL-OPEN (roadmap E;
790
- * #187 re-review, N4).
804
+ * THIS EVENT'S OUTPUT, WITH PLAIN REMINDERS AND THE UPDATE NOTICE FOLDED IN
805
+ * FAIL-OPEN (roadmap E; #187 re-review, N4; 2026-09-26 review).
791
806
  *
792
- * The plain delivery is computed first and is the answer whenever anything
793
- * about the notice goes wrong: a door that throws, a mark that will not land.
794
- * The notice is MARKED only once it is certainly leaving — after the envelope
795
- * is known to carry it — and SHOWN only if the mark landed, so it never repeats
796
- * and is never marked-but-lost; a turn whose recall leaves no room drops it,
797
- * marks nothing, and tries again next turn. Every event but
798
- * `user-prompt-submit` is exactly `hostDelivery`.
807
+ * PLAIN REMINDERS FIRST, and under the update notice's own rule — MARK ONLY
808
+ * WHAT IS CERTAINLY LEAVING. A plain beat is spent once and never comes back,
809
+ * so it is claimed only after the envelope is known to carry its line to the
810
+ * terminal, and it goes ahead of every other notice (the doctor's red line
811
+ * returns at the next start; the beat would not). A turn with no room — a full
812
+ * wake at SessionStart — claims nothing and strips the lines from the model's
813
+ * context too (`withoutPlain`), so the first prompt, whose envelope is small,
814
+ * says them instead. A line whose claim is lost to another process is stripped
815
+ * the same way.
816
+ *
817
+ * Then the update notice: the delivery without it is the answer whenever
818
+ * anything about it goes wrong — a door that throws, a mark that will not
819
+ * land, an envelope with no room for it — so it can never cost a line that
820
+ * already fit. It is MARKED only once it is certainly leaving and SHOWN only if
821
+ * the mark landed, so it never repeats and is never marked-but-lost; a turn
822
+ * whose recall leaves no room marks nothing and tries again next turn.
799
823
  */
800
824
  export function deliverTurn(
801
825
  name: HookName,
802
- result: { injection: string | null; ask: string | null },
826
+ result: {
827
+ injection: string | null;
828
+ ask: string | null;
829
+ notices?: readonly string[];
830
+ plain?: readonly PlainReminder[];
831
+ },
803
832
  payload: Record<string, unknown>,
804
- sessionStartNotices: readonly (string | null)[] | null,
833
+ /** SessionStart's priority-ordered notices (after any plain reminders), or
834
+ * null. At a prompt, null: the plain lines come from `result.plain`. */
835
+ notices: readonly (string | null)[] | null,
805
836
  doors: UpdateNoticeDoors,
806
837
  input: HookInput,
807
838
  ): Delivery {
808
- const plain = hostDelivery(name, result, payload, sessionStartNotices);
809
- if (name !== "user-prompt-submit") return plain;
839
+ let r = result;
840
+ let ordered = notices;
841
+ let deferred: Delivery["dropped"] = null;
842
+ const due = result.plain ?? [];
843
+ if (due.length > 0) {
844
+ // The longest run, in order, whose lines the envelope carries: a day with
845
+ // more plain items than room says what fits and keeps the rest for later.
846
+ let fits = 0;
847
+ for (let k = due.length; k > 0; k--) {
848
+ const probe = hostDelivery(name, r, payload, [due.slice(0, k).map(plainLine).join("\n")]);
849
+ if (probe.dropped === null) {
850
+ fits = k;
851
+ break;
852
+ }
853
+ if (k === due.length) deferred = probe.dropped;
854
+ }
855
+ let claimed: readonly PlainReminder[] = [];
856
+ if (fits > 0) {
857
+ try {
858
+ claimed = doors.claimPlain?.(input, due.slice(0, fits)) ?? [];
859
+ } catch {
860
+ claimed = [];
861
+ }
862
+ }
863
+ // By the beat's identity, not the object's: a door may hand back copies.
864
+ const beat = (x: PlainReminder): string => `${x.memoryId} ${x.windowKey} ${x.beat}`;
865
+ const kept = new Set(claimed.map(beat));
866
+ const shownPlain = due.filter((d) => kept.has(beat(d)));
867
+ r = withoutPlain(r, due.filter((d) => !kept.has(beat(d))));
868
+ if (shownPlain.length > 0) ordered = [shownPlain.map(plainLine).join("\n"), ...(notices ?? [])];
869
+ }
870
+ const shown = hostDelivery(name, r, payload, ordered);
871
+ const base = shown.dropped === null && deferred !== null ? { ...shown, dropped: deferred } : shown;
872
+ if (name !== "user-prompt-submit") return base;
810
873
  try {
811
874
  const update = doors.updateNotice(input);
812
- if (update === null) return plain;
813
- const carried = hostDelivery(name, result, payload, update);
814
- if (carried.dropped !== null) return carried;
815
- return doors.markUpdateNotice(input) ? carried : plain;
875
+ if (update === null) return base;
876
+ const carried = hostDelivery(name, r, payload, [...(ordered ?? []), update]);
877
+ if (carried.dropped !== null) return { ...base, dropped: base.dropped ?? carried.dropped };
878
+ return doors.markUpdateNotice(input) ? carried : base;
816
879
  } catch {
817
- return plain;
880
+ return base;
818
881
  }
819
882
  }
820
883
 
@@ -890,7 +953,7 @@ export function hostDelivery(
890
953
  * each is added only while the envelope still fits, so a lower line can never
891
954
  * cost a higher one its place. At a prompt the lines are ALL OR NOTHING —
892
955
  * joined into one `systemMessage`, or all dropped — which is what lets
893
- * `deliverTurn` mark only an envelope that carried them; today there is one.
956
+ * `deliverTurn` mark only an envelope that carried them; since 2026-09-26 that is plain reminders and the update notice.
894
957
  */
895
958
  notice: string | null | readonly (string | null)[] = null,
896
959
  ): Delivery {
@@ -935,7 +998,7 @@ export function hostDelivery(
935
998
  // no notice prints what it always has — plain text, or nothing. More than
936
999
  // one line would be JOINED into the one `systemMessage` an object carries,
937
1000
  // never one replacing another, and dropped all together or not at all —
938
- // not SessionStart's priority order; today the update notice is the only one.
1001
+ // not SessionStart's priority order; since 2026-09-26 the plain reminders and the update notice (`deliverTurn` tries the two together and falls back to the first alone).
939
1002
  if (name === "user-prompt-submit" && notices.length > 0) {
940
1003
  const message = notices.join("\n");
941
1004
  const envelope = JSON.stringify({
@@ -80,6 +80,13 @@ export const TUNABLES = {
80
80
  * own — and nothing here is at the Stop, where §13 G3's one pacer lives.
81
81
  */
82
82
  WRITE_UP_ASKS_PER_DAY: 2,
83
+ /**
84
+ * A plain reminder's handle — the memory's title or first line — is clipped
85
+ * to this many characters in the line a person reads (2026-09-26). One
86
+ * glance's worth: a longer title is a paragraph, and the memory's id rides
87
+ * beside it in the model's copy.
88
+ */
89
+ PLAIN_WHAT_MAX_CHARS: 120,
83
90
  /**
84
91
  * The host's cap on a hook's whole output, in characters. The host's own
85
92
  * words: "Hook output strings, including `additionalContext`, `systemMessage`,
@@ -2338,6 +2338,147 @@ export function journalCopyFindings(store: Store): Finding[] {
2338
2338
  * The reading is two row reads and a date comparison, so it sits with the cheap
2339
2339
  * groups rather than with `fired`.
2340
2340
  */
2341
+ /** The meta rows the v8 upgrade and its census write (`store/operational.ts`, `sleep/upgrade.ts`). */
2342
+ const V8_UPGRADE_META = "physics.v8.upgrade";
2343
+ const V8_CENSUS_META = "physics.v8.census";
2344
+
2345
+ function metaJson(store: Store, key: string): Record<string, unknown> | null {
2346
+ const raw = store.getMeta(key);
2347
+ if (raw === undefined) return null;
2348
+ try {
2349
+ const v: unknown = JSON.parse(raw);
2350
+ return v !== null && typeof v === "object" && !Array.isArray(v) ? (v as Record<string, unknown>) : {};
2351
+ } catch {
2352
+ return {};
2353
+ }
2354
+ }
2355
+
2356
+ function metaNum(v: unknown): number {
2357
+ return typeof v === "number" && Number.isFinite(v) ? v : 0;
2358
+ }
2359
+
2360
+ /**
2361
+ * DID THE v8 UPGRADE MOVE ANY MEMORY DOWN? (dreaming + consolidation,
2362
+ * 2026-09-26.) The migration marks every row it finds as keeping its old
2363
+ * consolidation path and records what it found; the first sleep after it
2364
+ * measures every memory by the old arithmetic and the new. Green when that
2365
+ * census says nothing changed band down, nothing got weaker and nothing prunes
2366
+ * sooner; amber while the census has not run yet; red if any memory moved
2367
+ * down — the one thing the upgrade promised not to do. A store born at v8 has
2368
+ * no upgrade record and gets no line.
2369
+ */
2370
+ export function upgradeV8Findings(store: Store): Finding[] {
2371
+ const upgrade = metaJson(store, V8_UPGRADE_META);
2372
+ if (upgrade === null) return [];
2373
+ const census = metaJson(store, V8_CENSUS_META);
2374
+ const from = typeof upgrade["from"] === "string" ? upgrade["from"] : String(upgrade["from"] ?? "?");
2375
+ const rows = metaNum(upgrade["rows"]);
2376
+ const kept = metaNum(upgrade["consolidated"]);
2377
+ const data: Record<string, string | number | boolean | null> = {
2378
+ from,
2379
+ rows,
2380
+ consolidated: kept,
2381
+ identity: metaNum(upgrade["identity"]),
2382
+ censused: census !== null,
2383
+ };
2384
+ if (census === null) {
2385
+ return [
2386
+ finding(
2387
+ "upgrade-v8",
2388
+ "amber",
2389
+ "Upgrade",
2390
+ `upgraded from schema v${from} to v8 (${String(rows)} memories kept their old consolidation path); the old-versus-new check has not run yet`,
2391
+ "Nothing to do: the next sleep measures it. counterparts doctor then says whether anything moved.",
2392
+ data,
2393
+ ),
2394
+ ];
2395
+ }
2396
+ const checked = metaNum(census["checked"]);
2397
+ const down = metaNum(census["bandDown"]);
2398
+ const weaker = metaNum(census["weaker"]);
2399
+ const sooner = metaNum(census["pruneSooner"]);
2400
+ const up = metaNum(census["bandUp"]);
2401
+ const measured = {
2402
+ ...data,
2403
+ checked,
2404
+ bandDown: down,
2405
+ bandUp: up,
2406
+ weaker,
2407
+ pruneSooner: sooner,
2408
+ pruneLater: metaNum(census["pruneLater"]),
2409
+ legacyConsolidated: metaNum(census["consolidated"]),
2410
+ v7WouldPromote: metaNum(census["v7WouldPromote"]),
2411
+ };
2412
+ // By construction the three down counts read zero: they compare each row
2413
+ // with itself, returns set aside, and returns are zero at the upgrade (the
2414
+ // arithmetic for existing rows is unchanged). The branch stays as the alarm
2415
+ // if that ever stops being true. (Adversarial review of #251.)
2416
+ if (down + weaker + sooner > 0) {
2417
+ return [
2418
+ finding(
2419
+ "upgrade-v8",
2420
+ "red",
2421
+ "Upgrade",
2422
+ `the v8 upgrade moved memories down: of ${String(checked)} checked, ${String(down)} changed band down, ${String(weaker)} got weaker, ${String(sooner)} would be let go sooner`,
2423
+ "Keep this store as it is and report it: the upgrade promised no memory would move down. The copy taken before it is in the snapshots directory.",
2424
+ measured,
2425
+ ),
2426
+ ];
2427
+ }
2428
+ // WHAT THE SELF-COMPARISON CANNOT SEE (review of #251): rows the old rules
2429
+ // were about to make core. The decision (working default 2026-09-26): they
2430
+ // are let go under the new rule — only memories about me or about us become
2431
+ // core — and take the DURABILITY route instead: the upgrade credited their
2432
+ // reinforcement days as returns, so they fade as slowly as that history
2433
+ // earns. Said, green: it is the design, not a fault.
2434
+ const road = metaNum(census["v7WouldPromote"]);
2435
+ const credited = metaNum(upgrade["legacyReturns"]);
2436
+ const roadLine =
2437
+ road > 0
2438
+ ? `; ${String(road)} ${road === 1 ? "was" : "were"} on the old road to the core and ${road === 1 ? "takes" : "take"} the durability route now (only memories about me or about us become core)`
2439
+ : "";
2440
+ const creditLine = credited > 0 ? `; ${String(credited)} had their reinforcement days counted as returns` : "";
2441
+ return [
2442
+ finding(
2443
+ "upgrade-v8",
2444
+ "green",
2445
+ "Upgrade",
2446
+ `Upgrade to v8: ${String(checked)} memories checked by the old arithmetic and the new; none changed band, none weaker, none prunes sooner; ${String(metaNum(census["consolidated"]))} kept their old consolidation${up > 0 ? `; ${String(up)} moved up a band` : ""}${creditLine}${roadLine}`,
2447
+ "",
2448
+ measured,
2449
+ ),
2450
+ ];
2451
+ }
2452
+
2453
+ /**
2454
+ * DREAMING, informational (2026-09-26): when the counterpart last dreamed, and
2455
+ * whether today's ask went out or was declined. Never amber: not dreaming is
2456
+ * the owner's choice, and a quiet week is not a fault.
2457
+ */
2458
+ export function dreamingFindings(input: DoctorInput, store: Store): Finding[] {
2459
+ let last: ReturnType<Store["dreams"]>[number] | undefined;
2460
+ let ask: ReturnType<Store["dreamAsk"]>;
2461
+ try {
2462
+ last = store.dreams({ limit: 5 }).find((d) => d.state !== "undone");
2463
+ ask = store.dreamAsk(input.today);
2464
+ } catch {
2465
+ return [];
2466
+ }
2467
+ const when = last === undefined ? null : (last.date ?? `lived day ${String(last.day)}`);
2468
+ const today =
2469
+ ask === undefined ? "not asked today" : ask.state === "declined" ? "asked today; the owner said not today" : "asked today";
2470
+ return [
2471
+ finding(
2472
+ "dreaming",
2473
+ "green",
2474
+ "Dreaming",
2475
+ `${when === null ? "has not dreamed yet" : `last dreamed ${when}${last?.title ? ` — "${last.title}"` : ""}`}; ${today}`,
2476
+ "",
2477
+ { last: when, dream: last?.id ?? null, ask: ask?.state ?? null },
2478
+ ),
2479
+ ];
2480
+ }
2481
+
2341
2482
  export function selfPageFindings(store: Store): Finding[] {
2342
2483
  const page = readSelfPage(store);
2343
2484
  if (page === null) {
@@ -2376,7 +2517,17 @@ export function selfPageFindings(store: Store): Finding[] {
2376
2517
  const detail =
2377
2518
  `${page.bytes} bytes, version ${page.version}, last revised ${page.revisedOn === "" ? "(unrecorded)" : page.revisedOn}` +
2378
2519
  `${page.by === null ? "" : ` by ${page.by}`}`;
2379
- const data = { present: true, bytes: page.bytes, version: page.version, revisedOn: page.revisedOn, stale };
2520
+ // The day count and the limit ride along so a surface can say it in words
2521
+ // ("not rewritten in 16 days") without re-deriving either (dashboard health).
2522
+ const data = {
2523
+ present: true,
2524
+ bytes: page.bytes,
2525
+ version: page.version,
2526
+ revisedOn: page.revisedOn,
2527
+ stale,
2528
+ daysSince: calendarDaysSince(page.revisedOn, store.today()),
2529
+ staleAfter: SELF_TUNABLES.PAGE_STALE_DAYS,
2530
+ };
2380
2531
  return [
2381
2532
  stale
2382
2533
  ? finding(
@@ -2561,12 +2712,18 @@ function clearedPage(
2561
2712
  * two are asserted to agree.
2562
2713
  */
2563
2714
  function pageStaleOn(revisedOn: string, today: string, limit: number): boolean {
2715
+ const days = calendarDaysSince(revisedOn, today);
2716
+ return days === null ? true : days > limit;
2717
+ }
2718
+
2719
+ /** Calendar days from `revisedOn` to `today`; null when either does not read. */
2720
+ function calendarDaysSince(revisedOn: string, today: string): number | null {
2564
2721
  const on = revisedOn.trim();
2565
- if (!/^\d{4}-\d{2}-\d{2}$/.test(on) || !/^\d{4}-\d{2}-\d{2}$/.test(today)) return true;
2722
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(on) || !/^\d{4}-\d{2}-\d{2}$/.test(today)) return null;
2566
2723
  const a = Date.parse(`${on}T00:00:00Z`);
2567
2724
  const b = Date.parse(`${today}T00:00:00Z`);
2568
- if (!Number.isFinite(a) || !Number.isFinite(b)) return true;
2569
- return Math.round((b - a) / 86_400_000) > limit;
2725
+ if (!Number.isFinite(a) || !Number.isFinite(b)) return null;
2726
+ return Math.round((b - a) / 86_400_000);
2570
2727
  }
2571
2728
 
2572
2729
  /**
@@ -3060,6 +3217,11 @@ export function doctorFindings(input: DoctorInput): Finding[] {
3060
3217
  // B3's week: one bounded read of the newest `remember.prune` row. Folds into
3061
3218
  // `Background` while green.
3062
3219
  ["retention", () => retentionFindings(input, store)],
3220
+ // The v8 upgrade's proof (2026-09-26): two meta reads. Silent on a store
3221
+ // born at v8. Folds into `Background` while green.
3222
+ ["upgrade-v8", () => upgradeV8Findings(store)],
3223
+ // Dreaming (2026-09-26): informational — last dreamed, and today's ask.
3224
+ ["dreaming", () => dreamingFindings(input, store)],
3063
3225
  // LAST, and deliberately: it is the widest read here — the whole event log,
3064
3226
  // plus a pass over the ids for the table probes — so when the console's
3065
3227
  // reading is cut short this is the group that goes, and the `Budget` finding