counterparts 0.3.8 → 0.3.9

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 (58) hide show
  1. package/CHANGELOG.md +130 -0
  2. package/docs/module-map.md +13 -4
  3. package/package.json +3 -1
  4. package/src/adapters/claude-code/CONTRACT.md +40 -13
  5. package/src/adapters/claude-code/INTERFACE-GAPS.md +12 -13
  6. package/src/adapters/claude-code/NOTES.md +31 -0
  7. package/src/adapters/claude-code/bin/hook.ts +2 -2
  8. package/src/adapters/claude-code/bin/runner.ts +3 -3
  9. package/src/adapters/claude-code/doctor.ts +111 -3
  10. package/src/adapters/claude-code/embed-client.ts +1 -1
  11. package/src/adapters/claude-code/hooks.ts +112 -1376
  12. package/src/adapters/claude-code/index.ts +5 -5
  13. package/src/adapters/claude-code/night-run.ts +8 -6
  14. package/src/adapters/cli/CONTRACT.md +19 -1
  15. package/src/adapters/cli/commands.ts +103 -7
  16. package/src/adapters/cli/coverage.ts +16 -2
  17. package/src/adapters/cli/desktop.ts +181 -0
  18. package/src/adapters/cli/help.ts +8 -0
  19. package/src/adapters/cli/install.ts +16 -10
  20. package/src/adapters/cli/report.ts +2 -0
  21. package/src/adapters/cli/uninstall.ts +1 -1
  22. package/src/adapters/{claude-code/config.ts → config.ts} +26 -4
  23. package/src/adapters/dashboard/web/actions.ts +4 -0
  24. package/src/adapters/dashboard/web/pages/memories/fold.js +6 -1
  25. package/src/adapters/dashboard/web/views/archive-words.ts +36 -22
  26. package/src/adapters/expansions.ts +4 -3
  27. package/src/adapters/fired.ts +5 -5
  28. package/src/adapters/hosts.ts +185 -0
  29. package/src/adapters/lifecycle.ts +1616 -0
  30. package/src/adapters/mcp/CONTRACT.md +86 -9
  31. package/src/adapters/mcp/INTERFACE-GAPS.md +17 -10
  32. package/src/adapters/mcp/NOTES.md +109 -11
  33. package/src/adapters/mcp/bin/serve.ts +86 -3
  34. package/src/adapters/mcp/deliberate.ts +56 -4
  35. package/src/adapters/mcp/index.ts +21 -2
  36. package/src/adapters/mcp/server.ts +637 -68
  37. package/src/adapters/mcp/tools.ts +97 -11
  38. package/src/adapters/mcp/write-up.ts +71 -11
  39. package/src/adapters/scopes.ts +9 -1
  40. package/src/adapters/sessions.ts +300 -12
  41. package/src/adapters/snapshots.ts +1 -1
  42. package/src/adapters/{claude-code/spawn.ts → spawn.ts} +13 -3
  43. package/src/core/associate/pending.ts +1 -1
  44. package/src/core/counterpart.ts +12 -0
  45. package/src/core/feelings-wheel.ts +2 -0
  46. package/src/core/leaving.ts +77 -0
  47. package/src/core/recall/CONTRACT.md +39 -0
  48. package/src/core/recall/NOTES.md +94 -0
  49. package/src/core/recall/activate.ts +250 -17
  50. package/src/core/recall/feeling-ask.ts +216 -0
  51. package/src/core/recall/gate.ts +15 -3
  52. package/src/core/recall/index.ts +74 -2
  53. package/src/core/recall/tunables.ts +16 -0
  54. package/src/core/self/NOTES.md +10 -0
  55. package/src/core/self/index.ts +19 -0
  56. package/src/core/sleep/cycle.ts +8 -0
  57. package/src/core/store/cache.ts +1 -1
  58. package/src/core/store/index.ts +25 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,135 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.9 — 2026-09-30
