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,1042 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The narration vocabulary: every durable event name, as one sentence in the
|
|
3
|
+
* brain's own voice, naming the SPECIFIC memory.
|
|
4
|
+
*
|
|
5
|
+
* The rule this file exists to keep comes from v1's dashboard batch, where the
|
|
6
|
+
* owner's verdict on the first narration draft was that it was "so generic it's
|
|
7
|
+
* not helpful at all": "a memory was reinforced" is a mechanism statement, and
|
|
8
|
+
* a mechanism statement is a legend, not a feed. What a feed owes the owner is
|
|
9
|
+
* *which* memory, *which* day, *which* number — and the mechanism by which that
|
|
10
|
+
* is possible without ever putting text in the log is render-time id
|
|
11
|
+
* resolution: the event carries `mem_…`, this file resolves it at the moment of
|
|
12
|
+
* printing, and a memory the owner removed this morning reads as removed in a
|
|
13
|
+
* line written three days ago.
|
|
14
|
+
*
|
|
15
|
+
* ## Tone is a payload judgement, never a name judgement
|
|
16
|
+
*
|
|
17
|
+
* Amber is reserved for "look at this": a refusal, a quarantine, a cap. It is
|
|
18
|
+
* NOT for ordinary aging — `decay`-side band moves and prunes are calm, because
|
|
19
|
+
* forgetting is the thesis, not a fault (constitution line 3; v1's flow-walk
|
|
20
|
+
* item 4 is the same call made once already). So the tone of a line is decided
|
|
21
|
+
* by reading the payload — a `sweep.gate` that quarantined spans is amber, one
|
|
22
|
+
* that swept nothing is calm — and two events with the same name can carry
|
|
23
|
+
* different tones on the same page.
|
|
24
|
+
*
|
|
25
|
+
* ## Totality
|
|
26
|
+
*
|
|
27
|
+
* `NARRATORS` is `satisfies Record<DurableEventName, Teller>`, so a durable
|
|
28
|
+
* event added to the core fails `tsc` here until it has a sentence. A feed that
|
|
29
|
+
* silently printed a raw name for the one new thing the system learned to
|
|
30
|
+
* record is exactly the starvation this project's registries exist to prevent
|
|
31
|
+
* (scar §2.17), and `test/dashboard-web.test.ts` asserts the same property at
|
|
32
|
+
* runtime for anyone reading the test instead of the type.
|
|
33
|
+
*/
|
|
34
|
+
import {
|
|
35
|
+
NOISY_IF_CHRONIC_SWEEP_REASONS,
|
|
36
|
+
NOISY_NOW_SWEEP_REASONS,
|
|
37
|
+
} from "../../../core/remember/index.js";
|
|
38
|
+
import { BAND_TRANSITION_FIELDS } from "../../../core/sleep/index.js";
|
|
39
|
+
import type { EventRow, Store } from "../../../core/store/index.js";
|
|
40
|
+
import { num } from "../layout.js";
|
|
41
|
+
import type { DurableEventName } from "../registries.js";
|
|
42
|
+
import { nodeOf } from "./flow.js";
|
|
43
|
+
import type { NodeKey } from "./flow.js";
|
|
44
|
+
import { reveal, revealHere, revealPayload, shortOf } from "./reveal.js";
|
|
45
|
+
|
|
46
|
+
/** `calm` — ordinary machinery. `notable` — a real change of state.
|
|
47
|
+
* `amber` — the owner should look. Nothing else exists. */
|
|
48
|
+
export type Tone = "calm" | "notable" | "amber";
|
|
49
|
+
|
|
50
|
+
export interface Narration {
|
|
51
|
+
readonly text: string;
|
|
52
|
+
readonly tone: Tone;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface Told {
|
|
56
|
+
readonly store: Store;
|
|
57
|
+
readonly row: EventRow;
|
|
58
|
+
/** The parsed payload, or an empty object when there was none. */
|
|
59
|
+
readonly p: Record<string, unknown>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
type Teller = (t: Told) => Narration;
|
|
63
|
+
|
|
64
|
+
const calm = (text: string): Narration => ({ text, tone: "calm" });
|
|
65
|
+
const notable = (text: string): Narration => ({ text, tone: "notable" });
|
|
66
|
+
const amber = (text: string): Narration => ({ text, tone: "amber" });
|
|
67
|
+
|
|
68
|
+
/** The gate row's per-reason map (G48), or `null` for a row written before it
|
|
69
|
+
* existed — an absence this file must never read as a pile of zeros. */
|
|
70
|
+
function refusalsOf(t: Told): Record<string, number> | null {
|
|
71
|
+
const v = t.p["refusals"];
|
|
72
|
+
if (v === null || typeof v !== "object" || Array.isArray(v)) return null;
|
|
73
|
+
const out: Record<string, number> = {};
|
|
74
|
+
for (const [k, x] of Object.entries(v as Record<string, unknown>)) {
|
|
75
|
+
if (typeof x === "number" && Number.isFinite(x)) out[k] = x;
|
|
76
|
+
}
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Verdicts that are NEVER NAMED ON A SCREEN, however true the row is.
|
|
82
|
+
*
|
|
83
|
+
* `confidential-withheld` is the one verdict this package holds silent to
|
|
84
|
+
* whoever asked (§9.1 G5), because announcing a gap leaks that something is
|
|
85
|
+
* behind it. The durable row keeps the count — it is the owner's own store, and
|
|
86
|
+
* without it the confidentiality gate is as unreadable as the 2026-09-17
|
|
87
|
+
* inventory found it — but a narrated page is a third audience the row is not:
|
|
88
|
+
* it gets screenshotted, screen-shared and demoed. "1 more was kept out
|
|
89
|
+
* (confidential-withheld)" is that gap announced in plain English on a page.
|
|
90
|
+
*
|
|
91
|
+
* The count still reaches the sentence; only the WORD is withheld.
|
|
92
|
+
*/
|
|
93
|
+
const UNNAMEABLE_VERDICTS: readonly string[] = ["confidential-withheld"];
|
|
94
|
+
|
|
95
|
+
/** `blockedBy` (E2), worst first, ties broken by name so a line is stable, and
|
|
96
|
+
* the silent verdicts folded into an unnamed total. */
|
|
97
|
+
function topBlocked(t: Told): { total: number; named: [string, number][] } {
|
|
98
|
+
const v = t.p["blockedBy"];
|
|
99
|
+
if (v === null || typeof v !== "object" || Array.isArray(v)) return { total: 0, named: [] };
|
|
100
|
+
const pairs = Object.entries(v as Record<string, unknown>).filter(
|
|
101
|
+
(e): e is [string, number] => typeof e[1] === "number" && e[1] > 0,
|
|
102
|
+
);
|
|
103
|
+
const total = pairs.reduce((sum, [, n]) => sum + n, 0);
|
|
104
|
+
const named = pairs
|
|
105
|
+
.filter(([reason]) => !UNNAMEABLE_VERDICTS.includes(reason))
|
|
106
|
+
.sort((a, b) => (b[1] === a[1] ? (a[0] < b[0] ? -1 : 1) : b[1] - a[1]));
|
|
107
|
+
return { total, named };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function n(t: Told, key: string): number | null {
|
|
111
|
+
const v = t.p[key];
|
|
112
|
+
return typeof v === "number" && Number.isFinite(v) ? v : null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function s(t: Told, key: string): string | null {
|
|
116
|
+
const v = t.p[key];
|
|
117
|
+
return typeof v === "string" && v.length > 0 ? v : null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The event's own subject, quoted. Resolved now; withheld if confidential. */
|
|
121
|
+
function subject(t: Told, id?: string | null): string {
|
|
122
|
+
const target = id ?? t.row.ref;
|
|
123
|
+
// 84, not 60. This string is the brain page's ticker — the one sentence the
|
|
124
|
+
// poster is judged on — and 60 was cutting it mid-word ("Cotter Street
|
|
125
|
+
// Clinic, t…"). A feed row wraps; a truncation does not un-truncate.
|
|
126
|
+
const r = reveal(t.store, target, 84);
|
|
127
|
+
if (r.text !== null) return `“${r.text}”`;
|
|
128
|
+
return r.label;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** The same, at THIS address rather than at the end of the forwarding chain. */
|
|
132
|
+
function subjectHere(t: Told): string {
|
|
133
|
+
const r = revealHere(t.store, t.row.ref, 84);
|
|
134
|
+
return r.text === null ? r.label : `“${r.text}”`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Ids the payload carries in a list — `recall.decision`'s two tiers. */
|
|
138
|
+
function idsIn(t: Told, key: string): string[] {
|
|
139
|
+
const v = t.p[key];
|
|
140
|
+
if (!Array.isArray(v)) return [];
|
|
141
|
+
const out: string[] = [];
|
|
142
|
+
for (const item of v) {
|
|
143
|
+
if (typeof item === "string") out.push(item);
|
|
144
|
+
else if (item !== null && typeof item === "object" && typeof (item as { id?: unknown }).id === "string") {
|
|
145
|
+
out.push((item as { id: string }).id);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** The phases in `sleep.cycle`'s `phases` list that carry one status, by NAME.
|
|
152
|
+
* A count without names sends the owner back to the raw payload. */
|
|
153
|
+
function phaseNames(t: Told, status: string): string {
|
|
154
|
+
const v = t.p["phases"];
|
|
155
|
+
if (!Array.isArray(v)) return "unnamed";
|
|
156
|
+
const names: string[] = [];
|
|
157
|
+
for (const item of v) {
|
|
158
|
+
if (item === null || typeof item !== "object") continue;
|
|
159
|
+
const p = item as { phase?: unknown; status?: unknown };
|
|
160
|
+
if (p.status === status && typeof p.phase === "string") names.push(p.phase);
|
|
161
|
+
}
|
|
162
|
+
return names.length === 0 ? "unnamed" : names.join(", ");
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** "X", "X and Y", "X, Y and 3 more" — a list a person reads, not a JSON array. */
|
|
166
|
+
function nameSome(t: Told, ids: readonly string[], cap = 2): string {
|
|
167
|
+
const named = ids.slice(0, cap).map((id) => `“${shortOf(t.store, id, 62)}”`);
|
|
168
|
+
const rest = ids.length - named.length;
|
|
169
|
+
const head = named.length === 2 ? `${named[0]} and ${named[1]}` : (named[0] ?? "");
|
|
170
|
+
if (rest <= 0) return head;
|
|
171
|
+
return `${head} and ${rest} more`;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export const NARRATORS = {
|
|
175
|
+
// ── the sleep cycle ────────────────────────────────────────────────────────
|
|
176
|
+
"band.promoted": (t) =>
|
|
177
|
+
notable(
|
|
178
|
+
`${subject(t)} crossed into identity — it had been in real use on ${n(t, "reinforcedDays") ?? 0} separate days.`,
|
|
179
|
+
),
|
|
180
|
+
"band.transition": (t) => {
|
|
181
|
+
// The payload's key names are TAKEN FROM the core's own pinned field tuple
|
|
182
|
+
// rather than retyped as literals — the same rule `registries.ts` keeps for
|
|
183
|
+
// the axes: a renamed field fails here instead of quietly reading undefined
|
|
184
|
+
// and narrating "moved from somewhere to somewhere" forever.
|
|
185
|
+
const [, FROM_FIELD, TO_FIELD, DIRECTION_FIELD] = BAND_TRANSITION_FIELDS;
|
|
186
|
+
const dir = s(t, DIRECTION_FIELD);
|
|
187
|
+
const wasBand = s(t, FROM_FIELD) ?? "somewhere";
|
|
188
|
+
const nowBand = s(t, TO_FIELD) ?? "somewhere";
|
|
189
|
+
// Down is ordinary aging and reads calm. Up is a state change worth seeing.
|
|
190
|
+
return dir === "down"
|
|
191
|
+
? calm(`${subject(t)} settled back from ${wasBand} to ${nowBand}. This is what forgetting looks like when it is working.`)
|
|
192
|
+
: notable(`${subject(t)} moved up from ${wasBand} to ${nowBand} — it has been proving itself.`);
|
|
193
|
+
},
|
|
194
|
+
"memory.pruned": (t) =>
|
|
195
|
+
calm(
|
|
196
|
+
`I let go of ${subject(t)} at the floor — born on day ${n(t, "birthDay") ?? 0}, used ${n(t, "uses") ?? 0} times, down to ${num(n(t, "strength") ?? 0)}.`,
|
|
197
|
+
),
|
|
198
|
+
"memory.merged": (t) =>
|
|
199
|
+
calm(
|
|
200
|
+
`${subject(t, s(t, "candidateId"))} was the same thing I already held; I merged it into ${subject(t, s(t, "originalId"))}.`,
|
|
201
|
+
),
|
|
202
|
+
"memory.unmerged": (t) => {
|
|
203
|
+
const original = s(t, "originalId");
|
|
204
|
+
// NOTABLE, not calm: a repair is the owner reaching in, and the one line
|
|
205
|
+
// that must not read as routine housekeeping.
|
|
206
|
+
return notable(
|
|
207
|
+
original === null
|
|
208
|
+
? `The owner put ${subject(t, s(t, "candidateId"))} back: a merge had archived it, and it should never have been a duplicate.`
|
|
209
|
+
: `The owner put ${subject(t, s(t, "candidateId"))} back — a merge had folded it into ${subject(t, original)}, and it should never have been a duplicate. The use that merge credited stands.`,
|
|
210
|
+
);
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
// ── the doors ──────────────────────────────────────────────────────────────
|
|
214
|
+
"gate.chunk": (t) => {
|
|
215
|
+
const proposals = n(t, "proposals") ?? 0;
|
|
216
|
+
const accepted = n(t, "accepted") ?? 0;
|
|
217
|
+
const fully = t.p["fullyGated"] === true;
|
|
218
|
+
if (fully) {
|
|
219
|
+
return amber(
|
|
220
|
+
`The gate refused a whole chunk: ${proposals} proposals in, nothing kept. Worth knowing why.`,
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
return calm(
|
|
224
|
+
`A swept chunk met the gate battery — ${proposals} proposals looked at, ${accepted} kept.`,
|
|
225
|
+
);
|
|
226
|
+
},
|
|
227
|
+
"gate.deposit": (t) => {
|
|
228
|
+
const accepted = n(t, "accepted") === 1;
|
|
229
|
+
const gates = Array.isArray(t.p["gates"]) ? (t.p["gates"] as { gate?: unknown; status?: unknown }[]) : [];
|
|
230
|
+
const acted = gates
|
|
231
|
+
.filter((g) => g.status !== "clear" && g.status !== "not-invoked")
|
|
232
|
+
.map((g) => String(g.gate));
|
|
233
|
+
if (!accepted) {
|
|
234
|
+
// THE REFUSING GATE, and only it. `acted` is every gate that did anything
|
|
235
|
+
// — the alias gate DROPS and the precision gate HEDGES while accepting by
|
|
236
|
+
// design — so naming that list made "the secrets, emotion, floor gate
|
|
237
|
+
// refused it" out of one floor refusal, which accuses three gates of a
|
|
238
|
+
// thing only one of them did. A refusal is `status: "rejected"`.
|
|
239
|
+
const refusers = gates.filter((g) => g.status === "rejected").map((g) => String(g.gate));
|
|
240
|
+
const blocked = Array.isArray(t.p["blockedBy"]) ? (t.p["blockedBy"] as unknown[]) : [];
|
|
241
|
+
const why = blocked.length > 0 ? blocked.map(String).join(", ") : "no reason recorded";
|
|
242
|
+
const by = refusers.length > 0 ? `${refusers.join(", ")} gate` : "battery";
|
|
243
|
+
return amber(`I tried to write something down and the ${by} refused it — ${why}.`);
|
|
244
|
+
}
|
|
245
|
+
// A clean gate whose ledger write then failed: accepted, but nothing was
|
|
246
|
+
// written. Saying "I wrote something down" here would be a false claim
|
|
247
|
+
// about the store, which is the one thing this feed may not make.
|
|
248
|
+
if (t.p["memoryId"] === null) {
|
|
249
|
+
return amber("The gate passed something I meant to keep, and the write did not land.");
|
|
250
|
+
}
|
|
251
|
+
if (acted.length === 0) {
|
|
252
|
+
return calm("I wrote something down and every gate was clear.");
|
|
253
|
+
}
|
|
254
|
+
return calm(
|
|
255
|
+
`I wrote something down; the ${acted.join(", ")} gate acted on it first, and it was kept.`,
|
|
256
|
+
);
|
|
257
|
+
},
|
|
258
|
+
// THE THREE SPAWN-SEAM RECORDS (I32). Amber on sight: each of them is the
|
|
259
|
+
// background half not running, and the whole reason they are durable is that
|
|
260
|
+
// for a week nobody could see it. `count` is the persisted per-reason counter
|
|
261
|
+
// at the moment of the row, so "the fourth time today" reads as such.
|
|
262
|
+
"adapter.spawn.refused": (t) => {
|
|
263
|
+
const reason = String(t.p["reason"] ?? "unnamed");
|
|
264
|
+
const count = n(t, "count") ?? 1;
|
|
265
|
+
return amber(
|
|
266
|
+
`My background worker did not start: ${reason}${count > 1 ? `, ${String(count)} times running` : ""}. The sleep cycle, the flush and the crash fallback all ride on it.`,
|
|
267
|
+
);
|
|
268
|
+
},
|
|
269
|
+
"adapter.spawn.failed": (t) =>
|
|
270
|
+
amber(
|
|
271
|
+
`My background worker could not be started at all — the system said ${String(t.p["code"] ?? "nothing")}.`,
|
|
272
|
+
),
|
|
273
|
+
"adapter.runner.failed": (t) =>
|
|
274
|
+
amber(
|
|
275
|
+
`My background worker opened the store and then failed at ${String(t.p["step"] ?? "an unnamed step")} (${String(t.p["code"] ?? "no code")}).`,
|
|
276
|
+
),
|
|
277
|
+
// WHICH CODE WAS LIVE. Calm on master, amber otherwise: the hooks run whatever
|
|
278
|
+
// the install tree has checked out, so a branch sitting in it is not a
|
|
279
|
+
// development state — it is the memory layer that ran that day.
|
|
280
|
+
"adapter.checkout": (t) => {
|
|
281
|
+
const reason = s(t, "reason") ?? "unnamed";
|
|
282
|
+
const where = `${s(t, "branch") ?? "a detached HEAD"}@${s(t, "head") ?? "?"}`;
|
|
283
|
+
const dirty = n(t, "dirty") ?? 0;
|
|
284
|
+
if (reason === "master") return calm(`I started at origin/master (${where}), with a clean tree.`);
|
|
285
|
+
if (reason === "behind") {
|
|
286
|
+
return amber(
|
|
287
|
+
`I started ${String(n(t, "behindBy") ?? 0)} commits behind origin/master (${where}) — the merge had landed and this checkout had not moved.`,
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
return amber(
|
|
291
|
+
`I started on ${where}${dirty > 0 ? `, ${String(dirty)} tracked file${dirty === 1 ? "" : "s"} modified` : ""} — not origin/master. Whatever is checked out there is what ran.`,
|
|
292
|
+
);
|
|
293
|
+
},
|
|
294
|
+
"recall.credit": (t) => {
|
|
295
|
+
const credited = n(t, "credited") ?? 0;
|
|
296
|
+
const expanded = n(t, "expanded") ?? 0;
|
|
297
|
+
const quoted = n(t, "quoted") ?? 0;
|
|
298
|
+
const reason = s(t, "reason");
|
|
299
|
+
if (reason === "failed") {
|
|
300
|
+
return amber(
|
|
301
|
+
`A session ended and I could not decide which memories its replies had used (${s(t, "code") ?? "no code"}); nothing was credited.`,
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
if (reason === "budget-exceeded") {
|
|
305
|
+
return amber(
|
|
306
|
+
`A session ended and I ran out of time deciding what its replies had used: ${credited} credited, ${n(t, "skippedForBudget") ?? 0} never compared.`,
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
if (credited > 0) {
|
|
310
|
+
return notable(
|
|
311
|
+
`A session ended and ${credited} ${credited === 1 ? "memory" : "memories"} it actually used got stronger (${expanded} expanded, ${quoted} quoted).`,
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
return calm("A session ended; its replies used nothing I had brought to mind, so nothing got stronger.");
|
|
315
|
+
},
|
|
316
|
+
"associate.flush": (t) => {
|
|
317
|
+
const rows = n(t, "rows") ?? 0;
|
|
318
|
+
const pairs = n(t, "pairs") ?? 0;
|
|
319
|
+
const evicted = n(t, "evicted") ?? 0;
|
|
320
|
+
const waited = n(t, "oldestMs") ?? 0;
|
|
321
|
+
const reason = s(t, "reason");
|
|
322
|
+
if (reason === "failed" || reason === "threw") {
|
|
323
|
+
const lost = n(t, "dropped") ?? 0;
|
|
324
|
+
return amber(
|
|
325
|
+
`I could not write down what the sessions wired together (${s(t, "error") ?? "no code"}); ${lost} ${lost === 1 ? "link is" : "links are"} still waiting on disk for the next boundary, and the memories themselves are untouched.`,
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
if (reason === "observer") return calm("I watched a boundary wire nothing: an instrument leaves the graph as it found it.");
|
|
329
|
+
if (rows > 0) {
|
|
330
|
+
const tail = evicted > 0 ? `, and ${evicted} weaker ${evicted === 1 ? "link" : "links"} made way for them` : "";
|
|
331
|
+
// Over a minute means the work waited for a later boundary than the one
|
|
332
|
+
// that earned it — worth saying, because it is what a busy database or a
|
|
333
|
+
// worker that never ran looks like from here.
|
|
334
|
+
const late = waited > 60_000 ? ` The oldest of it had been waiting ${Math.round(waited / 60_000)} minutes.` : "";
|
|
335
|
+
return notable(
|
|
336
|
+
`${pairs} ${pairs === 1 ? "pair" : "pairs"} of memories that were used together got more connected${tail}.${late}`,
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
const dropped = n(t, "pendingDropped") ?? 0;
|
|
340
|
+
if (dropped > 0) {
|
|
341
|
+
return amber(
|
|
342
|
+
`${dropped} ${dropped === 1 ? "link was" : "links were"} noticed while nothing was writing them down, and the file holding them was full.`,
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
return calm("A boundary carried in what the sessions had wired and nothing new came of it.");
|
|
346
|
+
},
|
|
347
|
+
"sweep.gate": (t) => {
|
|
348
|
+
const scopes = n(t, "scopes") ?? 0;
|
|
349
|
+
const ran = n(t, "ran") ?? 0;
|
|
350
|
+
const skipped = n(t, "skippedNotCrashed") ?? 0;
|
|
351
|
+
const quarantined = n(t, "quarantined") ?? 0;
|
|
352
|
+
const swept = n(t, "swept") ?? 0;
|
|
353
|
+
// THE REFUSALS WORTH A LOOK (G48). Read from the per-reason map, and NEVER
|
|
354
|
+
// from `otherRefusals`: that counter reads 5-7 on an ordinary day, because a
|
|
355
|
+
// session stays in the crashed set after it is retired and its scope answers
|
|
356
|
+
// `NOTHING_TO_SWEEP` for good. A row written before this shipped carries no
|
|
357
|
+
// map and gets no amber it cannot support — the old number could not tell a
|
|
358
|
+
// stuck buffer from a quiet one, so neither can a reader of it.
|
|
359
|
+
//
|
|
360
|
+
// AND THE AMBER IS ONLY THE FIRST HALF (M3). `BELOW_MIN_CLAIM` is permanent
|
|
361
|
+
// by construction — a crashed session's leftover under `MIN_CLAIM_BYTES` is
|
|
362
|
+
// restored to the buffer and the session is never forgotten, so the same
|
|
363
|
+
// scope refuses that way on every run for good. This narrator holds ONE row
|
|
364
|
+
// and cannot tell a first refusal from a thousandth, so ambering on it made
|
|
365
|
+
// one 200-byte leftover an amber dashboard forever. It is named instead, in
|
|
366
|
+
// the ordinary line, and the alarm is kept for the reasons that cannot be a
|
|
367
|
+
// normal day even once: IO_FAILED and OBSERVER.
|
|
368
|
+
const refusals = refusalsOf(t);
|
|
369
|
+
const sum = (rs: readonly string[]): number =>
|
|
370
|
+
refusals === null ? 0 : rs.reduce((acc, r) => acc + (refusals[r] ?? 0), 0);
|
|
371
|
+
const noisy = sum(NOISY_NOW_SWEEP_REASONS);
|
|
372
|
+
// Derived from the MAP, not from the row's own `chronicCandidates`, so a row
|
|
373
|
+
// written between G48 and this fix — map present, counter absent — still
|
|
374
|
+
// gets the sentence.
|
|
375
|
+
const chronic = sum(NOISY_IF_CHRONIC_SWEEP_REASONS);
|
|
376
|
+
const chronicNote =
|
|
377
|
+
chronic === 0
|
|
378
|
+
? ""
|
|
379
|
+
: ` ${chronic} scope${chronic === 1 ? "" : "s"} held a buffer too small to claim` +
|
|
380
|
+
" — fine once, a buffer that never drains if it is every day.";
|
|
381
|
+
// The SKIPPED row (I32): the worker ran the day — clock, flush, cycle — and
|
|
382
|
+
// deliberately did not sweep, because sweeping needs a model call it had no
|
|
383
|
+
// credential for. Saying "looked at 0 scopes and found nothing" of that
|
|
384
|
+
// would be the silence-as-health this row exists to prevent.
|
|
385
|
+
if (t.p["reason"] === "no-credential") {
|
|
386
|
+
return amber(
|
|
387
|
+
"I ran the day — the clock, the flush, the cycle — but skipped the crash fallback: there was no credential for the one model call it needs. Nothing was lost that a key would not fix.",
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
if (quarantined > 0) {
|
|
391
|
+
return amber(
|
|
392
|
+
`The crash fallback quarantined ${quarantined} spans it could not safely read. That is the one outcome here worth looking at.`,
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
if (noisy > 0) {
|
|
396
|
+
const named = NOISY_NOW_SWEEP_REASONS.filter((r) => (refusals?.[r] ?? 0) > 0)
|
|
397
|
+
.map((r) => `${r} ${refusals?.[r] ?? 0}`)
|
|
398
|
+
.join(", ");
|
|
399
|
+
return amber(
|
|
400
|
+
`The crash fallback refused ${noisy} of ${scopes} scopes for a reason that is never a normal day: ${named}. A claim the filesystem refused is not a quiet day, and a buffer that stood down under a root that did not is wiring.${chronicNote}`,
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
if (ran === 0) {
|
|
404
|
+
return calm(
|
|
405
|
+
`The crash fallback ran and found nothing to do: ${scopes} scopes looked at, ${skipped} of them with nothing crashed. This line is here to prove the silence is real.${chronicNote}`,
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
return notable(
|
|
409
|
+
`The crash fallback picked up after a session that ended badly — ${swept} spans swept from ${ran} of ${scopes} scopes.${chronicNote}`,
|
|
410
|
+
);
|
|
411
|
+
},
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* THE WAKE THE FALLBACK READ WITH. Neutral by rule, like `self.briefing`: a
|
|
415
|
+
* trim is the budget working and a cold store is a cold store, so nothing here
|
|
416
|
+
* is amber. `included: false` is not a fault — it is this row telling the
|
|
417
|
+
* truth about a run that had no self to carry.
|
|
418
|
+
*/
|
|
419
|
+
"sweep.wake": (t) => {
|
|
420
|
+
const reason = String(t.p["reason"] ?? "");
|
|
421
|
+
const bytes = n(t, "bytes") ?? 0;
|
|
422
|
+
const elements = n(t, "elements") ?? 0;
|
|
423
|
+
const omitted = n(t, "omitted") ?? 0;
|
|
424
|
+
const held =
|
|
425
|
+
omitted === 0
|
|
426
|
+
? ""
|
|
427
|
+
: ` ${omitted} confidential or permanent ${omitted === 1 ? "line" : "lines"} stayed behind, as ${omitted === 1 ? "it" : "they"} always will.`;
|
|
428
|
+
if (t.p["included"] !== true) {
|
|
429
|
+
if (reason === "not-reached") {
|
|
430
|
+
return calm(
|
|
431
|
+
"Nothing had crashed, so no transcript was read and I composed no wake at all — a quiet sweep costs nothing to be ready. This line is here to prove the sweep looked." + held,
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
if (reason === "no-budget") {
|
|
435
|
+
return calm(
|
|
436
|
+
"The crash fallback read a transcript without me: this host never said how much context it can carry, so there was no wake to compose against." + held,
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
if (reason === "no-room") {
|
|
440
|
+
return calm(
|
|
441
|
+
"The crash fallback read a transcript without me: the byte cap was too small for even the shape of a wake." + held,
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
if (reason === "failed") {
|
|
445
|
+
return amber(
|
|
446
|
+
`The crash fallback read a transcript without me: composing my wake failed (${String(t.p["code"] ?? "no code")}). It read cold, which is what it always did before.`,
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
return calm(
|
|
450
|
+
"The crash fallback read a transcript without me: there was nothing of me to bring yet." + held,
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
const trimmed = n(t, "trimmed") ?? 0;
|
|
454
|
+
const chunks = n(t, "chunks") ?? 0;
|
|
455
|
+
const cut =
|
|
456
|
+
trimmed === 0
|
|
457
|
+
? ""
|
|
458
|
+
: ` The cap set aside ${trimmed} element${trimmed === 1 ? "" : "s"} that would not fit.`;
|
|
459
|
+
return notable(
|
|
460
|
+
`The crash fallback read a transcript as ME: ${elements} element${elements === 1 ? "" : "s"} of my wake, ${num(bytes)} bytes, went in front of ${chunks} chunk${chunks === 1 ? "" : "s"}.${cut}${held}`,
|
|
461
|
+
);
|
|
462
|
+
},
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* THE CYCLE'S OWN ROW (U9). Amber when a phase failed, and NAMED: a cycle that
|
|
466
|
+
* lost consolidation is not a cycle that ran, and the whole point of the row is
|
|
467
|
+
* that the failure is still readable a week later, out of the store.
|
|
468
|
+
*/
|
|
469
|
+
"sleep.cycle": (t) => {
|
|
470
|
+
const failed = n(t, "failed") ?? 0;
|
|
471
|
+
const reason = String(t.p["reason"] ?? "ran");
|
|
472
|
+
if (reason === "threw") {
|
|
473
|
+
return amber(
|
|
474
|
+
`My nightly cycle died partway through (${String(t.p["code"] ?? "no code")}). What it had already finished stands; the rest is retried at the next boundary.`,
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
// BEFORE the generic failed-phase line, not after it: a failed clock IS a
|
|
478
|
+
// failed phase, so the generic branch would swallow this one entirely.
|
|
479
|
+
if (reason === "clock-failed") {
|
|
480
|
+
return amber(
|
|
481
|
+
"My nightly cycle could not advance its own clock, so it ran on the day the store already believed in. Everything else went ahead on that day.",
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
if (failed > 0) {
|
|
485
|
+
return amber(
|
|
486
|
+
`My nightly cycle ran, but ${failed} phase${failed === 1 ? "" : "s"} failed — ${phaseNames(t, "failed")}. Those markers did not advance, so the work is retried tomorrow.`,
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
const promoted = n(t, "promoted") ?? 0;
|
|
490
|
+
const pruned = n(t, "pruned") ?? 0;
|
|
491
|
+
const merged = n(t, "merged") ?? 0;
|
|
492
|
+
if (promoted + pruned + merged === 0) {
|
|
493
|
+
return calm(
|
|
494
|
+
"My nightly cycle ran end to end and changed nothing worth naming — nothing promoted, nothing let go, nothing merged. This line is here to prove the quiet is real.",
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
return notable(
|
|
498
|
+
`My nightly cycle ran: ${promoted} promoted, ${pruned} let go, ${merged} merged.`,
|
|
499
|
+
);
|
|
500
|
+
},
|
|
501
|
+
/**
|
|
502
|
+
* THE WAKE RENDER'S ROW (U9). Neutral by rule: a trim is the budget working,
|
|
503
|
+
* not a fault — the wake is SUPPOSED to be smaller than everything it knows,
|
|
504
|
+
* and amber is reserved for "look at this" (see the tone note in the header).
|
|
505
|
+
*/
|
|
506
|
+
"self.briefing": (t) => {
|
|
507
|
+
const bytes = n(t, "bytes") ?? 0;
|
|
508
|
+
const budget = n(t, "budget") ?? 0;
|
|
509
|
+
const trimmed = n(t, "trimmedTotal") ?? 0;
|
|
510
|
+
const where = budget > 0 ? ` of the ${num(budget)} bytes the host said it could carry` : "";
|
|
511
|
+
if (trimmed === 0) {
|
|
512
|
+
return calm(`I rewrote my wake: ${num(bytes)} bytes${where}, with nothing trimmed.`);
|
|
513
|
+
}
|
|
514
|
+
return calm(
|
|
515
|
+
`I rewrote my wake: ${num(bytes)} bytes${where}, after setting aside ${trimmed} element${trimmed === 1 ? "" : "s"} that would not fit.`,
|
|
516
|
+
);
|
|
517
|
+
},
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* THE PAGE'S TWO ROWS (2026-09-18). Calm on both arms: an amendment is the
|
|
521
|
+
* mechanism working, and a refusal is a cap doing its job out loud rather
|
|
522
|
+
* than a fault.
|
|
523
|
+
*/
|
|
524
|
+
"self.page.revised": (t) => {
|
|
525
|
+
const by = s(t, "by") ?? "someone";
|
|
526
|
+
const bytes = n(t, "bytes") ?? 0;
|
|
527
|
+
const why = s(t, "reason");
|
|
528
|
+
const who =
|
|
529
|
+
by === "owner"
|
|
530
|
+
? "the owner wrote my page"
|
|
531
|
+
: by === "writer"
|
|
532
|
+
? "the nightly writer revised my page"
|
|
533
|
+
: "I amended my page";
|
|
534
|
+
const because = why === null || why.length === 0 ? "" : `, ${why}`;
|
|
535
|
+
return calm(`${who}: ${num(bytes)} bytes${because}.`);
|
|
536
|
+
},
|
|
537
|
+
"self.page.refused": (t) => {
|
|
538
|
+
const why = s(t, "reason") ?? "refused";
|
|
539
|
+
const by = s(t, "by") ?? "someone";
|
|
540
|
+
return calm(`A write to my page was turned away (${why}), from ${by}. The page is unchanged.`);
|
|
541
|
+
},
|
|
542
|
+
/**
|
|
543
|
+
* THE NIGHTLY WRITER'S RUN (2026-09-20, S2). Calm on every arm including the
|
|
544
|
+
* failures: a night that could not run is the mechanism reporting, and the
|
|
545
|
+
* page is untouched either way. The one arm worth reading twice is
|
|
546
|
+
* `nothing-to-say` — it says out loud that the day changed nothing, which is
|
|
547
|
+
* the outcome a silence would otherwise be mistaken for.
|
|
548
|
+
*/
|
|
549
|
+
"self.page.writer.ran": (t) => {
|
|
550
|
+
const about = s(t, "about") ?? "a day";
|
|
551
|
+
const mode = s(t, "mode") ?? "session";
|
|
552
|
+
const outcome = s(t, "outcome") ?? "ran";
|
|
553
|
+
const considered = n(t, "considered") ?? 0;
|
|
554
|
+
const read = considered === 0 ? "" : ` after reading ${considered} memor${considered === 1 ? "y" : "ies"} from it`;
|
|
555
|
+
switch (outcome) {
|
|
556
|
+
case "asked":
|
|
557
|
+
return calm(`I was asked to revise my page from ${about}${read}.`);
|
|
558
|
+
case "started":
|
|
559
|
+
return calm(`A windowless session of me was started to revise my page from ${about}.`);
|
|
560
|
+
case "revised":
|
|
561
|
+
return calm(`My page was revised from ${about}${read}: ${num(n(t, "bytesBefore") ?? 0)} bytes became ${num(n(t, "bytesAfter") ?? 0)}.`);
|
|
562
|
+
case "nothing-to-say":
|
|
563
|
+
return calm(`I read ${about}${read} and left my page as it stands — nothing about who I am moved that day.`);
|
|
564
|
+
case "refused":
|
|
565
|
+
return calm(`A revision of my page from ${about} was turned away (${s(t, "detail") ?? "refused"}). The page is unchanged.`);
|
|
566
|
+
case "failed":
|
|
567
|
+
return calm(`The nightly writer could not run for ${about} (${s(t, "detail") ?? "failed"}). The page is unchanged.`);
|
|
568
|
+
default:
|
|
569
|
+
return calm(`The nightly writer stood down for ${about} (${s(t, "detail") ?? "skipped"}), in ${mode} mode.`);
|
|
570
|
+
}
|
|
571
|
+
},
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* THE HANDOFF'S THREE (2026-09-20, E1). Calm on all three: leaving one is the
|
|
575
|
+
* mechanism working, being handed one is the mechanism paying off, and a
|
|
576
|
+
* refusal is a cap doing its job out loud.
|
|
577
|
+
*/
|
|
578
|
+
"handoff.written": (t) => {
|
|
579
|
+
const bytes = n(t, "bytes") ?? 0;
|
|
580
|
+
const created = t.p["created"] === true;
|
|
581
|
+
const days = n(t, "lifeDays") ?? 0;
|
|
582
|
+
return calm(
|
|
583
|
+
`I left a handoff for the next session in this directory: ${num(bytes)} bytes, ` +
|
|
584
|
+
`${created ? "the first one here" : "replacing the one that stood"}, showing for ${num(days)} days of use.`,
|
|
585
|
+
);
|
|
586
|
+
},
|
|
587
|
+
"handoff.shown": (t) => {
|
|
588
|
+
const age = n(t, "ageDays");
|
|
589
|
+
const bytes = n(t, "bytes") ?? 0;
|
|
590
|
+
const when = age === null ? "" : age === 0 ? ", written today" : `, written ${num(age)} days of use ago`;
|
|
591
|
+
return calm(`I woke here and was handed the pointer to this directory's handoff${when} (${num(bytes)} bytes of the wake).`);
|
|
592
|
+
},
|
|
593
|
+
"handoff.cleared": (t) => {
|
|
594
|
+
const bytes = n(t, "bytes") ?? 0;
|
|
595
|
+
return calm(
|
|
596
|
+
`I finished the work in this directory and retired its handoff (${num(bytes)} bytes). The next session here is handed nothing.`,
|
|
597
|
+
);
|
|
598
|
+
},
|
|
599
|
+
"handoff.refused": (t) => {
|
|
600
|
+
const why = s(t, "reason") ?? "refused";
|
|
601
|
+
if (why === "no-room") {
|
|
602
|
+
const budget = n(t, "budget") ?? 0;
|
|
603
|
+
return calm(
|
|
604
|
+
`There was no room in this wake for the handoff pointer (the bundle would have been ${num(n(t, "bytes") ?? 0)} bytes against a ceiling of ${num(budget)}), so it was left off whole.`,
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
return calm(`A handoff was turned away (${why}). Nothing was left for the next session here.`);
|
|
608
|
+
},
|
|
609
|
+
|
|
610
|
+
// ── retrieval ──────────────────────────────────────────────────────────────
|
|
611
|
+
"recall.decision": (t) => {
|
|
612
|
+
const surfaced = idsIn(t, "surfaced");
|
|
613
|
+
const footnotes = idsIn(t, "footnotes");
|
|
614
|
+
const turn = n(t, "turn") ?? 0;
|
|
615
|
+
if (surfaced.length === 0 && footnotes.length === 0) {
|
|
616
|
+
return calm(
|
|
617
|
+
`On turn ${turn} nothing rose above the turn's own background, so I said nothing. Most turns end here, and that is the design.`,
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
if (surfaced.length === 0) {
|
|
621
|
+
return calm(
|
|
622
|
+
`On turn ${turn} I kept ${nameSome(t, footnotes)} as a footnote — near enough to mention, not near enough to say out loud.`,
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
const tail = footnotes.length === 0 ? "" : `, with ${footnotes.length} more held back as footnotes`;
|
|
626
|
+
return notable(`On turn ${turn} ${nameSome(t, surfaced)} came to mind${tail}.`);
|
|
627
|
+
},
|
|
628
|
+
"adapter.recall": (t) => {
|
|
629
|
+
const reason = s(t, "reason");
|
|
630
|
+
if (reason === "latency-abort") {
|
|
631
|
+
return amber(`Recall took too long for one turn and I abandoned it rather than make you wait.`);
|
|
632
|
+
}
|
|
633
|
+
const count = n(t, "surfaced") ?? n(t, "count") ?? 0;
|
|
634
|
+
const bytes = n(t, "bytes") ?? 0;
|
|
635
|
+
return calm(
|
|
636
|
+
count === 0
|
|
637
|
+
? `A turn's recall was composed and came to nothing — no bytes handed over.`
|
|
638
|
+
: `A turn's recall was composed for the host: ${count} memories, ${bytes} bytes.`,
|
|
639
|
+
);
|
|
640
|
+
},
|
|
641
|
+
"adapter.semantic.lag": (t) => {
|
|
642
|
+
const reason = s(t, "reason");
|
|
643
|
+
const hits = n(t, "hits");
|
|
644
|
+
if (hits !== null && hits >= 0 && reason === null) {
|
|
645
|
+
return calm(`I left next turn's semantic cue ready — ${hits} neighbours precomputed.`);
|
|
646
|
+
}
|
|
647
|
+
return amber(`I could not leave next turn's semantic cue: ${reason ?? "no reason recorded"}.`);
|
|
648
|
+
},
|
|
649
|
+
|
|
650
|
+
// ── waking ─────────────────────────────────────────────────────────────────
|
|
651
|
+
"adapter.wake.injected": (t) =>
|
|
652
|
+
notable(`I handed the host who I have been — ${n(t, "bytes") ?? 0} bytes of briefing, at the start of a session.`),
|
|
653
|
+
"adapter.wake.delivered": (t) => {
|
|
654
|
+
const seen = t.p["seen"] === true || t.p["sentinelSeen"] === true || t.p["ok"] === true;
|
|
655
|
+
if (seen) return calm(`I checked the next turn and my briefing had arrived intact.`);
|
|
656
|
+
// The check says WHY since 2026-09-17, and one of its answers is not a problem:
|
|
657
|
+
// a session that was owed no briefing (nothing was printed at its start).
|
|
658
|
+
const outcome = s(t, "outcome");
|
|
659
|
+
if (outcome === "no-wake-expected") {
|
|
660
|
+
return calm(`This session was owed no briefing, so there was nothing to check for.`);
|
|
661
|
+
}
|
|
662
|
+
if (outcome === "printed-unverified") {
|
|
663
|
+
return calm(
|
|
664
|
+
`My briefing was printed intact; this host does not record what it delivered, so I could not check further.`,
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
if (outcome === "truncated") {
|
|
668
|
+
return amber(`My briefing arrived cut short — the closing marker was missing from what the session was given.`);
|
|
669
|
+
}
|
|
670
|
+
if (outcome === "mismatch") {
|
|
671
|
+
return amber(`A briefing arrived, but not the one I composed for this session — most likely a resumed session showing an earlier run's.`);
|
|
672
|
+
}
|
|
673
|
+
return amber(`I checked the next turn and could not confirm my briefing arrived. A wake nobody read is a day I started as a stranger.`);
|
|
674
|
+
},
|
|
675
|
+
|
|
676
|
+
// ── the host's session ─────────────────────────────────────────────────────
|
|
677
|
+
"adapter.boundary": (t) =>
|
|
678
|
+
calm(
|
|
679
|
+
`A session reached its boundary — ${n(t, "spans") ?? n(t, "captured") ?? 0} turns captured, the cursor moved forward.`,
|
|
680
|
+
),
|
|
681
|
+
"adapter.primacy.deliver": (t) =>
|
|
682
|
+
calm(`A hook delivered while the parallel run was on: ${s(t, "kind") ?? "a delivery"} went out.`),
|
|
683
|
+
"adapter.primacy.standdown": (t) =>
|
|
684
|
+
calm(
|
|
685
|
+
`I stood down and let the other system speak — ${s(t, "reason") ?? "the parallel run's rule"}. Withholding on purpose is not a failure.`,
|
|
686
|
+
),
|
|
687
|
+
|
|
688
|
+
// ── the authored door's ask ────────────────────────────────────────────────
|
|
689
|
+
"adapter.ask": (t) => {
|
|
690
|
+
const outcome = s(t, "outcome");
|
|
691
|
+
if (outcome === "capped") {
|
|
692
|
+
return amber(
|
|
693
|
+
`I had already asked as often as a day allows, so I did not ask again. Whatever was learned in that session, I did not write.`,
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
if (outcome === "paced") {
|
|
697
|
+
return calm(`There was not enough new substance to be worth asking for, so I let the session end quietly.`);
|
|
698
|
+
}
|
|
699
|
+
return notable(`I asked for what this session taught me — chapter ${n(t, "chapter") ?? 0}.`);
|
|
700
|
+
},
|
|
701
|
+
"adapter.authorship.ask": (t) =>
|
|
702
|
+
calm(
|
|
703
|
+
`HISTORICAL — from the fortnight the Stop carried two asks on two pacers: the authorship half fired here (${s(t, "outcome") ?? "no outcome recorded"}).`,
|
|
704
|
+
),
|
|
705
|
+
"adapter.episode.ask": (t) =>
|
|
706
|
+
calm(
|
|
707
|
+
`HISTORICAL — the episode half of the old two-ask Stop: the journal's own ask fired here (${s(t, "outcome") ?? "no outcome recorded"}).`,
|
|
708
|
+
),
|
|
709
|
+
|
|
710
|
+
// ── the store's own upkeep ─────────────────────────────────────────────────
|
|
711
|
+
"adapter.embed.backfill": (t) => {
|
|
712
|
+
const failed = n(t, "failed") ?? 0;
|
|
713
|
+
const embedded = n(t, "embedded") ?? 0;
|
|
714
|
+
const remaining = n(t, "remaining") ?? 0;
|
|
715
|
+
if (failed > 0) {
|
|
716
|
+
return amber(
|
|
717
|
+
`The worker gave vectors to ${embedded} memories and failed on ${failed}. A memory with no vector is invisible to the semantic channel.`,
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
return calm(
|
|
721
|
+
remaining === 0
|
|
722
|
+
? `The worker finished the backfill: ${embedded} memories got a vector, none left without one.`
|
|
723
|
+
: `The worker gave ${embedded} memories a vector; ${remaining} are still waiting for one.`,
|
|
724
|
+
);
|
|
725
|
+
},
|
|
726
|
+
|
|
727
|
+
// ── going looking on purpose ───────────────────────────────────────────────
|
|
728
|
+
"mcp.recall": (t) => {
|
|
729
|
+
const { total, named } = topBlocked(t);
|
|
730
|
+
const worst = named[0];
|
|
731
|
+
// The NUMBER is always said; the REASON only when it is one this package
|
|
732
|
+
// will name on a screen. A gap with no word beside it is still a gap
|
|
733
|
+
// announced, so the sentence says "a gate" rather than trailing off.
|
|
734
|
+
const stopped =
|
|
735
|
+
total === 0
|
|
736
|
+
? ""
|
|
737
|
+
: worst === undefined
|
|
738
|
+
? ` ${String(total)} more ${total === 1 ? "was" : "were"} kept out by a gate.`
|
|
739
|
+
: ` ${String(total)} more ${total === 1 ? "was" : "were"} kept out (most often ${worst[0]}).`;
|
|
740
|
+
if (s(t, "path") === "handle") {
|
|
741
|
+
const opened = n(t, "expanded") ?? 0;
|
|
742
|
+
return calm(
|
|
743
|
+
opened === 0
|
|
744
|
+
? `Something was asked for by name and I had nothing at that address.${stopped}`
|
|
745
|
+
: `${String(opened)} memor${opened === 1 ? "y was" : "ies were"} opened in full, by name.${stopped}`,
|
|
746
|
+
);
|
|
747
|
+
}
|
|
748
|
+
const surfaced = n(t, "surfaced") ?? 0;
|
|
749
|
+
const dim = n(t, "dim") ?? 0;
|
|
750
|
+
const considered = n(t, "considered") ?? 0;
|
|
751
|
+
if (surfaced + dim === 0) {
|
|
752
|
+
return calm(
|
|
753
|
+
`I went looking on purpose and nothing came back, out of ${String(considered)} considered.${stopped}`,
|
|
754
|
+
);
|
|
755
|
+
}
|
|
756
|
+
return calm(
|
|
757
|
+
`I went looking on purpose and ${String(surfaced)} came clearly to mind` +
|
|
758
|
+
(dim === 0 ? "" : `, with ${String(dim)} reached only by the effort`) +
|
|
759
|
+
`, out of ${String(considered)} considered.${stopped}`,
|
|
760
|
+
);
|
|
761
|
+
},
|
|
762
|
+
|
|
763
|
+
// ── remembering to act ─────────────────────────────────────────────────────
|
|
764
|
+
"prospective.fire": (t) => {
|
|
765
|
+
const fires = n(t, "fires") ?? 0;
|
|
766
|
+
const cap = n(t, "cap") ?? 0;
|
|
767
|
+
return notable(
|
|
768
|
+
`The time came for ${subject(t)} and I let it come to mind` +
|
|
769
|
+
(cap === 0 ? "." : ` — ${String(Math.max(0, cap - fires))} more mention${cap - fires === 1 ? "" : "s"} allowed before I leave it alone.`),
|
|
770
|
+
);
|
|
771
|
+
},
|
|
772
|
+
"prospective.fire.refused": (t) =>
|
|
773
|
+
calm(
|
|
774
|
+
`I held back a reminder about ${subject(t)} (${s(t, "reason") ?? "no reason recorded"}). Holding debts and losing deadlines is the whole of the tact rule; this is it working.`,
|
|
775
|
+
),
|
|
776
|
+
|
|
777
|
+
// ── the worker that did start ──────────────────────────────────────────────
|
|
778
|
+
//
|
|
779
|
+
// NO COUNT IN THIS SENTENCE. The row is latched one per calendar date, so it
|
|
780
|
+
// is written by the day's FIRST start and any tally on it would read `1`
|
|
781
|
+
// forever. The day's real tally is in the adapter's meta counters, which
|
|
782
|
+
// doctor's Spawn line prints; this row says the door opened.
|
|
783
|
+
"adapter.spawn.started": () =>
|
|
784
|
+
calm("The background worker started when a session reached a boundary today."),
|
|
785
|
+
|
|
786
|
+
// ── the copy that is kept beside me ────────────────────────────────────────
|
|
787
|
+
"snapshot.taken": (t) => {
|
|
788
|
+
const kept = n(t, "kept") ?? 0;
|
|
789
|
+
const oldest = s(t, "oldest");
|
|
790
|
+
return calm(
|
|
791
|
+
`A whole copy of me was set aside — ${String(n(t, "files") ?? 0)} files. ${String(kept)} copies are kept` +
|
|
792
|
+
(oldest === null ? "." : `, the oldest from ${oldest.slice(0, 10)}.`),
|
|
793
|
+
);
|
|
794
|
+
},
|
|
795
|
+
"snapshot.failed": (t) =>
|
|
796
|
+
amber(
|
|
797
|
+
`No copy of me could be made today (${s(t, "step") ?? "unknown step"}: ${s(t, "reason") ?? "no reason recorded"}). Nothing was lost, and nothing old was deleted either — the copies already kept are untouched. Run counterparts doctor; its Snapshot line says what is actually on disk and how to restore from it.`,
|
|
798
|
+
),
|
|
799
|
+
"snapshot.rotated": (t) => {
|
|
800
|
+
const deleted = n(t, "deleted") ?? 0;
|
|
801
|
+
const oldest = s(t, "oldest");
|
|
802
|
+
return calm(
|
|
803
|
+
`${String(deleted)} old cop${deleted === 1 ? "y" : "ies"} of me ${deleted === 1 ? "was" : "were"} let go; ` +
|
|
804
|
+
`${String(n(t, "kept") ?? 0)} remain` +
|
|
805
|
+
(oldest === null ? "." : `, back to ${oldest.slice(0, 10)}.`),
|
|
806
|
+
);
|
|
807
|
+
},
|
|
808
|
+
|
|
809
|
+
// ── the diary you can open in any editor ───────────────────────────────────
|
|
810
|
+
"journal.copy.written": (t) => {
|
|
811
|
+
const file = s(t, "file");
|
|
812
|
+
const chapters = n(t, "chapters");
|
|
813
|
+
return calm(
|
|
814
|
+
"My journal was written out as a file you can open in any editor" +
|
|
815
|
+
(file === null ? "." : ` — ${file}.`) +
|
|
816
|
+
(chapters === null ? "" : ` Chapter ${String(chapters)}.`),
|
|
817
|
+
);
|
|
818
|
+
},
|
|
819
|
+
"journal.copy.failed": (t) =>
|
|
820
|
+
amber(
|
|
821
|
+
`The readable copy of my journal could not be written (${s(t, "reason") ?? "no reason recorded"}). ` +
|
|
822
|
+
"The chapter itself is safe — it is a row in the database, and that is the copy everything reads. " +
|
|
823
|
+
"Run counterparts doctor; its Journal copy line says what is standing.",
|
|
824
|
+
),
|
|
825
|
+
"store.export": (t) => {
|
|
826
|
+
const omitted = n(t, "omittedConfidential") ?? 0;
|
|
827
|
+
return notable(
|
|
828
|
+
`You took a copy of me out of here — ${s(t, "kind") ?? "an export"}, ` +
|
|
829
|
+
`${String(n(t, "rows") ?? 0)} memories, ` +
|
|
830
|
+
(t.p["encrypted"] === true ? "encrypted." : "NOT encrypted.") +
|
|
831
|
+
(omitted === 0
|
|
832
|
+
? ""
|
|
833
|
+
: ` ${String(omitted)} confidential ${omitted === 1 ? "one was" : "ones were"} left out.`),
|
|
834
|
+
);
|
|
835
|
+
},
|
|
836
|
+
|
|
837
|
+
// ── being argued with ──────────────────────────────────────────────────────
|
|
838
|
+
"revision.pressure": (t) => {
|
|
839
|
+
const force = n(t, "force") ?? 0;
|
|
840
|
+
const after = n(t, "pressureAfter") ?? 0;
|
|
841
|
+
const bar = n(t, "bar") ?? 0;
|
|
842
|
+
const challenger = subject(t, s(t, "challengerId"));
|
|
843
|
+
// The TARGET is resolved UNFOLLOWED. Following the supersede chain would
|
|
844
|
+
// print what the belief became — and since what it became was minted from
|
|
845
|
+
// this very challenge, the line would read "X broke the bar against X".
|
|
846
|
+
// What the owner needs is the belief AS IT STOOD when it was argued with,
|
|
847
|
+
// read live at its own address (the retained prose §5 G10 keeps for exactly
|
|
848
|
+
// this), which is the same choice `stories.ts` makes for "it began as".
|
|
849
|
+
const target = subjectHere(t);
|
|
850
|
+
const crossed = after >= bar && bar > 0;
|
|
851
|
+
return crossed
|
|
852
|
+
? notable(
|
|
853
|
+
`${challenger} broke the bar against ${target} — pressure ${num(after)} against ${num(bar)}. I changed my mind.`,
|
|
854
|
+
)
|
|
855
|
+
: calm(
|
|
856
|
+
`${challenger} argued with ${target} — force ${num(force)}, pressure now ${num(after)} of the ${num(bar)} it would take. I am holding for now.`,
|
|
857
|
+
);
|
|
858
|
+
},
|
|
859
|
+
} as const satisfies Record<DurableEventName, Teller>;
|
|
860
|
+
|
|
861
|
+
export const NARRATED_NAMES: readonly string[] = Object.keys(NARRATORS);
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* WHAT KIND OF THING EACH EVENT'S `ref` COLUMN HOLDS.
|
|
865
|
+
*
|
|
866
|
+
* The log's `ref` is not always a memory id, and putting one that is not through
|
|
867
|
+
* the memory resolver prints `[no longer at this address]` beside a turn that
|
|
868
|
+
* went perfectly well — a FALSE absence, which is worse than no line at all in a
|
|
869
|
+
* project whose whole absence discipline is about telling "never happened" from
|
|
870
|
+
* "gone". Four names carry something else: a surfacing decision is keyed by the
|
|
871
|
+
* SESSION it happened in, a chunk gate by the CHUNK's content key, an authored
|
|
872
|
+
* gate by the redacted DRAFT's content hash, and the sweep gate by nothing at
|
|
873
|
+
* all.
|
|
874
|
+
*
|
|
875
|
+
* EXHAUSTIVE BY TYPE, like every other registry here: a durable event added to
|
|
876
|
+
* the core fails `tsc` until someone has said what its `ref` is, rather than
|
|
877
|
+
* defaulting silently to "a memory" and rendering a lie.
|
|
878
|
+
*/
|
|
879
|
+
export const REF_KIND = {
|
|
880
|
+
"adapter.ask": "none",
|
|
881
|
+
"adapter.authorship.ask": "none",
|
|
882
|
+
"adapter.boundary": "none",
|
|
883
|
+
"adapter.embed.backfill": "none",
|
|
884
|
+
"adapter.episode.ask": "none",
|
|
885
|
+
"adapter.primacy.deliver": "none",
|
|
886
|
+
"adapter.primacy.standdown": "none",
|
|
887
|
+
"adapter.recall": "none",
|
|
888
|
+
"adapter.runner.failed": "none",
|
|
889
|
+
"adapter.semantic.lag": "none",
|
|
890
|
+
"adapter.spawn.failed": "none",
|
|
891
|
+
"adapter.spawn.refused": "none",
|
|
892
|
+
"adapter.spawn.started": "none",
|
|
893
|
+
// The deliberate look carries counts and verdicts and deliberately no ids —
|
|
894
|
+
// a durable pairing of memories with the moment somebody asked for them.
|
|
895
|
+
"mcp.recall": "none",
|
|
896
|
+
// Both prospective rows point at the MEMORY whose window it is: the window
|
|
897
|
+
// key is a derived address on that row, not an entity of its own.
|
|
898
|
+
"prospective.fire": "memory",
|
|
899
|
+
"prospective.fire.refused": "memory",
|
|
900
|
+
"adapter.checkout": "none",
|
|
901
|
+
"adapter.wake.delivered": "none",
|
|
902
|
+
"adapter.wake.injected": "none",
|
|
903
|
+
"band.promoted": "memory",
|
|
904
|
+
"band.transition": "memory",
|
|
905
|
+
"gate.chunk": "chunk",
|
|
906
|
+
// A content address for the REDACTED draft, not a memory id: a refused
|
|
907
|
+
// deposit has no memory to point at, and resolving this through the memory
|
|
908
|
+
// resolver would print `[no longer at this address]` beside a gate that
|
|
909
|
+
// worked perfectly. The minted id, when there is one, is in the payload.
|
|
910
|
+
"gate.deposit": "proposal",
|
|
911
|
+
"memory.merged": "memory",
|
|
912
|
+
"memory.unmerged": "memory",
|
|
913
|
+
"memory.pruned": "memory",
|
|
914
|
+
"recall.decision": "session",
|
|
915
|
+
"revision.pressure": "memory",
|
|
916
|
+
"sweep.gate": "none",
|
|
917
|
+
// A snapshot is about the WHOLE store, so there is no one memory to point at.
|
|
918
|
+
// The copy's own name is in the payload.
|
|
919
|
+
"snapshot.taken": "none",
|
|
920
|
+
"snapshot.failed": "none",
|
|
921
|
+
"snapshot.rotated": "none",
|
|
922
|
+
// The journal copy points at the EPISODE whose words it holds, which is what
|
|
923
|
+
// makes a removal's sync of that file legible in the feed.
|
|
924
|
+
"journal.copy.written": "memory",
|
|
925
|
+
"journal.copy.failed": "memory",
|
|
926
|
+
// An export is about the whole store; its counts are in the payload, and its
|
|
927
|
+
// target deliberately is not (§5 G10).
|
|
928
|
+
"store.export": "none",
|
|
929
|
+
// The sweep's wake row describes the RUN's prompt, and carries no id at all —
|
|
930
|
+
// counts, a flag and a reason, and deliberately not one line of the self.
|
|
931
|
+
"sweep.wake": "none",
|
|
932
|
+
// Neither U9 row points at a memory: one describes a RUN, the other the wake
|
|
933
|
+
// BUNDLE. The ids they do carry (the trimmed elements) ride in the payload.
|
|
934
|
+
"sleep.cycle": "none",
|
|
935
|
+
"self.briefing": "none",
|
|
936
|
+
// The revision points at the PAGE's own row, which is a real id in the store
|
|
937
|
+
// and resolves like any other; a refusal wrote nothing, so it points at
|
|
938
|
+
// nothing rather than at the page it did not change.
|
|
939
|
+
"self.page.revised": "memory",
|
|
940
|
+
"self.page.refused": "none",
|
|
941
|
+
// The writer's row is about a DAY, not a memory: the ids it read are the
|
|
942
|
+
// day's, and naming one of them would be picking a favourite.
|
|
943
|
+
"self.page.writer.ran": "none",
|
|
944
|
+
// A written, shown or cleared handoff points at its own row, which resolves
|
|
945
|
+
// like any other. A refusal usually wrote nothing and points at nothing —
|
|
946
|
+
// `no-room` is the exception and does carry the row's id, which prints as the
|
|
947
|
+
// raw address under `"none"`, and a raw id beside "there was no room for it"
|
|
948
|
+
// reads correctly.
|
|
949
|
+
// ITS OWN KIND, and not "memory" (adversarial review NIT 5). The ref is a
|
|
950
|
+
// real row id and resolves, but resolving it through the MEMORY door is the
|
|
951
|
+
// one surface where a reader of a feature whose thesis is "never a memory"
|
|
952
|
+
// could see it called one.
|
|
953
|
+
"handoff.written": "handoff",
|
|
954
|
+
"handoff.shown": "handoff",
|
|
955
|
+
"handoff.cleared": "handoff",
|
|
956
|
+
"handoff.refused": "none",
|
|
957
|
+
"recall.credit": "none",
|
|
958
|
+
// A flush describes a SET of pairs, not one memory. The ids stay in the edge
|
|
959
|
+
// rows, where they are the record; the row carries counts.
|
|
960
|
+
"associate.flush": "none",
|
|
961
|
+
} as const satisfies Record<
|
|
962
|
+
DurableEventName,
|
|
963
|
+
"memory" | "session" | "chunk" | "proposal" | "handoff" | "none"
|
|
964
|
+
>;
|
|
965
|
+
|
|
966
|
+
function subjectOf(store: Store, row: EventRow): string | null {
|
|
967
|
+
if (row.ref === null) return null;
|
|
968
|
+
switch ((REF_KIND as Record<string, string>)[row.name]) {
|
|
969
|
+
case "session":
|
|
970
|
+
return `session ${row.ref}`;
|
|
971
|
+
case "chunk":
|
|
972
|
+
return `swept chunk ${row.ref}`;
|
|
973
|
+
case "proposal":
|
|
974
|
+
return `authored draft ${row.ref}`;
|
|
975
|
+
case "handoff":
|
|
976
|
+
// A real row that resolves like any other — named for what it is, so the
|
|
977
|
+
// one feature whose thesis is "never a memory" is not printed as one.
|
|
978
|
+
return `handoff ${row.ref}`;
|
|
979
|
+
case "none":
|
|
980
|
+
// A name this file has never heard of, carrying a ref. Print the raw
|
|
981
|
+
// address rather than guessing at what it points to.
|
|
982
|
+
return row.ref;
|
|
983
|
+
default:
|
|
984
|
+
return reveal(store, row.ref, 60).label;
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
export interface NarratedEvent {
|
|
989
|
+
readonly seq: number;
|
|
990
|
+
readonly at: number;
|
|
991
|
+
readonly day: number;
|
|
992
|
+
readonly name: string;
|
|
993
|
+
readonly text: string;
|
|
994
|
+
readonly tone: Tone;
|
|
995
|
+
readonly node: NodeKey | null;
|
|
996
|
+
/** The stored ref, resolved now — or null when the row named nothing. */
|
|
997
|
+
readonly subject: string | null;
|
|
998
|
+
/** The payload, every id in it resolved. Ids and counts only, never text. */
|
|
999
|
+
readonly detail: { key: string; value: string }[];
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
function parse(payload: string | null): Record<string, unknown> {
|
|
1003
|
+
if (payload === null) return {};
|
|
1004
|
+
try {
|
|
1005
|
+
const v: unknown = JSON.parse(payload);
|
|
1006
|
+
return v !== null && typeof v === "object" && !Array.isArray(v)
|
|
1007
|
+
? (v as Record<string, unknown>)
|
|
1008
|
+
: {};
|
|
1009
|
+
} catch {
|
|
1010
|
+
return {};
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* One row, narrated. A name with no teller cannot happen (the `satisfies`
|
|
1016
|
+
* above), but the fallback is a sentence rather than a throw: an instrument that
|
|
1017
|
+
* crashes on an unfamiliar row is the one moment the owner most needs it to
|
|
1018
|
+
* render (scar E7).
|
|
1019
|
+
*/
|
|
1020
|
+
export function narrate(store: Store, row: EventRow): NarratedEvent {
|
|
1021
|
+
const p = parse(row.payload);
|
|
1022
|
+
const told: Told = { store, row, p };
|
|
1023
|
+
const teller = (NARRATORS as Record<string, Teller | undefined>)[row.name];
|
|
1024
|
+
let line: Narration;
|
|
1025
|
+
try {
|
|
1026
|
+
line = teller === undefined ? calm(`${row.name} — I have no sentence for this yet.`) : teller(told);
|
|
1027
|
+
} catch {
|
|
1028
|
+
line = calm(`${row.name} — recorded, but I could not read it back.`);
|
|
1029
|
+
}
|
|
1030
|
+
return {
|
|
1031
|
+
seq: row.seq,
|
|
1032
|
+
at: row.at,
|
|
1033
|
+
day: row.day,
|
|
1034
|
+
name: row.name,
|
|
1035
|
+
text: line.text,
|
|
1036
|
+
tone: line.tone,
|
|
1037
|
+
node: nodeOf(row.name),
|
|
1038
|
+
// Resolved BY EVENT NAME — see `REF_KIND`.
|
|
1039
|
+
subject: subjectOf(store, row),
|
|
1040
|
+
detail: revealPayload(store, p, 40),
|
|
1041
|
+
};
|
|
1042
|
+
}
|