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,189 @@
|
|
|
1
|
+
# `remember/` — interface gaps for the coordinator
|
|
2
|
+
|
|
3
|
+
*Everything this module needs from a module it must not import, and everything
|
|
4
|
+
another module must change to meet it. `remember/` was built alongside `encode/`;
|
|
5
|
+
where the two touch, the seam here is a narrow injected function and the wiring is
|
|
6
|
+
listed below. Nothing in this list is implemented in `remember/`, on purpose.*
|
|
7
|
+
|
|
8
|
+
## 1. `store/paths.ts` — `LAYOUT` must classify `spans/` (BLOCKING at integration)
|
|
9
|
+
|
|
10
|
+
The span buffer lives at `<dataDir>/spans/`. `Store` asserts every top-level path is
|
|
11
|
+
classified, so **as of today `Store.open()` on a data dir that has captured spans
|
|
12
|
+
throws `LAYOUT_UNCLASSIFIED`.** The entry to add:
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
{
|
|
16
|
+
name: "spans",
|
|
17
|
+
match: "exact",
|
|
18
|
+
backup: true,
|
|
19
|
+
why: "Captured lived experience awaiting encoding. Not reconstructible from anything; its loss is the loss of the day.",
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`backup: true` is the point — spans are the one thing in the data dir that is
|
|
24
|
+
neither the canonical database nor rebuildable cache, and dropping them from the
|
|
25
|
+
backup set is exactly the silent loss the buffer exists to prevent. (`store/`'s
|
|
26
|
+
own test asserts the whole backup set, so adding one is a line there too. Since
|
|
27
|
+
the floor, 2026-09-20, it is
|
|
28
|
+
`["counterparts.sqlite", "journal", "spans"]` — `prose` and `versions` went when
|
|
29
|
+
the bodies became rows.)
|
|
30
|
+
|
|
31
|
+
## 2. `encode/` — the `GateFn` (the gate battery)
|
|
32
|
+
|
|
33
|
+
`remember/` never gates. It calls an injected function and honors the verdict:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
type GateFn = (input: GateInput) => GateVerdict | Promise<GateVerdict>;
|
|
37
|
+
|
|
38
|
+
interface GateInput {
|
|
39
|
+
content: string;
|
|
40
|
+
kind: Kind;
|
|
41
|
+
aliases: readonly string[];
|
|
42
|
+
feeling: { feeling: string; quote: string; subject: string } | null;
|
|
43
|
+
/** The proposal's OWN span, when it has one — the emotion exemption is evaluated
|
|
44
|
+
* against THIS span by the engine that minted the proposal (encode §5 G5). */
|
|
45
|
+
span: { hash: string; text: string } | null;
|
|
46
|
+
source: "session-end" | "jot";
|
|
47
|
+
day: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
type GateVerdict =
|
|
51
|
+
| { ok: true; content: string; aliases?: readonly string[]; feeling?: Feeling | null;
|
|
52
|
+
novelty?: number | null;
|
|
53
|
+
records?: readonly GateRecord[]; channels?: readonly ChannelRecord[] }
|
|
54
|
+
| { ok: false; gate: string; reason: string; refusedByDesign?: boolean;
|
|
55
|
+
records?: readonly GateRecord[]; channels?: readonly ChannelRecord[];
|
|
56
|
+
blockedBy?: readonly string[] };
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Notes for the wiring:
|
|
60
|
+
- **`records` / `channels` / `blockedBy` are a RELAY, added 2026-09-05 (replay
|
|
61
|
+
INTERFACE-GAPS §2a).** `remember/` still never gates and still reads nothing out
|
|
62
|
+
of them: they cross the seam so a caller that writes telemetry can record what
|
|
63
|
+
the battery actually did instead of a first reason and a joined string. They are
|
|
64
|
+
the one place this module names an `encode/` type — a TYPE-ONLY import in
|
|
65
|
+
`proposals.ts`, erased at runtime, so the injected-gate property is unchanged.
|
|
66
|
+
All three are optional: a gate that is not the battery (`NO_GATE`, a test
|
|
67
|
+
double) has none, and "no battery ran" must stay distinguishable from "a
|
|
68
|
+
battery ran and found nothing". `SubmitResult` carries them out, together with
|
|
69
|
+
`kind` — the proposed kind, which now survives a refusal.
|
|
70
|
+
- **`content` on an `ok` verdict is the redacted/hedged text**, and it — never the
|
|
71
|
+
draft — becomes the memory. That is how "the gate runs before anything durable"
|
|
72
|
+
stays true from this side.
|
|
73
|
+
- The default when nothing is injected is `NO_GATE`, which **refuses**. A missing
|
|
74
|
+
battery must never read as "everything passes".
|
|
75
|
+
- A gate that THROWS is treated as a refusal (`GATE_FAILED`), and the proposal
|
|
76
|
+
claims no coverage.
|
|
77
|
+
- `remember/` does not implement the secrets-gate universality test; when `encode/`
|
|
78
|
+
writes it, `submitProposal` is one of the callers it must find.
|
|
79
|
+
|
|
80
|
+
## 3. An adapter — the `InterpretFn` (the crash fallback's model call)
|
|
81
|
+
|
|
82
|
+
No SDK, no network, no streaming code exists in this module. The fallback injects:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
type InterpretFn = (chunk: SweepChunk) => Promise<InterpretResult>;
|
|
86
|
+
interface InterpretResult { proposals?: readonly unknown[]; stopReason?: string }
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The adapter owns, and this module deliberately does not: streaming (scar E3), token
|
|
90
|
+
headroom, retries, the client chokepoint (E2), **and detached execution with a
|
|
91
|
+
watchdog** (E4/E5). `validateWatchdog(timeoutMs, staleClaimMs)` is exported so the
|
|
92
|
+
adapter can assert its timeout fires inside `TUNABLES.STALE_CLAIM_MS` — a watchdog
|
|
93
|
+
slower than the staleness window lets two runs hold the same spans.
|
|
94
|
+
|
|
95
|
+
`chunk.prompt` is the prompt-side rendering (coverage marks included);
|
|
96
|
+
`chunk.spans[].text` is the ungated source text. Never send the former anywhere a
|
|
97
|
+
gate reads.
|
|
98
|
+
|
|
99
|
+
## 4. `store/` + `schemas/` — `updates:` candidates and id resolution
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
type IdResolver = (id: string) => string | null | Promise<string | null>;
|
|
103
|
+
type CandidateSource = (q: { scope: string; content: string; limit: number })
|
|
104
|
+
=> readonly Candidate[] | Promise<readonly Candidate[]>;
|
|
105
|
+
interface Candidate { id: string; text: string; aliases?: readonly string[] }
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- `IdResolver` is `store.resolve()` with its throws turned into `null`
|
|
109
|
+
(`ID_UNKNOWN` / `ID_DANGLING` are *misses*, not errors, on this path).
|
|
110
|
+
- `CandidateSource` is a recall-shaped query. Whether it should be `store.search()`,
|
|
111
|
+
the schema slice the author was shown, or the union is a **decision for whoever
|
|
112
|
+
wires it** — see CONTRACT open question 4 (showing a census of ids is what produced
|
|
113
|
+
v1's confabulation incident, so the candidate set is a policy question, not a
|
|
114
|
+
plumbing one).
|
|
115
|
+
- The two thresholds (`UPDATES_FLOOR`, `UPDATES_MARGIN`) are marked CAL and are
|
|
116
|
+
**uncalibrated**: they need a measurement against a real corpus before anyone
|
|
117
|
+
quotes a resolution rate (scar §2.8).
|
|
118
|
+
|
|
119
|
+
## 5. `observer.ts` should now be hoisted to `src/core/observer.ts`
|
|
120
|
+
|
|
121
|
+
`store/observer.ts`'s own header says: *"when a second core module needs it, MOVE
|
|
122
|
+
this file"*. `remember/` is that second consumer — it imports `isObserver` from
|
|
123
|
+
`../store/observer.js` today. The move is a move, not a rewrite (the file imports
|
|
124
|
+
nothing), and observer-mode.md G1's "exactly one definition" test wants the hoisted
|
|
125
|
+
location. `remember/` also adds stand-down sites: `WRITE_SITES` here is the
|
|
126
|
+
counterpart of `store/`'s `WRITE_METHODS`, and the cross-module totality test should
|
|
127
|
+
enumerate both.
|
|
128
|
+
|
|
129
|
+
## 6. `encode/` (or the prompt builder) — coverage marks
|
|
130
|
+
|
|
131
|
+
`markCovered()` / `renderForSweep()` produce the prompt-side rendering, and
|
|
132
|
+
`ALREADY_AUTHORED_MARK` is the mark. Contract §5 G7: marks never enter the text a
|
|
133
|
+
gate checks. Whoever builds the sweep prompt must consume `chunk.prompt`, and
|
|
134
|
+
whoever calls the gate must consume `span.text`. Crossing those two wires is the
|
|
135
|
+
failure this guarantee exists to prevent.
|
|
136
|
+
|
|
137
|
+
## 7. Whoever mints memories from proposals — the salience floor
|
|
138
|
+
|
|
139
|
+
A `Proposal` carries `salience.claimed` (nullable) and per-dimension hints, and
|
|
140
|
+
`remember/` never re-judges either. The clamp is
|
|
141
|
+
`physics.clampSalienceAtSeam(dims, claimed)`, applied at the proposal → memory seam,
|
|
142
|
+
and it emits on any lift. `remember/` deliberately does not call it: the seam is
|
|
143
|
+
downstream of this module, and calling it here would put the clamp in two places.
|
|
144
|
+
|
|
145
|
+
## 8. `Kind` defaulting
|
|
146
|
+
|
|
147
|
+
A draft with no `kind` mints as `"fact"`. If `encode/` classifies kind, that default
|
|
148
|
+
should move behind the gate seam (the verdict can return one) rather than being
|
|
149
|
+
guessed twice.
|
|
150
|
+
|
|
151
|
+
## 9. Nothing prunes `buffer.jsonl` for a session that ended normally
|
|
152
|
+
|
|
153
|
+
**Filed 2026-09-05**, by the adversarial review of the span chase (finding F5).
|
|
154
|
+
|
|
155
|
+
The strike gave the owner a way to destroy a span. It also made a claim the
|
|
156
|
+
console printed and two documents repeated — that a conversation turn quoting a
|
|
157
|
+
removed memory is "drained by the sweep" — and that claim is false.
|
|
158
|
+
|
|
159
|
+
`crashedSessions()` excludes any session that recorded a `session-end`
|
|
160
|
+
boundary, by design (§4's three clauses: the author who reached the host's own
|
|
161
|
+
end-of-session path got the pen, and what it chose not to write is forgotten
|
|
162
|
+
deliberately). A session that ends normally therefore never has its spans
|
|
163
|
+
claimed by the fallback, and **nothing else prunes `buffer.jsonl` at all** —
|
|
164
|
+
not `consume()`, which only truncates a claim; not the ledger trim, which is
|
|
165
|
+
bookkeeping; not any phase of sleep, which never looks under `spans/`.
|
|
166
|
+
|
|
167
|
+
So the live buffer grows without bound in ordinary use, and every conversational
|
|
168
|
+
turn stays on disk verbatim, indefinitely. Two consequences, both real:
|
|
169
|
+
|
|
170
|
+
1. **A removal cannot promise what a grep will find.** The console now says
|
|
171
|
+
"nothing prunes the buffer today, so it stays there" instead of "the sweep
|
|
172
|
+
drains it". Honest, and not a fix.
|
|
173
|
+
2. **`spans/` is `backup: true`.** A store that has been running for a year
|
|
174
|
+
backs up a year of raw transcript beside the memories interpreted from it.
|
|
175
|
+
|
|
176
|
+
**What is missing.** A retention rule for the live buffer, owned by this module
|
|
177
|
+
because the buffer is: something on the order of "spans covered by an accepted
|
|
178
|
+
proposal, older than N lived days, are dropped — counted, in a record". The
|
|
179
|
+
pieces exist (`coveredHashes()` says what has been interpreted; the boundary
|
|
180
|
+
ledger says when a session ended; `strikes.jsonl` is the shape of the record).
|
|
181
|
+
What does not exist is the decision about N, and whether an UNCOVERED span may
|
|
182
|
+
ever be dropped on age alone — which is the same question the unaskable-stretch
|
|
183
|
+
bound (§5 G12) answers by refusing to pretend, and should probably answer the
|
|
184
|
+
same way here: bound it, count it, do not silently drop it.
|
|
185
|
+
|
|
186
|
+
**Not taken with the strike**, deliberately: retention is a policy about
|
|
187
|
+
forgetting, the strike is a mechanism for destroying on demand, and building the
|
|
188
|
+
first inside the second would have made a removal PR into a change of what the
|
|
189
|
+
system keeps.
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
# `remember/` — implementation notes
|
|
2
|
+
|
|
3
|
+
*What the CONTRACT left open, and the simplest reading this implementation took
|
|
4
|
+
(CLAUDE.md: ambiguities get the simplest reading, recorded here). The CONTRACT is
|
|
5
|
+
the spec and is never edited from this file. Everything below is a working default,
|
|
6
|
+
revisable without ceremony.*
|
|
7
|
+
|
|
8
|
+
## 1. The buffer is a top-level `spans/` directory
|
|
9
|
+
|
|
10
|
+
Captured spans are lived experience that has not been encoded yet: not
|
|
11
|
+
reconstructible from anything (so not `cache/`, box 3), and losing them loses the
|
|
12
|
+
day (so not `tmp/`, which is `backup: false` and documented as inert leavings).
|
|
13
|
+
That leaves a new top-level directory, `<dataDir>/spans/`, and one cross-module
|
|
14
|
+
consequence: `store/paths.ts` `LAYOUT` does not classify it yet, so `Store.open()`
|
|
15
|
+
on a dir that already has spans throws `LAYOUT_UNCLASSIFIED`. The exact entry the
|
|
16
|
+
coordinator must add is in INTERFACE-GAPS.md #1. **This module writes nothing
|
|
17
|
+
outside `spans/`.**
|
|
18
|
+
|
|
19
|
+
## 2. Scope and session keys are hashes, with a legend
|
|
20
|
+
|
|
21
|
+
A scope is a project path (`/Users/x/proj`). Pasted into `join()` it either explodes
|
|
22
|
+
into nested directories or escapes the data dir entirely, so the on-disk key is
|
|
23
|
+
`hashText(scope).slice(0, 12)` and `spans/scopes.json` is the key → scope legend
|
|
24
|
+
that makes `sweepAll()` able to enumerate. Cursor files are keyed the same way, as
|
|
25
|
+
`cursors/<scopeKey>.<sessionKey>.json` — scoped since 2026-08-26, when the PR-1
|
|
26
|
+
review proved a session id under two scopes starved the second one's capture (a
|
|
27
|
+
session-only cursor let scope B read scope A's advance as NOTHING_NEW; 11 real
|
|
28
|
+
v1 session ids do span scopes). A pre-change `cursors/<sessionKey>.json` file is
|
|
29
|
+
orphaned, not migrated: the next capture re-reads from turn 0, which the hash
|
|
30
|
+
layer bounds to the spec'd G9-case-3 duplicate — harmless for greenfield v2.
|
|
31
|
+
Cost: an owner reading the directory needs the legend. Alternative rejected:
|
|
32
|
+
`encodeURIComponent`, which is reversible but produces 200-character directory
|
|
33
|
+
names on real paths.
|
|
34
|
+
|
|
35
|
+
## 3. One span per boundary, per stream
|
|
36
|
+
|
|
37
|
+
`capture()` joins the turns since the cursor into ONE span (behavioral-spec §2's
|
|
38
|
+
output shape), and the assistant's turns into a second span in a separate stream —
|
|
39
|
+
`assistant.jsonl` is never claimed and never swept; it exists as the substrate for
|
|
40
|
+
"was a surfaced memory actually used?" (contract §5 Outputs).
|
|
41
|
+
|
|
42
|
+
Consequence, and it is the specced one: a *growing* re-read of the same turns
|
|
43
|
+
produces a different hash, so hash dedup misses it and the CURSOR is what prevents
|
|
44
|
+
the duplicate. Where the cursor is also unavailable (a different session id reading
|
|
45
|
+
an overlapping transcript slice), the duplicate lands. That is contract guarantee 9
|
|
46
|
+
answered honestly rather than assumed away: **bounded duplication is acceptable,
|
|
47
|
+
loss is not**, and `remember.test.ts` asserts all three cases including the one that
|
|
48
|
+
duplicates. The upgrade if replay ever prices it too high — hash per TURN and trim
|
|
49
|
+
the overlap before joining — is available and deliberately not built (Amendment 15).
|
|
50
|
+
|
|
51
|
+
## 4. Jots live in the buffer (CONTRACT open question 3)
|
|
52
|
+
|
|
53
|
+
Answered the uniform way: a jot is a `Span` with `kind: "jot"` in `jots.jsonl`,
|
|
54
|
+
claimed and swept with everything else. The alternative (already-formed proposals in
|
|
55
|
+
the operational DB) is simpler in isolation but would give jots their own ordering,
|
|
56
|
+
dedup and claim semantics — a second lifecycle to keep honest. Jots do not move the
|
|
57
|
+
turn cursor: they are not transcript positions.
|
|
58
|
+
|
|
59
|
+
## 5. Boundary kinds: all three end a session
|
|
60
|
+
|
|
61
|
+
`stop`, `session-end` and `pre-compaction` all route through `boundary()`, all three
|
|
62
|
+
raise the ask (G11's mechanized half), and all three make a session eligible for the
|
|
63
|
+
fallback. This follows the contract's own sentence — "every session-ending path is a
|
|
64
|
+
boundary" — literally. If a host's `stop` turns out to fire per assistant response
|
|
65
|
+
rather than per session, the eligibility predicate is the line to revisit, not the
|
|
66
|
+
ask.
|
|
67
|
+
|
|
68
|
+
## 6. What "a truncated response" means when nothing reports a stop reason
|
|
69
|
+
|
|
70
|
+
`InterpretResult.stopReason` is optional because the injected function may not know
|
|
71
|
+
one. Present-and-not-in-`OK_STOP_REASONS` is a chunk FAILURE (scar E2); absent is
|
|
72
|
+
allowed through. Whoever injects a real model call is expected to set it — the
|
|
73
|
+
alternative, refusing every result with no stop reason, would make the seam
|
|
74
|
+
un-injectable from a plain function and would fail closed on a fallback path whose
|
|
75
|
+
whole job is not losing the day.
|
|
76
|
+
|
|
77
|
+
## 7. Rejection ordering in `submitProposal`
|
|
78
|
+
|
|
79
|
+
Observer → malformed (degrade to span) → content-duplicate → gate → coverage. Two
|
|
80
|
+
consequences worth naming: a *duplicate* is checked before the gate, so an identical
|
|
81
|
+
re-deposit costs no gate work and claims nothing new; and a gate FAILURE (the
|
|
82
|
+
injected function threw) is treated as a refusal, not as a pass — fail toward not
|
|
83
|
+
authoring, the same direction observer mode fails.
|
|
84
|
+
|
|
85
|
+
## 8. Coverage is claimed sequentially, with no N
|
|
86
|
+
|
|
87
|
+
§4.1 G4 says the engine claims "the most recent N uncovered spans". This
|
|
88
|
+
implementation claims *all* currently-uncovered spans of the proposal's session,
|
|
89
|
+
which partitions a session across successive proposals exactly as the guarantee
|
|
90
|
+
requires and needs no N to tune. Reopen if a real session shows one proposal
|
|
91
|
+
swallowing material a later one should have owned.
|
|
92
|
+
|
|
93
|
+
## 9. Deliberately NOT built here
|
|
94
|
+
|
|
95
|
+
- **Pacing counters / the episode ritual.** v1 paced a ritual off capture; no [M]
|
|
96
|
+
guarantee in this contract mentions pacing, and Amendment 15 says machinery is
|
|
97
|
+
earned. The one pacing-adjacent property that IS specced — injected context is
|
|
98
|
+
kept in capture — is implemented (`enters()`).
|
|
99
|
+
- **Detached execution and the watchdog.** Detachment is the adapter's; this module
|
|
100
|
+
exports `TUNABLES.STALE_CLAIM_MS` and `validateWatchdog()` so the adapter can
|
|
101
|
+
prove its timeout fires inside the staleness window (scars E4/E5).
|
|
102
|
+
- **Streaming and retries.** Owned by whoever injects `InterpretFn` (scar E3).
|
|
103
|
+
- **The salience clamp.** `physics.clampSalienceAtSeam()` governs every memory; a
|
|
104
|
+
proposal carries `claimed` and nothing here re-judges it.
|
|
105
|
+
|
|
106
|
+
## 10. Every declarable field has an admission test and a negative example (§2.16)
|
|
107
|
+
|
|
108
|
+
v1's `thread.open` shipped with no criteria and produced 33 opens and 0 closes in 13
|
|
109
|
+
days. Here, each field a draft may declare is validated in `intake()` with its own
|
|
110
|
+
named reason (`CLAIMED_OUT_OF_RANGE`, `KIND_UNKNOWN`, `ALIASES_NOT_STRINGS`, …) and
|
|
111
|
+
`test/remember.test.ts` pins a negative example for each one in a single table. A
|
|
112
|
+
new declarable field is not done until it has both.
|
|
113
|
+
|
|
114
|
+
The one field that is *not* an admission test but a resolution rule — `updates:` —
|
|
115
|
+
gets the whole of `updates.ts` and its own describe block, because a declared
|
|
116
|
+
address is the field most likely to be confabulated.
|
|
117
|
+
|
|
118
|
+
## 11. What is NOT verified live yet
|
|
119
|
+
|
|
120
|
+
The suite exercises real files in real temp directories, and the kill-mid-arc test
|
|
121
|
+
is a real second process that dies holding a claim. What has NOT run is the whole
|
|
122
|
+
arc against a host: an adapter injecting a real gate and a real interpret function,
|
|
123
|
+
detached, under a watchdog. Per CLAUDE.md's definition of done, this module is
|
|
124
|
+
**merged, not verified** until that happens — and INTERFACE-GAPS.md #1 (`LAYOUT`)
|
|
125
|
+
is a hard blocker for it, because a `Store` opened beside a populated buffer throws
|
|
126
|
+
today.
|
|
127
|
+
|
|
128
|
+
## 12. Consuming a claim deletes the claim file
|
|
129
|
+
|
|
130
|
+
Spans are the tape, not the memory: once results are applied and persisted, the
|
|
131
|
+
claim file is removed and its hashes go to the bounded `consumed.jsonl` ledger
|
|
132
|
+
FIRST, so a crash between the two leaves spans that dedup away rather than
|
|
133
|
+
duplicate. This is not a canonical-prose deletion — nothing in this module can
|
|
134
|
+
touch box 1, and the constitution's "nothing bulk-wipes silently" is honored by the
|
|
135
|
+
event (`remember.claim.consumed`, with counts).
|
|
136
|
+
|
|
137
|
+
## 13. The retry bound: three failing lived days, then quarantine
|
|
138
|
+
|
|
139
|
+
The 2026-08-26 replay's P0 fix (a restored span's hash must stay OUT of
|
|
140
|
+
`consumed.jsonl`) traded silent loss for **indefinite retry**: a permanently-failing
|
|
141
|
+
span was restored and re-swept at every boundary forever, one model call each time,
|
|
142
|
+
on the owner's account. The review accepted the trade direction and queued the
|
|
143
|
+
bound; this is it, and it is parallel-run precondition §5.4.
|
|
144
|
+
|
|
145
|
+
- **The bound**: `TUNABLES.MAX_SPAN_FAILURES = 3` — three DISTINCT LIVED DAYS, not
|
|
146
|
+
three attempts (PR-8 review: an attempt count would have quarantined a whole chunk
|
|
147
|
+
after three Stop hooks inside one API outage). The ledger records every attempt;
|
|
148
|
+
the count is the number of days on which the span failed, so an outage day is one
|
|
149
|
+
failure and a poison pill is set aside on its third day.
|
|
150
|
+
- **The ledger**: `<scope>/failures.jsonl`, beside `consumed.jsonl`, one
|
|
151
|
+
`{hash, at, day, code}` line per (span, failure). **Never span text.** The hash is the
|
|
152
|
+
buffer's own span hash, which already lives in `consumed.jsonl`. Bounded by the
|
|
153
|
+
same `trimLedger()` as the consumed ledger: a trim can drop old failures and so
|
|
154
|
+
reset a count, which spends a few more calls and never loses a span.
|
|
155
|
+
- **Written by failures only.** `sweep()` calls `noteFailures()` for a chunk that
|
|
156
|
+
came back THREW / TRUNCATED / MALFORMED_RESULT / APPLY_FAILED. A restore that is a
|
|
157
|
+
*deferral* — `BELOW_MIN_CLAIM` scraps riding to the next boundary, spans of a
|
|
158
|
+
session still running, the already-authored retirement — touches nothing and is
|
|
159
|
+
never a step toward quarantine.
|
|
160
|
+
- **The quarantine**: at the bound the span is NOT put back. Its full line is
|
|
161
|
+
appended to `<scope>/quarantine.jsonl` — the whole span, so nothing is ever
|
|
162
|
+
dropped and the owner can read it in any editor (constitution line 16) — and
|
|
163
|
+
`remember.span.quarantined` fires with `{scope, spans, code}`: counts and a code,
|
|
164
|
+
never text, and never the hash of text either (hashing low-entropy content leaks
|
|
165
|
+
it). Exclusion from future claims is structural: the span is not in the buffer.
|
|
166
|
+
- **Quarantined hashes DO enter `consumed.jsonl`.** This is the third disposition,
|
|
167
|
+
and it is terminal rather than pass-through: recording it is what stops an
|
|
168
|
+
identical re-capture from restarting the loop and what lets `mergeOrphans()`
|
|
169
|
+
filter a replayed claim. It is not the P0 regression, whose whole point was that a
|
|
170
|
+
span *coming back* must stay out of the ledger.
|
|
171
|
+
- **Counted, never absent.** `coverageReport()` carries `quarantined`, and
|
|
172
|
+
`SweepReport` carries `spansQuarantined` — a span the sweep gave up on is a
|
|
173
|
+
number the owner can see (scar §2.4).
|
|
174
|
+
- **Fails toward retry.** If the ledger or the quarantine write does not land,
|
|
175
|
+
nothing is quarantined and every span goes back. A retry costs a call; a drop
|
|
176
|
+
costs the day.
|
|
177
|
+
|
|
178
|
+
**Named limitation — innocent siblings.** A chunk failure marks *every* span in the
|
|
179
|
+
chunk, so a healthy span chunked with a poison pill three times is quarantined with
|
|
180
|
+
it. That is the simplest rule that bounds the cost; bisecting a failing chunk to
|
|
181
|
+
find the actual pill is machinery in anticipation of a failure not yet seen
|
|
182
|
+
(Amendment 15). The material is in `quarantine.jsonl` either way, so the cost of
|
|
183
|
+
being wrong is a file the owner reads, not a lost day.
|
|
184
|
+
|
|
185
|
+
**Named window.** If `noteFailures()` writes the quarantine and `restore()` then
|
|
186
|
+
fails, the sweep returns without consuming and the claim file is kept — so the next
|
|
187
|
+
stale-claim merge brings the quarantined span back for one more failed call, and it
|
|
188
|
+
is quarantined a second time (a duplicate line). Bounded duplication is the accepted
|
|
189
|
+
failure mode here; loss is not.
|
|
190
|
+
|
|
191
|
+
**`arc()` is deliberately not wired to this.** It is a retry path by docstring, but
|
|
192
|
+
it has no production caller (only the kill-mid-arc tests), it restores the *whole*
|
|
193
|
+
claim and removes the claim file, and its `work` function is arbitrary — there is no
|
|
194
|
+
per-span model call to bound. Wiring quarantine into it would need partial-restore
|
|
195
|
+
choreography it does not have, for a cost that has never been observed. The sweep is
|
|
196
|
+
the loop that bills the owner, and the sweep is what is bounded.
|
|
197
|
+
|
|
198
|
+
## 14. 2026-09-05 — the strike: how a span is destroyed without racing a claim
|
|
199
|
+
|
|
200
|
+
**Why there is a destruction path in this module at all.** LAUNCH-STATUS §I2:
|
|
201
|
+
a note is CAPTURED before it is minted, so its verbatim words sit in
|
|
202
|
+
`<key>/jots.jsonl` while the memory minted from them lives in the store.
|
|
203
|
+
*(Written as "in `prose/`" on the file floor; since the floor — schema v6,
|
|
204
|
+
2026-09-20 — the memory is a row, and the buffer is still the other copy, which
|
|
205
|
+
is the whole reason this path exists.)* The
|
|
206
|
+
owner's `remove` chased six surfaces, none of them this one, reported
|
|
207
|
+
`unchased: nothing`, and a `backup` taken afterwards copied the removed words.
|
|
208
|
+
Constitution 6/7 — the owner's data, removable loudly — was not true of a note.
|
|
209
|
+
|
|
210
|
+
**Why the console could not just delete the line.** `spans/` is this module's
|
|
211
|
+
state machine. §2 G6 forbids a span being in NEITHER a claim nor the buffer,
|
|
212
|
+
and `claim()` works by renaming the live file aside — so an `rmSync` or a
|
|
213
|
+
read-filter-write-over from `adapters/cli/removal.ts` races exactly the move
|
|
214
|
+
that guarantee exists to protect. The fix had to be a door here.
|
|
215
|
+
|
|
216
|
+
**`owner-strike-seam.ts`, and the shape it borrowed.** `store/owner-op-seam.ts`
|
|
217
|
+
already solved "a destruction that must not be reachable by holding the
|
|
218
|
+
object": `SpanBuffer`'s constructor hands the seam a capability through a
|
|
219
|
+
WeakMap, and a test in `test/cli.test.ts` pins the two files in `src/` that may
|
|
220
|
+
import it (this module's `spans.ts`, which grants and never calls, and the
|
|
221
|
+
console's `removal.ts`). A `Counterpart` — which the MCP server holds, and a
|
|
222
|
+
model talks to — holds a buffer and reaches nothing.
|
|
223
|
+
|
|
224
|
+
**What the race defense actually is.** Three moves, and `mutate()` is NOT one of
|
|
225
|
+
them. `mutate()` is the stance check plus a try/catch that turns a throw into a
|
|
226
|
+
reason; it excludes nobody. What excludes:
|
|
227
|
+
|
|
228
|
+
1. **The ledger, first.** The struck hashes go into `consumed.jsonl` before a
|
|
229
|
+
byte moves. That file is already the terminal filter for `seenHashes()`,
|
|
230
|
+
`restore()` and `mergeOrphans()`, so from that instant a re-capture of the
|
|
231
|
+
same words dedups away, a worker holding the span in memory mid-arc cannot
|
|
232
|
+
restore it, and a crashed run's orphan cannot merge it back. Ledgering a
|
|
233
|
+
struck span is the same disposition a QUARANTINED one gets — terminal, not
|
|
234
|
+
pass-through — so §12's rule (a RESTORED hash must never enter the ledger)
|
|
235
|
+
is not in tension with it. **It is BOUNDED, like every consumed hash**:
|
|
236
|
+
`consumed.jsonl` trims at `CONSUMED_LEDGER_MAX`, so far enough into the
|
|
237
|
+
future the struck hash ages out and an identical re-capture would land as a
|
|
238
|
+
new span. That is bookkeeping's price, not a hole in the removal — the
|
|
239
|
+
memory stays dark, the old capture stays gone, and what would land is
|
|
240
|
+
somebody saying the same words again.
|
|
241
|
+
2. **The rename aside.** Each file is `rename(2)`d to `<name>.striking` and the
|
|
242
|
+
survivors appended back to the original path. An append racing the strike
|
|
243
|
+
lands in a FRESH file at that path and is untouched; a read-filter-write-over
|
|
244
|
+
would have lost it on the old inode. Ordering inside a stream shuffles by at
|
|
245
|
+
most one batch, which `spans()` re-sorts on `at` anyway.
|
|
246
|
+
3. **The fold-back, and the order that makes it true.** A `.striking` file left
|
|
247
|
+
by a crashed strike is folded home before anything else happens — appended to
|
|
248
|
+
its stream (deduped by hash), **fsync'd, and only then removed**. The first
|
|
249
|
+
draft read it into an array, removed it, and wrote the array back afterwards,
|
|
250
|
+
so the survivors lived in RAM across a rename and a full re-read; a crash
|
|
251
|
+
there lost them, and this paragraph's earlier claim that "a crash strands
|
|
252
|
+
nothing" was false (review F2). It is true now, in the direction that
|
|
253
|
+
matters: a crash before the fsync leaves the aside whole and the next fold
|
|
254
|
+
repeats, deduped; loss is not on the table, bounded duplication is.
|
|
255
|
+
|
|
256
|
+
The review asked for temp → fsync → *rename over the original*. Not taken,
|
|
257
|
+
and the reason is the aside itself: renaming over the live path clobbers a
|
|
258
|
+
turn a hook appended in the meantime, which is the exact race the aside
|
|
259
|
+
exists to survive. Append-then-fsync buys the same crash property without
|
|
260
|
+
buying that one back.
|
|
261
|
+
|
|
262
|
+
The fold runs **unconditionally, per scope, before the strike decides it has
|
|
263
|
+
anything to do** (review F3). Survivors in an aside belong to nobody's
|
|
264
|
+
removal; a scope repaired only by the removal that happens to name them is a
|
|
265
|
+
scope repaired by luck. The suffix is deliberately not `.jsonl`:
|
|
266
|
+
`claimFiles()` must not see an aside as an ordinary orphan — and the console's
|
|
267
|
+
residue walk now looks for `*.jsonl.striking` by name, because an aside it
|
|
268
|
+
could not see was a "not applicable" printed over words that were on disk
|
|
269
|
+
(review F1).
|
|
270
|
+
|
|
271
|
+
**What it does NOT defend against, said plainly.** A worker that has already read
|
|
272
|
+
`claim.spans` into memory will finish its arc and may mint a memory from a span
|
|
273
|
+
struck a millisecond later. The deny-list stops the removed id from coming back;
|
|
274
|
+
it does not stop a NEW id being minted from the same words in that window. The
|
|
275
|
+
window is the length of one model call, the strike is owner-invoked and rare, and
|
|
276
|
+
closing it properly means a lock the module does not have. Named, not fixed.
|
|
277
|
+
|
|
278
|
+
**A predicate may only ever take a JOT — and the console may only ever hand it
|
|
279
|
+
an exact line, inside one scope.** Two rules, in two places, because they are
|
|
280
|
+
two different mistakes.
|
|
281
|
+
|
|
282
|
+
*Here:* the hash names one span; a predicate names a SHAPE, and the only shape
|
|
283
|
+
it is allowed to name is a jot. A conversation span is many turns joined
|
|
284
|
+
together, belongs to no single memory, and striking one because a memory's body
|
|
285
|
+
appears inside it destroys material nobody named. `matches()` enforces it, so no
|
|
286
|
+
caller can get round it.
|
|
287
|
+
|
|
288
|
+
*In the console:* the predicate it builds is **full-text equality after trim,
|
|
289
|
+
never a substring**, and it is only ever built when the memory's `origin_scope`
|
|
290
|
+
is recorded. Review F4 measured what the substring version did: removing "buy
|
|
291
|
+
milk" from a MIGRATED row — and `tools/migrate/apply.ts` writes `origin: { ref }`
|
|
292
|
+
with no scope at all, so that is the shape of every imported row — struck a jot
|
|
293
|
+
reading "buy milk and call the vet" in one project and an unrelated "buy milk"
|
|
294
|
+
in another, and ledgered both their hashes. With no scope the console now
|
|
295
|
+
REFUSES the content chase, prints the candidate files and counts, and leaves the
|
|
296
|
+
decision with the owner (`--strike-by-content-across-scopes`).
|
|
297
|
+
|
|
298
|
+
Lines left by either rule are counted and printed by the console as `spans
|
|
299
|
+
echo`, on their own line — not as `unchased`, which is about failure.
|
|
300
|
+
|
|
301
|
+
**Files it rewrites:** `buffer.jsonl`, `jots.jsonl`, `assistant.jsonl`,
|
|
302
|
+
`quarantine.jsonl`, and every `claims/*.jsonl`. Those are the five that carry
|
|
303
|
+
`text`. `coverage.jsonl`, `consumed.jsonl` and `failures.jsonl` carry span
|
|
304
|
+
hashes and are left alone — the hash is the thing that must SURVIVE, or nothing
|
|
305
|
+
stops the words being re-captured.
|
|
306
|
+
|
|
307
|
+
**What it records.** `strikes.jsonl` beside the streams: `at`, lived `day`,
|
|
308
|
+
`by`, and three counts. No hash and no text, for §16 G9's reason — hashing
|
|
309
|
+
low-entropy content is a way of keeping it. The ring event
|
|
310
|
+
`remember.span.struck` carries the same counts. It is deliberately not a box-2
|
|
311
|
+
durable event: this module has no `Store`, and adding a `DURABLE_EVENT_NAMES`
|
|
312
|
+
name was the second, explicitly deferred half of cli/INTERFACE-GAPS §9.
|
|
313
|
+
|
|
314
|
+
**The brain analog, since every physics decision here has one.** This is not
|
|
315
|
+
forgetting — decay, interference, failure to consolidate. It is the one
|
|
316
|
+
operation biological memory has no counterpart for: excision on demand. That is
|
|
317
|
+
why it is a seam nobody can reach by accident rather than a phase of sleep.
|
|
318
|
+
|
|
319
|
+
## 15. 2026-09-14 — `crashedSessions()` still never forgets, and that is the answer to G48
|
|
320
|
+
|
|
321
|
+
**The finding.** A session leaves the crashed set only by ending normally, which
|
|
322
|
+
a crashed session by definition never does. So once a scope has been swept and
|
|
323
|
+
retired, `crashedSessions()` keeps naming its session forever, `crashedPending()`
|
|
324
|
+
finds no spans behind it, and the sweep answers `NOTHING_TO_SWEEP` on that scope
|
|
325
|
+
every day for the life of the store. On the live run that was 5–7 scopes a day,
|
|
326
|
+
counted into the gate row's `otherRefusals` under a comment claiming a nonzero
|
|
327
|
+
count "is NOT a quiet day".
|
|
328
|
+
|
|
329
|
+
**What was considered.** Dropping a session from the crashed set once all of its
|
|
330
|
+
spans are consumed — a `retired` marker, or a set filtered by "still holds spans
|
|
331
|
+
in the buffer or a claim file".
|
|
332
|
+
|
|
333
|
+
**What was done instead: the reading was fixed, not the mechanism.** Three
|
|
334
|
+
reasons, in order of weight:
|
|
335
|
+
|
|
336
|
+
1. **The mechanism is already correct and the row was the thing lying.**
|
|
337
|
+
`crashedPending()` returns `spans: 0` for a retired session, so it costs no
|
|
338
|
+
rename, no claim, no restore and above all no model call — the gate is doing
|
|
339
|
+
exactly what the 2026-09-04 ruling asked. What was wrong is that a *reporting*
|
|
340
|
+
counter folded that answer in with `BELOW_MIN_CLAIM` and `IO_FAILED`. The gate
|
|
341
|
+
row now counts every reason by name, so the daily reads 7 quiet refusals
|
|
342
|
+
instead of an ambiguous 7. The division is THREE-WAY, not two —
|
|
343
|
+
`QUIET_SWEEP_REASONS`, `NOISY_NOW_SWEEP_REASONS` (`IO_FAILED`, `OBSERVER`)
|
|
344
|
+
and `NOISY_IF_CHRONIC_SWEEP_REASONS` (`BELOW_MIN_CLAIM`) — because the same
|
|
345
|
+
never-forgetting that made `NOTHING_TO_SWEEP` permanent makes
|
|
346
|
+
`BELOW_MIN_CLAIM` permanent too: a crashed session whose leftover is under
|
|
347
|
+
`MIN_CLAIM_BYTES` has it restored to the buffer (`spans.ts#claim`) and is
|
|
348
|
+
never forgotten, so that scope refuses the same way on every run for good.
|
|
349
|
+
The first cut of this row ambered the dashboard on the first one, which would
|
|
350
|
+
have left one 200-byte leftover ambering it forever — the same shape of false
|
|
351
|
+
signal, one reason further along. `noisyRefusals` counts the reasons that can
|
|
352
|
+
never be a normal day even once; `chronicCandidates` counts the one that is
|
|
353
|
+
only worth reading as a RUN, which needs a reader holding several days of
|
|
354
|
+
rows (`tools/parallel/`), not the one-row dashboard or daily.
|
|
355
|
+
2. **Forgetting would erase a distinction the gate deliberately keeps.**
|
|
356
|
+
"Nothing crashed here" and "a crashed session left nothing behind" are two
|
|
357
|
+
different facts, kept apart on purpose (§2.4 and the comment at the gate). A
|
|
358
|
+
retired session that stopped being crashed would answer `NO_CRASHED_SESSION`
|
|
359
|
+
— which is *not* what happened, and the day a crashed session's spans go
|
|
360
|
+
missing for some other reason is the day that difference matters.
|
|
361
|
+
3. **Forgetting needs new durable state, which is complexity bought in
|
|
362
|
+
anticipation.** "All its spans are consumed" is not readable from the
|
|
363
|
+
boundaries file; it needs either a per-session retired marker (a new record
|
|
364
|
+
whose own staleness is a new failure mode) or a span scan folded into a
|
|
365
|
+
function whose callers expect it to be cheap. Amendment 15: the simplest rule
|
|
366
|
+
that could work has not yet failed — the set's only cost is that
|
|
367
|
+
`crashedPending()` walks a scope's spans, which it does anyway.
|
|
368
|
+
|
|
369
|
+
**Left open, and named rather than closed:** G48's other half — `buffer.jsonl`
|
|
370
|
+
for a normally-ended session is never swept (by design) and has no prune path,
|
|
371
|
+
so it only grows (131 KB in the counterparts scope on 2026-09-14). That is a
|
|
372
|
+
retention question for the buffer, not a gate question, and nothing here touches
|
|
373
|
+
it.
|