4
+
5
+ Counterparts now reaches Claude Desktop's chat: one command connects it, a chat wakes
6
+ with the same memory a Claude Code session does, and each call says which chat it
7
+ belongs to. Underneath, the host-neutral part of a session moved out of the Claude Code
8
+ adapter so a second host could use it; Claude Code behaves as it did, apart from two
9
+ small, deliberate changes. Recall can now answer a question about how something felt,
10
+ and a journal chapter and the memory made from it come back as one. **The store's format
11
+ does not change** (it stays v10), so nothing is copied or upgraded. The hooks run the
12
+ new code at once; a session left open keeps 0.3.8's memory server until it is restarted
13
+ or `/mcp` → Reconnect.
14
+
15
+ Claude Desktop chat.
16
+
17
+ - **`counterparts install --host claude-desktop`** connects Desktop's chat. Quit Claude
18
+ Desktop first: it rewrites its own config file while it runs, and can write over the
19
+ change. The command makes (or keeps) the store and configuration exactly as the
20
+ scripted install does, then merges one `counterparts` entry into Desktop's
21
+ `claude_desktop_config.json`, found under the home directory it was given. The file is
22
+ backed up first, every other server and setting in it is left exactly as it was, and
23
+ a second run changes nothing ("already connected"). The file is written back as
24
+ 2-space JSON, the way Desktop writes it. If it replaces an entry that named a different
25
+ store, it names that store: the memory there is still there. Plain `install` is
26
+ unchanged and doesn't touch Desktop.
27
+ - **The `wake` tool** is Desktop's session start, and only Desktop is offered it. It
28
+ starts a new session (host `claude-desktop`, in the `claude-desktop:` place) and
29
+ returns what a Claude Code session start would: the wake, the clock, today's plain
30
+ reminders, the day's dream line when it is an ask, the update and doctor notices, and
31
+ the write-up pointer, sized for a tool result. It also starts the turn-end worker, as
32
+ the hook does. It doesn't ask the first-launch question and doesn't start the headless
33
+ nightly run. Desktop also lists one prompt, **"Start with Counterparts"**, which asks
34
+ the chat to call `wake` first and keep the session id it gets.
35
+ - **Each call binds to a session, and says when it guessed.** One server serves every
36
+ Desktop chat, and Desktop sends no chat id, so every Desktop tool takes an optional
37
+ `session`. A call that names a live Desktop session is filed under it. A call that
38
+ names none binds to the most recent live Desktop session and says so (`boundTo`,
39
+ `boundBy: "most-recent"`, and one line). A tool that needs a session (`session_end`,
40
+ `chapter`, `dream`, `reflect`) refuses a named id that is unknown or has gone quiet
41
+ (`session-unknown`, `session-not-live`), and never swaps in another; with no live
42
+ session at all it refuses and names `wake`. The other tools (`note`, `recall`,
43
+ `status`, `scope`, `self_page`) run unbound in those cases, as they always could. Only a call that names its session keeps that session alive
44
+ and counts toward its write-up ask; a guessed call moves nothing, because it may belong
45
+ to another chat.
46
+ - **The write-up ask.** After 3 named calls and 20 minutes since the later of the wake,
47
+ the last `session_end` or `chapter`, and the last ask, the next named result carries a
48
+ write-up ask. `session_end` can be called again in the same chat; later calls add to
49
+ what the first one wrote.
50
+ - **Desktop's own place.** `claude-desktop:` is a place, not a folder: `counterparts scope
51
+ claude-desktop: --on` and the other mode flags work on it, the off and paused refusals
52
+ are worded for Desktop, and observer is read on every call, so a change takes effect
53
+ at once. Desktop never takes on the observer setting of the folder the server was
54
+ started in.
55
+ - **Doctor has a Claude Desktop line.** It is quiet when Desktop has no entry, green with
56
+ the last wake and last session when it has one, and amber only when the entry names
57
+ another store.
58
+ - **`counterparts coverage` shows Desktop sessions as unmeasured**: "Claude Desktop: N
59
+ sessions that day — unmeasured: Desktop chat keeps no transcript, so what they did not
60
+ write up cannot be counted (not lost; what was written through the tools is kept)."
61
+ - **A Desktop session may write up a chat that went quiet, only when its launcher grants
62
+ it.** A session's record can carry `mayWriteUp`, the ended sessions it may write up.
63
+ Only a launcher writes it (`sessions.ts#grantWriteUps`); no tool can, and a
64
+ `mayWriteUp` argument is ignored. The subject must be listed, ended, and owed, and its
65
+ memories are filed where it was lived. Nothing in this release grants it yet.
66
+ - **How the server tells the hosts apart.** The client's name at `initialize` decides:
67
+ `claude-ai` (chat) or `local-agent-mode-*` (Cowork) makes it Desktop's. A process whose
68
+ environment carries Claude Code's markers (`CLAUDE_PROJECT_DIR`, `CLAUDECODE`,
69
+ `CLAUDE_CODE_ENTRYPOINT`) was started by Claude Code and stays Claude Code's whatever
70
+ its client says. Any other client gets the handshake, the nine tools and the refusals
71
+ it always got: `wake` is an unknown tool there.
72
+
73
+ Claude Code: two deliberate changes.
74
+
75
+ - **`status` explains `owner: false`.** When the server isn't the owner's,
76
+ `status.stance.ownerMeans` says in one phrase what that means: "owner: false is the
77
+ ordinary setting — confidential memories are left out of this server's answers;
78
+ nothing is wrong."
79
+ - **No scope question in Desktop's scratch folders.** The first-launch scope question is
80
+ skipped in a Code-tab "No folder" workspace
81
+ (`…/Library/Application Support/Claude/scratch-workspaces/…`).
82
+
83
+ The host seam (#292; no change in behaviour).
84
+
85
+ - **The host-neutral part of a session has its own module.** `src/adapters/lifecycle.ts`
86
+ (`HostLifecycle`, `Lifecycle`) holds what any host does at a session's start, turn
87
+ boundary and end: the registry record, the wake, recall and its record, capture, the
88
+ ask pacer, the write-up ask, the worker. The Claude Code adapter extends it, and each
89
+ hook runs the same steps in the same order. `src/adapters/hosts.ts` holds the wording
90
+ that differs by host; Claude Code's strings are byte-identical.
91
+ - `config.ts` and `spawn.ts` moved from `src/adapters/claude-code/` to `src/adapters/`.
92
+ The `./claude-code` export still re-exports everything that moved.
93
+ - **Registry records carry `host`.** A record written before this reads as `claude-code`.
94
+ - **New package exports**: `counterparts/lifecycle` and `counterparts/hosts`.
95
+
96
+ Recall and chapters.
97
+
98
+ - **Recall by feeling, for a deliberate question.** Asked "what have I felt most
99
+ strongly" or "what moved me", the `recall` tool (and `counterparts ask`) answers from
100
+ the feelings recorded on memories, strongest first. Stamps rank the answer only when
101
+ the question is really about a feeling: a feel-word (`feel`, `felt`, `feeling`,
102
+ `emotion`, `mood`), or a feeling word used about a person. Everyday phrasings don't
103
+ trigger it: "the happy path", "moved the parser", "I feel like…", "I moved it to src",
104
+ "is my build open" still work as ordinary words. "I" is whoever asks: the counterpart
105
+ in `recall`, you in `counterparts ask`. "afraid" is now an alias of scared. The
106
+ per-turn recall never opens this path.
107
+ - **A journal chapter and the memory made from it are one result**, and that memory now
108
+ keeps the chapter's title (the next time its chapter grows; nothing is backfilled).
109
+ The chapter is the row shown; credit reaches the copy only when recall showed the
110
+ chapter this session.
111
+ - **`status` counts `replaced` apart from `exited`.** `symmetry.exited` now means only
112
+ what left for good (let go, removed); a revision, a merge, a correction, or a journal
113
+ copy rebuilt when its chapter grew is counted under the new `symmetry.replaced`. A
114
+ store whose chapters keep growing used to read as losing its self-kind memories, so
115
+ **any note comparing `exited` across days sees a step on the day this is installed.**
116
+ - **The dashboard's Ask shows a chapter as its journal entry** (it used to show the
117
+ memory, with a "from chapter …" link), and the questions it rewrites into the
118
+ counterpart's voice ask as the counterpart (`--voiced`): there "I" means the
119
+ counterpart. An exact ask and a typed `counterparts ask` keep you as "I".
120
+
121
+ Not proven here.
122
+
123
+ - Desktop has never run against a real Claude Desktop app. The client names, the
124
+ prompt, the per-call binding and the write-up ask were checked over stdio with a
125
+ client that calls itself `claude-ai`.
126
+ - The Desktop Code tab's environment and client name were never measured live. A Code
127
+ tab session is expected to carry Claude Code's markers and stay Claude Code's.
128
+ - A process that Claude Code did not launch, started in a folder set to observer, opens
129
+ the store writable before `initialize` tells it which host it serves.
130
+ - A Desktop-only user on automatic dreaming gets no dream line: the wake leaves the
131
+ headless run for a Claude Code session to start.
132
+
3
133
  ## 0.3.8 — 2026-09-30
