counterparts 0.1.0
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/CONSTITUTION.md +68 -0
- package/LICENSE +21 -0
- package/README.md +348 -0
- package/docs/ELI5.md +84 -0
- package/docs/QUICKSTART.md +1258 -0
- package/docs/module-map.md +81 -0
- package/package.json +63 -0
- package/src/adapters/claude-code/CONTRACT.md +606 -0
- package/src/adapters/claude-code/INTERFACE-GAPS.md +655 -0
- package/src/adapters/claude-code/NOTES.md +1055 -0
- package/src/adapters/claude-code/bin/hook.ts +820 -0
- package/src/adapters/claude-code/bin/runner.ts +522 -0
- package/src/adapters/claude-code/config.ts +778 -0
- package/src/adapters/claude-code/credentials.ts +199 -0
- package/src/adapters/claude-code/doctor.ts +2557 -0
- package/src/adapters/claude-code/embed-client.ts +617 -0
- package/src/adapters/claude-code/hooks.ts +2240 -0
- package/src/adapters/claude-code/index.ts +224 -0
- package/src/adapters/claude-code/interpret-client.ts +395 -0
- package/src/adapters/claude-code/page-writer.ts +462 -0
- package/src/adapters/claude-code/primacy.ts +162 -0
- package/src/adapters/claude-code/spawn.ts +241 -0
- package/src/adapters/claude-code/standdown.ts +536 -0
- package/src/adapters/claude-code/transcript.ts +661 -0
- package/src/adapters/claude-code/vectors.ts +415 -0
- package/src/adapters/cli/CONTRACT.md +255 -0
- package/src/adapters/cli/INTERFACE-GAPS.md +350 -0
- package/src/adapters/cli/NOTES.md +936 -0
- package/src/adapters/cli/bin/counterparts.ts +74 -0
- package/src/adapters/cli/commands.ts +6095 -0
- package/src/adapters/cli/export.ts +766 -0
- package/src/adapters/cli/index.ts +103 -0
- package/src/adapters/cli/install.ts +670 -0
- package/src/adapters/cli/removal.ts +1186 -0
- package/src/adapters/cli/repair-dates.ts +659 -0
- package/src/adapters/cli/self-page.ts +229 -0
- package/src/adapters/cli/snapshot.ts +279 -0
- package/src/adapters/cli/start-fresh.ts +1228 -0
- package/src/adapters/config-path.ts +342 -0
- package/src/adapters/dashboard/CONTRACT.md +67 -0
- package/src/adapters/dashboard/INTERFACE-GAPS.md +139 -0
- package/src/adapters/dashboard/NOTES.md +474 -0
- package/src/adapters/dashboard/activity.ts +121 -0
- package/src/adapters/dashboard/ansi.ts +82 -0
- package/src/adapters/dashboard/bin/dashboard.ts +479 -0
- package/src/adapters/dashboard/browse.ts +298 -0
- package/src/adapters/dashboard/identity.ts +182 -0
- package/src/adapters/dashboard/index.ts +183 -0
- package/src/adapters/dashboard/layout.ts +149 -0
- package/src/adapters/dashboard/registries.ts +291 -0
- package/src/adapters/dashboard/resolve.ts +206 -0
- package/src/adapters/dashboard/source.ts +48 -0
- package/src/adapters/dashboard/status.ts +327 -0
- package/src/adapters/dashboard/stories.ts +194 -0
- package/src/adapters/dashboard/web/app.html +1731 -0
- package/src/adapters/dashboard/web/brain.html +463 -0
- package/src/adapters/dashboard/web/fired.ts +31 -0
- package/src/adapters/dashboard/web/flow.ts +457 -0
- package/src/adapters/dashboard/web/narrate.ts +1042 -0
- package/src/adapters/dashboard/web/reveal.ts +135 -0
- package/src/adapters/dashboard/web/server.ts +287 -0
- package/src/adapters/dashboard/web/views.ts +1744 -0
- package/src/adapters/expansions.ts +569 -0
- package/src/adapters/fired.ts +1580 -0
- package/src/adapters/mcp/CONTRACT.md +240 -0
- package/src/adapters/mcp/INTERFACE-GAPS.md +271 -0
- package/src/adapters/mcp/NOTES.md +205 -0
- package/src/adapters/mcp/bin/serve.ts +349 -0
- package/src/adapters/mcp/deliberate.ts +619 -0
- package/src/adapters/mcp/index.ts +101 -0
- package/src/adapters/mcp/protocol.ts +170 -0
- package/src/adapters/mcp/server.ts +1740 -0
- package/src/adapters/mcp/stdio.ts +56 -0
- package/src/adapters/mcp/tools.ts +779 -0
- package/src/adapters/scopes.ts +657 -0
- package/src/adapters/sessions.ts +402 -0
- package/src/adapters/snapshots.ts +1069 -0
- package/src/adapters/stance-env.ts +137 -0
- package/src/core/associate/CONTRACT.md +118 -0
- package/src/core/associate/INTERFACE-GAPS.md +173 -0
- package/src/core/associate/NOTES.md +194 -0
- package/src/core/associate/buffer.ts +66 -0
- package/src/core/associate/edges.ts +188 -0
- package/src/core/associate/index.ts +570 -0
- package/src/core/associate/pending.ts +383 -0
- package/src/core/associate/spread.ts +149 -0
- package/src/core/associate/tunables.ts +123 -0
- package/src/core/bridge.ts +272 -0
- package/src/core/briefing.ts +67 -0
- package/src/core/counterpart.ts +3855 -0
- package/src/core/encode/CONTRACT.md +151 -0
- package/src/core/encode/INTERFACE-GAPS.md +135 -0
- package/src/core/encode/NOTES.md +146 -0
- package/src/core/encode/aliases.ts +71 -0
- package/src/core/encode/battery.ts +284 -0
- package/src/core/encode/chunk.ts +265 -0
- package/src/core/encode/emotion.ts +119 -0
- package/src/core/encode/floor.ts +76 -0
- package/src/core/encode/index.ts +100 -0
- package/src/core/encode/precision.ts +162 -0
- package/src/core/encode/preselect.ts +269 -0
- package/src/core/encode/salience.ts +108 -0
- package/src/core/encode/secrets.ts +265 -0
- package/src/core/encode/tunables.ts +99 -0
- package/src/core/encode/types.ts +286 -0
- package/src/core/encode/words.ts +75 -0
- package/src/core/handoff/CONTRACT.md +199 -0
- package/src/core/handoff/INTERFACE-GAPS.md +166 -0
- package/src/core/handoff/NOTES.md +206 -0
- package/src/core/handoff/index.ts +957 -0
- package/src/core/mint.ts +279 -0
- package/src/core/observer.ts +28 -0
- package/src/core/physics/CONTRACT.md +341 -0
- package/src/core/physics/NOTES.md +155 -0
- package/src/core/physics/clock.ts +51 -0
- package/src/core/physics/index.ts +1054 -0
- package/src/core/prospective/CONTRACT.md +137 -0
- package/src/core/prospective/INTERFACE-GAPS.md +112 -0
- package/src/core/prospective/NOTES.md +160 -0
- package/src/core/prospective/derive.ts +188 -0
- package/src/core/prospective/index.ts +1030 -0
- package/src/core/prospective/tunables.ts +72 -0
- package/src/core/prospective/windows.ts +187 -0
- package/src/core/recall/CONTRACT.md +326 -0
- package/src/core/recall/INTERFACE-GAPS.md +163 -0
- package/src/core/recall/NOTES.md +472 -0
- package/src/core/recall/activate.ts +521 -0
- package/src/core/recall/cues.ts +275 -0
- package/src/core/recall/gate.ts +441 -0
- package/src/core/recall/index.ts +692 -0
- package/src/core/recall/probe.ts +239 -0
- package/src/core/recall/reference.ts +201 -0
- package/src/core/recall/render.ts +285 -0
- package/src/core/recall/session.ts +403 -0
- package/src/core/recall/tunables.ts +329 -0
- package/src/core/remember/CONTRACT.md +293 -0
- package/src/core/remember/INTERFACE-GAPS.md +189 -0
- package/src/core/remember/NOTES.md +373 -0
- package/src/core/remember/fallback.ts +452 -0
- package/src/core/remember/index.ts +103 -0
- package/src/core/remember/owner-strike-seam.ts +479 -0
- package/src/core/remember/proposals.ts +609 -0
- package/src/core/remember/spans.ts +1310 -0
- package/src/core/remember/tunables.ts +111 -0
- package/src/core/remember/updates.ts +198 -0
- package/src/core/retrieval.ts +96 -0
- package/src/core/revision.ts +441 -0
- package/src/core/schemas/CONTRACT.md +190 -0
- package/src/core/schemas/INTERFACE-GAPS.md +172 -0
- package/src/core/schemas/NOTES.md +260 -0
- package/src/core/schemas/aliases.ts +160 -0
- package/src/core/schemas/index.ts +1459 -0
- package/src/core/schemas/tunables.ts +44 -0
- package/src/core/schemas/types.ts +387 -0
- package/src/core/self/CONTRACT.md +459 -0
- package/src/core/self/INTERFACE-GAPS.md +284 -0
- package/src/core/self/NOTES.md +1057 -0
- package/src/core/self/briefing.ts +980 -0
- package/src/core/self/episodes.ts +483 -0
- package/src/core/self/freeze.ts +103 -0
- package/src/core/self/identity.ts +604 -0
- package/src/core/self/index.ts +2130 -0
- package/src/core/self/journal-file.ts +760 -0
- package/src/core/self/page.ts +404 -0
- package/src/core/self/tunables.ts +244 -0
- package/src/core/self/writer.ts +714 -0
- package/src/core/sleep/CONTRACT.md +298 -0
- package/src/core/sleep/INTERFACE-GAPS.md +262 -0
- package/src/core/sleep/NOTES.md +770 -0
- package/src/core/sleep/briefing.ts +86 -0
- package/src/core/sleep/consolidate.ts +241 -0
- package/src/core/sleep/cycle.ts +598 -0
- package/src/core/sleep/decay.ts +237 -0
- package/src/core/sleep/dedup.ts +373 -0
- package/src/core/sleep/index.ts +112 -0
- package/src/core/sleep/log.ts +116 -0
- package/src/core/sleep/markers.ts +164 -0
- package/src/core/sleep/prune.ts +170 -0
- package/src/core/sleep/strength-cache.ts +176 -0
- package/src/core/sleep/tunables.ts +135 -0
- package/src/core/sleep/types.ts +542 -0
- package/src/core/store/CONTRACT.md +446 -0
- package/src/core/store/NOTES.md +1068 -0
- package/src/core/store/cache.ts +709 -0
- package/src/core/store/db.ts +275 -0
- package/src/core/store/errors.ts +134 -0
- package/src/core/store/index.ts +2450 -0
- package/src/core/store/operational.ts +610 -0
- package/src/core/store/owner-op-seam.ts +428 -0
- package/src/core/store/paths.ts +494 -0
- package/src/core/store/prose.ts +165 -0
- package/src/core/store/render.ts +87 -0
- package/src/core/store/walk-seam.ts +78 -0
- package/src/core/types.ts +68 -0
- package/tools/install-loop/run.sh +1063 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# `handoff/` — interface gaps
|
|
2
|
+
|
|
3
|
+
Things this module needs from a neighbour and worked around instead of editing. Each entry
|
|
4
|
+
names the owner, the workaround now in the code, and what the real fix looks like.
|
|
5
|
+
|
|
6
|
+
## 1. `store/` has no query by prose meta
|
|
7
|
+
|
|
8
|
+
**Owner:** `store/` (the same gap `schemas/INTERFACE-GAPS §2` records).
|
|
9
|
+
**Needed:** "the handoff row for THIS directory", in one query.
|
|
10
|
+
**Have:** `findHandoffRow` lists `{ type: "schema", kind: "place", archived: false }` — the
|
|
11
|
+
columns box 2 does index — and then reads prose per row to compare `meta.scope`. It is the
|
|
12
|
+
same shape `findSelfPage` uses for `meta.role`, and it is bounded by the number of schema
|
|
13
|
+
rows about places, which is a handful in any store anyone has.
|
|
14
|
+
|
|
15
|
+
**The real fix** is a meta-indexed lookup, which F5 may make cheap when bodies move into
|
|
16
|
+
rows. Until then: do not put this call on a hot path. It runs at a boundary
|
|
17
|
+
(`liveBlockBytes`, one walk), at a wake (`pointer`) and at a write, and nowhere else.
|
|
18
|
+
|
|
19
|
+
## 2. `expandHandle` has no scope filter
|
|
20
|
+
|
|
21
|
+
**Owner:** `mcp/deliberate.ts`.
|
|
22
|
+
**Needed:** a handoff reachable by id from the directory it belongs to, and only there.
|
|
23
|
+
**Have:** `recall({ handle: <id> })` expands any live row by exact id or title, and a handoff
|
|
24
|
+
is deliberately NOT refused there — the pointer's shape is "a line of it, and its id".
|
|
25
|
+
Credit is refused (`counterpart.ts#creditReferences`), so expanding one reinforces nothing;
|
|
26
|
+
what is not refused is the READ.
|
|
27
|
+
|
|
28
|
+
**The exposure, stated plainly:** a session that is handed another directory's handoff id can
|
|
29
|
+
read that body. The id appears only in that directory's own wake, so this needs a session to
|
|
30
|
+
be *told* an id, not to find one. It is the same shape as any other id in this store, which
|
|
31
|
+
is why it was not closed unilaterally — a scope filter on `expandHandle` is a change to how
|
|
32
|
+
every id resolves, and that belongs to `mcp/`.
|
|
33
|
+
|
|
34
|
+
**The real fix:** `expandHandle` consults the caller's scope for rows that carry one, and
|
|
35
|
+
says "handle-unknown" rather than "refused" so the answer carries no information.
|
|
36
|
+
|
|
37
|
+
## 3. `self/briefing.ts` owns the splice; this module owns the block
|
|
38
|
+
|
|
39
|
+
**Owner:** shared, on purpose.
|
|
40
|
+
**Needed:** insert two lines above the tail sentinel and keep both byte counts true.
|
|
41
|
+
**Have:** `spliceBeforeSentinel` lives in `self/briefing.ts` beside `applyPreface`, because
|
|
42
|
+
the byte fixed point, the two comment regexes and the "a damaged bundle is left alone" rule
|
|
43
|
+
all live there and a second copy would be the staleness the first one exists to prevent.
|
|
44
|
+
This module composes the block and knows nothing about the bundle.
|
|
45
|
+
|
|
46
|
+
**What it costs:** a change to the wake's comment format is now a change two modules must
|
|
47
|
+
agree on, and `handoff/` has no test of the bundle's shape of its own — `test/handoff.test.ts`
|
|
48
|
+
asserts it through `readSentinel`, which is `self/`'s own reader.
|
|
49
|
+
|
|
50
|
+
## 4. Nothing shows the handoff to the OWNER outside the fired view
|
|
51
|
+
|
|
52
|
+
**Owner:** `cli/` and `dashboard/`.
|
|
53
|
+
**Needed:** constitution 16 — the owner can read what the system is carrying.
|
|
54
|
+
**Have:** `handoff.written` / `handoff.shown` rows in the fired view and the dashboard's
|
|
55
|
+
event log, and the row itself readable by `counterparts show <id>` like anything else.
|
|
56
|
+
There is no `counterparts handoff` command, no dashboard panel, and no way for the owner to
|
|
57
|
+
clear one by hand short of `remove`.
|
|
58
|
+
|
|
59
|
+
**The real fix** is a small console door — list the handoffs by directory, print one, clear
|
|
60
|
+
one — shaped like `counterparts self-page`. It was left out rather than guessed at: the
|
|
61
|
+
owner has not used this mechanism yet, and the first thing he wants from it is not a thing
|
|
62
|
+
to decide in advance (constitution line 15).
|
|
63
|
+
|
|
64
|
+
## 5. Every handoff row is one more file `Schemas.load` reads at open
|
|
65
|
+
|
|
66
|
+
**Owner:** `store/` (F5 closes it).
|
|
67
|
+
**Needed:** nothing — this is recorded, not worked around.
|
|
68
|
+
**Have:** `Schemas.load` reads every `type: "schema"` row's prose at open, and on a v5 store
|
|
69
|
+
a missing prose file throws `PROSE_FILE_MISSING` from `Counterpart.open` before anything
|
|
70
|
+
else runs: the session stands down and doctor reads RED. That is the self page's hazard
|
|
71
|
+
(`docs/adversarial-review-s1c-2026-09-20.md` MAJOR-1), and a handoff row is one more of the
|
|
72
|
+
same, once per directory the owner works in.
|
|
73
|
+
|
|
74
|
+
**The real fix is F5**, which moves bodies into rows and removes the class. Nothing is done
|
|
75
|
+
here: adding a second read path for one row would be machinery bought against a failure that
|
|
76
|
+
is already being fixed at its root.
|
|
77
|
+
|
|
78
|
+
## 6. An AWS SECRET access key survives the shared battery
|
|
79
|
+
|
|
80
|
+
**Owner:** `core/encode/secrets.ts`, through `bridge.episodeGate()` — NOT this module, and
|
|
81
|
+
NOT fixed here.
|
|
82
|
+
**Needed:** the gate every entrance passes takes credentials out.
|
|
83
|
+
**Have:** it takes most of them out. The adversarial review of 2026-09-20 put a fake AWS
|
|
84
|
+
key pair in a handoff and measured this:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
aws-looking: written=true reason=revised redacted=yes gate=null
|
|
88
|
+
stored = "[REDACTED:aws-access-key-id] and the secret wJalr…EXAMPLEKEY (…)"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The access key **id** is redacted; the **secret** beside it is stored verbatim. Everything
|
|
92
|
+
else thrown at it behaved: a body that is only a key is refused `empty-after-redaction`, a
|
|
93
|
+
model-provider key inside prose is redacted and the writer is told, a GitHub token and a
|
|
94
|
+
PEM block are refused.
|
|
95
|
+
|
|
96
|
+
This is the SHARED battery, so the journal and the self page have it too. It is recorded
|
|
97
|
+
here because E1's own CONTRACT calls a handoff "the prose most likely to carry a token",
|
|
98
|
+
which makes it this module's business to say the guarantee is narrower than it sounds — and
|
|
99
|
+
because a fix belongs in `encode/secrets.ts` where every entrance gets it at once, not in a
|
|
100
|
+
special case for one row class.
|
|
101
|
+
|
|
102
|
+
## 7. The self page is excluded too, as a working default — and a vector already made is never retracted
|
|
103
|
+
|
|
104
|
+
**Owner of the question:** `self/` (S1). **Still open with the owner.**
|
|
105
|
+
**What it was:** E1 excluded the handoff from embedding and left the self page in
|
|
106
|
+
`missingVectors()`, flagged loudly here rather than fixed, because setting another
|
|
107
|
+
module's policy in a one-line predicate is not a seam's business.
|
|
108
|
+
|
|
109
|
+
**What happened, said exactly.** The coordinating session asked for the page to be
|
|
110
|
+
excluded too, on 2026-09-20. **That is a WORKING DEFAULT and not a ruling: the owner has
|
|
111
|
+
not been asked, and a coordinator's ask is never his word.** It is revisable without
|
|
112
|
+
ceremony (CLAUDE.md), and one line in `store/#noVector` reverses it.
|
|
113
|
+
|
|
114
|
+
**The three reasons it was asked for, which are the whole of the argument.** It is never
|
|
115
|
+
recalled (`activate` skips it; it is delivered at the wake only), so a vector buys
|
|
116
|
+
retrieval nothing; it is up to 16 KB of the most identity-bearing prose in the store, which
|
|
117
|
+
would leave the machine for an embedding API for that nothing (constitution 6 — data leaves
|
|
118
|
+
by the owner's choice, and "the indexer indexes everything" is not a choice); and it would
|
|
119
|
+
sit in `doctor`'s embed backlog for ever on a keyless store. If the owner wants the page
|
|
120
|
+
searchable by meaning one day, all three stop being true at once and this goes.
|
|
121
|
+
|
|
122
|
+
**And the fix is at the WRITE seam, which is the part that nearly went wrong.** The first
|
|
123
|
+
version filtered only `unembeddedIds`, the backfill. The live adapter wires a SYNC embedder
|
|
124
|
+
(`claude-code/index.ts`), so `indexOne` embeds at every `put` and `revise` — measured with a
|
|
125
|
+
stub: three calls, two of them carrying prose that can never reach a turn. `noVector` is
|
|
126
|
+
asked at all three doors now (`indexOne`, `unembeddedIds`, `embedOne`), and the test that
|
|
127
|
+
caught it is the one the coordinating session asked for.
|
|
128
|
+
|
|
129
|
+
**Checked by the same test and deliberately left alone.** The JOURNAL (`type: "episode"`)
|
|
130
|
+
is a real recall candidate — `activate` does not skip it, `expandHandle` returns it with
|
|
131
|
+
`journal: true`, and the backfill puts episodes in the FIRST group on purpose — so a vector
|
|
132
|
+
buys it something and it keeps one. Beliefs and entities likewise. S2's nightly writer
|
|
133
|
+
mints no row of its own: it revises the PAGE row and writes events, so excluding the page
|
|
134
|
+
covers it whole.
|
|
135
|
+
|
|
136
|
+
**THE OPEN HALF: nothing retracts a vector that already exists.** Measured, on this floor:
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
embedOne(page) -> {"found":true,"vector":true} vector present: true
|
|
140
|
+
after revise(page) vector present: true (now STALE)
|
|
141
|
+
after archive(page) vector present: true
|
|
142
|
+
after pruneDeadIndex() vector present: true (removed=0)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`deindexDoc` deletes `doc_tokens` and `doc_lens` and leaves `embeddings` alone — named in
|
|
146
|
+
its own docblock as an open problem, with `nearestTo` scanning the table with no liveness
|
|
147
|
+
filter (`recall/NOTES.md` §13). `pruneDeadIndex` walks the token table, not the vector one.
|
|
148
|
+
The only path that clears a vector is `rebuildCache()`, which drops the whole table and
|
|
149
|
+
rebuilds from live rows — and after this change a rebuild will not re-embed either role.
|
|
150
|
+
|
|
151
|
+
**What that means in practice, stated plainly rather than fixed here.** A store that ran an
|
|
152
|
+
earlier build with an embedder wired holds vectors for its page and its handoffs; nothing
|
|
153
|
+
removes them, and a stale one can still displace a live neighbour on the semantic slate.
|
|
154
|
+
`counterparts verify --rebuild` is the owner's door if it ever matters. **The owner's live
|
|
155
|
+
store has never had a page written, so nothing has been embedded there.** No retraction
|
|
156
|
+
path is built now: it would be machinery bought against a state no store this project owns
|
|
157
|
+
is in, and `rebuildCache` already reaches it.
|
|
158
|
+
|
|
159
|
+
## 8. No host but Claude Code passes a scope at wake
|
|
160
|
+
|
|
161
|
+
**Owner:** whoever writes the next adapter.
|
|
162
|
+
**Needed:** `Counterpart.wake(budget, delivery, here)`'s third argument.
|
|
163
|
+
**Have:** only `claude-code/hooks.ts#sessionStart` passes it. Every other caller — the CLI,
|
|
164
|
+
the dashboard, replay — passes nothing and gets the published bundle with no pointer, which
|
|
165
|
+
is correct for all of them. A host that resolves a working directory and does not pass it
|
|
166
|
+
gets no pointer and no error, which is the quiet direction.
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# `handoff/` — implementation notes
|
|
2
|
+
|
|
3
|
+
Choices the CONTRACT does not make, recorded here rather than left to be re-discovered from
|
|
4
|
+
the code. None is a guarantee; each is the smallest rule that could work, and each names
|
|
5
|
+
what would have to fail before machinery is added. True for now (2026-09-20), not law.
|
|
6
|
+
|
|
7
|
+
## 1. Why the pointer is spliced at DELIVERY and not composed into the bundle
|
|
8
|
+
|
|
9
|
+
The wake bundle is composed once per boundary and published under one meta key. `Self.wake()`
|
|
10
|
+
reads that one bundle back with zero compute, and every session in every directory reads the
|
|
11
|
+
same bytes. So "which directory am I in" is not knowable when the body is composed — it is a
|
|
12
|
+
delivery-time fact, exactly like today's date and the store's current size, which is why the
|
|
13
|
+
delivery preface exists at all (`self/briefing.ts#prefaceLine`).
|
|
14
|
+
|
|
15
|
+
The splice therefore reuses the preface's own mechanism, pointed at the other end of the
|
|
16
|
+
bundle: `spliceBeforeSentinel` inserts above the tail sentinel and re-solves the byte fixed
|
|
17
|
+
point so both comment lines state the delivered total. A damaged bundle is returned
|
|
18
|
+
untouched, for `applyPreface`'s reason — rewriting the byte count of a damaged bundle erases
|
|
19
|
+
the damage the sentinel exists to show.
|
|
20
|
+
|
|
21
|
+
Joined at `counterpart.ts` and not inside `self/`: `self/` knows nothing about directories
|
|
22
|
+
and gains nothing by learning. The composition root is the one place that holds the
|
|
23
|
+
published bundle, the host's ceiling and the scope at once.
|
|
24
|
+
|
|
25
|
+
## 2. Why the reserve is CONDITIONAL, sized to the real block, and off below a share
|
|
26
|
+
|
|
27
|
+
`wakeReserveBytes()` adds `reserveBytes(...)` to the preface's reserve only while some
|
|
28
|
+
directory in this store holds a live, unexpired handoff.
|
|
29
|
+
|
|
30
|
+
- **Unconditional** would make every wake in every store 448 bytes smaller than master's
|
|
31
|
+
forever, including on the blank store the owner is about to start on. The claim "with no
|
|
32
|
+
handoff written the wake is byte-identical" would be false, and the first thing anyone
|
|
33
|
+
would notice is a store that trims one more element than it used to for no visible reason.
|
|
34
|
+
- **No reserve at all** fails the other way, and worse, because it fails silently and late.
|
|
35
|
+
The boundary trims the composition to exactly `budget - PREFACE_RESERVE`, so on any store
|
|
36
|
+
with enough elements the bundle fills the ceiling and a pointer spliced afterwards would be
|
|
37
|
+
dropped at every wake. It would work on a new store for two weeks and then stop, and the
|
|
38
|
+
only symptom would be `handoff.shown` going quiet — which is exactly the shape of failure
|
|
39
|
+
the fired view exists to catch and exactly the shape nobody looks for.
|
|
40
|
+
|
|
41
|
+
The scan `liveBlockBytes()` runs is ONE walk of the schema rows of the place kind — a
|
|
42
|
+
handful — and it is wrapped: a store that will not answer reserves nothing, which composes
|
|
43
|
+
the wake master composes. It builds each `Handoff` from the row it already holds rather
|
|
44
|
+
than asking `readHandoff` per directory, which would walk the store once per directory at
|
|
45
|
+
every boundary for a number that is the same shape as the one in hand.
|
|
46
|
+
|
|
47
|
+
**Two more things, both learned from the adversarial review of 2026-09-20 (MAJOR-1).**
|
|
48
|
+
|
|
49
|
+
- **A flat reserve over-reserved, and other directories paid for it.** 448 was the widest
|
|
50
|
+
block this module can produce; a real pointer is 250–300 bytes, and the reserve is
|
|
51
|
+
store-wide while the pointer is per-directory. Measured at a 1,200-byte ceiling, a session
|
|
52
|
+
in a directory with NO handoff lost 4 of its 6 identity elements; in the directory that
|
|
53
|
+
DID get the pointer, five memories bought two lines and 295 bytes of unused headroom. So
|
|
54
|
+
`reserveBytes` now takes the widest block that actually exists — one per directory, newest
|
|
55
|
+
row per scope — plus a margin, capped at that same 448.
|
|
56
|
+
- **Below a share of the budget the reserve is not taken at all.** A pointer is a fortnight
|
|
57
|
+
of working context; it is not worth a third of a small wake's memories. The rule is one
|
|
58
|
+
comparison (`want * 8 <= budget`), which turns the reserve on from about 2,400 bytes up
|
|
59
|
+
and leaves every smaller ceiling composing exactly what it composed before. At that size
|
|
60
|
+
the pointer is simply not carried, and `handoff.refused{reason:"no-room"}` says so rather
|
|
61
|
+
than leaving it to be noticed.
|
|
62
|
+
|
|
63
|
+
**Named cost: the reserve lags one boundary.** The first handoff a directory ever gets is
|
|
64
|
+
written at a boundary whose composition was already published, so the very next wake in that
|
|
65
|
+
directory may be the one case where the pointer does not fit. It is delivered without the
|
|
66
|
+
pointer, the `no-room` row is written (deduped per row per lived day — it was ring-only, and
|
|
67
|
+
every hook is its own process, so the lag left no trace at all), and the boundary after that
|
|
68
|
+
has the room. Every wake fact behaves this way; it is not worth a second publish to fix.
|
|
69
|
+
|
|
70
|
+
## 3. Why `type: "schema"`, `kind: "place"`, `meta.role = "handoff"`
|
|
71
|
+
|
|
72
|
+
`ProseType` is a closed union of three in `store/prose.ts`, and `store/` is not this module's
|
|
73
|
+
to edit. `Kind` is a closed union of six enumerated exhaustively in the MCP tool schemas, the
|
|
74
|
+
census, the claim counters and the CLI — adding to it would make "handoff" a kind a model can
|
|
75
|
+
propose a memory as, which is the opposite of the point.
|
|
76
|
+
|
|
77
|
+
So the row goes on the shelf the self page uses, one role along. `kind: "place"` is the
|
|
78
|
+
honest subject (a handoff is about a directory, a place of work) and it also keeps the recall
|
|
79
|
+
scan's exemption cheap: the prose read is gated on `type === "schema" && kind === "place"`,
|
|
80
|
+
so only schema rows about places pay for it.
|
|
81
|
+
|
|
82
|
+
**What that placement buys free**, all of it by mechanisms that already existed: dedup skips
|
|
83
|
+
schema rows by name; `scanActive` lists `{ type: "memory" }` so no lane can reach it; and
|
|
84
|
+
`schemas/#toMetaRecord` returns null for any role but entity, belief and current-state, so
|
|
85
|
+
the index build skips it rather than mis-filing it.
|
|
86
|
+
|
|
87
|
+
## 4. Why NOT `protected`, and the dwell clock that follows from it
|
|
88
|
+
|
|
89
|
+
The self page is `protected` at birth because it is standing ink. The handoff is the one
|
|
90
|
+
standing row in the store that is *meant* to be let go, so it is not — `protected` is exactly
|
|
91
|
+
what would stop `physics#pruneVerdict` ever archiving it.
|
|
92
|
+
|
|
93
|
+
That makes one thing load-bearing: `store.revise` writes prose and a version row and touches
|
|
94
|
+
no physics column. A row born on day 1 and rewritten on day 200 would still read
|
|
95
|
+
`lastUsedDay = 1` — dwell 199, strength under the floor, band episodic — and the prune would
|
|
96
|
+
archive a pointer written that morning. So every write does
|
|
97
|
+
`updatePhysics(id, { lastUsedDay: day })`. That is the whole of the interaction, and it is
|
|
98
|
+
tested by name.
|
|
99
|
+
|
|
100
|
+
**And it really can be let go, which was worth checking rather than assuming.**
|
|
101
|
+
`pruneVerdict`'s fifth blocker is `inLiveRevisionChain`, and a row that is revised on every
|
|
102
|
+
handoff accumulates version rows forever. That clause reads `superseded_by` on the ROW and
|
|
103
|
+
`successor_id` on the version rows — and `store.revise` writes version rows with
|
|
104
|
+
`successor_id = NULL` (only `store.supersede` sets one). So versions on one row do not block
|
|
105
|
+
the prune; supersession between two rows does, and nothing here supersedes. The row's own
|
|
106
|
+
`pressureAt` is zero for the same reason nothing else about it moves: no challenge ever
|
|
107
|
+
lands on it.
|
|
108
|
+
|
|
109
|
+
The numbers it leans on: `D_FLOOR_DAYS = 90` and `PHI_PRUNE = 0.02`. A pointer expires from
|
|
110
|
+
view at 14 lived days and the row survives roughly 90 more before the prune can take it. The
|
|
111
|
+
gap is deliberate — the row is the only copy, and an owner reading the dashboard three weeks
|
|
112
|
+
later should still find what was handed over.
|
|
113
|
+
|
|
114
|
+
## 5. Why expansion by id is allowed, and credit is not
|
|
115
|
+
|
|
116
|
+
The brief asks for the pointer to be expandable through the door that already exists, which
|
|
117
|
+
is `recall({ handle: <id> })` → `deliberate.ts#expandHandle`. The self page is refused there;
|
|
118
|
+
the handoff is not, because the pointer's whole shape is "here is a line of it, and here is
|
|
119
|
+
its id".
|
|
120
|
+
|
|
121
|
+
That opens the one path by which working context could reinforce itself:
|
|
122
|
+
`expandHandle` → `recordHandleResolution` → `creditAtBoundary` → `creditReferences` →
|
|
123
|
+
`resolveUse`, which advances `uses` and `reinforced_days`, which is the input
|
|
124
|
+
`promotionEligibility` reads. So the refusal sits in `creditReferences`' own filter, beside
|
|
125
|
+
`unknown-id` and `archived`, and is counted as `handoff` rather than swallowed.
|
|
126
|
+
|
|
127
|
+
**Named cost:** `expandHandle` has no scope filter, so a session that somehow holds another
|
|
128
|
+
directory's handoff id can read that body. The id only ever appears in that directory's own
|
|
129
|
+
wake, so this is a hazard for a session that was told an id, not one that can find one. Filed
|
|
130
|
+
in INTERFACE-GAPS §2.
|
|
131
|
+
|
|
132
|
+
## 5b. What a PRESENT but blank field means, and why archiving is the retirement
|
|
133
|
+
|
|
134
|
+
`handoff: ""` used to be total silence: `writeHandoffField` returned null, nothing was
|
|
135
|
+
written, and the stale pointer stood. It is the shape a model reaches for when it means
|
|
136
|
+
"the work here is finished" — which is the one thing CONTRACT open question 3 said it must
|
|
137
|
+
not be unable to say — so it is now a CLEAR.
|
|
138
|
+
|
|
139
|
+
**Archived, not revised to a cleared body.** The self page's precedent points the other way
|
|
140
|
+
(`self/page.ts`, "ONE ROW FOR THE LIFE OF THE PAGE") and it is the right precedent for the
|
|
141
|
+
page and the wrong one here, for one reason: the page must be restorable by an owner who
|
|
142
|
+
cleared it by mistake, so its history has to stay reachable through a live row. A handoff
|
|
143
|
+
has no restore door and wants none — it is working context whose whole design is to be let
|
|
144
|
+
go. Archiving gets every property for free: `handoffRows` filters `archived: false`, so the
|
|
145
|
+
pointer leaves the wake, leaves the reserve and leaves `anyLive` in one move; the words stay
|
|
146
|
+
on the row for an owner who asks for it by id; and the next handoff for that directory mints
|
|
147
|
+
a fresh row rather than reviving a retired one.
|
|
148
|
+
|
|
149
|
+
**A clear on a directory with no pointer is `nothing-to-clear`, with its own durable row.**
|
|
150
|
+
A session that finished work in a directory that never had a handoff said something true,
|
|
151
|
+
and the honest answer is a named fact rather than a silent success.
|
|
152
|
+
|
|
153
|
+
## 5c. No refusal channel on either fired row, and why
|
|
154
|
+
|
|
155
|
+
`Mechanism.refusals` (E2) exists because reading a namespace wholesale made a healthy store
|
|
156
|
+
report `BLOCKED prune … dwell-too-short ×240` for ever. `RefusalSource.only` is the
|
|
157
|
+
allow-list that fixes it, and the test it sets is whether a NAMED RULE turned away a
|
|
158
|
+
candidate that otherwise QUALIFIED — the owner saying no — rather than arithmetic saying
|
|
159
|
+
not yet.
|
|
160
|
+
|
|
161
|
+
By that test this module has almost nothing to declare. `no-scope` is "there is no
|
|
162
|
+
directory to file one against"; `not-text` and `too-large` are a malformed or oversized
|
|
163
|
+
input; `nothing-to-clear` is "there was no pointer here"; `empty` is nothing written.
|
|
164
|
+
None of them is a rule refusing something that qualified — they are all *not applicable*
|
|
165
|
+
or *not yet*. `gate-refused` and `store-refused` ARE real gates, and they are also the
|
|
166
|
+
rarest rows in the set: a handoff carrying a credential or a body the floor rejects is an
|
|
167
|
+
event worth a line, and the line it gets is the refusal row itself in the fired view's
|
|
168
|
+
evidence, not a permanent `blocked` state on the mechanism.
|
|
169
|
+
|
|
170
|
+
The one that argues for itself is `no-room` — a host's ceiling turning away a pointer that
|
|
171
|
+
qualified. It is left out for the reason S2 left its own `no-room` out (`self/NOTES` §19):
|
|
172
|
+
one fact, two surfaces, and the permanent one is the wrong one. A store whose ceiling is
|
|
173
|
+
below the share rule would read `blocked` for ever, which is the shape E2's own review was
|
|
174
|
+
about; what that store wants said is "your ceiling is small", and that belongs beside the
|
|
175
|
+
ceiling, not beside the mechanism.
|
|
176
|
+
|
|
177
|
+
So: **no `refusals` declared on either row.** The refusals are still durable, still read by
|
|
178
|
+
`fired` as evidence, and still in the dashboard's log — they simply do not grade the
|
|
179
|
+
mechanism as blocked.
|
|
180
|
+
|
|
181
|
+
## 6. Why the field is processed BEFORE `session_end` checks `memories`
|
|
182
|
+
|
|
183
|
+
`session_end` requires a non-empty `memories` array. A session that learned nothing worth
|
|
184
|
+
keeping but is leaving a directory half-finished would otherwise have its handoff thrown away
|
|
185
|
+
with the refusal. So the handoff is written right after the session bind, and its outcome
|
|
186
|
+
rides out on the refusal as well as on the success. The `memories` contract is unchanged.
|
|
187
|
+
|
|
188
|
+
## 6b. Why `flatten` strips control and format characters
|
|
189
|
+
|
|
190
|
+
`\s+` is `\n \r \t` and friends. It is not NUL, not ESC and not U+202E. Measured
|
|
191
|
+
(adversarial review MINOR-4), a right-to-left override in a handoff reversed the display of
|
|
192
|
+
everything after it in the delivered wake for any reader that honours bidi, and an ANSI
|
|
193
|
+
escape landed in a prompt that is sometimes rendered in a terminal. Line injection was
|
|
194
|
+
already blocked — the CR case folds here and only one line is ever excerpted — so this
|
|
195
|
+
closes the rest of the class in the same function, where there is one thing to check.
|
|
196
|
+
|
|
197
|
+
Order matters and is the only subtle part: a control that IS whitespace becomes a space
|
|
198
|
+
first (or `"a\nb"` would join into `"ab"`), everything else in `\p{Cc}` and `\p{Cf}` is
|
|
199
|
+
dropped, and then the ordinary collapse runs so a dropped character cannot leave a double
|
|
200
|
+
space.
|
|
201
|
+
|
|
202
|
+
## 7. Why the excerpt reserves three bytes for its ellipsis
|
|
203
|
+
|
|
204
|
+
`…` is U+2026 and is three bytes in UTF-8. The first draft reserved one character's worth and
|
|
205
|
+
a 160-byte cap rendered 161. Measured, not reasoned about — and the same class of mistake as
|
|
206
|
+
every other byte cap in this tree that counts characters somewhere and bytes somewhere else.
|