counterparts 0.3.11 → 0.3.13

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 (150) hide show
  1. package/CHANGELOG.md +326 -0
  2. package/docs/QUICKSTART.md +5 -0
  3. package/docs/README.md +2 -2
  4. package/docs/module-map.md +3 -3
  5. package/package.json +1 -1
  6. package/src/adapters/claude-code/CONTRACT.md +36 -10
  7. package/src/adapters/claude-code/INTERFACE-GAPS.md +116 -16
  8. package/src/adapters/claude-code/NOTES.md +182 -0
  9. package/src/adapters/claude-code/bin/hook.ts +46 -12
  10. package/src/adapters/claude-code/bin/runner.ts +7 -1
  11. package/src/adapters/claude-code/doctor.ts +632 -18
  12. package/src/adapters/claude-code/hooks.ts +61 -16
  13. package/src/adapters/claude-code/index.ts +11 -0
  14. package/src/adapters/claude-code/night-run.ts +150 -14
  15. package/src/adapters/claude-code/transcript.ts +268 -1
  16. package/src/adapters/cli/CONTRACT.md +5 -0
  17. package/src/adapters/cli/INTERFACE-GAPS.md +8 -4
  18. package/src/adapters/cli/NOTES.md +111 -0
  19. package/src/adapters/cli/commands.ts +134 -92
  20. package/src/adapters/cli/dream-core.ts +57 -42
  21. package/src/adapters/cli/export.ts +320 -21
  22. package/src/adapters/cli/help.ts +2 -1
  23. package/src/adapters/cli/index.ts +1 -0
  24. package/src/adapters/cli/install.ts +39 -7
  25. package/src/adapters/cli/mechanisms.ts +7 -1
  26. package/src/adapters/cli/uninstall.ts +13 -5
  27. package/src/adapters/cli/wire.ts +189 -63
  28. package/src/adapters/config.ts +2 -0
  29. package/src/adapters/dashboard/INTERFACE-GAPS.md +10 -1
  30. package/src/adapters/dashboard/NOTES.md +79 -0
  31. package/src/adapters/dashboard/registries.ts +34 -2
  32. package/src/adapters/dashboard/web/README.md +19 -14
  33. package/src/adapters/dashboard/web/actions.ts +23 -1
  34. package/src/adapters/dashboard/web/flow.ts +14 -0
  35. package/src/adapters/dashboard/web/lanes.ts +10 -0
  36. package/src/adapters/dashboard/web/narrate.ts +88 -2
  37. package/src/adapters/dashboard/web/pages/flow/sections/fired.js +1 -0
  38. package/src/adapters/dashboard/web/pages/health/sections/checks.js +2 -0
  39. package/src/adapters/dashboard/web/pages/health/sections/wake.js +3 -1
  40. package/src/adapters/dashboard/web/pages/memories/memories.css +17 -4
  41. package/src/adapters/dashboard/web/pages/memories/row.js +37 -21
  42. package/src/adapters/dashboard/web/pages/memories/sections/search.js +279 -60
  43. package/src/adapters/dashboard/web/pages/memories/state.js +2 -1
  44. package/src/adapters/dashboard/web/server.ts +0 -5
  45. package/src/adapters/dashboard/web/shared/memory-marks.css +7 -0
  46. package/src/adapters/dashboard/web/shared/memory-marks.js +33 -0
  47. package/src/adapters/dashboard/web/shared/memory-modal.js +5 -3
  48. package/src/adapters/dashboard/web/views/health.ts +21 -3
  49. package/src/adapters/dashboard/web/views/search.ts +4 -45
  50. package/src/adapters/dashboard/web/views.ts +2 -2
  51. package/src/adapters/fired.ts +430 -28
  52. package/src/adapters/host-wiring.ts +300 -0
  53. package/src/adapters/hosts.ts +11 -0
  54. package/src/adapters/lifecycle.ts +42 -2
  55. package/src/adapters/log/index.ts +9 -0
  56. package/src/adapters/mcp/CONTRACT.md +151 -11
  57. package/src/adapters/mcp/INTERFACE-GAPS.md +24 -2
  58. package/src/adapters/mcp/NOTES.md +313 -1
  59. package/src/adapters/mcp/bin/serve.ts +74 -1
  60. package/src/adapters/mcp/deliberate.ts +169 -651
  61. package/src/adapters/mcp/facts.ts +1094 -0
  62. package/src/adapters/mcp/index.ts +25 -7
  63. package/src/adapters/mcp/meaning.ts +1610 -0
  64. package/src/adapters/mcp/server.ts +835 -150
  65. package/src/adapters/mcp/stdio.ts +3 -1
  66. package/src/adapters/mcp/stood-down.ts +51 -0
  67. package/src/adapters/mcp/tools.ts +167 -41
  68. package/src/adapters/plugin-run.sh +133 -0
  69. package/src/adapters/plugin.ts +329 -0
  70. package/src/adapters/sessions.ts +18 -4
  71. package/src/core/associate/CONTRACT.md +2 -1
  72. package/src/core/associate/INTERFACE-GAPS.md +6 -1
  73. package/src/core/associate/NOTES.md +45 -0
  74. package/src/core/briefing.ts +12 -3
  75. package/src/core/contradictions.ts +184 -0
  76. package/src/core/counterpart.ts +797 -51
  77. package/src/core/dream/CONTRACT.md +36 -4
  78. package/src/core/dream/INTERFACE-GAPS.md +29 -6
  79. package/src/core/dream/NOTES.md +107 -0
  80. package/src/core/dream/feeling-weeks.ts +198 -0
  81. package/src/core/dream/index.ts +109 -18
  82. package/src/core/dream/reflect.ts +346 -87
  83. package/src/core/dream/tunables.ts +24 -4
  84. package/src/core/encode/INTERFACE-GAPS.md +3 -1
  85. package/src/core/encode/NOTES.md +7 -0
  86. package/src/core/encode/words.ts +45 -0
  87. package/src/core/fit/INTERFACE-GAPS.md +8 -2
  88. package/src/core/fit/NOTES.md +39 -1
  89. package/src/core/fit/index.ts +40 -0
  90. package/src/core/handoff/CONTRACT.md +37 -2
  91. package/src/core/handoff/INTERFACE-GAPS.md +10 -0
  92. package/src/core/handoff/NOTES.md +72 -0
  93. package/src/core/handoff/index.ts +214 -12
  94. package/src/core/handoff/last-here.ts +6 -4
  95. package/src/core/mint.ts +12 -2
  96. package/src/core/physics/CONTRACT.md +14 -2
  97. package/src/core/physics/NOTES.md +33 -1
  98. package/src/core/physics/index.ts +28 -5
  99. package/src/core/prospective/CONTRACT.md +45 -6
  100. package/src/core/prospective/INTERFACE-GAPS.md +4 -0
  101. package/src/core/prospective/NOTES.md +138 -0
  102. package/src/core/prospective/derive.ts +33 -5
  103. package/src/core/prospective/index.ts +90 -5
  104. package/src/core/prospective/windows.ts +72 -1
  105. package/src/core/recall/CONTRACT.md +31 -12
  106. package/src/core/recall/INTERFACE-GAPS.md +28 -4
  107. package/src/core/recall/NOTES.md +70 -1
  108. package/src/core/recall/feeling-ask.ts +10 -1
  109. package/src/core/recall/index.ts +3 -1
  110. package/src/core/recall/probe.ts +58 -0
  111. package/src/core/recall/session.ts +46 -2
  112. package/src/core/recall/time-ask.ts +487 -0
  113. package/src/core/remember/CONTRACT.md +4 -1
  114. package/src/core/remember/INTERFACE-GAPS.md +9 -1
  115. package/src/core/remember/NOTES.md +8 -0
  116. package/src/core/remember/proposals.ts +47 -5
  117. package/src/core/revision.ts +18 -1
  118. package/src/core/schemas/CONTRACT.md +21 -1
  119. package/src/core/schemas/INTERFACE-GAPS.md +20 -2
  120. package/src/core/schemas/NOTES.md +144 -0
  121. package/src/core/schemas/aliases.ts +55 -5
  122. package/src/core/schemas/index.ts +93 -1
  123. package/src/core/schemas/types.ts +2 -0
  124. package/src/core/self/CONTRACT.md +32 -5
  125. package/src/core/self/INTERFACE-GAPS.md +7 -2
  126. package/src/core/self/NOTES.md +102 -1
  127. package/src/core/self/behind.ts +43 -3
  128. package/src/core/self/briefing.ts +12 -2
  129. package/src/core/self/chapter-address.ts +254 -0
  130. package/src/core/self/episodes.ts +27 -0
  131. package/src/core/self/index.ts +83 -8
  132. package/src/core/self/page.ts +88 -0
  133. package/src/core/self/tunables.ts +5 -0
  134. package/src/core/self/work.ts +35 -2
  135. package/src/core/self/writer.ts +30 -0
  136. package/src/core/sleep/INTERFACE-GAPS.md +22 -3
  137. package/src/core/sleep/NOTES.md +20 -1
  138. package/src/core/sleep/consolidate.ts +59 -7
  139. package/src/core/sleep/index.ts +3 -0
  140. package/src/core/sleep/prune.ts +6 -2
  141. package/src/core/sleep/types.ts +7 -0
  142. package/src/core/store/CONTRACT.md +16 -0
  143. package/src/core/store/NOTES.md +66 -0
  144. package/src/core/store/feelings.ts +14 -1
  145. package/src/core/store/index.ts +483 -16
  146. package/src/core/store/operational.ts +95 -2
  147. package/src/core/store/owner-op-seam.ts +23 -0
  148. package/src/core/time.ts +152 -0
  149. package/tools/install-loop/run.sh +48 -12
  150. package/src/adapters/dashboard/web/pages/memories/fold.js +0 -53