4
134
 
5
135
  When two memories disagree, Claude can now say how: the fact changed, the old one was
@@ -29,6 +29,7 @@ code and the `NOTES.md` / `INTERFACE-GAPS.md` next to it.*
29
29
  | *(`contradictions.ts`)* | reconsolidation + interference | Two memories that disagree: flagged (a dream, today), noticed at write time (the nearest few live memories come back with a stored one), and SETTLED — `changed` (both true at their time: one strength cut, labelled earlier), `corrected` (archived, readable by id), or `open` (both kept, shown together) — by a new memory's `updates` + `how`, a `note` settle, a dream or reflection with a plain reason, or the owner's `counterparts settle`. Every settle is on a trail (who, how, why, when) and can be undone. A file beside `revision.ts`, whose ordinary-memory arm it is; its tables are the store's (schema v10), its labels recall's (`recall/standing.ts`). **Added 2026-09-29.** |
30
30
  | *(`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`).** |
31
31
  | *(`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.** |
32
+ | *(`leaving.ts`)* | — (a table) | What counts as having left: every `archived_reason` the code writes, filed `replaced` (a live row carries it — a revision, a merge, a rebuilt journal copy), `let-go` or `removed`. The `status` census and the dashboard's archive words both read it, so they agree. **Added 2026-09-30.** |
32
33
  | *(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`. |
33
34
 
34
35
  **Third open question (check-in): the `remember`/`encode` boundary.** With the
@@ -39,13 +40,21 @@ input — does `encode` shrink to gates-and-tagging inside `remember`'s pipeline
39
40
 
40
41
  | adapter | job |
41
42
  |---|---|
42
- | `claude-code/` | Hooks: wake injection at session start, end-of-session remember, crash detection. The launch adapter. |
43
- | `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**), and `reflect`, the waking self's (**added 2026-09-27**). |
44
- | `cli/` | `counterparts` command: status, install, owner operations (delete, export, backup). |
43
+ | `claude-code/` | Hooks: Claude Code's five events driving the host lifecycle (`lifecycle.ts`, below) — its payload translation, JSON envelope and the room it measures, transcript reader and wake-arrival check, the Stop ask's words, the first-launch question, the update and doctor notices, the dream line, and the headless nightly run (`night-run.ts`, `claude -p`, **2026-09-29**). The launch adapter. |
44
+ | `mcp/` | Deliberate tools, nine: note, recall, status — plus the Stop ask's two return channels, `session_end` (memories, and the next-session write-up's door) and `chapter` (the episode's own journal, **added 2026-09-04**, because the ask named a door no adapter had built) — `scope` (this directory's setting, **2026-09-15**), `self_page` (the page the wake opens with, **2026-09-18**), `dream`, the dreamer's phases (**added 2026-09-26**), and `reflect`, the waking self's (**added 2026-09-27**). A result's words about the host come from `hosts.ts`. For a Claude Desktop client (by its name at `initialize`, **2026-09-30**) a tenth, `wake` — Desktop's session start, since it has no hooks — plus per-call binding to the most recent live Desktop session, the write-up ask on a tool result, and a "Start with Counterparts" prompt; a Claude Code client sees none of it. |
45
+ | `cli/` | `counterparts` command — the full list is `COMMANDS` in `cli/commands.ts`: status, install, connect / disconnect (the host's two files), `install --host claude-desktop` (Desktop's config entry, **2026-09-30**), uninstall, start-fresh, init, owner operations (note, ask, export, backup, remove, verify, repairs, rebrief), the readings (doctor, mechanisms, log, coverage, version, help), scope, self-page, dream, core, settle, and dashboard. |
45
46
  | `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).** |
46
- | `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. |
47
+ | `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. Since **2026-09-30** Claude Desktop's MCP server writes its own records here (its `wake`), refreshed per call, and a runner's record can list the ended sessions a launcher granted it to write up (`mayWriteUp`). |
47
48
  | `expansions.ts` | The same shape, for the other direction: the handle-resolution log the MCP `recall` tool writes (`<dataDir>/sessions/expansions.jsonl` — a per-store SALTED hash of the handle (G58), the id it reached or `null` for a refusal, a timestamp, the project) and the boundary's credit pass reads, so an expansion by TITLE credits the memory it actually reached, and a refusal shadows it. **Added 2026-09-15** (LAUNCH-STATUS G50): `recall/reference.ts` credits literal `mem_…` addresses and resolves nothing, so until this the most deliberate act a session had — naming a memory and reading it — earned no credit at all. |
