counterparts 0.3.18 → 0.3.19
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.
- package/CHANGELOG.md +122 -0
- package/docs/module-map.md +17 -0
- package/package.json +1 -1
- package/src/adapters/claude-code/CONTRACT.md +34 -13
- package/src/adapters/claude-code/INTERFACE-GAPS.md +13 -10
- package/src/adapters/claude-code/NOTES.md +50 -0
- package/src/adapters/claude-code/child.ts +44 -4
- package/src/adapters/claude-code/doctor-checkout.ts +335 -0
- package/src/adapters/claude-code/doctor-finding.ts +168 -0
- package/src/adapters/claude-code/doctor-host.ts +400 -0
- package/src/adapters/claude-code/doctor-open.ts +337 -0
- package/src/adapters/claude-code/doctor-report.ts +188 -0
- package/src/adapters/claude-code/doctor-self-page.ts +504 -0
- package/src/adapters/claude-code/doctor-upgrades.ts +238 -0
- package/src/adapters/claude-code/doctor-write-ups.ts +278 -0
- package/src/adapters/claude-code/doctor.ts +101 -2399
- package/src/adapters/claude-code/hooks.ts +27 -8
- package/src/adapters/claude-code/index.ts +0 -3
- package/src/adapters/claude-code/night-catch-up.ts +92 -24
- package/src/adapters/claude-code/night-run.ts +52 -41
- package/src/adapters/claude-code/reowe.ts +239 -0
- package/src/adapters/claude-code/transcript.ts +53 -78
- package/src/adapters/cli/CONTRACT.md +2 -2
- package/src/adapters/cli/INTERFACE-GAPS.md +5 -3
- package/src/adapters/cli/NOTES.md +10 -2
- package/src/adapters/cli/catch-up.ts +79 -1
- package/src/adapters/cli/commands-dashboard.ts +254 -0
- package/src/adapters/cli/commands-install.ts +1387 -0
- package/src/adapters/cli/commands-note.ts +624 -0
- package/src/adapters/cli/commands-readings.ts +983 -0
- package/src/adapters/cli/commands-remove.ts +659 -0
- package/src/adapters/cli/commands-scope.ts +474 -0
- package/src/adapters/cli/commands-self.ts +766 -0
- package/src/adapters/cli/commands-shared.ts +554 -0
- package/src/adapters/cli/commands-start-fresh.ts +1233 -0
- package/src/adapters/cli/commands-verify.ts +1301 -0
- package/src/adapters/cli/commands.ts +219 -8115
- package/src/adapters/cli/coverage.ts +40 -5
- package/src/adapters/cli/dream-core.ts +13 -7
- package/src/adapters/cli/help.ts +9 -6
- package/src/adapters/cli/mechanisms.ts +3 -1
- package/src/adapters/cli/start-fresh.ts +13 -8
- package/src/adapters/dashboard/NOTES.md +1 -1
- package/src/adapters/dashboard/stories.ts +3 -1
- package/src/adapters/dashboard/web/narrate.ts +10 -6
- package/src/adapters/dashboard/web/pages/self/sections/settling.js +15 -4
- package/src/adapters/dashboard/web/views/archive-words.ts +2 -1
- package/src/adapters/dashboard/web/views/dreams.ts +10 -2
- package/src/adapters/dashboard/web/views/mechanisms.ts +1 -0
- package/src/adapters/dashboard/web/views/mind.ts +20 -1
- package/src/adapters/lifecycle.ts +11 -5
- package/src/adapters/mcp/CONTRACT.md +4 -4
- package/src/adapters/mcp/NOTES.md +8 -4
- package/src/adapters/mcp/facts.ts +3 -2
- package/src/adapters/mcp/meaning.ts +17 -2
- package/src/adapters/mcp/server-args.ts +522 -0
- package/src/adapters/mcp/server-options.ts +259 -0
- package/src/adapters/mcp/server-self-tools.ts +725 -0
- package/src/adapters/mcp/server-session-end.ts +654 -0
- package/src/adapters/mcp/server-words.ts +225 -0
- package/src/adapters/mcp/server.ts +149 -2238
- package/src/adapters/mcp/tools.ts +48 -5
- package/src/adapters/mcp/write-up.ts +54 -8
- package/src/adapters/mechanism-evidence.ts +21 -5
- package/src/adapters/sessions.ts +54 -8
- package/src/core/associate/index.ts +34 -7
- package/src/core/counterpart-boundary.ts +911 -0
- package/src/core/counterpart-deposit.ts +726 -0
- package/src/core/counterpart-events.ts +968 -0
- package/src/core/counterpart-sweep.ts +884 -0
- package/src/core/counterpart-types.ts +715 -0
- package/src/core/counterpart.ts +351 -3960
- package/src/core/coverage/CONTRACT.md +20 -1
- package/src/core/coverage/NOTES.md +4 -1
- package/src/core/coverage/index.ts +5 -3
- package/src/core/dream/CONTRACT.md +61 -22
- package/src/core/dream/NOTES.md +62 -0
- package/src/core/dream/index.ts +444 -122
- package/src/core/dream/reflect.ts +66 -11
- package/src/core/dream/tunables.ts +43 -11
- package/src/core/fit/index.ts +2 -2
- package/src/core/handoff/CONTRACT.md +1 -1
- package/src/core/leaving.ts +3 -1
- package/src/core/mint.ts +5 -0
- package/src/core/physics/CONTRACT.md +23 -7
- package/src/core/physics/index.ts +141 -37
- package/src/core/prospective/CONTRACT.md +9 -1
- package/src/core/prospective/index.ts +53 -7
- package/src/core/recall/CONTRACT.md +19 -5
- package/src/core/recall/NOTES.md +1 -1
- package/src/core/recall/activate.ts +22 -0
- package/src/core/recall/index.ts +12 -4
- package/src/core/recall/standing.ts +29 -14
- package/src/core/reconsolidation.ts +653 -63
- package/src/core/remember/CONTRACT.md +3 -1
- package/src/core/remember/INTERFACE-GAPS.md +2 -2
- package/src/core/remember/NOTES.md +17 -0
- package/src/core/remember/proposals.ts +8 -2
- package/src/core/remember/spans.ts +82 -2
- package/src/core/revision.ts +168 -45
- package/src/core/schemas/CONTRACT.md +22 -2
- package/src/core/schemas/NOTES.md +75 -0
- package/src/core/schemas/index.ts +138 -1
- package/src/core/schemas/names.ts +298 -0
- package/src/core/schemas/tunables.ts +18 -0
- package/src/core/schemas/types.ts +25 -0
- package/src/core/self/CONTRACT.md +7 -3
- package/src/core/self/INTERFACE-GAPS.md +1 -1
- package/src/core/self/NOTES.md +2 -2
- package/src/core/self/briefing.ts +46 -3
- package/src/core/self/identity.ts +42 -3
- package/src/core/self/index.ts +59 -18
- package/src/core/self/tunables.ts +8 -0
- package/src/core/sleep/CONTRACT.md +14 -2
- package/src/core/sleep/NOTES.md +26 -1
- package/src/core/sleep/births.ts +74 -0
- package/src/core/sleep/consolidate.ts +254 -26
- package/src/core/sleep/core-standing.ts +155 -0
- package/src/core/sleep/cycle.ts +15 -0
- package/src/core/sleep/index.ts +8 -0
- package/src/core/sleep/tunables.ts +21 -0
- package/src/core/sleep/types.ts +17 -2
- package/src/core/store/NOTES.md +62 -5
- package/src/core/store/db.ts +61 -13
- package/src/core/store/errors.ts +7 -0
- package/src/core/store/index-text.ts +110 -0
- package/src/core/store/index.ts +374 -1541
- package/src/core/store/marks.ts +277 -0
- package/src/core/store/operational.ts +9 -1
- package/src/core/store/owner-op-seam.ts +22 -1
- package/src/core/store/paths.ts +18 -0
- package/src/core/store/pre-migration.ts +17 -2
- package/src/core/store/reads-history.ts +273 -0
- package/src/core/store/reads-marks.ts +165 -0
- package/src/core/store/reads-memories.ts +453 -0
- package/src/core/store/shapes.ts +549 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,127 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.19 — 2026-10-12
|
|
4
|
+
|
|
5
|
+
Reminders now arrive. A reminder due today stays under "Arriving:" in the wake all day, the near ones come first when a session starts, a reminder is no longer counted as told to a message nobody typed (an agent's hand-back or a task notification), and a memory that reads like a reminder but has no date now says so. Counterparts also reads far less of Claude Code's own files: the nightly run no longer scans `~/.claude/projects`, and the wake-arrival check is off unless you ask for it, which is what the plugin directory asked for. Underneath: the core can change (a kept promise can retire, a declared change moves it in about three days), the night folds memories that belong together and writes up everything it was owed, cards for people and projects are born at last, and the biggest source files are split so the plugin bundle fits the directory's file limit. No store-format change (store v13, cache v6), so there is no migration, and nothing to run after upgrading from 0.3.18.
|
|
6
|
+
|
|
7
|
+
- **The core can change now.** A core memory used to be write-once in practice: a kept promise could never
|
|
8
|
+
retire the promise. A change you declare at one now counts at full daily weight, so it moves in about three
|
|
9
|
+
days of saying so, and a plan the core held (with a status or a date) leaves it at once when a memory says it
|
|
10
|
+
is done. Either can be undone.
|
|
11
|
+
- **A moved reminder's old memory steps back.** When a reminder moves to a newer memory, the one it left is
|
|
12
|
+
marked as the earlier one and fades, instead of staying as current with its future-tense words. The few
|
|
13
|
+
older ones get the same once.
|
|
14
|
+
- **One record for every "this replaces that".** A dream's merge, a settle, a write that updates a memory, the
|
|
15
|
+
core's slow change and a moved reminder now all leave the same record and the same undo, and a settle over a
|
|
16
|
+
memory with a date still to come carries the reminder to the newer one. A dream's merge keeps its originals
|
|
17
|
+
as faded earlier versions behind the merged memory (hidden from what comes up on its own) until they fade
|
|
18
|
+
out, instead of putting them away, and one original can be brought back on its own. A corrected memory hands
|
|
19
|
+
its links to the one that holds.
|
|
20
|
+
- **"Done" ends a reminder.** A memory that says something is done no longer takes over the reminder of the
|
|
21
|
+
plan it finishes, so it does not remind you on the day of something already done. The dashboard counts what was noticed (merges, newer states found) apart from what
|
|
22
|
+
was declared, so nothing shows under both.
|
|
23
|
+
- **Earlier versions say so in more places.** A "meaning" answer marks an earlier moment with the memory that
|
|
24
|
+
holds now, and a newer memory reached only through a link now stands in for its earlier version instead of
|
|
25
|
+
showing beside it.
|
|
26
|
+
- **Cards for the people and projects you talk about are born at last.** A card used to be
|
|
27
|
+
born only when a memory's title was exactly a name, which almost never happens, so a store
|
|
28
|
+
in daily use for weeks had one card: yours. Now, once a day at the end of a session, the
|
|
29
|
+
names your memories keep saying (in at least 3 memories on at least 2 days) get a card, ten
|
|
30
|
+
a day at most, the most-said first. Capitalized words that are also ordinary words, and days
|
|
31
|
+
and months, don't. A new card links every memory that names it, and a question by that name
|
|
32
|
+
reads those links.
|
|
33
|
+
- **A card no longer shows up as a memory.** A newborn card holds only its name, so it isn't
|
|
34
|
+
shown in a turn's recall or among the results of a question by name; the memories it links
|
|
35
|
+
are.
|
|
36
|
+
- **A card you remove stays removed.** Removing a person's or project's card no longer lets
|
|
37
|
+
the nightly count of names give it a new card from the same memories.
|
|
38
|
+
- **What keeps coming back can become core.** The slow road into the core asked for five separate days of use
|
|
39
|
+
over three weeks, and nothing ever made it. Now it counts a memory together with its earlier and later states:
|
|
40
|
+
used, cited in a reflection, or written about again, on four days, in three sessions, over a week, within the
|
|
41
|
+
last month, as long as the memory itself was used. The newest state is the one that crosses.
|
|
42
|
+
- **The core is about me and us.** A memory about you alone, a fact, or a plan no longer becomes core. The ones
|
|
43
|
+
already there that this moves out are not dropped: they show as "being reconsidered", in the wake's Still open
|
|
44
|
+
list and on the dashboard's Self page, and stay core until one of us decides.
|
|
45
|
+
- **Nothing leaves the core without a decision.** A core memory that stops coming back for 60 lived days is
|
|
46
|
+
reconsidered too, never dropped on its own. You keep one with `counterparts core --reaffirm <id> --reason "…"` or send
|
|
47
|
+
it back with `--demote`. I can do the same, awake (`remember` with `core`) or when I reflect, and a flag lifts
|
|
48
|
+
itself when its reason goes away (say a memory is re-marked as about us).
|
|
49
|
+
- **The night folds what belongs together.** When several memories are parts of one event or one stretch
|
|
50
|
+
of work (a day's merges, a release, one book), the dream can now fold them into one memory that says what
|
|
51
|
+
they add up to. The fold starts as strong as its strongest part, and the parts stay, marked earlier under it,
|
|
52
|
+
at half their strength, so recall leads with the fold and the parts are there when you ask for detail.
|
|
53
|
+
Readings, strongly felt memories about you or someone, and the core are never faded by a fold. At most five folds a night; any past that
|
|
54
|
+
are counted and said in the morning line.
|
|
55
|
+
- **A correction reaches the summary.** When a memory a fold was made from is corrected, the fold is flagged
|
|
56
|
+
beside the correction as possibly out of date, so it gets read again instead of carrying the old claim.
|
|
57
|
+
- **A personal fold can become core the ordinary way.** A fold is about you or about us only when most of its
|
|
58
|
+
parts are. Once folded, what comes back counts toward the slow road into the core: the fold's own uses and
|
|
59
|
+
its parts' later uses, across sessions and days. Its parts' history from before the fold does not.
|
|
60
|
+
- **A newer settle no longer stands an outdated memory back up.** Settling "B replaces A" after "C replaces B"
|
|
61
|
+
used to make B current again over C. Now a settle speaks only about the two memories it names, and B stays
|
|
62
|
+
earlier under C. To make B current again, settle B over C: that reorders the pair.
|
|
63
|
+
- **A catch-up no longer re-reads what a session already wrote up.** A long session that wrote its own
|
|
64
|
+
chapters as it went left parts whose every word was already written up, and a catch-up handed each one to a
|
|
65
|
+
reader anyway, about 24 KB at a time, only for it to answer "nothing new" in two seconds. Those parts are now
|
|
66
|
+
passed over without a reader and cost a batch nothing, and the run's summary says how many there were
|
|
67
|
+
("16 parts written, 11 of them already written up in their own session"). On the first live catch-up's
|
|
68
|
+
biggest session that is one child instead of three, with about the same memories kept.
|
|
69
|
+
- **A catch-up's "nothing worth keeping" says why.** In the nightly run or `counterparts catch-up`, an empty
|
|
70
|
+
answer for a part that holds words not yet written up now needs a one-line reason; without one the part is
|
|
71
|
+
not counted as written, stays owed for the next run, and doctor and `counterparts coverage` say how many
|
|
72
|
+
parts were left unread. A live session's empty answer is unchanged.
|
|
73
|
+
- **`counterparts catch-up --reowe <run>`.** Owes again the parts a named run closed with nothing kept, when
|
|
74
|
+
their words were not yet written up. It prints the plan first, then asks for the run's id typed back
|
|
75
|
+
(`--yes` skips that, `--dry-run` stops at the plan), and refuses by name what it cannot do: a session the
|
|
76
|
+
run went on to write up, parts after them that brought memories back, or words no longer kept. It reads the
|
|
77
|
+
run from the log, which keeps a week.
|
|
78
|
+
- **A note no longer marks the whole session as written up.** A note written mid-session used to count everything
|
|
79
|
+
said before it as written up, so one short note could leave hours of conversation that nothing ever wrote
|
|
80
|
+
down. Now a note covers only the turn it was written in; the rest waits for the session's own write-up, a
|
|
81
|
+
later session, or the night's catch-up, and the end-of-session ask still comes when it is due.
|
|
82
|
+
- **`counterparts coverage` agrees with the catch-up and doctor about who owes.** A small stretch from a session
|
|
83
|
+
that was not a person's (`claude -p`, the Agent SDK) is listed as left to lapse, not as owed, and the line about
|
|
84
|
+
parts a catch-up left unread shows only for today or for the date that run was on.
|
|
85
|
+
- **The night picks what to dream by what it is worth and how close it is to fading.** The dream used to read
|
|
86
|
+
only the newest 2,000 not-yet-dreamed memories and keep each one waiting for at most a week. Now it reads all of
|
|
87
|
+
them and ranks them by value (how much a memory mattered, how strongly it was felt, whether it is dated or on
|
|
88
|
+
my mind) times how weakly it is held on its own forgetting curve. A memory waits as long as it is still within
|
|
89
|
+
reach, however old, and one that fades below reach before a dream gets to it is counted and said, not dropped
|
|
90
|
+
silently. The night's budget is the same as before.
|
|
91
|
+
- **A fold the night had no room for comes back.** When a night has already made its five folds, the parts of
|
|
92
|
+
the next fold are carried to the next night, together and first in line, so it can be made then. Parts a fold
|
|
93
|
+
would not fade (readings, strongly felt memories, dated ones, the core) are not carried.
|
|
94
|
+
- **A reminder due today stays under "Arriving:" all day.** A dated item that had already come up twice in
|
|
95
|
+
conversation in the days before, or had come up once earlier the same day, dropped out of the wake's
|
|
96
|
+
"Arriving:" list, sometimes on the very day it was due. A plain reminder told to the first session of its
|
|
97
|
+
day also dropped out, even when that "session" was an agent's message at midnight that nobody read. Now
|
|
98
|
+
the list keeps a dated item until its day is behind it. How often a reminder is raised mid-conversation is
|
|
99
|
+
unchanged.
|
|
100
|
+
- **"Arriving:" no longer goes silent.** When a long self page left room for no dated line, the wake said
|
|
101
|
+
nothing at all about what was arriving. Now it always gives the one-line count with the ids
|
|
102
|
+
(`Arriving: 7 — no room to list them in this wake`), taking that room from "Work here", the Yesterday
|
|
103
|
+
line's titles and the handoffs. Doctor's Wake line now counts these as renders of the wake, and its advice
|
|
104
|
+
says what actually gives way.
|
|
105
|
+
- **A reminder written without a date now says so.** When a memory reads like a reminder ("remind", "don't forget", "follow up", "check back" beside a date such as "Oct 14", a weekday or "tomorrow") but is stored with no `eventDate`, the `remember` and `session_end` answers carry a one-line `reminderHint`: it will never come back on a date, and revising it with an `eventDate` makes it fire. The date is never guessed from the text and the write is never refused.
|
|
106
|
+
- **Fewer reads of Claude Code's own files.** The nightly run no longer looks through `~/.claude/projects` for
|
|
107
|
+
its own background session's transcript: it reads what that session printed as it ran, and doctor's Tool
|
|
108
|
+
results line says whether that output was read. Claude Code's compaction summaries, skill bodies, hook
|
|
109
|
+
feedback and other lines it writes for itself are no longer kept with a session's words; a message another
|
|
110
|
+
session sent to this one still is.
|
|
111
|
+
- **The wake-arrival check is off by default.** It read the start of the session's transcript only to confirm
|
|
112
|
+
the wake arrived whole. Set `COUNTERPARTS_WAKE_CHECK=1` in Claude Code's environment to turn it back on;
|
|
113
|
+
doctor's Wake line names the setting when no wake was checked.
|
|
114
|
+
- **A reminder is no longer "told" to a message nobody read.** When an agent's hand-back, a task
|
|
115
|
+
notification or another session's message started a turn, a plain reminder due that day was said
|
|
116
|
+
there and counted as told. Now it waits for the next message you type. The same goes for the
|
|
117
|
+
morning's dream line and share.
|
|
118
|
+
- **Dated items due in the next few days come first when a session starts.** At session start, the
|
|
119
|
+
"Arriving:" lines due today through three days ahead are listed first and take room before "Last
|
|
120
|
+
here", "Last said here", "Today, elsewhere" and the older handoffs. The newest handoff always keeps
|
|
121
|
+
its place.
|
|
122
|
+
- **A quiet dated item that already came up leaves after its day.** One that had been raised twice in
|
|
123
|
+
the days before stayed under "Arriving:" for a week as "was due". Now it leaves once its day is past.
|
|
124
|
+
|
|
3
125
|
## 0.3.18 — 2026-10-11
|
|
4
126
|
|
|
5
127
|
A new install now starts with a first meeting: in its first session Counterparts offers,
|
package/docs/module-map.md
CHANGED
|
@@ -58,6 +58,23 @@ input — does `encode` shrink to gates-and-tagging inside `remember`'s pipeline
|
|
|
58
58
|
| `stance-env.ts` | `COUNTERPARTS_OBSERVER` / `COUNTERPARTS_OWNER`, read the way the explicit-dir guard is, each failing toward less power. Unset, the configuration's `owner: true` decides for a server Claude Code starts (`mcp/bin/serve.ts#ownerStance`, 2026-10-02). |
|
|
59
59
|
| `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. |
|
|
60
60
|
|
|
61
|
+
**The five largest files, split by concern (2026-10-11)** — moves only, for the plugin
|
|
62
|
+
directory's check on files over 256 KiB. Each file still exports everything it did, so no
|
|
63
|
+
import changed. `core/counterpart.ts` keeps the class; its event names and record builders
|
|
64
|
+
are in `counterpart-events.ts`, its shapes in `counterpart-types.ts`, and the bodies of the
|
|
65
|
+
boundary, the sweep fallback and the deposit in `counterpart-boundary.ts`,
|
|
66
|
+
`counterpart-sweep.ts` and `counterpart-deposit.ts`. `core/store/index.ts` keeps the class
|
|
67
|
+
and every write; `marks.ts`, `shapes.ts` and `index-text.ts` hold its marks, shapes and
|
|
68
|
+
index text, and `reads-memories.ts`, `reads-marks.ts` and `reads-history.ts` the bodies of
|
|
69
|
+
its public reads. `mcp/server.ts` keeps the class; `server-words.ts`, `server-options.ts`
|
|
70
|
+
and `server-args.ts` hold its words, options and argument readers, and
|
|
71
|
+
`server-session-end.ts` and `server-self-tools.ts` the bodies of five of its tools.
|
|
72
|
+
`cli/commands.ts` keeps the dispatcher, the help, and the repair that reads through the
|
|
73
|
+
walk seam (its importers are pinned); each other command family is a `commands-*.ts` file. `claude-code/doctor.ts` keeps `doctorFindings` and about half the checks
|
|
74
|
+
(every one that reads the zone it sets); the finding's shape and the checkout, open, upgrade,
|
|
75
|
+
self-page, host, write-up and report groups are `doctor-*.ts` files. A moved class body is a free function taking the
|
|
76
|
+
instance, behind a one-line delegate on the class (`docs/decisions.d/refactor-file-split.md`).
|
|
77
|
+
|
|
61
78
|
## Tools (`tools/`)
|
|
62
79
|
|
|
63
80
|
| tool | job |
|
package/package.json
CHANGED
|
@@ -75,7 +75,9 @@ credential — belongs here, discovered at runtime, never assumed by the core.
|
|
|
75
75
|
because only the render was instrumented. SessionStart writes the sentinel it printed
|
|
76
76
|
into the session registry record, and the session's FIRST PROMPT reads the head of the
|
|
77
77
|
host's transcript (or, when the host has not written the file yet, the next prompt or the
|
|
78
|
-
first Stop — 2026-10-08)
|
|
78
|
+
first Stop — 2026-10-08) — **an opt-in diagnostic since 2026-10-12: only when the hooks'
|
|
79
|
+
environment sets `COUNTERPARTS_WAKE_CHECK=1`; off, nothing is read and no row written,
|
|
80
|
+
and doctor's Wake line names the opt-in when it has no rows** — for this package's SessionStart attachment — what the hook printed
|
|
79
81
|
beside what the host recorded as injected — and leaves one `adapter.wake.delivered` row
|
|
80
82
|
saying `delivered`, `truncated`, `mismatch`, `printed-unverified` (this host build
|
|
81
83
|
records no injected copy to check against), `not-found` or `no-wake-expected`, in counts
|
|
@@ -189,7 +191,13 @@ owner's (measured 2026-09-04, `fix/transcript-peer-speakers`):
|
|
|
189
191
|
2026-09-23; shapes measured on 2.1.28x, table in `NOTES.md`): `origin.kind: "human"` is the
|
|
190
192
|
person — typed, queued, or pasted; `isMeta`, `isCompactSummary`, and any other
|
|
191
193
|
`origin.kind` (`peer` for a subagent's hand-back, `task-notification`) are the host, and
|
|
192
|
-
are `injected` — kept in capture, out of pacing.
|
|
194
|
+
are `injected` — kept in capture, out of pacing. **Except the host's own lines
|
|
195
|
+
(2026-10-12, `transcript.ts#hostRecord`, held lightly):** a compaction summary and every
|
|
196
|
+
`isMeta` line but a peer's message (hook feedback, `/context` output, image captions, skill
|
|
197
|
+
bodies, the idle notice) enter no turn at all — they are Claude Code's bookkeeping and its
|
|
198
|
+
conversation summaries, not the conversation, and a summary repeats turns already
|
|
199
|
+
captured. What they would have been refused as (`foreign`, `ritual`, `dream`) is still
|
|
200
|
+
read and counted. The new text markers (anchored at the
|
|
193
201
|
start of the block) decide only for a USER-role entry that carries no metadata; the
|
|
194
202
|
assistant's text is never reclassified by a marker, and `classifyBlock` — the rule both
|
|
195
203
|
roles share — is unchanged. The two refusals (`foreign`, `ritual`) come before the
|
|
@@ -591,7 +599,7 @@ row, saying which source answered, existed until the keys were removed — §1a.
|
|
|
591
599
|
`assertSafeDataDir` and writes tmp-then-rename, `sessions.ts`'s own rule for
|
|
592
600
|
the same directory.
|
|
593
601
|
`counterparts doctor` reads the same open with the same predicates
|
|
594
|
-
(`doctor.ts#readCounterpartOpen`) — RED for a store that will not open, AMBER
|
|
602
|
+
(`doctor-open.ts#readCounterpartOpen`) — RED for a store that will not open, AMBER
|
|
595
603
|
for one that was busy or that only an owner may initialize — so the terminal
|
|
596
604
|
and the console cannot disagree about what happened.
|
|
597
605
|
|
|
@@ -811,17 +819,22 @@ deny beats the user's own allow rules; `ToolSearch` stays, for hosts that defer
|
|
|
811
819
|
`--strict-mcp-config` with an `--mcp-config` naming only the counterparts server, as the
|
|
812
820
|
install registers it (`nightMcpConfig`); `--max-turns` (`NIGHT_MAX_TURNS` 60,
|
|
813
821
|
`dreaming.maxTurns`); `--model` only when `dreaming.model` is set; `--session-id` a fresh
|
|
814
|
-
UUID the waiting process chose (2026-10-09),
|
|
822
|
+
UUID the waiting process chose (2026-10-09), which keeps the children apart; and
|
|
823
|
+
`--output-format stream-json --verbose` (2026-10-12; `-p` refuses `stream-json` without
|
|
824
|
+
`--verbose`, measured on 2.1.296), its STDOUT kept in memory to 64 MiB
|
|
825
|
+
(`child.ts#OUTPUT_MAX_BYTES`) and read once for the host's cut. The catch-up child's
|
|
826
|
+
output is ignored. It
|
|
815
827
|
starts in a NEUTRAL directory — the store's own — so no project's CLAUDE.md, hooks or MCP
|
|
816
828
|
servers load. The parent's stance, `CLAUDE_PROJECT_DIR` and `CLAUDECODE` variables are
|
|
817
829
|
removed; this package's values are written last.
|
|
818
830
|
|
|
819
|
-
**[M] The run reads its child's
|
|
820
|
-
lightly).** Once the child exits, the waiting process
|
|
821
|
-
|
|
822
|
-
`
|
|
823
|
-
|
|
824
|
-
|
|
831
|
+
**[M] The run reads its child's own output for the host's cut (2026-10-09, U14 item 3; from
|
|
832
|
+
the output since 2026-10-12 — held lightly).** Once the child exits, the waiting process
|
|
833
|
+
reads the `assistant` and `user` lines of its `stream-json` output
|
|
834
|
+
(`night-run.ts#readNightSpills`) for results of ours — `mcp__counterparts__*` — that the
|
|
835
|
+
host replaced with its marker (`transcript.ts#parseToolSpills`). Nothing under the host's
|
|
836
|
+
directory is listed or read: until 2026-10-12 the run found the child's transcript under
|
|
837
|
+
`~/.claude/projects` by its session id, and that lookup is gone. The markers: `<persisted-output>` "Output too large (…)" or
|
|
825
838
|
"Output exceeded the … persist limit", `<truncated-output>`, "Error: result (…) exceeds
|
|
826
839
|
maximum allowed tokens", or the "[OUTPUT TRUNCATED - exceeded … token limit]" trailer — as
|
|
827
840
|
read from Claude Code 2.1.295. Matched where the host puts each one, at the start or the very
|
|
@@ -831,7 +844,8 @@ writes the swap as a `content-replacement` line of its own, the result's line le
|
|
|
831
844
|
those lines are read too, shaped `turn-budget` (review of #330). Each cut result is one durable `mcp.result.spilled` row (run, tool, phase, shape, the
|
|
832
845
|
size the host said; never the saved file's path); the run's row carries `transcript` (`read`
|
|
833
846
|
| `absent` | `unreadable`) and, when read, `spills`. Doctor's Tool results line goes amber on
|
|
834
|
-
any row in its window and says in green whether the last night's
|
|
847
|
+
any row in its window and says in green whether the last night's output was read (the row's
|
|
848
|
+
field keeps its name, `transcript`); the
|
|
835
849
|
morning hand-back adds a plain line (`Dreams.nightSpillLine`), even for a run that journaled
|
|
836
850
|
nothing. The catch-up child is not read. A host that refuses the flag
|
|
837
851
|
(a quick non-zero exit, no transcript under the name, nothing begun in the store) costs the
|
|
@@ -874,7 +888,14 @@ not read as lost. A clean exit that stopped short of
|
|
|
874
888
|
its allowance — some granted session neither written up nor brought to its `upTo` part —
|
|
875
889
|
is recorded `partial`, not `done` (a usage limit exits 0 too; its output is not read), and
|
|
876
890
|
starts no further batch. A runner record a killed process left open is ended at the
|
|
877
|
-
next run's start (`endStaleRunners`).
|
|
891
|
+
next run's start (`endStaleRunners`). A part whose every word is already written up (the
|
|
892
|
+
session's own chapters or notes claimed them) is passed over by the door and costs a batch
|
|
893
|
+
nothing — never the last part (`sessions.ts#firstUnwrittenPart`, 2026-10-11) — and the row
|
|
894
|
+
counts those (`passed`). A catch-up's `[]` for a part with unwritten words needs a one-line
|
|
895
|
+
`nothing` reason or is refused, and the part stays owed; the row counts parts a child was
|
|
896
|
+
handed and did not bring back (`unread`). `counterparts catch-up --reowe <run>`
|
|
897
|
+
(`reowe.ts`) owes again what a run closed empty while its words were unwritten, moving only
|
|
898
|
+
the progress counter, and refuses by name what that cannot do. `counterparts catch-up` runs the same launcher in the
|
|
878
899
|
foreground (`cli/catch-up.ts`, run ids `cup_…`), its runners filed under the store's own
|
|
879
900
|
directory. Under dreaming `auto` the SessionStart write-up pointer is retired
|
|
880
901
|
(`lifecycle.ts#writeUpPointerRetired`); under `ask` or `off` no night runs and the pointer
|
|
@@ -1030,7 +1051,7 @@ DEFERRAL and sessions are waiting — saying the wake was too full, by how many
|
|
|
1030
1051
|
`injectionBudgetBytes` by that much (never "open a session", which would defer again);
|
|
1031
1052
|
and (until 2026-09-30, when the `Write-ups` rule above replaced it) amber when a session had
|
|
1032
1053
|
waited past a 3-day `WRITE_UP_WAIT_DAYS`. Counted with the pointer's own eligibility: a small
|
|
1033
|
-
debt the pointer never offers (not a person's session) is named apart, as left to lapse. Never red; not in the session-start reading. `Sweep`: `not-opted-in` —
|
|
1054
|
+
debt the pointer never offers (not known as a person's session) is named apart, as left to lapse. Never red; not in the session-start reading. `Sweep`: `not-opted-in` —
|
|
1034
1055
|
and an older build's `no-credential` — is green `next session`.
|
|
1035
1056
|
|
|
1036
1057
|
## 6. Scars honored
|
|
@@ -578,7 +578,7 @@ That is a different mechanism, not a wider parameter, and it is not built.
|
|
|
578
578
|
live; the workaround is exact, not approximate, and the cost is up to five
|
|
579
579
|
queries on a 150 ms hot path. *(Noted 2026-10-09: the store side is built,
|
|
580
580
|
`order: "desc"`, 2026-09-24 (cli §10); doctor keeps its ladder on purpose, as
|
|
581
|
-
`doctor.ts#WINDOWS` says.)*
|
|
581
|
+
`doctor-finding.ts#WINDOWS` says.)*
|
|
582
582
|
2. **`adapter.checkout` is a durable name in `core/counterpart.ts`.** The third
|
|
583
583
|
time the core has learned a string for an adapter's sake, and for the same
|
|
584
584
|
narrow reason the spawn names did: `dashboard/registries.ts` derives
|
|
@@ -885,15 +885,18 @@ one; closing such a session by hand needs a console command that marks `by: "own
|
|
|
885
885
|
|
|
886
886
|
## 18. The host's cut is read only for the nightly run, and only as the host writes it today (2026-10-09, U14 item 3)
|
|
887
887
|
|
|
888
|
-
The nightly run reads its child's
|
|
889
|
-
(`night-run.ts#readNightSpills`, `transcript.ts#
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
888
|
+
The nightly run reads its child's own `stream-json` output for the host's marker on our
|
|
889
|
+
results (`night-run.ts#readNightSpills`, `transcript.ts#parseToolSpills`; until 2026-10-12 it
|
|
890
|
+
read the child's transcript under `~/.claude/projects`). Three things it owes:
|
|
891
|
+
|
|
892
|
+
1. **Unmeasured on a real machine.** That a cut result reaches the `stream-json` output in
|
|
893
|
+
the shape the transcript records it — the preview in the `tool_result`, as the model saw
|
|
894
|
+
it — and that the per-turn budget's `content-replacement` swap is said there at all. The
|
|
895
|
+
message lines were seen on 2.1.296 to carry the transcript's block shapes; a spill was
|
|
896
|
+
not. If the swap is transcript-only, `turn-budget` cuts go unseen (a missed spill, never
|
|
897
|
+
a false one). Check doctor's Tool results line after the first night on a build with
|
|
898
|
+
this. A host that refuses the arguments outright is retried once without them (review of
|
|
899
|
+
#330), so the night itself is not lost to this check.
|
|
897
900
|
2. **The markers are the host's wording.** Read from 2.1.295's code; a host that rewords
|
|
898
901
|
them makes the check go quiet (a missed spill), never noisy. A new marker shape is one
|
|
899
902
|
regex in `transcript.ts`.
|
|
@@ -2510,3 +2510,53 @@ reason `unread`, with its code, not `nothing-ran` (`night-run.ts`).
|
|
|
2510
2510
|
`nightRunLost` reads a row past that plus 10 minutes' grace as lost, and the next prompt would
|
|
2511
2511
|
have asked to dream while a long catch-up ran. The row now carries the catch-up's hour from the
|
|
2512
2512
|
start (`nightRowTimeoutMs`).
|
|
2513
|
+
|
|
2514
|
+
## 2026-10-11 — the first live `counterparts catch-up`: sixteen empty parts, read back
|
|
2515
|
+
|
|
2516
|
+
**It looked like skimming and was not.** Run `cup_463025455d83` closed 16 of its 24 parts with
|
|
2517
|
+
`[]`, about 2–3 s from fetch to answer (e92c5180 parts 10–15, 0464c1d3 parts 2–11). The parts
|
|
2518
|
+
the three children were actually served (their transcripts) show every entry of those 16 marked
|
|
2519
|
+
`[already written up]`: 14 were claimed by the sessions' own half-hourly chapters, 2 by one
|
|
2520
|
+
mid-session note. The prompt says not to write marked words again; the reader didn't. Fetch to
|
|
2521
|
+
answer measures output, not reading: the parts with unwritten words took 16–25 s each and kept
|
|
2522
|
+
5–10 memories. So the cause was the door serving parts with nothing to write, and the batch
|
|
2523
|
+
allowance counting them (one batch's whole allowance, and most of another's, went on them).
|
|
2524
|
+
|
|
2525
|
+
**Fixed.** `writeUpPartsDated` counts each part's `unwritten` bytes; the door passes such parts
|
|
2526
|
+
over on a fetch, never the last (`firstUnwrittenPart`), and `planCatchUp` starts each batch at
|
|
2527
|
+
the first part the door will serve, charging passed-over parts nothing. The row carries
|
|
2528
|
+
`passed` and `unread`. Replayed on a copy of the preserved spans with 0464c1d3 alone and a real
|
|
2529
|
+
child: one batch, parts 1–11 passed over in one fetch, parts 12–16 read in 108 s, 37 memories
|
|
2530
|
+
(the live run: three children, 0 for parts 2–11, 35 for 12–16).
|
|
2531
|
+
|
|
2532
|
+
**The guard.** On the granted path a `[]` for a part with unwritten words needs a one-line
|
|
2533
|
+
`nothing` reason, or it is refused `reason-required` and the part stays owed. No timer, no
|
|
2534
|
+
run-of-empties rule: both would have re-owed the sixteen right answers forever.
|
|
2535
|
+
|
|
2536
|
+
**`--reowe <run>`** reads the run's `mcp.write_up` rows from the log (a week) and the coverage
|
|
2537
|
+
ledger as it stood when the run began. On a copy of the post-run spans with the run's log lines
|
|
2538
|
+
it says, for both sessions, "nothing to re-owe". It moves only the progress counter; a session
|
|
2539
|
+
the run went on to mark is refused `needs-retraction` (see the decisions fragment).
|
|
2540
|
+
|
|
2541
|
+
**Not changed, flagged.** A jot claims every unwritten word its session said before it
|
|
2542
|
+
(`submitJot` → the default `cover`): one short note covered e92c5180's evening, about
|
|
2543
|
+
2.5 hours and 48 KB, whose other substance no chapter or memory of that session holds.
|
|
2544
|
+
|
|
2545
|
+
## 2026-10-12 — three reads of Claude Code's files trimmed (directory review, 1D/1F)
|
|
2546
|
+
|
|
2547
|
+
**The nightly run reads its child's output, not its transcript.** `claude -p --output-format
|
|
2548
|
+
stream-json` is refused without `--verbose` on 2.1.296 ("requires --verbose"), so both go on the
|
|
2549
|
+
run's children; the catch-up child's output stays ignored. Its `assistant` and `user` lines carry
|
|
2550
|
+
the transcript's block shapes, so `parseToolSpills` reads them unchanged. Not seen: a real spill in
|
|
2551
|
+
the stream, and whether the per-turn budget's `content-replacement` swap is written there at all
|
|
2552
|
+
(INTERFACE-GAPS §18). With STDOUT piped, `close` waits for every holder of the pipe, so the
|
|
2553
|
+
starter ends on `exit` plus `REAP_GRACE_MS` when it captures. The output also carries other hooks'
|
|
2554
|
+
`hook_response` lines; only the counts leave `readNightSpills`.
|
|
2555
|
+
|
|
2556
|
+
**Claude Code's own lines are not kept** (`hostRecord`): the compaction summary and `isMeta` lines
|
|
2557
|
+
other than a peer's message. One expectation moved with it: a slice holding a compaction summary
|
|
2558
|
+
and then typed words used to "say less" in the last exchange; with the summary gone, the typed
|
|
2559
|
+
words are said.
|
|
2560
|
+
|
|
2561
|
+
**The wake-arrival check is opt-in** (`COUNTERPARTS_WAKE_CHECK=1`). Off, `checkWakeArrival` returns
|
|
2562
|
+
before the registry read; doctor's Wake line, with no arrival rows, names the opt-in.
|
|
@@ -41,6 +41,11 @@ export interface ChildResult {
|
|
|
41
41
|
/** The OS's code when the child could not be started at all (`ENOENT` for a
|
|
42
42
|
* command that is not there). Absent otherwise. */
|
|
43
43
|
readonly spawnCode?: string;
|
|
44
|
+
/** What the child wrote to STDOUT, when its plan asked for it
|
|
45
|
+
* (`captureOutput`): at most `OUTPUT_MAX_BYTES`, the rest drained unread. */
|
|
46
|
+
readonly output?: string;
|
|
47
|
+
/** True when the child wrote more than was kept. */
|
|
48
|
+
readonly outputShort?: boolean;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
/** WHAT `startChild` NEEDS OF A PLAN. */
|
|
@@ -55,8 +60,15 @@ export interface ChildPlan {
|
|
|
55
60
|
readonly timeoutMs: number;
|
|
56
61
|
/** The child's working directory; absent, this process's. */
|
|
57
62
|
readonly cwd?: string;
|
|
63
|
+
/** Keep what the child writes to STDOUT (2026-10-12): the nightly run reads
|
|
64
|
+
* its own child's `stream-json` output rather than looking for the host's
|
|
65
|
+
* transcript under `~/.claude/projects`. Absent, STDOUT is ignored. */
|
|
66
|
+
readonly captureOutput?: boolean;
|
|
58
67
|
}
|
|
59
68
|
|
|
69
|
+
/** **CAL.** The most of a child's STDOUT kept in memory; the rest is drained unread. */
|
|
70
|
+
export const OUTPUT_MAX_BYTES = 64 * 1024 * 1024;
|
|
71
|
+
|
|
60
72
|
/**
|
|
61
73
|
* HOW LONG A CHILD GETS TO DIE POLITELY before it is killed, and how long after
|
|
62
74
|
* that before this stops waiting for the OS to confirm it.
|
|
@@ -80,12 +92,19 @@ export async function startChild(plan: ChildPlan, abort?: AbortSignal): Promise<
|
|
|
80
92
|
let terminated = false;
|
|
81
93
|
const timers: ReturnType<typeof setTimeout>[] = [];
|
|
82
94
|
let off: (() => void) | null = null;
|
|
95
|
+
// THE CHILD'S OWN OUTPUT (2026-10-12), kept only when asked for and only
|
|
96
|
+
// up to the cap. A child that writes past it is drained, never blocked.
|
|
97
|
+
const chunks: Buffer[] = [];
|
|
98
|
+
let kept = 0;
|
|
99
|
+
let outputShort = false;
|
|
100
|
+
const output = (): Pick<ChildResult, "output" | "outputShort"> =>
|
|
101
|
+
plan.captureOutput === true ? { output: Buffer.concat(chunks).toString("utf8"), ...(outputShort ? { outputShort } : {}) } : {};
|
|
83
102
|
const done = (r: ChildResult): void => {
|
|
84
103
|
if (settled) return;
|
|
85
104
|
settled = true;
|
|
86
105
|
for (const t of timers) clearTimeout(t);
|
|
87
106
|
off?.();
|
|
88
|
-
resolve(r);
|
|
107
|
+
resolve({ ...r, ...output() });
|
|
89
108
|
};
|
|
90
109
|
let child: ReturnType<typeof spawn>;
|
|
91
110
|
try {
|
|
@@ -100,7 +119,7 @@ export async function startChild(plan: ChildPlan, abort?: AbortSignal): Promise<
|
|
|
100
119
|
// command line is readable by every process on the machine through
|
|
101
120
|
// `ps` (S2 review, NIT-2). `claude -p` with no positional prompt reads
|
|
102
121
|
// stdin.
|
|
103
|
-
stdio: ["pipe", "ignore", "ignore"],
|
|
122
|
+
stdio: ["pipe", plan.captureOutput === true ? "pipe" : "ignore", "ignore"],
|
|
104
123
|
env: { ...plan.env },
|
|
105
124
|
...(plan.cwd === undefined ? {} : { cwd: plan.cwd }),
|
|
106
125
|
});
|
|
@@ -110,6 +129,17 @@ export async function startChild(plan: ChildPlan, abort?: AbortSignal): Promise<
|
|
|
110
129
|
done({ code: null, timedOut: false, error: err instanceof Error ? err.name : "UNKNOWN", ...spawnCodeOf(err) });
|
|
111
130
|
return;
|
|
112
131
|
}
|
|
132
|
+
child.stdout?.on("data", (chunk: Buffer) => {
|
|
133
|
+
if (kept >= OUTPUT_MAX_BYTES) {
|
|
134
|
+
outputShort = true;
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const room = OUTPUT_MAX_BYTES - kept;
|
|
138
|
+
const part = chunk.length > room ? chunk.subarray(0, room) : chunk;
|
|
139
|
+
if (part.length < chunk.length) outputShort = true;
|
|
140
|
+
chunks.push(part);
|
|
141
|
+
kept += part.length;
|
|
142
|
+
});
|
|
113
143
|
try {
|
|
114
144
|
child.stdin?.end(plan.stdin);
|
|
115
145
|
} catch {
|
|
@@ -161,13 +191,23 @@ export async function startChild(plan: ChildPlan, abort?: AbortSignal): Promise<
|
|
|
161
191
|
child.on("error", (err) => {
|
|
162
192
|
done({ code: null, timedOut: false, error: err.name, ...spawnCodeOf(err) });
|
|
163
193
|
});
|
|
164
|
-
|
|
194
|
+
const ended = (exit: number | null, sig: NodeJS.Signals | null): void => {
|
|
165
195
|
done({
|
|
166
196
|
code: exit,
|
|
167
197
|
timedOut: terminated || sig === "SIGTERM" || sig === "SIGKILL",
|
|
168
198
|
error: terminated ? "killed" : null,
|
|
169
199
|
});
|
|
170
|
-
}
|
|
200
|
+
};
|
|
201
|
+
child.on("close", ended);
|
|
202
|
+
// A PIPED STDOUT can outlive the child (2026-10-12): `close` waits for every
|
|
203
|
+
// holder of the pipe, and a helper the host left behind would hold the run
|
|
204
|
+
// until the watchdog. The exit, then a short grace for the last of the
|
|
205
|
+
// output, is the end.
|
|
206
|
+
if (plan.captureOutput === true) {
|
|
207
|
+
child.on("exit", (exit, sig) => {
|
|
208
|
+
timers.push(arm(() => ended(exit, sig), REAP_GRACE_MS));
|
|
209
|
+
});
|
|
210
|
+
}
|
|
171
211
|
});
|
|
172
212
|
}
|
|
173
213
|
|