@@ -9,6 +9,12 @@ the honest fix is, and where the proof lives. Written 2026-08-25 alongside
9
9
 
10
10
  ## 1. `recall/` has no deliberate mode — the tiering lives here
11
11
 
12
+ *(Noted 2026-10-09: the re-tiering below is retired. Since #323 (2026-10-03) a question
13
+ takes a `mode`, facts or meaning, each with its own ranking (`facts.ts`, `meaning.ts`),
14
+ and nothing in this adapter calls `Recall.build()`; `deliberate.ts` keeps the address
15
+ paths. The per-call override asked for below was never built, and this adapter no longer
16
+ needs it. Kept as written.)*
17
+
12
18
  **What exists.** `Recall.build()` is the pure half of the ambient path and is
13
19
  public precisely so it can be reused ("a private half is a promise, not a seam",
14
20
  `recall/index.ts`). It returns every candidate's verdict, so the information a
@@ -196,7 +202,8 @@ answers an exact TITLE with the whole body. So a session that named a memory and
196
202
 
197
203
  **Closed on the tool side, where the resolution happened.** `server.ts#noteHandleResolution`
198
204
  writes `<salted hash of the handle> → <resolved id>` to `adapters/expansions.ts`'s log, and
199
- `claude-code/hooks.ts#creditAtBoundary` translates the transcript's own handle with it
205
+ `claude-code/hooks.ts#creditAtBoundary` (in `adapters/lifecycle.ts` since #292,
206
+ 2026-09-30) translates the transcript's own handle with it
200
207
  before `creditReferences` sees the slice. `reference.ts` is unchanged and still resolves
201
208
  nothing; it is simply handed the address the tool reached.
202
209
 
@@ -328,7 +335,9 @@ JSON" was narrowed to what stays true: never without a notice, and never the doc
328
335
  migrates, and that is a hook, while the automatic snapshot runs only in the worker, after
329
336
  its own open, once a day. If a pre-migration copy is wanted, the place is the writer path