48
49
  | `scopes.ts` | The third shared leaf: the per-directory scope registry (`scopes.json` BESIDE the config, never inside the store, because the hook decides `off` before anything opens) — `on` / `observer` / `off` / `paused`, longest prefix wins, absent-or-unreadable meaning `unset` meaning on. Written by the `counterparts scope` console and the MCP `scope` tool, read by every hook. **Added 2026-09-15** (PR #92, G19): the hooks are registered globally, so until this the only way to say *not here* was a second config file and two environment variables. |
50
+ | `lifecycle.ts` | The host seam (**2026-09-30**): `HostLifecycle`, the interface a host adapter drives, and `Lifecycle`, its one implementation — what a session is to this memory whatever the host: the wake's composition and the registry's expectation of it, plain reminders, recall for a turn, the boundary (capture, the retroactive-capture seal, credit, the orphan tail), the ask's pacing (not its words), the next-session write-up pointer, every registry write, and the worker spawn with its counters. `claude-code/`'s `ClaudeCodeAdapter` extends it. Imports no adapter. |
51
+ | `hosts.ts` | Which host a session lives in (`claude-code` is the default, and what a registry record with no `host` reads as) and the few sentences that depend on it — how to reconnect after an update, what switching the scope does — plus Claude Desktop's: the host name, its pseudo-scope `claude-desktop:` (a name, never resolved as a path), which MCP clients are Desktop, and the Code tab's scratch workspaces. **Added 2026-09-30.** |
52
+ | `config.ts` | The host configuration's shape and reader (`AdapterConfig`, `loadConfig`, `TUNABLES`, capabilities) — read by the hooks, the worker, the console and the MCP server. Moved out of `claude-code/` on **2026-09-30**. |
53
+ | `config-path.ts` | Where every entry point looks for that configuration: `--config`, else `COUNTERPARTS_CONFIG`, else `~/.counterparts/claude-code.json`; a named configuration that cannot be honoured refuses rather than falling back. |
54
+ | `spawn.ts` | The detached worker's plan and start (`planSpawn`, `spawnDetached`): watchdog checked against the staleness window, environment pinned last. Moved out of `claude-code/` on **2026-09-30** so any host's adapter can start the same worker. |
55
+ | `fired.ts` | Which mechanisms have fired and which have gone quiet, read only from the store's rows — `counterparts mechanisms`, the dashboard's panel. Each entry names the module that does the work. |
56
+ | `snapshots.ts` | The daily rotating snapshot and its rotation — the one place this package deletes a copy of the memory, and only what it can prove is a snapshot. |
57
+ | `stance-env.ts` | `COUNTERPARTS_OBSERVER` / `COUNTERPARTS_OWNER`, read the way the explicit-dir guard is, each failing toward less power. |
49
58
  | `log/` | A shared leaf with its own CONTRACT: the process log — one line per allowlisted event (failures, stand-downs, turn ends, write-ups, the night, the wake) from the hook, the worker, the nightly run and the MCP server, to `<dataDir>/sessions/log/<date>.log`, ids and codes only, kept 7 days. Read by `counterparts log` and one doctor line. **Added 2026-09-30**: none of the four processes wired its `onEvent`, so ~270 event names died with their process. |
50
59
 
51
60
  ## Tools (`tools/`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "counterparts",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
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": {
@@ -39,6 +39,8 @@
39
39
  "./dashboard": "./src/adapters/dashboard/index.ts",
40
40
  "./sessions": "./src/adapters/sessions.ts",
41
41
  "./scopes": "./src/adapters/scopes.ts",
42
+ "./lifecycle": "./src/adapters/lifecycle.ts",
43
+ "./hosts": "./src/adapters/hosts.ts",
42
44
  "./package.json": "./package.json"
43
45
  },
44
46
  "files": [
@@ -10,6 +10,24 @@ same composer, minus the prospective lane and minus anything protected or confid
10
10
  and this adapter's interpret client put that prompt on the wire until 2026-09-24 (see
11
11
  §1a: the sweep no longer interprets here).
12
12
 
13
+ **Where the parts live (2026-09-30, the host seam).** What a session is to this memory
14
+ whatever the host — the wake's composition and the registry's expectation of it, plain
15
+ reminders, recall for a turn and its row, the boundary (capture, the retroactive-capture
16
+ seal, credit, the orphan tail), the ask's *pacing*, the next-session write-up pointer,
17
+ every registry write, and the worker spawn with its counters — is the shared leaf
18
+ `adapters/lifecycle.ts`: the `HostLifecycle` interface and its one implementation,
19
+ `Lifecycle`. `ClaudeCodeAdapter` **extends** it, so each hook body calls those methods
20
+ where it called its own, in the same order, with the same rows. What stays here is this
21
+ host's: the five event names and their dispatch (`hooks.ts`), the payload translation, the
22
+ JSON envelope and the room it measures (`bin/hook.ts`, `envelope.ts`), the transcript
23
+ reader and the wake-arrival check against it (`transcript.ts`), the Stop ask's words
24
+ (`stopAsk`, `STOP_HUMAN_LINE`), the first-launch question, the parallel run's primacy, the
25
+ update and doctor notices, the dream line and the headless nightly run. The configuration
26
+ (`AdapterConfig`, `loadConfig`) and the worker spawn (`planSpawn`, `spawnDetached`) moved to
27
+ the shared leaves `adapters/config.ts` and `adapters/spawn.ts` the same day; `index.ts`
28
+ still re-exports them. Every registry record the lifecycle writes carries `host:
29
+ "claude-code"` (`sessions.ts#hostOf` reads an absent one the same way).
30
+
13
31
  ## 1a. Keyless (owner, 2026-09-24)
14
32
 
