counterparts 0.3.15 → 0.3.16
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 +132 -0
- package/package.json +1 -1
- package/src/adapters/claude-code/CONTRACT.md +44 -13
- package/src/adapters/claude-code/INTERFACE-GAPS.md +9 -2
- package/src/adapters/claude-code/NOTES.md +228 -0
- package/src/adapters/claude-code/bin/hook.ts +211 -33
- package/src/adapters/claude-code/claim.ts +319 -13
- package/src/adapters/claude-code/doctor.ts +140 -31
- package/src/adapters/claude-code/envelope.ts +6 -15
- package/src/adapters/claude-code/hooks.ts +86 -76
- package/src/adapters/claude-code/index.ts +2 -2
- package/src/adapters/cli/commands.ts +43 -3
- package/src/adapters/cli/self-page.ts +30 -4
- package/src/adapters/config.ts +24 -11
- package/src/adapters/dashboard/web/pages/health/sections/wake.js +9 -3
- package/src/adapters/dashboard/web/views/health.ts +15 -12
- package/src/adapters/hosts.ts +41 -10
- package/src/adapters/mcp/NOTES.md +1 -1
- package/src/adapters/mcp/bin/serve.ts +12 -1
- package/src/adapters/mcp/index.ts +1 -0
- package/src/adapters/mcp/server.ts +112 -23
- package/src/adapters/mcp/tools.ts +11 -8
- package/src/adapters/plugin.ts +111 -23
- package/src/adapters/scopes.ts +78 -0
- package/src/adapters/sessions.ts +8 -2
- package/src/core/briefing.ts +28 -6
- package/src/core/counterpart.ts +88 -11
- package/src/core/dream/CONTRACT.md +2 -2
- package/src/core/dream/index.ts +1 -1
- package/src/core/dream/reflect.ts +115 -15
- package/src/core/fit/index.ts +4 -0
- package/src/core/handoff/INTERFACE-GAPS.md +1 -1
- package/src/core/handoff/NOTES.md +22 -0
- package/src/core/handoff/index.ts +2 -2
- package/src/core/handoff/last-here.ts +21 -8
- package/src/core/prospective/CONTRACT.md +3 -1
- package/src/core/prospective/NOTES.md +19 -0
- package/src/core/prospective/index.ts +34 -4
- package/src/core/recall/activate.ts +1 -1
- package/src/core/self/CONTRACT.md +85 -47
- package/src/core/self/INTERFACE-GAPS.md +22 -0
- package/src/core/self/NOTES.md +182 -0
- package/src/core/self/briefing.ts +674 -160
- package/src/core/self/identity.ts +13 -1
- package/src/core/self/index.ts +442 -103
- package/src/core/self/page.ts +157 -6
- package/src/core/self/tunables.ts +24 -14
- package/src/core/self/writer.ts +13 -11
- package/src/core/store/db.ts +26 -0
- package/src/core/store/index.ts +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,137 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.16 — 2026-10-10
|
|
4
|
+
|
|
5
|
+
The self page is kept whole up to 16 KB, and when it doesn't fit, the wake steps down to
|
|
6
|
+
something whole instead of cutting it: the page, a short version written with it, an
|
|
7
|
+
outline, the headings, or one line saying where to read it. At the default 9,000-byte
|
|
8
|
+
ceiling the page's room is now 5,681 bytes (it was 6,078). Dated items come before the
|
|
9
|
+
wake's furniture: an "Arriving:" item or a plain reminder due today is listed before the
|
|
10
|
+
handoffs, "Last here" and "Work here" take their room, and doctor's Wake line turns amber
|
|
11
|
+
when one still goes unlisted. A paused folder says so in one line when a session starts.
|
|
12
|
+
Each field of a hook's output is now held to Claude Code's 10,000-character limit on its
|
|
13
|
+
own, so a red doctor notice shows beside a full wake. A damaged claims file mends itself,
|
|
14
|
+
a late twin of a session's first start stands down, and every `counterparts scope` command
|
|
15
|
+
Claude is shown names its folder. The plugin's first-run line is back, and its sidebar
|
|
16
|
+
lights every mechanism an event proves. **Nothing to run after upgrading from 0.3.15**:
|
|
17
|
+
the hooks, the memory server's registration and Claude Desktop's entry are the same as
|
|
18
|
+
0.3.15's (coming from 0.3.14 or earlier, see those versions' notes on `counterparts
|
|
19
|
+
connect`). **No change to the store's format (still v12)**: a page's short version is kept
|
|
20
|
+
in the page's own record, which 0.3.15 reads past. Going back to 0.3.15 is the order in
|
|
21
|
+
QUICKSTART's "Going back to an earlier version": `counterparts disconnect` while 0.3.16 is
|
|
22
|
+
still installed, then the 0.3.15 reinstall, then `counterparts connect`.
|
|
23
|
+
|
|
24
|
+
The self page in the wake (#363).
|
|
25
|
+
|
|
26
|
+
- **A long self page is kept, not refused, and the wake steps down to something whole.**
|
|
27
|
+
0.3.15 refused a page past 6,078 bytes. Now the page is kept whole up to 16,384 bytes,
|
|
28
|
+
and the wake shows the first of these that fits, each one whole: the page; a short
|
|
29
|
+
version its writer wrote with it; each section's heading and first sentence; the
|
|
30
|
+
headings alone; or one line saying where to read it. Each starts with a line giving the
|
|
31
|
+
page's size and the line it ends with — "if you don't see that line, it was cut off:
|
|
32
|
+
read it whole with the self_page tool or `counterparts self-page`" — and ends with that
|
|
33
|
+
line. The page's room at the default 9,000-byte ceiling is now 5,681 bytes (it was
|
|
34
|
+
6,078; the new top and end lines and the wake's opening line take the difference): a
|
|
35
|
+
page within it always shows whole, even on a day the wake also holds handoffs and
|
|
36
|
+
"Work here" lines, and a longer one still shows whole on most days, borrowing the room
|
|
37
|
+
held for "Work here". The nightly writer, the reflection and the self_page tool are told
|
|
38
|
+
to aim under it and, when a page runs past it, asked for a short version in the same
|
|
39
|
+
call (the tool's new `short`, the console's new `--short <file>`). A short version
|
|
40
|
+
belongs to the page it was written with — a page rewritten without one shows its
|
|
41
|
+
headings and first sentences, never an old short version — and crosses the same checks
|
|
42
|
+
as the page, a reflection's included (no confidential memory's words, no dream marks).
|
|
43
|
+
Adding a short version on its own never undoes a page written in between, and the
|
|
44
|
+
wake's own top and end lines are never stored as part of the page. Doctor's Self page
|
|
45
|
+
line says what the last wake showed: green for the page or its short version, amber
|
|
46
|
+
below, with what to do. Every wake's opening line now also says: if a note says this
|
|
47
|
+
was too large and saved to a file, read that file — which is what Claude Code does with
|
|
48
|
+
a hook's output past 10,000 characters (measured on 2.1.296: the model then sees only
|
|
49
|
+
the first 2,000 characters and is not told to look). Past 16,384 bytes a page is
|
|
50
|
+
refused, never cut. Below a ceiling of about 530 bytes the wake is now larger than its
|
|
51
|
+
ceiling, because of those fixed lines; the default is 9,000.
|
|
52
|
+
|
|
53
|
+
Dated items first in the wake (#367).
|
|
54
|
+
|
|
55
|
+
- **Dated items come before the wake's furniture.** A wake could say "Arriving: 1 — no
|
|
56
|
+
room to list them in this wake" while it still printed yesterday's chapter titles and
|
|
57
|
+
four handoffs: the room held for the handoffs and "Last here" was never offered to the
|
|
58
|
+
rest of the wake. Now the wake follows one declared order of what gives way: when an
|
|
59
|
+
"Arriving:" item has no room, "Work here" shows fewer lines first, then the Yesterday
|
|
60
|
+
line swaps titles for chapter ids one at a time, then "Last here" is dropped and fewer
|
|
61
|
+
handoffs are shown in full, the others named by id while there is room for them. The
|
|
62
|
+
newest handoff's own room goes only to a plain reminder due that day; no other line
|
|
63
|
+
can take it. Only then does a dated item go unlisted. An arriving item past the two
|
|
64
|
+
the wake lists is no longer left out silently: the lane's "N more arriving" line names
|
|
65
|
+
it by id, and when even that line has no room, doctor counts it as unlisted. "Still
|
|
66
|
+
open" keeps its first item before Arriving's second line, as before, but now after
|
|
67
|
+
those same lanes give way. A plain reminder due the day the wake is read comes first
|
|
68
|
+
in "Arriving:" (and in the two the wake is offered), and it outranks the self page
|
|
69
|
+
borrowing past its room: the page steps down to its short version or outline rather
|
|
70
|
+
than leave it out. The page within its own room still comes first. Beside a page that
|
|
71
|
+
borrowed, the Yesterday line was sometimes dropped whole; it now keeps its ids. If a
|
|
72
|
+
dated item still goes unlisted, doctor's Wake line says so in amber, with what to do.
|
|
73
|
+
|
|
74
|
+
Paused folders and the scope commands (#362, #366).
|
|
75
|
+
|
|
76
|
+
- **A paused folder now says so when a session starts.** With memory paused in a folder
|
|
77
|
+
(`counterparts scope . --pause`, or the sidebar's switch), a new, resumed, cleared or
|
|
78
|
+
compacted session there shows one line naming the paused folder and the command that
|
|
79
|
+
turns it back on, which works from any terminal. If the pause is on a parent folder, the
|
|
80
|
+
line names that folder and the command resumes it there. Claude gets a matching line so
|
|
81
|
+
it doesn't act as if it remembers.
|
|
82
|
+
Nothing else changes: no memories are loaded or recorded, nothing is written, other
|
|
83
|
+
hooks stay silent, and a folder turned `off` stays completely silent.
|
|
84
|
+
- **Every `counterparts scope` command Claude is shown now names the folder.** In a
|
|
85
|
+
folder that is off or paused, the memory tools' refusal used to tell Claude to run
|
|
86
|
+
`counterparts scope . --resume`, and the question a new folder gets in its first session
|
|
87
|
+
said `counterparts scope . --on`. The `.` meant wherever the command was run, and from a
|
|
88
|
+
subfolder `--resume` refuses. Now the command names the folder, and when the setting
|
|
89
|
+
belongs to a parent folder it names that one ("paused for ~/work, which includes this
|
|
90
|
+
directory"). Under the plugin it uses the plugin's own launcher, and with a
|
|
91
|
+
configuration other than the default it adds `--config`, as the paused notice does.
|
|
92
|
+
|
|
93
|
+
The hooks: each output field, the claims file, late twins (#366).
|
|
94
|
+
|
|
95
|
+
- **A red doctor notice now shows beside a full wake.** Measured on Claude Code 2.1.296:
|
|
96
|
+
the 10,000-character limit applies to each field of a hook's output, not to the output
|
|
97
|
+
as a whole. Counterparts held the whole output to 9,500 characters, so on a morning with
|
|
98
|
+
a full wake the doctor's notice was left out, and plain reminders, the dream question and
|
|
99
|
+
the update notice waited for a later turn. Now each field is held to the limit on its
|
|
100
|
+
own: they show beside a full wake or a full recall, and wait only when Claude's own text
|
|
101
|
+
would pass the limit.
|
|
102
|
+
- **A damaged claims file repairs itself.** If `sessions/claims/hook-claims.sqlite`
|
|
103
|
+
can't be read as a database, the next hook moves it aside (one copy is kept) and makes a
|
|
104
|
+
new one, and the event is still delivered. Before, every event printed an error and the
|
|
105
|
+
guard against double delivery stayed off until someone deleted the file. Doctor's new
|
|
106
|
+
amber "Hook claims" line says when it happened, for a week. The claims folder and file
|
|
107
|
+
are now private to you (0700 and 0600), like the log, and the log says why a claim
|
|
108
|
+
could not be made instead of giving only the length of the message.
|
|
109
|
+
- **With two installs live, a session's first start runs once even on a busy machine.**
|
|
110
|
+
The 0.3.15 release check found one double wake under load: the second hook started 45
|
|
111
|
+
ms after the first had finished, so its claim read it as a new event. A session's first
|
|
112
|
+
start, and a prompt Claude Code gives an id, are sent only once, so a second copy within
|
|
113
|
+
15 seconds now always steps aside. Doctor's "Installed twice" line no longer says
|
|
114
|
+
nothing was delivered twice; its fix also names `~/.claude/settings.json`.
|
|
115
|
+
A correction to the 0.3.15 notes, which said the claim "works between any two
|
|
116
|
+
versions": the plugin stepping aside is the main guard, and the claim is a backstop. It
|
|
117
|
+
catches a second hook that runs at the same time; for a resumed or compacted session, a
|
|
118
|
+
Stop, or a prompt without an id, one that starts after the first has finished can
|
|
119
|
+
still deliver again on a busy machine.
|
|
120
|
+
|
|
121
|
+
The plugin (#360, #365).
|
|
122
|
+
|
|
123
|
+
- **The sidebar lights every mechanism an event proves.** Each event is one row and lights
|
|
124
|
+
every mechanism it proves: a turn where a matching mood brought a memory closer lights
|
|
125
|
+
Emotion beside Retrieval, and a dream that wrote a gist and merged near-copies lights
|
|
126
|
+
Gist, Interference and Consolidation beside Dreaming.
|
|
127
|
+
- **A new plugin user is told their memory was set up, again.** In 0.3.15, the
|
|
128
|
+
sidebar's hooks module makes Claude Code start the plugin's SessionStart hook later,
|
|
129
|
+
after the plugin's server has already made the new memory, so the first session
|
|
130
|
+
didn't show "Counterparts: first run — a new memory was set up". Now whichever of the
|
|
131
|
+
two makes the memory leaves a note, and the first session start shows the line once,
|
|
132
|
+
never again after. Beside a live npm install the plugin still stands down and says
|
|
133
|
+
nothing about a first run. Nothing else changes.
|
|
134
|
+
|
|
3
135
|
## 0.3.15 — 2026-10-10
|
|
4
136
|
|
|
5
137
|
The self page is never cut in the wake. A page may now be at most 6,078 bytes, which the
|
package/package.json
CHANGED
|
@@ -393,7 +393,8 @@ row, saying which source answered, existed until the keys were removed — §1a.
|
|
|
393
393
|
G41–G43) is read at the ENTRY POINT, from the file `config-path.ts` resolved,
|
|
394
394
|
before a store is opened: an `off` or `paused` directory returns from
|
|
395
395
|
`bin/hook.ts#main` with byte-for-byte empty stdout, empty stderr, no session
|
|
396
|
-
record, no capture, no spawn and no store
|
|
396
|
+
record, no capture, no spawn and no store — except that a `paused` one's
|
|
397
|
+
SessionStart prints ONE notice (below). `guard()` carries the same predicate
|
|
397
398
|
at the seam so a caller who builds an adapter directly inherits it, but the
|
|
398
399
|
guarantee itself is the absence of construction, and the install loop proves it
|
|
399
400
|
on a real process against a real clean-room install.
|
|
@@ -420,6 +421,22 @@ row, saying which source answered, existed until the keys were removed — §1a.
|
|
|
420
421
|
prints it. An `off` is not an instrument standing down; it is the owner saying
|
|
421
422
|
this directory is not part of the memory.
|
|
422
423
|
|
|
424
|
+
**A `paused` directory says so once, at SessionStart (rulings brief #19,
|
|
425
|
+
2026-10-10 — a working default).** A pause is meant to end, and a silent one was
|
|
426
|
+
missed: on 2026-10-09 three sessions ran without memory for ten minutes before
|
|
427
|
+
anyone noticed. So SessionStart, on every source (startup, resume, clear,
|
|
428
|
+
compact), prints one envelope from the registry already read: a `systemMessage`
|
|
429
|
+
for the person — the folder is paused and the command that resumes it — and an
|
|
430
|
+
`additionalContext` line for the model, so it does not act as if it remembers
|
|
431
|
+
(`bin/hook.ts#pausedNotice`). The folder whose entry paused it is NAMED, and the
|
|
432
|
+
command names it — never `.`, which is wherever the person types it — because
|
|
433
|
+
`--resume` refuses a directory that only inherits a pause. It
|
|
434
|
+
writes nothing anywhere — not the store, not a session record, not the per-event
|
|
435
|
+
claim, which comes after this return — so beside the npm install it is the
|
|
436
|
+
plugin's gate, not the claim, that keeps it to one line. Every other event, `off`
|
|
437
|
+
on every event, a session whose own folder is `off` (resuming the paused one
|
|
438
|
+
would turn nothing back on), and the headless nightly run stay silent.
|
|
439
|
+
|
|
423
440
|
**The guarantee is the HOOKS', and only the hooks'.** The MCP server still opens
|
|
424
441
|
a store when the host launches it in an `off` directory (`mcp/bin/serve.ts`): it
|
|
425
442
|
refuses every tool but `scope` with `scope-off`, per call, before any session bind
|
|
@@ -459,7 +476,7 @@ row, saying which source answered, existed until the keys were removed — §1a.
|
|
|
459
476
|
22. **[M] TURNING A DIRECTORY BACK ON NEVER REACHES BACK.** A session that lived
|
|
460
477
|
under `off` or `paused` left no session record and no span cursor, because the
|
|
461
478
|
hook process returned before anything was constructed (G19). Flip the registry
|
|
462
|
-
to `on` mid-session — `counterparts scope
|
|
479
|
+
to `on` mid-session — `counterparts scope <folder> --resume`, or the `scope` tool, which
|
|
463
480
|
is deliberately the one tool that answers in an off directory — and the next
|
|
464
481
|
boundary would otherwise slice the transcript from cursor 0 and deposit the whole
|
|
465
482
|
off conversation. It does not: a boundary that finds NO session record and a
|
|
@@ -629,19 +646,32 @@ row, saying which source answered, existed until the keys were removed — §1a.
|
|
|
629
646
|
`adapter.hook.claim.lost` row, and leaves one stderr line. All five events
|
|
630
647
|
are claimed. A matching key from a process that started after the holder
|
|
631
648
|
finished is a separate event (a host with no `prompt_id` sending the same
|
|
632
|
-
words twice) and delivers
|
|
649
|
+
words twice) and delivers — EXCEPT for an event the host sends once per key
|
|
650
|
+
(`firesOnce`: a SessionStart whose `source` opens a session id — `startup`,
|
|
651
|
+
`clear`, `fork` — and a prompt with its `prompt_id`), where any same-key
|
|
652
|
+
process inside the window is the twin however late its runtime came up
|
|
653
|
+
(2026-10-10: the 0.3.15 release check measured a twin starting 45 ms after
|
|
654
|
+
the winner finished, under load, and two wakes). For the events that can
|
|
655
|
+
legitimately repeat, a twin that starts that late still delivers: the
|
|
656
|
+
stand-down above is the main guard, and the claim a backstop that stops
|
|
657
|
+
the twins it sees. **Fail-open:** no session id, an observer, or a
|
|
633
658
|
claims file that will not take the write, and the process delivers, so one
|
|
634
659
|
wiring behaves exactly as before (two small writes: about 0.3 ms measured in
|
|
635
|
-
process, within noise end to end).
|
|
660
|
+
process, within noise end to end). A claims file that is not a database
|
|
661
|
+
is set aside with its `-wal`/`-shm` as `hook-claims.unreadable-<ms>.sqlite`
|
|
662
|
+
(one copy kept) and made again, once, and the event is claimed on the new
|
|
663
|
+
file; doctor's `Hook claims` line (amber, a week) reads the copy. The
|
|
664
|
+
directory is 0700 and the file 0600. The claims are in their own file, not
|
|
636
665
|
the store's `meta`, so a claim waits only on another claim: the store's
|
|
637
666
|
writers (the worker the last Stop started, the MCP server, the CLI) never
|
|
638
667
|
hold it up, and a store somebody holds costs it nothing. Each of the two
|
|
639
668
|
writes waits at most `CLAIM_WAIT_MS` (500 ms). A claim that could not be
|
|
640
|
-
written is in the hook's `process.end` log line
|
|
641
|
-
only when it is a fault (the file cannot be made or
|
|
642
|
-
another claim held the file. Doctor's `Installed twice`
|
|
643
|
-
reads the week's `claim.lost` rows
|
|
644
|
-
the host may write between
|
|
669
|
+
written is in the hook's `process.end` log line, as its error's code; it is
|
|
670
|
+
said on stderr too only when it is a fault (the file cannot be made or
|
|
671
|
+
written), not when another claim held the file. Doctor's `Installed twice`
|
|
672
|
+
line (amber) reads the week's `claim.lost` rows, and says only what they
|
|
673
|
+
show. The transcript's size is not in the key: the host may write between
|
|
674
|
+
the twins starting.
|
|
645
675
|
|
|
646
676
|
### The nightly run, and the page writer inside it (2026-09-28 — working defaults, held lightly)
|
|
647
677
|
|
|
@@ -821,11 +851,12 @@ terminal; "dream on your own" sets it again. Any setting chosen on this version
|
|
|
821
851
|
### One size budget per hook envelope (2026-09-29 — a working default)
|
|
822
852
|
|
|
823
853
|
**[M] Everything one SessionStart or one UserPromptSubmit prints is measured against one
|
|
824
|
-
budget**, the host's cap (`TUNABLES.HOST_OUTPUT_CHARS`, 10,000, counted in bytes; the JSON
|
|
825
|
-
form
|
|
854
|
+
budget**, the host's cap (`TUNABLES.HOST_OUTPUT_CHARS`, 10,000, counted in bytes; in the JSON
|
|
855
|
+
form each field is held to it on its own, as the host measures it — 2026-10-10, it was 9,500
|
|
856
|
+
characters of whole envelope before), and a crowded envelope gives way in a stated order, first to
|
|
826
857
|
last. Each part that gives way is DEFERRED, never cut, and never spent on a line the session
|
|
827
858
|
did not get.
|
|
828
|
-
- **SessionStart:** the owner's notices (dropped
|
|
859
|
+
- **SessionStart:** the owner's notices (dropped when a field of the JSON form would pass the cap) →
|
|
829
860
|
the write-up pointer → the first-launch question (measured against this budget, no
|
|
830
861
|
longer the reported injection budget) → plain reminders due today (they wait for the
|
|
831
862
|
first prompt, unclaimed) → the wake, which is never cut at delivery: it was composed to
|
|
@@ -900,7 +931,7 @@ session, because an MCP result is not under the host's 10,000-character cap on a
|
|
|
900
931
|
output and the wake is. The pointer is measured against that cap as PLAIN stdout
|
|
901
932
|
(`HOST_OUTPUT_CHARS` = 10,000; bytes ≥ characters): with no owner notice
|
|
902
933
|
`bin/hook.ts#hostDelivery` prints plain text, and with one it drops the notice before it
|
|
903
|
-
lets the JSON
|
|
934
|
+
lets either field of the JSON form pass the cap (`fieldsFit`). It is NOT held to the reported budget,
|
|
904
935
|
which is what the wake is composed to; a 9,038-byte wake leaves room (tested with host
|
|
905
936
|
ids). Past the cap it DEFERS, claims nothing, and records the deferral DURABLY
|
|
906
937
|
(`sessions.ts#WRITE_UP_POINTER_KEY`, one meta row: outcome, need, room), which doctor
|
|
@@ -615,7 +615,12 @@ That is a different mechanism, not a wider parameter, and it is not built.
|
|
|
615
615
|
not the wake's — neither was taken here. *(The record half CLOSED 2026-10-02 by
|
|
616
616
|
#318 (`8916e8c`), noted 2026-10-09: `adapter.notice.dropped` is a durable row,
|
|
617
617
|
one per hook, part and session a lived day, and doctor's Wake line reads it. The
|
|
618
|
-
terminal still says nothing on the day it happens.)*
|
|
618
|
+
terminal still says nothing on the day it happens.)* *(The terminal half CLOSED for
|
|
619
|
+
every wake within the cap, 2026-10-10: measured on Claude Code 2.1.296, the host caps
|
|
620
|
+
each field of the JSON form on its own and an over-long envelope parses, so the
|
|
621
|
+
9,500-character envelope rule is gone and the notice rides whenever the wake and the
|
|
622
|
+
notice each fit (`bin/hook.ts#fieldsFit`). It is dropped now only beside a wake that is
|
|
623
|
+
itself past the cap, which the host previews anyway.)*
|
|
619
624
|
7. **Three findings cannot say "I do not know" — they say green.** `Severity` is
|
|
620
625
|
red / amber / green, so the unknown-newest-row reading (`undetermined`) is
|
|
621
626
|
reported as GREEN with a sentence that explains it is not a grade. Right for
|
|
@@ -768,7 +773,9 @@ on the owner's store it defers every morning by the same arithmetic.
|
|
|
768
773
|
can push the envelope past `ENVELOPE_MAX_CHARS` and the doctor notice is the part dropped
|
|
769
774
|
(the wake wins, as always; `adapter.notice.dropped` records it). At a full 9 KB wake the
|
|
770
775
|
notice is dropped with or without it. Bounded: at most two starts a day carry a pointer,
|
|
771
|
-
and the notice returns at the next start.
|
|
776
|
+
and the notice returns at the next start. *(CLOSED 2026-10-10: the notice is its own field
|
|
777
|
+
of the JSON form, measured as the host measures it, so the pointer no longer costs it; the
|
|
778
|
+
pointer and the question are measured against the model's field alone.)*
|
|
772
779
|
|
|
773
780
|
**Residual cost (PR #192 review, n1):** the eligibility plan (`writeUpPlan`) runs at EVERY
|
|
774
781
|
session start whose allowance is not spent — and when nothing is owed, the allowance is
|
|
@@ -466,6 +466,29 @@ own last line is telling the owner to run anyway. The alternative is a session
|
|
|
466
466
|
that starts with no memory at all, and memory is the thing the session cannot be
|
|
467
467
|
had without.
|
|
468
468
|
|
|
469
|
+
**2026-10-10: measured, and the cap is per field.** On Claude Code 2.1.296, with 19
|
|
470
|
+
`claude -p` probes in an isolated project, each checked against its session transcript
|
|
471
|
+
(`~/counterparts-notes/2026-10-10-session-start-limits.md`): the 10,000-character cap
|
|
472
|
+
applies to each STRING FIELD (`additionalContext`, `systemMessage`) and to plain stdout,
|
|
473
|
+
not to the JSON stdout as a whole; it counts characters (9,800 accented characters, 23,483
|
|
474
|
+
bytes, arrived whole); exactly 10,000 passes. An over-long envelope parses: a 12,637-
|
|
475
|
+
character escape-heavy one carrying a 9,900-character field, and a 10,488-character one in
|
|
476
|
+
this hook's own shape (`systemMessage` 376 + `additionalContext` 9,910), both arrived with
|
|
477
|
+
every field whole. A field past 10,000 is replaced by a ~2,000-character preview and a file
|
|
478
|
+
path, and the JSON still parses. The current docs say the same ("For JSON output, each field
|
|
479
|
+
is measured separately"). Whether the 09-14 host behaved the 09-14 way was never measured.
|
|
480
|
+
So `ENVELOPE_MAX_CHARS` (9,500 of whole envelope) is gone: `bin/hook.ts#fieldsFit` holds
|
|
481
|
+
the model's text and the person's line each to `TUNABLES.HOST_OUTPUT_CHARS`, the one place
|
|
482
|
+
the host's number lives, and the notice is kept whenever both fit — on the measured 9,038-
|
|
483
|
+
byte red morning it now shows. The adapter sizes the same way (`hooks.ts#sessionStart`'s
|
|
484
|
+
room and `recallRoom`): the model's field in bytes against the cap in either form, the
|
|
485
|
+
person's lines costing it nothing, and no escape reserve (`ENVELOPE_ESCAPE_RESERVE` and
|
|
486
|
+
`envelope.ts#escapedBytes` went too). What follows in practice: a plain reminder, the dream
|
|
487
|
+
offer and the update notice ride beside a full wake or a full recall instead of waiting for a
|
|
488
|
+
roomier turn; they wait only when the model's own field would pass the cap. The
|
|
489
|
+
`adapter.notice.dropped` row keeps its shape: `envelopeChars` is still the whole object's
|
|
490
|
+
length, a fact for the record, and `limitChars` is now the per-field cap.
|
|
491
|
+
|
|
469
492
|
## "Newest row" can be unknown, and says so (2026-09-14)
|
|
470
493
|
|
|
471
494
|
`Store.eventLog` is `ORDER BY seq ASC LIMIT` (the missing DESC read is filed in
|
|
@@ -2227,3 +2250,208 @@ INTERFACE-GAPS §15.
|
|
|
2227
2250
|
- **Left as is.** A twin's `adapter.hook.claim.lost` row still goes to the store, with the
|
|
2228
2251
|
store's 5 s wait. It is written only when two wirings are live, after the twin has
|
|
2229
2252
|
decided to stand down, and it is the record doctor reads.
|
|
2253
|
+
|
|
2254
|
+
## 2026-10-10 — a paused folder says so at session start (rulings brief #19)
|
|
2255
|
+
|
|
2256
|
+
- **Why.** A pause was as silent as `off` (§12, CONTRACT §5 G19): every hook returned
|
|
2257
|
+
before anything was opened, so a paused folder gave no wake, no recall and no hint. On
|
|
2258
|
+
10-09 three `~/random` sessions ran without memory for ten minutes before anyone noticed.
|
|
2259
|
+
Ruled: one SessionStart line for `paused`; `off` stays silent, because it is a deliberate
|
|
2260
|
+
opt-out and a line every session would nag.
|
|
2261
|
+
- **The words.** Own entry: `Counterparts memory is paused in ~/random; \`counterparts
|
|
2262
|
+
scope ~/random --resume\` turns it back on.` A parent's: `… is paused for ~/random, which
|
|
2263
|
+
includes this folder; \`counterparts scope ~/random --resume\` …` — the command has to
|
|
2264
|
+
name the entry that paused it, since `--resume` refuses a directory that only inherits a
|
|
2265
|
+
pause. The folder is always named, never `.` (review of #362): `.` is wherever the person
|
|
2266
|
+
types it — another terminal, or a shell that moved after a compaction — and from a
|
|
2267
|
+
subfolder of the entry `--resume` refuses it. The session's own folder paused while the shell stands elsewhere (a compaction, or
|
|
2268
|
+
a start whose `CLAUDE_PROJECT_DIR` is not the payload's `cwd`): `… paused for ~/proj,
|
|
2269
|
+
which covers this session; …`. Under the plugin the command is `sh <plugin root>/src/
|
|
2270
|
+
adapters/plugin-run.sh cli scope … --resume`, because a plugin install puts no
|
|
2271
|
+
`counterparts` on PATH (`commands/doctor.md`). A path that would need quoting is quoted
|
|
2272
|
+
whole and never `~`-shortened (a quoted `~` does not expand). A hook that read a
|
|
2273
|
+
registry other than the console's default (wired with `--config`, or
|
|
2274
|
+
`COUNTERPARTS_CONFIG`, somewhere else) adds `--config <that file>` to the command, as two
|
|
2275
|
+
words so a `~/…` expands (review of #362): without it the command resumed an entry in
|
|
2276
|
+
the default registry, or refused, and the folder stayed paused. A test types the
|
|
2277
|
+
printed command verbatim through `/bin/sh` from another directory and watches the next
|
|
2278
|
+
start wake.
|
|
2279
|
+
- **Two channels, the SessionStart envelope every notice already rides.** The person's line
|
|
2280
|
+
is the `systemMessage`; the model gets one `additionalContext` line (paused, nothing is
|
|
2281
|
+
loaded or remembered, the resume command, "don't act as if you remember"). H1's fault
|
|
2282
|
+
stand-downs print the `systemMessage` alone; a pause adds the model's line because it is
|
|
2283
|
+
a known, lasting state of the folder, and a model that is not told answers as if it had
|
|
2284
|
+
its memory. It goes out through `hostDelivery`, so it is the measured JSON shape (the one
|
|
2285
|
+
the doctor notice rides beside the wake) and not a new one.
|
|
2286
|
+
- **Every SessionStart source**, compaction included: a compaction rewrites the terminal and
|
|
2287
|
+
the model's context, and H1 already says its line again there. Never at a prompt (every
|
|
2288
|
+
turn), a Stop, SessionEnd or PreCompact. Not in the headless nightly run, which nobody
|
|
2289
|
+
watches and whose hooks are kept quiet like every other ask there.
|
|
2290
|
+
- **Not when the session's own folder is `off`** (review of #362). A session that started
|
|
2291
|
+
in an `off` folder and whose shell stands in a paused one (a compaction after a `cd`, or
|
|
2292
|
+
a start whose `CLAUDE_PROJECT_DIR` is not the `cwd`) is off whatever the paused folder
|
|
2293
|
+
says; "resume turns it back on" would be false, so it stays silent like any `off`. The
|
|
2294
|
+
session's folder is taken from `startDirectory` (environment and payload), so the first
|
|
2295
|
+
return still reads nothing but the registry. Not handled: both folders paused by
|
|
2296
|
+
different entries — the line names the shell's, and the next start names the other.
|
|
2297
|
+
- **Writes nothing.** It prints from the registry the scope check already read, at the two
|
|
2298
|
+
`off` returns in `bin/hook.ts#runHook` — before the configuration (first return) or
|
|
2299
|
+
before the store (second) — so no store, session record, process log or claim. The
|
|
2300
|
+
per-event claim (`../claim.ts`, now `sessions/claims/hook-claims.sqlite` since #359) is
|
|
2301
|
+
made only after the adapter opens, which a paused folder never reaches; the tests check
|
|
2302
|
+
that file is not created and that nothing under an existing store changes.
|
|
2303
|
+
- **Two wirings.** Beside the npm install the plugin's gate stands the plugin down in
|
|
2304
|
+
`main`, before the scope check, so only the npm hook says it: one line (plus the plugin's
|
|
2305
|
+
own stand-down line, as in any folder). If the gate misses the npm wiring (the 10-09
|
|
2306
|
+
shape the claim backs up), both hooks reach the scope check and each says it once: two
|
|
2307
|
+
lines, because the claim that would dedupe them is a write a paused folder may not make.
|
|
2308
|
+
A second claim outside the store was not built (guards loose-first); doctor's "Installed
|
|
2309
|
+
twice" line is what names that shape.
|
|
2310
|
+
|
|
2311
|
+
## 2026-10-10 — every printed `counterparts scope` line names its folder (follow-up to #362)
|
|
2312
|
+
|
|
2313
|
+
- **What was left.** #362 named the folder in the paused notice. Two other texts a model
|
|
2314
|
+
reads still said `.`: the MCP refusal in an off or paused folder (`hosts.ts`, "run
|
|
2315
|
+
`counterparts scope . --resume`") and the first-launch question (`hooks.ts`, "`counterparts
|
|
2316
|
+
scope . --on`"). `.` is wherever the line is run: the model's shell after a `cd`, or
|
|
2317
|
+
another terminal. From a subfolder of a paused entry, `--resume` is refused outright.
|
|
2318
|
+
- **One helper.** `scopes.ts#scopeCommand(folder, flag, ctx)` builds the line all three
|
|
2319
|
+
print, with #362's `shortPath`/`shellWord` moved beside it. `ScopeCommandContext` carries
|
|
2320
|
+
`home`, the plugin's root (its launcher, since a plugin install puts no `counterparts` on
|
|
2321
|
+
PATH) and the configuration to name with `--config` when the registry read is not the
|
|
2322
|
+
default's (`scopeCommandContext`). The hook builds it once (`bin/hook.ts#hookScopeContext`)
|
|
2323
|
+
for the paused notice and the adapter (`AdapterOptions.scopeCommand`); `mcp/bin/serve.ts`
|
|
2324
|
+
builds it for the server (`McpServerOptions.scopeCommand`). Absent (tests, embedders): the
|
|
2325
|
+
npm install's `counterparts`, with `--config` only for a non-default `configPath`.
|
|
2326
|
+
- **The refusal names the entry that set it.** `HostWording.offRefusal`/`pausedRefusal` are
|
|
2327
|
+
functions of a `RefusalPlace` now (`hosts.ts` cannot import `scopes.ts`, which imports it,
|
|
2328
|
+
so the lines arrive built). Own entry: "paused for this directory (~/p) … call `scope`
|
|
2329
|
+
with mode `resume`, or run `counterparts scope ~/p --resume`". A parent's pause: "paused
|
|
2330
|
+
for ~/p, which includes this directory (~/p/sub) … run `counterparts scope ~/p --resume`",
|
|
2331
|
+
and it says the `scope` tool sets only this directory (its `resume` refuses there, its
|
|
2332
|
+
`on` turns this one on alone). A parent's `off` offers both lines: this folder alone, or
|
|
2333
|
+
the whole parent. Desktop's `claude-desktop:` is never inherited and keeps its own words.
|
|
2334
|
+
- **The first-launch question** names the session's folder. An `unset` folder has no entry
|
|
2335
|
+
above it, so there is nothing inherited to name instead. Its bytes are measured from the
|
|
2336
|
+
text it prints (`SCOPE_ASK_BYTES` is gone with the constant).
|
|
2337
|
+
- **Proved.** A refusal's printed line, run through the console from another directory,
|
|
2338
|
+
resumes the parent and the next call is served (`scopes.test.ts`); the healthy
|
|
2339
|
+
SessionStart stdout in `hook-standdown.test.ts` now carries the run's folder and
|
|
2340
|
+
`--config`.
|
|
2341
|
+
|
|
2342
|
+
## 2026-10-10 — the claims file, after #359's review
|
|
2343
|
+
|
|
2344
|
+
- **A file that is not a database is set aside and made again, once.** Before, a corrupt or
|
|
2345
|
+
foreign `hook-claims.sqlite` failed every claim: a "delivered unclaimed" line on stderr at
|
|
2346
|
+
every event, and the backstop off until somebody deleted the file. Now the write that meets
|
|
2347
|
+
`SQLITE_NOTADB`, `SQLITE_CORRUPT` or `SQLITE_IOERR_SHORT_READ` (`db.ts#isUnreadableDatabase`)
|
|
2348
|
+
checks the path still holds the file it met (a twin may have rebuilt it already), moves it
|
|
2349
|
+
with its `-wal` and `-shm` to `hook-claims.unreadable-<epoch ms>.sqlite` beside it, then removes any
|
|
2350
|
+
older copy, and runs the transaction once more on a fresh file. Fail-open still: a
|
|
2351
|
+
set-aside that cannot be made, or a second failure, delivers unclaimed as before.
|
|
2352
|
+
**Review of #366: two twins meeting one bad file.** Both passed the still-unreadable
|
|
2353
|
+
check; the one that lost the move threw ENOENT (on macOS, `SQLITE_IOERR_VNODE` when its
|
|
2354
|
+
open file was moved) and delivered unclaimed beside the winner, in 30 of 30 rounds, and
|
|
2355
|
+
because older copies were removed before the move it once removed the winner's copy. Now
|
|
2356
|
+
a move that finds the file gone returns no copy, `SQLITE_IOERR_VNODE` also retries once,
|
|
2357
|
+
and older copies go after the move: 40 of 40 rounds one delivery, every copy kept
|
|
2358
|
+
(`hook-claim.test.ts`, "two twins meet one bad file"). CI's macOS runner then met
|
|
2359
|
+
`SQLITE_IOERR_FSTAT` in that test, and under load (12 busy loops) about 1 round in 70 still
|
|
2360
|
+
delivered twice: both twins checked the file and then moved it, so the later one moved the
|
|
2361
|
+
first one's NEW file, or its `-wal`. Now: (a) each write notes which file (device and inode)
|
|
2362
|
+
it met, and when a write fails and the path holds another file or none, a twin moved it,
|
|
2363
|
+
whatever the driver called that, and the write runs once more on the twin's file; (b) only
|
|
2364
|
+
the twin that makes `hook-claims.setting-aside/` beside the file moves it, sidecars first
|
|
2365
|
+
while the bad file still holds the path, then the file; a twin that finds the lock waits up
|
|
2366
|
+
to `CLAIM_WAIT_MS` for the file to go, then tries the new one; a lock older than 5 s is a dead
|
|
2367
|
+
holder's and is taken over. The still-unreadable probe went, and with it the 0644 file it
|
|
2368
|
+
could create. Measured after: macOS under 12 busy loops 0 doubles in 2,400 rounds (1 in 800
|
|
2369
|
+
in a run where a wait likely passed its 500 ms), quiet 0 in 200; Linux, 2 CPUs and 2 busy
|
|
2370
|
+
loops (`cp-ci-linux` container), 0 in 450.
|
|
2371
|
+
**Second reading of that: a dead holder's lock.** Taking it over was a stat, a remove and a
|
|
2372
|
+
make, so two twins that both judged it stale both took it (the second's remove took the
|
|
2373
|
+
first's NEW lock), and a twin that looked between the other's remove and make found no
|
|
2374
|
+
lock and did not wait: with a stale lock beside a bad file, 40 and 49 rounds in 300
|
|
2375
|
+
delivered twice on macOS (`ENOENT`, `EFAULT` from the `finally`'s remove, `SQLITE_NOTADB`).
|
|
2376
|
+
And nothing removed a stale lock while the file was healthy, so from then on every busy
|
|
2377
|
+
write waited for it as well — about 1.6 s per write where 0.55 s is the bound. Now: (a) the
|
|
2378
|
+
takeover renames the old lock to `.stale-<pid>` (of twins that judged one lock stale, one
|
|
2379
|
+
rename finds it), removes it only if it IS the lock judged stale, and puts a twin's fresh
|
|
2380
|
+
one back (removing it itself once the file has gone, since that twin may have looked to let
|
|
2381
|
+
go of it in the instant it was off); (b) a twin that finds no lock tries once more to take
|
|
2382
|
+
it; (c) the holder lets go with `rmdir`, only of the lock it made, and never throws doing so;
|
|
2383
|
+
(d) a lock older than 5 s is no twin at work, so nothing waits on it; (e) a write that met
|
|
2384
|
+
another error with no lock in sight looks at the file once more, because a twin moves the
|
|
2385
|
+
file before it lets go of the lock (under load about 1 round in 1,500 delivered twice,
|
|
2386
|
+
`SQLITE_IOERR_VNODE`, before this). Measured after, the stale-lock variant of the twins
|
|
2387
|
+
test ("… AND a dead holder's set-aside lock", 300 rounds): macOS quiet 0 in 1,500, under 12
|
|
2388
|
+
busy loops 0 in 4,800 (and the fresh twins at 300 rounds 0 in 1,500); Linux, 2 CPUs and 2
|
|
2389
|
+
busy loops, 0 in 1,500.
|
|
2390
|
+
**A known limit, not fixed:** the holder checks the path still holds the file it met and
|
|
2391
|
+
then renames it, sidecars first, without looking again. A holder suspended between the two
|
|
2392
|
+
for more than `SET_ASIDE_STALE_MS` (a machine put to sleep at that instant) can have its
|
|
2393
|
+
lock taken over, the file set aside and made again by the next one, and then, waking, move
|
|
2394
|
+
that NEW file and its `-wal` aside: one more delivery, and that set of claims lost. It
|
|
2395
|
+
needs a sleep inside a window of a few system calls, while a twin meets a bad file.
|
|
2396
|
+
`SQLITE_IOERR_SHORT_READ` is in the list because that is what a garbage file reads as when
|
|
2397
|
+
a WAL from the healthy one is still beside it, which on macOS it is: Apple's SQLite keeps
|
|
2398
|
+
`-wal` and `-shm` after the last connection closes (measured while writing the test). So
|
|
2399
|
+
the sidecars move with the file; a stale log replayed into the new file would be the same
|
|
2400
|
+
fault again.
|
|
2401
|
+
- **The trace.** The copy itself, named by when. Doctor reads it (`claim.ts#claimsSetAside`)
|
|
2402
|
+
and says `Hook claims` (amber) for a week after, naming the copy and that every event was
|
|
2403
|
+
still delivered. A new durable event name was not added for it (a core change for one
|
|
2404
|
+
rare fact); the hook says it once on stderr.
|
|
2405
|
+
- **The `process.end` line keeps the reason.** `unclaimed` was the error's message, which the
|
|
2406
|
+
log writes as its length (`[text:9]`). It is the error's code now (`Claim.code`:
|
|
2407
|
+
`SQLITE_BUSY`, `SQLITE_NOTADB`, `EEXIST`, …; `node:sqlite`'s number as `SQLITE_<n>`), and
|
|
2408
|
+
a rebuild adds `claimsSetAside: true`.
|
|
2409
|
+
- **The week-old prune skips directories by rule** (`sessions.ts#pruneSessions`): `log/`,
|
|
2410
|
+
`association/` and `claims/` were kept only because `rmSync` without `recursive` throws on
|
|
2411
|
+
a directory.
|
|
2412
|
+
- **Private like `log/`.** The directory is made 0700 and the file is created 0600 before
|
|
2413
|
+
SQLite opens it, so its `-wal` and `-shm` take 0600 too (SQLite gives them the database
|
|
2414
|
+
file's mode; the test holds a reader open so they exist to check). Only at creation, as
|
|
2415
|
+
`log/` does: a directory an earlier build made stays as it is.
|
|
2416
|
+
|
|
2417
|
+
## 2026-10-10 — a late twin got through at SessionStart (the 0.3.15 release check)
|
|
2418
|
+
|
|
2419
|
+
- **What was measured.** The release check wired two settings hooks for one build in a
|
|
2420
|
+
throwaway HOME, so the plugin's gate could not stop either, and fired every event on both
|
|
2421
|
+
at once. On a quiet machine 5 of 5 sessions delivered once at every event. With the suite
|
|
2422
|
+
loading the machine, the first session delivered two wakes at SessionStart; its other
|
|
2423
|
+
three events claimed correctly. The second hook's `performance.timeOrigin` was 45 ms after
|
|
2424
|
+
the first had finished, so the twin rule (started before the holder finished) read a new
|
|
2425
|
+
event. Not a gap in claim/finish ordering, and not a SessionStart path that skips the
|
|
2426
|
+
claim: only `off`/`paused` and the plugin gate return before it.
|
|
2427
|
+
- **The fix, contained.** Some events the host sends once per key: a SessionStart whose
|
|
2428
|
+
`source` opens a session id (`startup`, `clear`, `fork` — each a new id) and a prompt with
|
|
2429
|
+
its `prompt_id`. For those (`claim.ts#firesOnce`, `ClaimInput.once`) a same-key process
|
|
2430
|
+
inside the 15 s window is a twin whenever it started. The events that can repeat with
|
|
2431
|
+
the same key — `resume`, `compact`, Stop, SessionEnd, PreCompact, a prompt with no id —
|
|
2432
|
+
keep the start-time rule, because #355's review made "a repeat is never swallowed" the
|
|
2433
|
+
rule and its tests run those back to back. A general grace period was looked at and not
|
|
2434
|
+
taken: it would swallow exactly those repeats.
|
|
2435
|
+
- **What stays true.** For the repeatable events a twin whose runtime starts after the
|
|
2436
|
+
holder finished still delivers. The plugin's stand-down (`plugin.ts#hookGate`) is the
|
|
2437
|
+
main guard; the claim is a backstop. Doctor's `Installed twice` line said "so nothing was
|
|
2438
|
+
delivered twice", which it cannot see; it now says the claim is a backstop that counts
|
|
2439
|
+
the twins it stopped. Its fix text names `~/.claude/settings.json` too, where the release
|
|
2440
|
+
check had both wirings.
|
|
2441
|
+
|
|
2442
|
+
## 2026-10-10 — doctor's Wake line: a dated item the wake did not list is amber
|
|
2443
|
+
|
|
2444
|
+
The wake now ranks its lanes in one list (`self/briefing.ts#ROOM_ORDER`): "Work here", the
|
|
2445
|
+
Yesterday line's titles, "Last here" and the handoffs give their room before an "Arriving:"
|
|
2446
|
+
item goes unlisted. When one still does, the render's durable `self.briefing` row says so
|
|
2447
|
+
in its new per-lane count (`trimmedLanes.horizon`; a row from before it is read by its
|
|
2448
|
+
`trimmed` list), and the Wake line adds "a dated item under "Arriving:" was not listed for
|
|
2449
|
+
want of room in N wakes (newest <date>)" and turns amber: the wake is over-full, so the fix
|
|
2450
|
+
names the self page (a short version, or under its room) and `injectionBudgetBytes`. Its
|
|
2451
|
+
`--json` data gains `datedUnlisted`.
|
|
2452
|
+
|
|
2453
|
+
Plain reminders were checked and nothing changed here: the line is said beside the wake
|
|
2454
|
+
(above its opening comment, and as the person's notice), claimed only once the envelope
|
|
2455
|
+
carries it, and waits for the first prompt when there is no room — never dropped. What rode
|
|
2456
|
+
inside the wake was the same memory's Arriving line, which now leads the lane and outranks
|
|
2457
|
+
the self page's borrowing.
|