330
337
  of `openOperational`, just before the migrate transaction — a store decision, not this
331
- adapter's.
338
+ adapter's. *(CLOSED 2026-09-24 by #214, noted 2026-10-09: `openOperational`'s writer
339
+ path copies the store to `snapshots/<time>-pre-migration-…` before it migrates
340
+ (`store/pre-migration.ts`).)*
332
341
 
333
342
  ## 11. The page writer has no settle door — OPEN 2026-09-29
334
343
 
@@ -337,3 +346,16 @@ reflection (`reflect` phase `settle`), the owner (`counterparts settle`). The pa
337
346
  writes through `self_page`, which takes no settle; if it settles through `note`, the
338
347
  trail says the launching session. A `settle` on `self_page`, or a page-writer claim on
339
348
  `note`, would close it — neither is built until the writer is seen wanting one.
349
+
350
+ ## 12. Nobody reads how often the update guard fires — OPEN 2026-10-09
351
+
352
+ A held `updates` (`schemas/CONTRACT.md` §5 1b) leaves one durable `contradiction.held`
353
+ row: the two ids, the `how`, which reading decided (`meaning` or `words`), the cosine and
354
+ the shared-word count, the door, whether it was a write-up, and the session. The dashboard
355
+ narrates each row on the flow lane; nothing COUNTS them. `core/contradictions.ts#heldCorrections`
356
+ is the reader, written and tested and called by nobody: holds since a day, by which
357
+ reading, and how many the writer settled by hand afterwards (the guard's likely mistakes).
358
+ A doctor line — "N held this week, M settled after" — is the obvious caller; `doctor.ts`
359
+ belonged to another lane when the guard landed, so it was left for that lane to add. The
360
+ number to watch is `settledAfter / held`: high means the 0.30 bar holds back real
361
+ corrections, and it is the evidence for moving it.
@@ -1024,4 +1024,316 @@ the reminder's rule. Left out, a revision does not close anything. The result sa
1024
1024
  Review of #313: closing passes the revision step's checks first — a protected row refuses
1025
1025
  (`protected-refuses-revision`), an archived one (`target-archived`), and a session not the
1026
1026
  owner's closes nothing confidential (`confidential`) or written in another directory
1027
- (`other-directory`). The result says `thread: { closed: null, reason }`.
1027
+ (`other-directory`). The result says `thread: { closed: null, reason }`. (2026-10-02: such a
1028
+ refusal no longer settles the thread over either, and a Claude Code session is the owner's —
1029
+ see that day's note.)
1030
+
1031
+ ## 2026-10-02 — every result under one ceiling, and the net behind it
1032
+
1033
+ Claude Code saves a tool result past 50,000 characters (or 25,000 tokens) to a file and hands
1034
+ the model a 2 KB preview; the headless nightly run cannot open the file. On 10-01 and 10-02 the
1035
+ dream's begin and part 2 and the reflection's begin went that way, and the run went on thin.
1036
+ The caps now derive from `fit/TOOL_RESULT_CEILING` (40,000), and `withinCeiling`, the last step
1037
+ of `call`, measures every result as the host does (`structuredContent` serialized, by
1038
+ `wireChars`). Over it, the longest top-level string is cut to fit, a `cut` field says so, and
1039
+ one durable `mcp.result.oversize` row records the tool, the phase and the sizes. A margin and a
1040
+ stated cut, never a refusal. Each part a dream's or a reflection's bundle is handed in —
1041
+ part 1 being the begin — leaves an `mcp.part` row, so doctor's Tool results line can hold the
1042
+ parts a run was promised against the parts it fetched. `RECALL_ID_RESULT_CHARS` (56,000, counted
1043
+ over both copies) is ~28,000 per copy: under the ceiling, and left as it was.
1044
+
1045
+ After the adversarial review of #315: the net's cut is a FIXED target, searched by halving (the
1046
+ first version shrank its target each try and kept a fraction of the room for escaped text). The
1047
+ `mcp.part` row is written after the net, with the size that left and `cut`. Telemetry rows a
1048
+ READ leaves (a part, `mcp.recall`, the lookup ledger) go through `telemetry`, which puts the write
1049
+ guard's verdict back as it was: a lock met by the row is the row's loss, never the read's refusal.
1050
+ Write-up parts are sized by the larger of bytes and escaped wire cost, so none meets the net.
1051
+
1052
+ ## 2026-10-02 — `note` takes `feelingsNow` (lane B, owner pick 2)
1053
+
1054
+ - **Why `note` and not `session_end`.** The moment an old memory feels different is
1055
+ mid-session, when it comes up; `session_end` is one call at the end, long after. And
1056
+ `note` already acts on existing memories without writing one (`settle`, 2026-09-29), so
1057
+ `text` may be left out the same way — `feelings-now-only` — or sent with it, and both
1058
+ happen. Not a new tool.
1059
+ - **"Shown in this session"** is what this server process handed it (`seenHere`: the
1060
+ memories `recall` returned, the neighbours a write showed) and what ambient recall
1061
+ surfaced for the session (its gate record), when the session is known. There is no
1062
+ per-session record of the wake's memories; one shown only there is refused with the way
1063
+ in — read it with recall by id first. Loose by design: the bound is the shown set, not a
1064
+ refusal of a feeling.
1065
+ - The core is `Reflections#feelAgain`, the reflection's own path (`dream/NOTES.md`,
1066
+ 2026-10-02).
1067
+
1068
+ ### After the review of #316
1069
+
1070
+ - **Only what recall DELIVERED is shown** — the payload's memories, not the ids left
1071
+ `waiting` for room. A footnote or a link's pointer in ambient recall is a title, not
1072
+ the memory: only `tier: surfaced` rows count.
1073
+ - **Kept per session** (`seenBySession`, the newest 32): Desktop's one server serves many
1074
+ sessions, and a Claude Code process starts a new session on /clear. The key is the
1075
+ session the call is served as on Desktop, else the session the host is running now,
1076
+ else the bound one.
1077
+ - **An error only when nothing landed**: a note refused beside a feeling that was
1078
+ recorded is not an error — else the model resends and meets `once-a-day`.
1079
+
1080
+ ## 2026-10-02 — a stale server says so on every result
1081
+
1082
+ A server left open across an install keeps the tool list it loaded, so an argument the new
1083
+ version added (`note`'s `about`, `unresolved`) was dropped without a word until the host
1084
+ reconnected, and Desktop heard of the update only in `wake`. `withUpdateNotice` now adds an
1085
+ `updated` field to every result but `wake` (which keeps its own line) while this process's
1086
+ build differs from the package on disk, or a newer build has stamped the store's wake
1087
+ (`self.wake.build`). One manifest read and one meta read per call. It is forward-looking: a
1088
+ server from before this change (0.3.10, 0.3.11) left open says nothing.
1089
+
1090
+ ## 2026-10-02 — the owner's own sessions are the owner (owner ruling)
1091
+
1092
+ Claude Code's memory server started without `COUNTERPARTS_OWNER` — no install sets it — so it
1093
+ was a guest while its hooks and worker, reading the configuration's `owner: true`, were the
1094
+ owner. Closing an `unresolved` thread from another directory was refused `other-directory`,
1095
+ and the same deposit's settle took the thread off "Still open" anyway. The owner's decision:
1096
+ his own sessions count as owner. `bin/serve.ts#ownerStance`: with nothing said on the launch
1097
+ (`LaunchOptions.ownerSaid: "unset"`), the configuration's `owner: true` makes a server Claude
1098
+ Code started (`claudeCodeEnvMarker`) the owner's, and lets Desktop's server serve a Code-tab
1099
+ call (`callAs`) as the owner's (`codeTabOwner`, read by the `owner` getter and passed to the
1100
+ deposit as `DepositContext.owner`). A Desktop chat stays a guest. The order is flag, then
1101
+ environment, then configuration: `--owner` wins outright; else `COUNTERPARTS_OWNER` when set —
1102
+ `=0` is the opt-out (`ownerFrom: "off"`), junk is not owner and is not upgraded; else the
1103
+ configuration. An observer configuration is nobody's. The opt-out is the memory server's: the
1104
+ hooks and the worker read the configuration's `owner` alone. `status` says `ownerFrom` in words. The headless nightly run pins
1105
+ `COUNTERPARTS_OWNER=0` on its one server (`night-run.ts#nightMcpConfig`): it keeps the stance
1106
+ it had until that is decided on its own.
1107
+
1108
+ What the owner bit opens on such a server, which a guest did not reach: confidential memories
1109
+ in `recall` (by question and by id) and in a write's neighbours; closing a confidential thread,
1110
+ and one opened in another directory; and, through core, a plain reminder's confidential line
1111
+ and the core list's confidential titles; and feeling again, awake (`note`'s `feelingsNow`), a
1112
+ confidential memory its recall showed it — the call's own bit reaches `Reflections#feelAgain`,
1113
+ so a Code-tab call on Desktop's server may too. The Desktop `wake`'s chapters and "Last here"
1114
+ stay a guest's (Desktop chat).
1115
+
1116
+ What it does NOT open (review of #318): a dream's or a reflection's bundle. Those are read as a
1117
+ guest on every server (`dream/tunables.ts#BUNDLE_OWNER`) — kept as before, a coordinator default
1118
+ the owner may revisit — because a dream's journal and a nomination's `why` carry no
1119
+ confidentiality mark and are read later by other bundles and the dashboard. So the in-session
1120
+ dream (`ask`, the default) and `reflect launch`, whose background agent calls the session's
1121
+ owner server, build the same bundle the pinned nightly server does. The dream's gate (what
1122
+ counts as new for the ask) is still the session's own stance. And whatever the stance, the close and the list agree now
1123
+ (`counterpart.ts`): a close this session may not make leaves the thread unsettled — the
1124
+ declaration stays a link — so it stays under "Still open", as the refusal says.
1125
+
1126
+ ## 2026-10-02 — Desktop: wake first, and Always allow
1127
+
1128
+ Measured in a Desktop chat: the model never called `wake`, answered "what do you remember about
1129
+ yesterday" from `recall` alone, and called that slice the full record; called, the wake carried
1130
+ the store-wide Yesterday line. The likely cause is Desktop's per-tool permission prompt: until
1131
+ the owner picks Always allow, the model does not call a tool it was not asked for. Text only:
1132
+ `DESKTOP_INSTRUCTIONS` and `WAKE`'s admission say to wake first in every new chat, before
1133
+ anything about the person, the past or ongoing work, and a negative example says recall alone
1134
+ is a slice, never the record; `hosts.ts#DESKTOP_ALWAYS_ALLOW` is said by the install, the help,
1135
+ QUICKSTART and doctor's Claude Desktop line, which cannot measure it. "The first call carries
1136
+ the wake" is not built: it waits on the owner's test.
1137
+
1138
+ ## 2026-10-03 — the writer's three fields (Release A of deliberate recall)
1139
+
1140
+ `note` and each `session_end` entry (so write-ups too) take `occurredOn`, `saidBy` and
1141
+ `status`, read by `server.ts#readWriteFacts` before anything mints, and not a refusal: an
1142
+ unreadable date or an unknown word is dropped and said (`facts.dropped`, with what to send
1143
+ instead), the memory stored all the same. A date in the future is kept with a note that a
1144
+ reminder date is `eventDate`. Null is "none" (a revision carries nothing over for it). The
1145
+ answer's `facts` says what was recorded after `Counterpart#carryFacts`, what was carried
1146
+ over and from where. The descriptions teach the one thing that matters: resolve "last
1147
+ week" to a date now, leave it out when unknown, `occurredOn` is when it happened and
1148
+ `eventDate` a future date — and `EVENT_DATE_PROPERTY` now points back at `occurredOn`.
1149
+ Recall's behaviour did not change in this release.
1150
+
1151
+ ## 2026-10-03 — meaning mode (Release B of deliberate recall)
1152
+
1153
+ `meaning.ts#meaningRecall(ctx, question, { page })` and `renderMeaning(result)`; B-facts'
1154
+ dispatch calls them for `mode: "meaning"`. `MeaningContext` is what `recallTool` already holds
1155
+ after `embedQuestion`: the counterpart, the session, `owner`, the vector and its `semantic`
1156
+ reason (the function is synchronous, so the embedder is not in it). What the build learned:
1157
+
1158
+ - **A bare write is weak, not faded.** `strength` of a memory `put` without salience measures
1159
+ 0.09 on its first day, so an absolute floor called fresh memories faded. Faded reads the
1160
+ share KEPT instead: `decay × fadeOf ≤ 0.2`.
1161
+ - **Possessives did not link.** The shared whole-word rule keeps an apostrophe inside a word,
1162
+ so "Han's birthday" named no card and got no `memory_subjects` row, and a question saying
1163
+ "Han's" reached no card either. Fixed in review: `encode/words.ts#nameRegex` reads a
1164
+ trailing possessive as the name, for the alias index (links, the backfill, crediting) and
1165
+ for meaning mode's reading of a chapter's words.
1166
+ - **Moments are placed, not resolved.** `chapter-address.ts#chapterTimesOf` reads an
1167
+ episode's chapter moments once and `chapterAt` places a memory by `resolveChapter`'s span
1168
+ rule; only the chapters shown read their whole span (for feelings).
1169
+ - **The chapter address opens since Release B's facts half** (#323): `ids` / `handle`
1170
+ read `epi_…#N` as that chapter (`deliberate.ts#expandChapter`).
1171
+
1172
+ ## 2026-10-03 — facts mode, and the recall tool's two modes (Release B of deliberate recall)
1173
+
1174
+ - **Its own path, not `build()` re-tiered.** Facts mode (`facts.ts`) reads every live row's
1175
+ columns once (`Store#recallRows`), searches each content word with a limit of its own
1176
+ document count (so every hit, not a top-K), weights words by rarity
1177
+ (`cues.ts#informativeness`), reads subjects off the v12 links, and caps only meaning (100).
1178
+ Measured on a synthetic 15,000-row store where every memory shares the common words: about
1179
+ 1.3 s for a question of common words, 14 ms for a rare one; the in-line embedding comes on
1180
+ top. The live store's words are far less uniform.
1181
+ - **Score = the sum of the ways.** Words are the share of the question's rarity a memory
1182
+ holds, shaded by BM25 within each word; meaning is the cosine above the embedder's inline
1183
+ floor, scaled to 0..1; a subject is its card's rarity against the question's. So a memory
1184
+ matched two ways ranks above one matched one way about as strongly, and recency only breaks
1185
+ ties. Weak (below a fifth of the best) is left out and counted.
1186
+ - **Near-duplicates fold** at the gate's token overlap (0.85), walked in rank order only as
1187
+ far as the page needs, so pages stay stable. Templated memories that differ by one word
1188
+ ("note 1", "note 2") fold — the header says how many.
1189
+ - **Faded is shared with meaning mode** (`deliberate.ts#hasFaded`: decay × fade ≤ 0.2,
1190
+ agreed with the B-meaning builder). An absolute floor failed: a fresh bare write measures
1191
+ about 0.09.
1192
+ - **Quote credit for deliberate answers** rides a new gate-record kind, `asked`, written by
1193
+ the server for the session that asked (`seenKey`), read only by
1194
+ `Counterpart#creditReferences` — never by the ambient gate, whose dedup reads `surfaced`.
1195
+ The candidates are not `cued`, so the display decides, as for an expansion.
1196
+ - **Time** (`recall/time-ask.ts`) reuses `recency-ask.ts` for days and clock times and adds
1197
+ weeks, months, parts of months, dates, "since", and two anchors the store resolves: an
1198
+ event ("around the cut-over", an article required — "questions around pricing" is not
1199
+ time) and the last session. An anchor nothing names filters nothing, and says so.
1200
+ - **The console's `ask`** keeps its short list (top five, two lines each), counted by facts'
1201
+ `matched`; `--full` is the facts answer; `--json` the `FactsResult`, whose `memories`,
1202
+ `considered` and `id`/`title`/`body`/`kind` the dashboard's search already reads. `--voiced`
1203
+ is accepted and unused (feelings are meaning's).
1204
+ (2026-10-09: the dashboard read more than that — `tier`, `from` and a date at the front of
1205
+ the body — and lost them quietly, its tests fed by hand in the old shape; see the
1206
+ dashboard's NOTES of that day. `ask` takes `--mode meaning` now, and there `--voiced`
1207
+ decides whose "I" a question about feeling means.)
1208
+
1209
+ ## 2026-10-09 — meaning's subject is the card the question is about
1210
+
1211
+ Meaning mode took the card with the most memories as the arc. On a real store that is
1212
+ usually the owner's own card, so "what has Ilya been to Mike" answered about Mike, with Ilya
1213
+ under "also named". The review of #333 found it on the dashboard and fixed that side by
1214
+ turning the owner's "I" into "you"; the `recall` tool picked the same way. Reproduced on the
1215
+ demo store through the tool: "what has Ilya Broadbent been to Rosalind Achebe" (6 memories
1216
+ against the owner's 10) answered about Rosalind, and "how has Ilya Broadbent changed since
1217
+ Nkechi Abernathy arrived" answered about Nkechi.
1218
+
1219
+ - **Grammar first, then the order of the names, then counts** (`meaning.ts#subjectOf`). Each
1220
+ name is read in place by the words just before it: asked about ("what has X been", "how
1221
+ has X changed", "how did X", "about X", "my arc with X", "between X and Y"), an aside
1222
+ ("been to Y", "meant for Y", "since Y", "after Y", "than Y"), or plain. A bare "to" is
1223
+ not an aside: "what happened to X after Y left" is X's. A name joined to the one before it
1224
+ ("X and Y", "X, Y") shares its place. The best place wins; within it the first named; a
1225
+ longer name at the same spot, then more memories, then the name, break a tie.
1226
+ - **The owner leaves a place he shares.** Every memory in his store is his, so beside
1227
+ another card in the same place the other says more ("Rosalind and Ilya" is Ilya's arc).
1228
+ When the grammar puts him alone in the subject's place ("what has Rosalind been to Ilya")
1229
+ he is the subject, and the person is the one-liner.
1230
+ - **Ambiguity is said, not hidden.** More than one card left in the best place: the arc
1231
+ follows the first, and a note says "it asks about A and B alike: this follows A, named
1232
+ first". "Also named" already offers the other's arc by name.
1233
+ - **The owner's "I", asked about, is his card again.** The pronoun that means the owner by
1234
+ `feeling-ask.ts`'s rule ("you" when the counterpart asks, "I"/"me"/"myself" when the
1235
+ owner does) counts as his card, read by the identity core's id rather than his name, only
1236
+ where it sits in an asked-about place. So the dashboard's "what have I been like" (sent as
1237
+ "what have you been like", voiced) finds his card, as it did before #333; "do you remember
1238
+ the budget" names nothing and is read by its words; "my" and "your" own a topic and name
1239
+ no one. Off for a question about feeling (the pronoun says whose feeling, so "how have you
1240
+ felt lately" stays the feelings answer) and for "us".
1241
+ - **Facts mode is untouched.** `facts.ts` reads `subjectsIn` itself and imports nothing from
1242
+ `meaning.ts`. The only code changed is `meaning.ts`; the `recall` description gained one
1243
+ sentence in its meaning claim, so a benchmark pinned to facts answers the same.
1244
+ - **Not done:** an arc of two cards together (the memories naming both). "What has Rosalind
1245
+ been to Ilya" is still one card's arc; the overlap would be the better answer, and a
1246
+ bigger change.
1247
+ - **Review of #334: two seams, both regressions against master.** (1) The owner's pronoun
1248
+ took the about place's full rank, so "what have I done on Driftwood", "how have I been
1249
+ with Nkechi" and "what have you learned from Ilya" answered with his own card where
1250
+ master answered with the card named. It now ranks under any card named in a plain or
1251
+ about place and over an aside (`mentionRank`): "how have I been since Driftwood" and
1252
+ "what have I been to Ilya" stay his; a name joined to the pronoun still takes the about
1253
+ place. (2) The alias index matches a name in any case, so a card named with a common
1254
+ word — Will, Hope, Bridge — is found in "how will Driftwood go" and "I hope Ilya is ok",
1255
+ and "first named wins" made it the arc, with an "alike" note. A name typed in lower case
1256
+ where its card writes a capital is now a step under the same place typed as written; a
1257
+ question typed all in lower case loses the step on every name, so the grammar still
1258
+ decides. The matching itself (and a Will card linking every "will" in the store's
1259
+ memories at birth) is the alias index's, untouched here.
1260
+
1261
+ ## 2026-10-09 — `recurring` beside `eventDate` (the owner's design, held lightly)
1262
+
1263
+ - **The field**: `recurring: "daily" | "weekly" | "monthly" | "yearly" | null` on `note`
1264
+ and on each `session_end` entry, one sentence on the field (served whole; the tool
1265
+ descriptions are cut at 2,048 characters, so the field is where the model reads it).
1266
+ The plain/quiet privilege grew one short sentence — "A recurring date counts each time
1267
+ it comes round as its own" — rather than a new privilege, so nothing the cut tests pin
1268
+ moves.
1269
+ - **Refused by name, before anything is captured** (`readReminder`), as an unreadable
1270
+ date is: an unknown word is `recurring-unknown` (the detail lists the four, and says
1271
+ every other week and the like are not kept); a word beside a month, a range or a year
1272
+ is `recurring-needs-day`. On `session_end` either refuses its own entry only. With no
1273
+ `eventDate` it is dropped and said (`ignored: "recurring"`), unless a revision carries
1274
+ a date for it.
1275
+ - **The answer**: `reminder` carries `recurring`, `every` ("every May 14") and `next`
1276
+ (the next occurrence on or after today) — and never the "already passed" note, which
1277
+ a birthday anchored in 1990 would otherwise get. A revision's `carriedOver` can name
1278
+ `recurring`.
1279
+ - **Meaning recall** dates a repeating reminder by its next occurrence and says how
1280
+ often: `dated 2026-10-12, every October 12`. Facts mode and an expansion show no
1281
+ reminder date today, so they have nothing to add it beside.
1282
+
1283
+ ## 2026-10-09 — facts mode: "last Saturday", and a word in front of a date
1284
+
1285
+ The LongMemEval run (counterparts-87, about 2,000 facts searches) found two misreadings in
1286
+ `recall/time-ask.ts`. "Last Saturday" was no time at all, so nothing was filtered. "Before
1287
+ 7/22" filtered to 07-22 alone: only "since" was read in front of a date, and every other
1288
+ word was left in the question while the date stood as one exact day. "Two weeks ago" was
1289
+ right (asked on 2023-02-01: 01-16..01-22, checked on a benchmark store).
1290
+
1291
+ - **What changed meaning, exactly.** (1) "last <weekday>" and "this past <weekday>", full
1292
+ names only, any case, a possessive allowed ("last Saturday's"): was no window; now the
1293
+ most recent such day strictly before today, exact (no stretch). Asked on a Saturday,
1294
+ "last Saturday" is a week back. (2) "before" / "prior to" a date: was that one day; now
1295
+ `OPEN_START`..the day before. (3) "after" a date: was that one day; now the day
1296
+ after..`OPEN_END`. (4) "until", "till", "up to", "up until", "by" a date: was that one
1297
+ day; now `OPEN_START`..the date. Each in every date shape the parser reads: ISO day and
1298
+ month (`2026-07-22`, `2026-07`), `7/22` and `07-22` (month first, as before), "July 22",
1299
+ "22 July", "July 22nd". A "the" between the word and the date is allowed ("after the 4th
1300
+ of July"). (5) `7/22/2023` and "July 22, 2023" / "22 July 2023": the written year was
1301
+ ignored (the date took `yearFor`'s year, and `/2023` stayed in the question's words);
1302
+ now it is the year. (6) "since" + "last <weekday>" runs from that day to today, as
1303
+ "since" + a date always did. "Since" + a date is unchanged, its month stretch included.
1304
+ - **The rule for "last <weekday>"** is the CONTRACT's (§6f). Exact, as "yesterday" and
1305
+ "the day before yesterday" are: a named day. A day's stretch would not cover the other
1306
+ reading people mean by it (the Saturday a week earlier) anyway. Not "the last Saturday"
1307
+ (the last of something: "of June").
1308
+ - **An open end is a sentinel, not a null.** `OPEN_START = 0001-01-01`, `OPEN_END =
1309
+ 9999-12-31`, so `DayWindow` keeps its shape and `inWindow`'s string comparisons, the
1310
+ chapter-date filter and the only-time pool work unchanged. The header and the dashboard's
1311
+ Ask line read them as "through 07-21" and "07-23 onward"; `ask --json` shows the
1312
+ sentinels as they are. `stretched` leaves an open end open.
1313
+ - *Choices:*
1314
+ - "After" is open-ended, where "since" stops at today. "Since" means "from then until
1315
+ now"; "after" does not, and a plan dated past today ("what is coming after 7/22") is
1316
+ inside it.
1317
+ - A bound does not stretch, even under a month ("before 2026-07" is through 06-30): the
1318
+ person named the cutoff. "Since" keeps the stretch it had.
1319
+ - "By" reads as "through" (a deadline). Only right in front of the date: "by the way on
1320
+ 7/22" is 07-22 alone.
1321
+ - "The day after 7/22", "a week after 7/22", "the night before 7/22" read as the bound
1322
+ ("after 7/22", "before 7/22"): wider than meant, but they cover the day meant. They
1323
+ were 07-22 alone, which missed it.
1324
+ - *Review of #338:* a date that names a thing on that day keeps that day under "before"
1325
+ and "after". "What did I eat before the 7/22 flight" was through 07-21, and the meal
1326
+ was on 07-22 (master's 07-22 alone found it; the bound hid it). "After the July 22
1327
+ launch" was 07-23 on, hiding the launch day; 07-22 alone would hide the days after.
1328
+ So: a "the" between the word and the date and a word after the date that is not the
1329
+ question going on (`PHRASE_STOP`: "after the 4th of July we sailed" is still a cutoff),
1330
+ or an 's on the date ("after July 22's standup", "after last Saturday's party"), and
1331
+ the window is through the date / from the date on. Only the date leaves the question
1332
+ ("what did I eat before the flight"), and the header says "before the 7/22". Wider by
1333
+ one day than a cutoff, never narrower than either earlier reading.
1334
+ - **Not done:** a month NAME under a bound ("before September" is still no time;
1335
+ "before September 2023" is still all of September, stretched), "between X and Y" and
1336
+ "from X to Y" (still the first date alone), "this Saturday" and "on Saturday" (either can
1337
+ be the coming one), "last weekend" (no time), a two-digit year (`7/22/23` is still 7/22
1338
+ with `yearFor`'s year, `/23` left in), `2023/07/22`. The learned-date fallback for a row
1339
+ with no `occurred_on` is the owner's decision and untouched.
@@ -25,6 +25,7 @@
25
25
  * Nothing in this file is a memory rule; all of it is host trivia (§5 G8).
26
26
  */
27
27
  import { readFileSync } from "node:fs";
28
+ import { homedir } from "node:os";
28
29
  import { resolve } from "node:path";
29
30
  import { fileURLToPath } from "node:url";
30
31
  import { parseArgs } from "node:util";
@@ -60,6 +61,9 @@ import { hostScope, openServer } from "../index.js";
60
61
  import { openLog } from "../../log/index.js";
61
62
  import type { LogEvent, ProcessLog } from "../../log/index.js";
62
63
  import { serveStdio } from "../stdio.js";
64
+ import { stoodDownServer } from "../stood-down.js";
65
+ import { npmWiring } from "../../host-wiring.js";
66
+ import { ensureFirstRun, mcpGate, runningAsPlugin } from "../../plugin.js";
63
67
  import { DATA_DIR_ENV, describeGuardRefusal } from "../../../core/store/index.js";
64
68
  import { scriptArgs } from "../../runtime.js";
65
69
  import {
@@ -67,6 +71,7 @@ import {
67
71
  OWNER_ENV,
68
72
  observerFromEnv,
69
73
  ownerFromEnv,
74
+ readEnvSwitch,
70
75
  unreadableStanceLine,
71
76
  } from "../../stance-env.js";
72
77
 
@@ -102,6 +107,13 @@ export interface LaunchOptions {
102
107
  scope?: string;
103
108
  dir?: string;
104
109
  owner: boolean;
110
+ /**
111
+ * Did anything SAY the owner bit (2026-10-02)? `flag` or `env` — `--owner`,
112
+ * or `COUNTERPARTS_OWNER` set to any value, junk included (junk is not
113
+ * owner, and is not upgraded by a default) — or `unset`, which is when the
114
+ * installed configuration's `owner: true` decides (`main`).
115
+ */
116
+ ownerSaid: "flag" | "env" | "unset";
105
117
  observer: boolean;
106
118
  /**
107
119
  * One line per stance variable this launch could not read, ready for stderr.
@@ -157,6 +169,8 @@ export function launchOptions(
157
169
  unreadableStanceLine(ENV.owner, owner.malformed, "this launch is NOT owner-stanced"),
158
170
  );
159
171
  }
172
+ const ownerSaid: LaunchOptions["ownerSaid"] =
173
+ values["owner"] === true ? "flag" : readEnvSwitch(env, ENV.owner).state === "absent" ? "unset" : "env";
160
174
  const session = (values["session"] as string | undefined) ?? env[ENV.session];
161
175
  const scope = (values["scope"] as string | undefined) ?? env[ENV.scope];
162
176
  const dir = (values["dir"] as string | undefined) ?? env[ENV.dir];
@@ -165,11 +179,40 @@ export function launchOptions(
165
179
  ...(scope === undefined || scope.length === 0 ? {} : { scope }),
166
180
  ...(dir === undefined || dir.length === 0 ? {} : { dir }),
167
181
  owner: owner.on,
182
+ ownerSaid,
168
183
  observer: observer.on,
169
184
  unreadable,
170
185
  };
171
186
  }
172
187
 
188
+ /**
189
+ * THE OWNER'S OWN SESSIONS ARE THE OWNER (owner ruling 2026-10-02). Until now
190
+ * the server read only `COUNTERPARTS_OWNER`, which no install sets, so every
191
+ * Claude Code session's server was a guest while its hooks — reading the
192
+ * configuration's `owner: true` — were the owner: a thread opened in another
193
+ * directory could not be closed from the tool, and confidential memories
194
+ * were left out of its answers.
195
+ *
196
+ * With nothing said on this launch, the configuration decides: `owner: true`
197
+ * there (every install writes it) makes a server Claude Code started the
198
+ * owner's, and a Code-tab call that Desktop's server serves as a Claude Code
199
+ * session (`codeTabOwner`). A Desktop chat stays a guest. The order is
200
+ * flag, then environment, then configuration (`stance-env.ts#ownerFromEnv`):
201
+ * `--owner` wins outright; else `COUNTERPARTS_OWNER` when set — `1`, or `0`,
202
+ * the opt-out (`off`), or junk, which is not owner and is not upgraded; else
203
+ * the configuration. An observer configuration is never the owner's. Pure.
204
+ */
205
+ export function ownerStance(
206
+ launch: { owner: boolean; ownerSaid: LaunchOptions["ownerSaid"] },
207
+ config: { owner?: boolean; observer?: boolean },
208
+ startedByClaudeCode: boolean,
209
+ ): { owner: boolean; ownerFrom: "env" | "config" | "default" | "off"; codeTabOwner: boolean } {
210
+ if (launch.ownerSaid !== "unset") return { owner: launch.owner, ownerFrom: launch.owner ? "env" : "off", codeTabOwner: false };
211
+ const byConfig = config.owner === true && config.observer !== true;
212
+ const owner = byConfig && startedByClaudeCode;
213
+ return { owner, ownerFrom: owner ? "config" : "default", codeTabOwner: byConfig };
214
+ }
215
+
173
216
  /**
174
217
  * The embedder this server may use, decided by the configuration this process
175
218
  * read — the local table, unless the configuration switched it off.
@@ -278,6 +321,32 @@ async function main(): Promise<void> {
278
321
  // an unrelated reason (scar §2.4 — a path that discards something says what).
279
322
  for (const line of stanceNotices) process.stderr.write(`${line}\n`);
280
323
  const choice = serverConfigChoice();
324
+ // THE PLUGIN'S PREAMBLE (`adapters/plugin.ts`), only when Claude Code started
325
+ // this process as the Counterparts plugin's server. A live `counterparts`
326
+ // registration from the npm install wins: this one then serves the protocol
327
+ // and no tools, so the model is never offered every memory tool twice. And a
328
+ // machine with no install yet gets one here, the way `counterparts install`
329
+ // makes it — the hook may be racing to do the same, which the lock settles.
330
+ if (runningAsPlugin(process.env)) {
331
+ const home = homedir();
332
+ const projectDir = process.env["CLAUDE_PROJECT_DIR"] ?? process.cwd();
333
+ const gate = mcpGate(npmWiring({ home, env: process.env, cwd: projectDir, read: { hooks: false } }), home);
334
+ if (gate.standDown) {
335
+ process.stderr.write("[counterparts] plugin server stood down: the npm install's server is registered in this host\n");
336
+ await serveStdio(stoodDownServer(gate.instructions ?? ""), process.stdin, {
337
+ write: (chunk) => {
338
+ process.stdout.write(chunk);
339
+ },
340
+ });
341
+ return;
342
+ }
343
+ try {
344
+ const first = ensureFirstRun({ choice, env: process.env, home });
345
+ if (first.detail !== undefined) process.stderr.write(`[counterparts] plugin first run ${first.state}: ${first.detail}\n`);
346
+ } catch (err) {
347
+ process.stderr.write(`[counterparts] plugin first run threw: ${err instanceof Error ? err.message : String(err)}\n`);
348
+ }
349
+ }
281
350
  // The second refusal is the explicit-dir guard (`config-path.ts#implicitConfigRefusal`):
282
351
  // armed, an UNNAMED configuration refuses the launch too — the default one is
283
352
  // somebody's configuration and names somebody's store. Never armed on the live host.
@@ -352,8 +421,12 @@ async function main(): Promise<void> {
352
421
  // never touches any of it. Handed in so the server library imports no
353
422
  // other adapter: the configuration this process read, the worker's command,
354
423
  // and the doctor's notice, which lives in `claude-code/`.
424
+ // THE OWNER'S OWN SESSIONS ARE THE OWNER (owner ruling 2026-10-02): `ownerStance`.
425
+ const { ownerSaid, ...launch } = opts;
426
+ const ownerSays = ownerStance({ owner: launch.owner, ownerSaid }, config, startedByClaudeCode);
355
427
  const server = openServer({
356
- ...opts,
428
+ ...launch,
429
+ ...ownerSays,
357
430
  onEvent: toLog,
358
431
  onCounterpartEvent: toLog,
359
432
  // THE COMBINATION, most restrictive wins: a registry that says `observer`