15
33
  The package reads no API key and calls no model API of its own. Removed that day: the
@@ -112,16 +130,19 @@ credential — belongs here, discovered at runtime, never assumed by the core.
112
130
  v1's own assignment file and lets the delivering hooks speak only when that file names the
113
131
  slot v2 occupies; it **fails toward mute** where v1 fails toward inject, so the joint
114
132
  failure state is v1-only rather than two voices or none. Absent flag ⇒ v2 delivers, which
115
- is the ordinary build. The flag, the resolver, and the two durable events are **retired at
116
- PROMOTE** — they are scaffolding for a comparison, not a feature.
133
+ is the ordinary build. The flag, the resolver, and the two durable events were meant to be
134
+ **retired at PROMOTE** — they are scaffolding for a comparison, not a feature. The parallel
135
+ run ended on 2026-09-21 and nothing retired them: they are **still wired**
136
+ (`hooks.ts#deliveryVerdict`, config `parallel`), and inert on every install that does not
137
+ set the flag. Removing them is a separate change.
117
138
  - **The 9,000-byte wake budget is not a constant here or anywhere.** The adapter
118
139
  **discovers or asserts** its host's injection ceiling and reports it as a capability;
119
140
  the core composes to whatever it is told (scar §2.18). v1's number was 90% of one host's
120
141
  cliff, encoded as though it were physiology.
121
- - **Multi-file API-key rotation and per-key cursor bookkeeping are dropped**; credentials
122
- come from one configured source the package owns, not from an inherited shell
123
- environment (scar §2.18: "nothing in the core depends on a tool, file, or environment the
124
- host may not provide"). Settled by the scar.
142
+ - **Multi-file API-key rotation and per-key cursor bookkeeping are dropped** — and since
143
+ 2026-09-24 there are no keys at all (§1a), so there is nothing to rotate and no credential
144
+ source to configure. (Until then credentials came from one configured source the package
145
+ owned, never an inherited shell environment — scar §2.18.)
125
146
  - **Model-seat pins are dropped.** **PROPOSED** — owner call at check-in. Constitution
126
147
  line 2 says which seat runs which job is a design choice, never doctrine, and the model
127
148
  lineup will have moved. What is **kept** is the bake-off *method* (earned-mechanism #20:
@@ -193,9 +214,12 @@ row, saying which source answered, existed until the keys were removed — §1a.
193
214
  checkable values**, never assumed; exceeding one is an event, not silent degradation
194
215
  (scar §2.18).
195
216
  5. **[M] The spawner pins the child's environment last**, so no caller can leak a run into
196
- the wrong store (scar §2.13).
197
- 6. **[M] A long call proves it survives this host's ceilings, once, in this host** —
198
- adapter-level evidence, per scar E3's rescope.
217
+ the wrong store (scar §2.13). (`adapters/spawn.ts` since 2026-09-30, shared so another
218
+ host's adapter can start the same worker.)
219
+ 6. ~~**[M] A long call proves it survives this host's ceilings, once, in this host**~~ —
220
+ **moot since 2026-09-24 (§1a).** The package makes no model call of its own, so there is
221
+ no long call to prove; the headless nightly run is `claude -p` — the host's own call,
222
+ under its own watchdog (`night-run.ts`), not one this adapter streams.
199
223
  7. **[M] Under observer, the boundary appends no span, resolves no references, spawns no
200
224
  worker, and asks for no episode** — and logs that it stood down (scar E7, §2.4).
201
225
  8. **[M] The read cursor is per-session and advances only after a successful append**, and
@@ -422,7 +446,10 @@ row, saying which source answered, existed until the keys were removed — §1a.
422
446
  smuggled past the limit. `SessionRecord.askedScope` is what makes "once" true
423
447
  across a resume or a compaction. The WORDING is advisory; that an unset directory
424
448
  raises the question exactly once and that any recorded mode ends it are the
425
- mechanized parts.
449
+ mechanized parts. Not asked at all in a Claude Desktop Code-tab "No folder"
450
+ scratch workspace (`hosts.ts#isDesktopScratchWorkspace`, 2026-09-30): Desktop
451
+ deletes that directory with the session, and an answer recorded for it would
452
+ outlive the folder it names (event `adapter.scope.ask.skipped`, `scratch-workspace`).
426
453
 
427
454
  22. **[M] TURNING A DIRECTORY BACK ON NEVER REACHES BACK.** A session that lived
428
455
  under `off` or `paused` left no session record and no span cursor, because the
@@ -803,9 +830,9 @@ charter).
803
830
 
804
831
  ## 7. Open questions
805
832
 
806
- 1. **Does the host offer an in-the-moment jot channel at all?** The owner's decision allows
807
- jots "where the host allows"; whether this host does, and at what cost to the turn, is
808
- unmeasured.
833
+ 1. ~~**Does the host offer an in-the-moment jot channel at all?**~~ **ANSWERED.** Not
834
+ through a hook: the jot channel is the MCP adapter's `note` tool (`mcp/CONTRACT.md`),
835
+ which the model calls mid-session; no hook calls `submitJot`.
809
836
  2. **What is the honest bound on the orphanable tail** — the stretch after the last
810
837
  session-ending event nobody can ask about — in this host specifically? v1 bounded it by
811
838
  its re-ask threshold and logged it, which is the right shape; the number is host-local.
@@ -99,9 +99,11 @@ entrance and prove the gate battery covers each (encode's caller-side half)."
99
99
  | `sweepFallback` → apply | `bridge.gateSweepChunk()` (CHUNK level) | `counterpart.ts` `applySweep()` |
100
100
 
101
101
  **Not yet covered, and named so it is not mistaken for covered:** anything an
102
- adapter other than this one adds. `mcp/`, `cli/` and `dashboard/` do not exist
103
- yet; when they do, the table above is the thing to extend, and the totality test
104
- in `test/claude-code.test.ts` is the shape to copy.
102
+ adapter other than this one adds. `mcp/`, `cli/` and `dashboard/` exist now, and
103
+ reach the core through the same `Counterpart` entrances above (the MCP tools
104
+ through `submitSessionEnd`, `submitJot` and `appendEpisode`); an entrance one of
105
+ them adds is the thing to extend this table with, and the totality test in
106
+ `test/claude-code.test.ts` is the shape to copy.
105
107
 
106
108
  ## 5. `kind` defaults in two places (SEAMS queued item 9, still open)
107
109
 
@@ -177,11 +179,9 @@ into the wrapper.
177
179
 
178
180
  ## Host-side gaps — this adapter's own open questions (CONTRACT §7)
179
181
 
180
- 1. **Is there a jot channel in this host?** `Counterpart.captureJot` and
181
- `submitJot` exist and are tested; no hook calls them, because the host offers
182
- no in-the-moment deposit surface this adapter can see. The MCP adapter is the
183
- likely home (`mcp/CONTRACT.md`: note, recall, status). Cost to the turn:
184
- unmeasured.
182
+ 1. **Is there a jot channel in this host? — CLOSED.** Yes, and not through a
183
+ hook: the MCP adapter's `note` tool is the jot channel (`mcp/CONTRACT.md`),
184
+ which the model calls mid-session. No hook calls `submitJot`.
185
185
  2. **The orphanable tail is measured, not bounded by anything host-specific.**
186
186
  `noteOrphanTail` runs on `session-end` and `pre-compact`, and its bound is
187
187
  `self/`'s re-ask thresholds — a memory number, not a host one. The host-local
@@ -195,11 +195,10 @@ into the wrapper.
195
195
  primary path in fact: it ran after every Stop, and on 2026-09-04 one evening's
196
196
  sweeps billed 13 chunks and minted 61 memories beside 34 authored ones.
197
197
  `pre-compact` is still wired and still captures; it is not by itself a crash.
198
- 4. **Long-call survival is asserted, not proven in this host (CONTRACT §5 G6).**
199
- The call streams (scar E3) and `socketLifetimeMs` is a reported capability
200
- with no reporter. The proof G6 asks for — one long call surviving this host's
201
- ceilings, in this host — needs a live run with a real credential, which no
202
- test here is entitled to make.
198
+ 4. **Long-call survival — MOOT since 2026-09-24 (keyless, CONTRACT §1a).** The
199
+ package makes no model call of its own, so there is no long call to prove and
200
+ no credential to prove it with (CONTRACT §5 G6 is struck).
201
+ `socketLifetimeMs` is still a reported capability with no reporter.
203
202
  5. **`executionCeilingMs` has no consumer.** It is reported and checkable; no
204
203
  code compares against it yet, because every foreground path is an appender and
205
204
  the heavy work is already detached. When something in the foreground can grow,
@@ -1849,3 +1849,34 @@ Working defaults, held lightly.
1849
1849
  `start` that runs the worker first).
1850
1850
  - **Delivery.** The delivery check compares each session's wake with the sentinel recorded
1851
1851
  at ITS start, so a session that woke before a rebuild still reads `delivered` (tested).
1852
+
1853
+ ## 2026-09-30 — the host seam (PR A of the host groundwork)
1854
+
1855
+ - **What moved.** The host-neutral half of `ClaudeCodeAdapter` is `adapters/lifecycle.ts`:
1856
+ the `HostLifecycle` interface and its implementation `Lifecycle` — `composeWake` (the
1857
+ wake plus the registry's sentinel), `plainFor` / `claimPlain` / `nowLine`, `recallTurn`
1858
+ (recall plus the `recall.delivered` row), `captureBoundary` (capture, the seal, credit,
1859
+ the `adapter.boundary` row), `noteTail`, `paceAsk` (the pacer and the `adapter.ask` row;
1860
+ the words stay here in `stopAsk`), `deliverWriteUpAsk`, `noteSession`, `spawnWorker` and
1861
+ its counters. `config.ts` and `spawn.ts` became the shared leaves `adapters/config.ts`
1862
+ and `adapters/spawn.ts`. The bodies moved verbatim; only their `this.` receiver changed.
1863
+ - **Extends, not holds.** `ClaudeCodeAdapter extends Lifecycle`. Two tests reach into the
1864
+ adapter by name (`envelope-budget.test.ts` stubs `a.dreamLines`, `write-up.test.ts`
1865
+ binds `a.deliverWriteUpAsk`); a held lifecycle would have made both stubs inert, and a
1866
+ refactor that has to change a test to pass is not a proof of no change.
1867
+ - **What stayed.** The re-fired Stop is refused in `askAtStop` before the pacer is asked
1868
+ (it was the first line of the old `askAtStop`'s try; same effect). The first-launch
1869
+ question, the wake-arrival check, the dream line and the headless nightly run, the
1870
+ update and doctor notices, primacy and every envelope measurement are still here —
1871
+ they are Claude Code's, or not yet needed by a second host.
1872
+ - **On disk.** Every registry record the lifecycle writes now carries `host:
1873
+ "claude-code"`; a record without one reads the same (`sessions.ts#hostOf`). That is the
1874
+ only on-disk change. A neutral config name (`counterparts.json`, read first when present)
1875
+ was built and taken back out before merge: the default path's identity checks
1876
+ (`throwawayDefaultRefusal`, `isNamed`, the console's `=== defaultConfigPath` tests)
1877
+ assume one fixed default, and a default that depends on which files exist let a named
1878
+ config slip past them. Nothing needs the new name yet; the config stays `claude-code.json`.
1879
+ - **Left for the Desktop work (PR B).** The worker script (`bin/runner.ts`) and the
1880
+ nightly run's planner still live here; a host that starts either from the MCP server
1881
+ needs their paths, not an import. `deliverWriteUpAsk`'s default limit is still this
1882
+ host's `HOST_OUTPUT_CHARS`; a tool result has no such cap and should pass its own.
@@ -38,8 +38,8 @@ import { canonicalScope, isEntrypoint, readSession } from "../../sessions.js";
38
38
  import { openLog } from "../../log/index.js";
39
39
  import type { LogEvent, ProcessLog } from "../../log/index.js";
40
40
  import { resolveZone, todayIn } from "../../../core/time.js";
41
- import { TUNABLES, loadConfig, withEmbedderDefault } from "../config.js";
42
- import type { AdapterConfig } from "../config.js";
41
+ import { TUNABLES, loadConfig, withEmbedderDefault } from "../../config.js";
42
+ import type { AdapterConfig } from "../../config.js";
43
43
  import { HOOKS, openAdapter } from "../index.js";
44
44
  import { STOP_HUMAN_LINE, plainLine, withoutDream, withoutDreamNote, withoutPlain } from "../hooks.js";
45
45
  import type { PlainReminder } from "../../../core/counterpart.js";
@@ -90,11 +90,11 @@ import {
90
90
  } from "../../config-path.js";
91
91
  import type { ConfigChoice } from "../../config-path.js";
92
92
 
93
- import { loadConfig, withEmbedderDefault } from "../config.js";
94
- import type { AdapterConfig } from "../config.js";
93
+ import { loadConfig, withEmbedderDefault } from "../../config.js";
94
+ import type { AdapterConfig } from "../../config.js";
95
95
  import { openEmbedder } from "../index.js";
96
96
  import type { LiveEmbedder } from "../embed-client.js";
97
- import { DATA_DIR_ENV, SCOPE_ENV, SESSION_ENV, WATCHDOG_ENV } from "../spawn.js";
97
+ import { DATA_DIR_ENV, SCOPE_ENV, SESSION_ENV, WATCHDOG_ENV } from "../../spawn.js";
98
98
  import { backfillVectors, laggedSemantic } from "../vectors.js";
99
99
  import type { BackfillReport, LagReport } from "../vectors.js";
100
100
  import { runSnapshot } from "../../snapshots.js";
@@ -100,8 +100,8 @@ import {
100
100
  readSnapshotsDir,
101
101
  resolveSnapshotsDir,
102
102
  } from "../snapshots.js";
103
- import { TUNABLES, pageWriterMode, resolveEmbedder, withEmbedderDefault } from "./config.js";
104
- import type { EmbedderSource } from "./config.js";
103
+ import { TUNABLES, pageWriterMode, resolveEmbedder, withEmbedderDefault } from "../config.js";
104
+ import type { EmbedderSource } from "../config.js";
105
105
  import { MODEL_FILE, STATIC_WEIGHTS_ENV, STATIC_WEIGHTS_PACKAGE, resolveStaticWeights } from "../../core/embed/static.js";
106
106
  import { heldExits } from "../../core/store/index.js";
107
107
  // Retention's own reading and its own week, so the Raw transcripts line cannot
@@ -111,7 +111,10 @@ import { SpanBuffer, TUNABLES as REMEMBER_TUNABLES, lastRetentionRun } from "../
111
111
  import { lapsesSince, ledger } from "../../core/coverage/index.js";
112
112
  import type { LedgerEntry } from "../../core/coverage/index.js";
113
113
  import {
114
+ DESKTOP_WAKE_KEY,
115
+ hostOf,
114
116
  hostSessionEvidence,
117
+ listSessions,
115
118
  pointable,
116
119
  progressKey,
117
120
  readWriteUpPointer,
@@ -120,7 +123,9 @@ import {
120
123
  writeUpEntries,
121
124
  writeUpPlan,
122
125
  } from "../sessions.js";
123
- import type { AdapterConfig } from "./config.js";
126
+ import { DESKTOP_HOST } from "../hosts.js";
127
+ import { localStamp } from "../../core/time.js";
128
+ import type { AdapterConfig } from "../config.js";
124
129
  // The same vocabulary the hook's stand-down uses, so the terminal and the
125
130
  // console cannot end up with two answers to "why did it not open".
126
131
  import { describeFault, faultId, faultPath } from "./standdown.js";
@@ -261,6 +266,13 @@ export interface DoctorInput {
261
266
  * four more file reads.
262
267
  */
263
268
  readonly host?: HostReading;
269
+ /**
270
+ * CLAUDE DESKTOP'S CONFIG ENTRY (2026-09-30), read by the console
271
+ * (`cli/desktop.ts#readDesktop`). Absent: not read, no finding — the hook's
272
+ * case, and Desktop's `wake`. No entry: no finding either — Desktop is
273
+ * optional, and a line about it would be noise to everyone without it.
274
+ */
275
+ readonly desktop?: DesktopReading;
264
276
  /** Bound the whole reading. Absent: no bound (the console's case). */
265
277
  readonly budgetMs?: number;
266
278
  readonly now?: () => number;
@@ -3578,6 +3590,100 @@ export interface HostReading {
3578
3590
  readonly mcpAddLine?: string;
3579
3591
  }
3580
3592
 
3593
+ /** What the console read of Claude Desktop's config (`cli/desktop.ts#readDesktop`). */
3594
+ export interface DesktopReading {
3595
+ readonly path: string;
3596
+ readonly state: "absent" | "no-entry" | "entry" | "unreadable";
3597
+ /** The store Desktop's `counterparts` entry names, or null. */
3598
+ readonly dataDir: string | null;
3599
+ /** Claude Code's own registration names `counterparts` too — the Code-tab clash. */
3600
+ readonly codeTab: boolean;
3601
+ /** The store Claude Code's registration names, or null. */
3602
+ readonly codeDataDir: string | null;
3603
+ }
3604
+
3605
+ /**
3606
+ * THE CLAUDE DESKTOP LINE (2026-09-30, brief item 8): whether its config entry
3607
+ * is present, and when the last Desktop wake and session were. QUIET when there
3608
+ * is no entry — Desktop is optional — and never amber for that. Amber only for
3609
+ * an entry that is there and names another store than this one, directly or
3610
+ * through the Code tab's name clash (`cli/desktop.ts`'s header). Desktop
3611
+ * sessions are named as NOT MEASURED for write-ups: nothing is captured there,
3612
+ * so there is no stretch to count as written up or not — never as lost.
3613
+ */
3614
+ function desktopFindings(reading: DesktopReading, store: Store | null, dir: string): Finding[] {
3615
+ if (reading.state === "absent" || reading.state === "no-entry") return [];
3616
+ const data: Record<string, string | number | boolean | null> = {
3617
+ path: reading.path,
3618
+ state: reading.state,
3619
+ dataDir: reading.dataDir,
3620
+ codeTab: reading.codeTab,
3621
+ codeDataDir: reading.codeDataDir,
3622
+ };
3623
+ if (reading.state === "unreadable") {
3624
+ return [
3625
+ finding(
3626
+ "desktop",
3627
+ "green",
3628
+ "Claude Desktop",
3629
+ `${reading.path} could not be read as JSON, so whether Counterparts is connected there is not known`,
3630
+ "",
3631
+ data,
3632
+ ),
3633
+ ];
3634
+ }
3635
+ const same = (a: string | null, b: string | null): boolean => a === null || b === null || sameScope(a, b);
3636
+ const fix = "Run: counterparts install --host claude-desktop — then quit and reopen Claude Desktop.";
3637
+ if (!same(reading.dataDir, dir)) {
3638
+ return [
3639
+ finding(
3640
+ "desktop",
3641
+ "amber",
3642
+ "Claude Desktop",
3643
+ `connected, but its entry names a different store (${reading.dataDir ?? "?"}) from this one (${dir})`,
3644
+ fix,
3645
+ data,
3646
+ ),
3647
+ ];
3648
+ }
3649
+ if (reading.codeTab && !same(reading.dataDir, reading.codeDataDir)) {
3650
+ return [
3651
+ finding(
3652
+ "desktop",
3653
+ "amber",
3654
+ "Claude Desktop",
3655
+ `Desktop's Code tab loads Desktop's counterparts entry in place of ~/.claude.json's, and the two name different stores (${reading.dataDir ?? "?"} and ${reading.codeDataDir ?? "?"})`,
3656
+ fix,
3657
+ data,
3658
+ ),
3659
+ ];
3660
+ }
3661
+ // WHEN IT LAST WOKE, AND WHAT IS LIVE — one meta read and the registry's week.
3662
+ const zone = store?.zone() ?? "UTC";
3663
+ let lastWake: number | null = null;
3664
+ try {
3665
+ const raw = store?.getMeta(DESKTOP_WAKE_KEY);
3666
+ lastWake = raw === undefined || raw === null || !Number.isFinite(Number(raw)) ? null : Number(raw);
3667
+ } catch {
3668
+ lastWake = null;
3669
+ }
3670
+ const desktop = listSessions(dir).filter((r) => hostOf(r) === DESKTOP_HOST);
3671
+ const lastSession = desktop[0]?.lastBoundaryAt ?? null;
3672
+ data["lastWake"] = lastWake;
3673
+ data["lastSession"] = lastSession;
3674
+ data["sessions"] = desktop.length;
3675
+ const parts = [
3676
+ `connected (${reading.path.split("/").pop() ?? reading.path})`,
3677
+ lastWake === null ? "no wake yet" : `last wake ${localStamp(lastWake, zone)}`,
3678
+ ...(lastSession === null ? [] : [`last session active ${localStamp(lastSession, zone)}`]),
3679
+ ...(desktop.length === 0
3680
+ ? []
3681
+ : [`${String(desktop.length)} Desktop ${desktop.length === 1 ? "session" : "sessions"} this week, not measured for write-ups (Desktop chat keeps no transcript)`]),
3682
+ ...(reading.codeTab ? ["its Code tab uses this entry in place of ~/.claude.json's — both name this store"] : []),
3683
+ ];
3684
+ return [finding("desktop", "green", "Claude Desktop", parts.join("; "), "", data)];
3685
+ }
3686
+
3581
3687
  function hostFindings(reading: HostReading): Finding[] {
3582
3688
  const total = reading.expected.length;
3583
3689
  const missing = reading.expected.filter((e) => !reading.events.includes(e));
@@ -3784,6 +3890,8 @@ export function doctorFindings(input: DoctorInput): Finding[] {
3784
3890
  // DID THE HOST STEPS TAKE (finding 4). Also read by the caller — it is four
3785
3891
  // small file reads outside this store, and the hook does not pay for them.
3786
3892
  ...(input.host === undefined ? [] : hostFindings(input.host)),
3893
+ // CLAUDE DESKTOP (2026-09-30): its config entry, and when it last woke.
3894
+ ...(input.desktop === undefined ? [] : desktopFindings(input.desktop, input.store, input.dir)),
3787
3895
  ];
3788
3896
  const store = input.store;
3789
3897
  if (store === null) return worstFirst(out);
@@ -21,7 +21,7 @@ import type { StaticModel } from "../../core/embed/static.js";
21
21
  import type { Embedder, EmbedderIdentity } from "../../core/store/index.js";
22
22
  import { hashText } from "../../core/store/index.js";
23
23
 
24
- import type { AdapterConfig, EmbedderKind } from "./config.js";
24
+ import type { AdapterConfig, EmbedderKind } from "../config.js";
25
25
 
26
26
  /** One fill's failure, named — what the worker's backfill row persists as `codes`. */
27
27
  export interface ChunkFailure {