counterparts 0.3.7 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +142 -0
- package/docs/module-map.md +4 -1
- package/package.json +1 -1
- package/src/adapters/claude-code/CONTRACT.md +73 -52
- package/src/adapters/claude-code/INTERFACE-GAPS.md +8 -3
- package/src/adapters/claude-code/NOTES.md +119 -0
- package/src/adapters/claude-code/bin/hook.ts +95 -33
- package/src/adapters/claude-code/bin/nightly.ts +21 -2
- package/src/adapters/claude-code/bin/runner.ts +55 -44
- package/src/adapters/claude-code/child.ts +203 -0
- package/src/adapters/claude-code/config.ts +66 -69
- package/src/adapters/claude-code/doctor.ts +249 -68
- package/src/adapters/claude-code/envelope.ts +38 -0
- package/src/adapters/claude-code/hooks.ts +206 -42
- package/src/adapters/claude-code/index.ts +7 -20
- package/src/adapters/claude-code/night-run.ts +19 -8
- package/src/adapters/cli/CONTRACT.md +9 -0
- package/src/adapters/cli/commands.ts +282 -4
- package/src/adapters/cli/coverage.ts +100 -0
- package/src/adapters/cli/dream-core.ts +11 -0
- package/src/adapters/cli/help.ts +6 -0
- package/src/adapters/cli/mechanisms.ts +23 -6
- package/src/adapters/cli/self-page.ts +4 -4
- package/src/adapters/cli/settle.ts +63 -0
- package/src/adapters/dashboard/registries.ts +29 -1
- package/src/adapters/dashboard/web/README.md +41 -11
- package/src/adapters/dashboard/web/flow.ts +12 -0
- package/src/adapters/dashboard/web/lanes.ts +11 -0
- package/src/adapters/dashboard/web/mechanisms/dreaming/panel.js +2 -1
- package/src/adapters/dashboard/web/mechanisms/emotional/panel.js +2 -2
- package/src/adapters/dashboard/web/mechanisms/episodic-semantic/panel.js +2 -1
- package/src/adapters/dashboard/web/mechanisms/index.js +2 -0
- package/src/adapters/dashboard/web/mechanisms/interference/index.js +8 -4
- package/src/adapters/dashboard/web/mechanisms/interference/panel.js +13 -0
- package/src/adapters/dashboard/web/mechanisms/prospective/panel.js +2 -1
- package/src/adapters/dashboard/web/narrate.ts +62 -4
- package/src/adapters/dashboard/web/pages/health/sections/cycle.js +2 -4
- package/src/adapters/dashboard/web/pages/memories/index.js +6 -1
- package/src/adapters/dashboard/web/pages/memories/memories.css +43 -26
- package/src/adapters/dashboard/web/pages/memories/row.js +52 -15
- package/src/adapters/dashboard/web/pages/memories/sections/hold.js +112 -24
- package/src/adapters/dashboard/web/pages/memories/sections/list.js +3 -3
- package/src/adapters/dashboard/web/pages/memories/sections/search.js +75 -15
- package/src/adapters/dashboard/web/pages/memories/state.js +3 -2
- package/src/adapters/dashboard/web/pages/self/sections/dreams.js +2 -2
- package/src/adapters/dashboard/web/pages/self/sections/journal.js +7 -11
- package/src/adapters/dashboard/web/pages/self/sections/page.js +47 -17
- package/src/adapters/dashboard/web/pages/self/sections/wake.js +16 -5
- package/src/adapters/dashboard/web/shared/dates.js +55 -0
- package/src/adapters/dashboard/web/shared/memory-marks.css +1 -0
- package/src/adapters/dashboard/web/shared/memory-marks.js +23 -12
- package/src/adapters/dashboard/web/shared/memory-modal.js +15 -11
- package/src/adapters/dashboard/web/shared/widgets/feel-radar.js +8 -5
- package/src/adapters/dashboard/web/views/mechanism-panel.ts +39 -0
- package/src/adapters/dashboard/web/views/mechanisms.ts +9 -1
- package/src/adapters/dashboard/web/views/mind.ts +57 -17
- package/src/adapters/dashboard/web/views/search.ts +170 -58
- package/src/adapters/fired.ts +28 -0
- package/src/adapters/log/CONTRACT.md +70 -0
- package/src/adapters/log/INTERFACE-GAPS.md +15 -0
- package/src/adapters/log/NOTES.md +49 -0
- package/src/adapters/log/index.ts +420 -0
- package/src/adapters/mcp/CONTRACT.md +11 -0
- package/src/adapters/mcp/INTERFACE-GAPS.md +8 -0
- package/src/adapters/mcp/NOTES.md +34 -0
- package/src/adapters/mcp/bin/serve.ts +23 -1
- package/src/adapters/mcp/deliberate.ts +39 -2
- package/src/adapters/mcp/index.ts +5 -2
- package/src/adapters/mcp/server.ts +181 -43
- package/src/adapters/mcp/tools.ts +78 -11
- package/src/adapters/mcp/write-up.ts +5 -9
- package/src/adapters/mechanism-evidence.ts +28 -9
- package/src/adapters/sessions.ts +158 -172
- package/src/core/contradictions.ts +607 -0
- package/src/core/counterpart.ts +273 -26
- package/src/core/coverage/CONTRACT.md +77 -0
- package/src/core/coverage/INTERFACE-GAPS.md +46 -0
- package/src/core/coverage/NOTES.md +100 -0
- package/src/core/coverage/index.ts +660 -0
- package/src/core/coverage/tunables.ts +29 -0
- package/src/core/dream/CONTRACT.md +14 -8
- package/src/core/dream/INTERFACE-GAPS.md +6 -0
- package/src/core/dream/NOTES.md +27 -0
- package/src/core/dream/index.ts +90 -29
- package/src/core/dream/mind.ts +14 -13
- package/src/core/dream/reflect.ts +29 -0
- package/src/core/dream/tunables.ts +3 -0
- package/src/core/handoff/CONTRACT.md +8 -2
- package/src/core/handoff/NOTES.md +2 -0
- package/src/core/handoff/index.ts +100 -14
- package/src/core/physics/CONTRACT.md +23 -1
- package/src/core/physics/NOTES.md +10 -0
- package/src/core/physics/index.ts +78 -1
- package/src/core/prospective/CONTRACT.md +4 -1
- package/src/core/prospective/NOTES.md +16 -1
- package/src/core/prospective/index.ts +21 -2
- package/src/core/recall/CONTRACT.md +10 -0
- package/src/core/recall/INTERFACE-GAPS.md +7 -0
- package/src/core/recall/NOTES.md +11 -0
- package/src/core/recall/index.ts +20 -1
- package/src/core/recall/render.ts +15 -3
- package/src/core/recall/standing.ts +124 -0
- package/src/core/remember/CONTRACT.md +8 -8
- package/src/core/remember/NOTES.md +41 -0
- package/src/core/remember/index.ts +2 -5
- package/src/core/remember/owes.ts +80 -217
- package/src/core/remember/proposals.ts +31 -2
- package/src/core/revision.ts +60 -3
- package/src/core/schemas/CONTRACT.md +6 -3
- package/src/core/schemas/NOTES.md +15 -0
- package/src/core/self/CONTRACT.md +28 -13
- package/src/core/self/NOTES.md +86 -0
- package/src/core/self/behind.ts +89 -0
- package/src/core/self/briefing.ts +136 -5
- package/src/core/self/episodes.ts +43 -48
- package/src/core/self/identity.ts +42 -6
- package/src/core/self/index.ts +20 -2
- package/src/core/self/writer.ts +26 -26
- package/src/core/store/CONTRACT.md +12 -0
- package/src/core/store/NOTES.md +52 -0
- package/src/core/store/errors.ts +6 -0
- package/src/core/store/index.ts +339 -0
- package/src/core/store/operational.ts +248 -3
- package/src/core/store/owner-op-seam.ts +65 -1
- package/src/core/time.ts +60 -3
- package/src/core/types.ts +25 -0
- package/src/adapters/claude-code/page-writer.ts +0 -516
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ONE WINDOWLESS HOST CHILD — started, watched, and ended.
|
|
3
|
+
*
|
|
4
|
+
* The headless nightly run (`night-run.ts`) starts `claude -p` as a child of a
|
|
5
|
+
* detached process and waits for it under a watchdog. This file is the part of
|
|
6
|
+
* that which is about the CHILD rather than about the night: the host command,
|
|
7
|
+
* the permission mode, the plan shape a starter needs, and the starter itself.
|
|
8
|
+
*
|
|
9
|
+
* It lived in `page-writer.ts` until 2026-09-29, when the page writer's host
|
|
10
|
+
* mode — the first thing in this package to start a windowless session — was
|
|
11
|
+
* removed (the nightly run carries the page writer now). What the nightly run
|
|
12
|
+
* shared with it moved here unchanged: the plan is pure and decides
|
|
13
|
+
* everything, the starter is small enough to read, the prompt rides on STDIN
|
|
14
|
+
* and never in `argv`, and the child's environment is the caller's to scrub
|
|
15
|
+
* (`night-run.ts#planNightChild`).
|
|
16
|
+
*/
|
|
17
|
+
import { spawn } from "node:child_process";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The host CLI a windowless child runs — always this one, resolved on the
|
|
21
|
+
* child's PATH. It was once overridable by `pageWriter.command` in the
|
|
22
|
+
* configuration; that key was removed on 2026-09-24 ("runs a command named by
|
|
23
|
+
* config" was a supply-chain scanner's finding). A configuration that still
|
|
24
|
+
* carries it is read with the key ignored and named (`config.ts#loadConfig`).
|
|
25
|
+
*/
|
|
26
|
+
export const DEFAULT_HOST_COMMAND = "claude";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The permission mode a windowless child runs under: `default`, beside an
|
|
30
|
+
* explicit allow-list. In a session with no window a prompt nobody can answer
|
|
31
|
+
* is a refusal, which is the direction this should fail in.
|
|
32
|
+
*/
|
|
33
|
+
export const PERMISSION_MODE = "default";
|
|
34
|
+
|
|
35
|
+
/** What one child did, as the OS reported it. Injected so a test can prove the
|
|
36
|
+
* whole path without starting a process. */
|
|
37
|
+
export interface ChildResult {
|
|
38
|
+
readonly code: number | null;
|
|
39
|
+
readonly timedOut: boolean;
|
|
40
|
+
readonly error: string | null;
|
|
41
|
+
/** The OS's code when the child could not be started at all (`ENOENT` for a
|
|
42
|
+
* command that is not there). Absent otherwise. */
|
|
43
|
+
readonly spawnCode?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** WHAT `startChild` NEEDS OF A PLAN. */
|
|
47
|
+
export interface ChildPlan {
|
|
48
|
+
readonly command: string;
|
|
49
|
+
readonly args: readonly string[];
|
|
50
|
+
/** What goes on the child's STDIN — the instruction. It is not in `argv`
|
|
51
|
+
* because a command line is readable by every process on the machine. */
|
|
52
|
+
readonly stdin: string;
|
|
53
|
+
/** The child's complete environment. The caller's own values are written LAST. */
|
|
54
|
+
readonly env: Readonly<Record<string, string>>;
|
|
55
|
+
readonly timeoutMs: number;
|
|
56
|
+
/** The child's working directory; absent, this process's. */
|
|
57
|
+
readonly cwd?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* HOW LONG A CHILD GETS TO DIE POLITELY before it is killed, and how long after
|
|
62
|
+
* that before this stops waiting for the OS to confirm it.
|
|
63
|
+
*
|
|
64
|
+
* Both exist because of one hole (S2 review, MAJOR-3): the first version
|
|
65
|
+
* resolved only on `close` or `error`, and both alarms — `spawn`'s own timeout
|
|
66
|
+
* and the caller's abort — send SIGTERM and nothing else. A child that ignores
|
|
67
|
+
* SIGTERM (a trapping shell wrapper, an uninterruptible wait, a CLI with its
|
|
68
|
+
* own handler) therefore kept the promise pending, which kept the waiting
|
|
69
|
+
* process HOLDING THE STORE OPEN for as long as the child lived. It was
|
|
70
|
+
* reproduced: `trap '' TERM; sleep 60` with a 3-second child watchdog and a
|
|
71
|
+
* 1.2-second abort still had the waiter alive at 25 seconds.
|
|
72
|
+
*/
|
|
73
|
+
export const KILL_GRACE_MS = 5_000;
|
|
74
|
+
export const REAP_GRACE_MS = 2_000;
|
|
75
|
+
|
|
76
|
+
/** The real starter: one child, two alarms, and an end that does not need it. */
|
|
77
|
+
export async function startChild(plan: ChildPlan, abort?: AbortSignal): Promise<ChildResult> {
|
|
78
|
+
return await new Promise<ChildResult>((resolve) => {
|
|
79
|
+
let settled = false;
|
|
80
|
+
let terminated = false;
|
|
81
|
+
const timers: ReturnType<typeof setTimeout>[] = [];
|
|
82
|
+
let off: (() => void) | null = null;
|
|
83
|
+
const done = (r: ChildResult): void => {
|
|
84
|
+
if (settled) return;
|
|
85
|
+
settled = true;
|
|
86
|
+
for (const t of timers) clearTimeout(t);
|
|
87
|
+
off?.();
|
|
88
|
+
resolve(r);
|
|
89
|
+
};
|
|
90
|
+
let child: ReturnType<typeof spawn>;
|
|
91
|
+
try {
|
|
92
|
+
child = spawn(plan.command, [...plan.args], {
|
|
93
|
+
// DETACHED ONLY SO THERE IS A PROCESS GROUP TO KILL. The caller still
|
|
94
|
+
// awaits this child — `unref` is deliberately not called — so a child
|
|
95
|
+
// whose outcome nobody can record is still impossible. What `detached`
|
|
96
|
+
// buys is that a host CLI which spawned helpers of its own cannot
|
|
97
|
+
// survive in them after the watchdog fires.
|
|
98
|
+
detached: true,
|
|
99
|
+
// THE PROMPT GOES ON STDIN, not in `argv`: what a child is handed in a
|
|
100
|
+
// command line is readable by every process on the machine through
|
|
101
|
+
// `ps` (S2 review, NIT-2). `claude -p` with no positional prompt reads
|
|
102
|
+
// stdin.
|
|
103
|
+
stdio: ["pipe", "ignore", "ignore"],
|
|
104
|
+
env: { ...plan.env },
|
|
105
|
+
...(plan.cwd === undefined ? {} : { cwd: plan.cwd }),
|
|
106
|
+
});
|
|
107
|
+
} catch (err) {
|
|
108
|
+
// A runtime that refuses synchronously rather than by `error` (a command
|
|
109
|
+
// that is not there, on some runtimes): the same answer, now.
|
|
110
|
+
done({ code: null, timedOut: false, error: err instanceof Error ? err.name : "UNKNOWN", ...spawnCodeOf(err) });
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
child.stdin?.end(plan.stdin);
|
|
115
|
+
} catch {
|
|
116
|
+
/* a child that died before its stdin opened is handled by `error` below */
|
|
117
|
+
}
|
|
118
|
+
/** SIGTERM, then SIGKILL, then stop waiting. Each step arms the next. */
|
|
119
|
+
const terminate = (): void => {
|
|
120
|
+
if (terminated) return;
|
|
121
|
+
terminated = true;
|
|
122
|
+
signal(child, "SIGTERM");
|
|
123
|
+
timers.push(
|
|
124
|
+
arm(() => {
|
|
125
|
+
// The polite ask was ignored. SIGKILL cannot be trapped; the process
|
|
126
|
+
// GROUP goes with it, because a `claude` that spawned its own
|
|
127
|
+
// children would otherwise leave them holding the terminal.
|
|
128
|
+
signal(child, "SIGKILL");
|
|
129
|
+
// ...and if even that does not produce a `close` — a child wedged in
|
|
130
|
+
// an uninterruptible wait is the case — this stops waiting anyway.
|
|
131
|
+
// The caller gets its answer and exits; the row says
|
|
132
|
+
// `failed(unkillable)` rather than nothing at all.
|
|
133
|
+
timers.push(
|
|
134
|
+
arm(() => {
|
|
135
|
+
done({ code: null, timedOut: true, error: "unkillable" });
|
|
136
|
+
}, REAP_GRACE_MS),
|
|
137
|
+
);
|
|
138
|
+
}, KILL_GRACE_MS),
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
// THE CHILD'S OWN WATCHDOG, armed here rather than left to `spawn`'s
|
|
142
|
+
// `timeout` option, which only signals and never resolves anything.
|
|
143
|
+
if (Number.isFinite(plan.timeoutMs) && plan.timeoutMs > 0) {
|
|
144
|
+
timers.push(arm(terminate, plan.timeoutMs));
|
|
145
|
+
}
|
|
146
|
+
// THE CALLER'S WATCHDOG, which may be shorter than the child's. Fired, it
|
|
147
|
+
// takes the child with it rather than leaving the caller holding the store
|
|
148
|
+
// open past the life its own contract states.
|
|
149
|
+
if (abort !== undefined) {
|
|
150
|
+
const onAbort = (): void => {
|
|
151
|
+
terminate();
|
|
152
|
+
};
|
|
153
|
+
if (abort.aborted) onAbort();
|
|
154
|
+
else {
|
|
155
|
+
abort.addEventListener("abort", onAbort, { once: true });
|
|
156
|
+
off = (): void => {
|
|
157
|
+
abort.removeEventListener("abort", onAbort);
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
child.on("error", (err) => {
|
|
162
|
+
done({ code: null, timedOut: false, error: err.name, ...spawnCodeOf(err) });
|
|
163
|
+
});
|
|
164
|
+
child.on("close", (exit, sig) => {
|
|
165
|
+
done({
|
|
166
|
+
code: exit,
|
|
167
|
+
timedOut: terminated || sig === "SIGTERM" || sig === "SIGKILL",
|
|
168
|
+
error: terminated ? "killed" : null,
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** The OS error code on a failed start (`ENOENT`, `EACCES`), as a field or nothing. */
|
|
175
|
+
function spawnCodeOf(err: unknown): { spawnCode?: string } {
|
|
176
|
+
const c = err !== null && typeof err === "object" ? (err as { code?: unknown }).code : undefined;
|
|
177
|
+
return typeof c === "string" && c.length > 0 ? { spawnCode: c } : {};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** A timer that never keeps the process alive on its own. */
|
|
181
|
+
function arm(fn: () => void, ms: number): ReturnType<typeof setTimeout> {
|
|
182
|
+
const t = setTimeout(fn, ms);
|
|
183
|
+
t.unref?.();
|
|
184
|
+
return t;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Signal the child's whole process GROUP where the platform has one, falling
|
|
189
|
+
* back to the child alone. A host CLI that spawned helpers of its own would
|
|
190
|
+
* otherwise survive in them.
|
|
191
|
+
*/
|
|
192
|
+
function signal(child: { pid?: number | undefined; kill: (s: NodeJS.Signals) => boolean }, sig: NodeJS.Signals): void {
|
|
193
|
+
try {
|
|
194
|
+
if (child.pid !== undefined) process.kill(-child.pid, sig);
|
|
195
|
+
} catch {
|
|
196
|
+
/* no group, or already gone — fall through to the child itself */
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
child.kill(sig);
|
|
200
|
+
} catch {
|
|
201
|
+
/* already gone */
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -56,14 +56,6 @@ export const TUNABLES = {
|
|
|
56
56
|
/** Detached-worker watchdog, ms. Validated against `remember/`'s staleness
|
|
57
57
|
* window by `validateWatchdog` before any spawn (scars E4/E5). */
|
|
58
58
|
WATCHDOG_MS: 5 * 60_000,
|
|
59
|
-
/** The nightly page writer's own watchdog in `host` mode, ms. Longer than the
|
|
60
|
-
* worker's because the child is a whole host session — it loads MCP servers,
|
|
61
|
-
* runs SessionStart hooks and then makes a model call — and shorter than any
|
|
62
|
-
* person would wait, because a writer still running at the next boundary is a
|
|
63
|
-
* writer that failed. It bounds a process this package STARTED; unlike the
|
|
64
|
-
* worker's it is not validated against `remember/`'s claim staleness, because
|
|
65
|
-
* it claims no spans. */
|
|
66
|
-
PAGE_WRITER_MS: 10 * 60_000,
|
|
67
59
|
/**
|
|
68
60
|
* THE HEADLESS NIGHTLY RUN'S WATCHDOG (2026-09-29), ms: `claude -p` running
|
|
69
61
|
* the page writer, the dream and the reflection in one windowless session.
|
|
@@ -107,19 +99,32 @@ export const TUNABLES = {
|
|
|
107
99
|
*/
|
|
108
100
|
PLAIN_WHAT_MAX_CHARS: 120,
|
|
109
101
|
/**
|
|
110
|
-
*
|
|
111
|
-
* words: "Hook output
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
102
|
+
* ONE BUDGET PER HOOK ENVELOPE (2026-09-29, audit item 9): the host's cap on
|
|
103
|
+
* a hook's whole output, in characters. The host's own words: "Hook output
|
|
104
|
+
* strings, including `additionalContext`, `systemMessage`, and plain stdout,
|
|
105
|
+
* are capped at 10,000 characters. Output that exceeds this limit is saved to
|
|
106
|
+
* a file and replaced with a preview and file path." Past it, what the
|
|
107
|
+
* session would read is a preview — of the WAKE, or of the turn's recall.
|
|
108
|
+
*
|
|
109
|
+
* Everything one SessionStart or one UserPromptSubmit prints is measured
|
|
110
|
+
* against this one number, in a stated order of what gives way first
|
|
111
|
+
* (`hooks.ts#sessionStart`, `hooks.ts#userPromptSubmit`; adapter NOTES
|
|
112
|
+
* 2026-09-29). Measured in BYTES (bytes ≥ characters), the safe direction.
|
|
113
|
+
* With no owner notice the hook prints PLAIN text, so there is no JSON
|
|
114
|
+
* escaping to leave room for (PR #192 review, MAJOR 1); with one, the JSON
|
|
115
|
+
* envelope is held to `ENVELOPE_CHARS` below. It is also why the write-up's
|
|
116
|
+
* words travel through the MCP door.
|
|
117
|
+
*/
|
|
118
|
+
HOST_OUTPUT_CHARS: 10_000,
|
|
119
|
+
/**
|
|
120
|
+
* The same budget for the JSON form (`bin/hook.ts#ENVELOPE_MAX_CHARS`): 500
|
|
121
|
+
* characters under the host's cap, for the escaping (a newline is two
|
|
122
|
+
* characters in JSON). Over it the notices are dropped and the plain form
|
|
123
|
+
* printed — never the wake. At a prompt that carries a person-facing line (a
|
|
124
|
+
* plain reminder, the dream offer), the turn's recall is sized to this, so
|
|
125
|
+
* the line is not what gives way.
|
|
121
126
|
*/
|
|
122
|
-
|
|
127
|
+
ENVELOPE_CHARS: 9_500,
|
|
123
128
|
// The Stop ask's pacing is NOT here: two pacers on one blocked moment drew
|
|
124
129
|
// about a dozen asks in 13 owner turns (2026-09-04). The one pacer lives in
|
|
125
130
|
// `self/tunables.ts` (FIRST_ASK_* / REASK_*).
|
|
@@ -212,32 +217,24 @@ export interface AdapterConfig {
|
|
|
212
217
|
/**
|
|
213
218
|
* THE NIGHTLY PAGE WRITER (2026-09-20, S2), and it defaults to `session`.
|
|
214
219
|
*
|
|
215
|
-
* `session` — the
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
220
|
+
* `session` — the page writer runs as the first part of the nightly run
|
|
221
|
+
* (the dream tool's `writer` phase, since 2026-09-28). `off` — nothing runs
|
|
222
|
+
* and nothing is written. (`host` — a windowless `claude -p` the boundary's
|
|
223
|
+
* worker started for the writer alone — was removed on 2026-09-29: the
|
|
224
|
+
* nightly run does that job now. A configuration that still names it loads;
|
|
225
|
+
* the value is ignored and named among the old settings, as is
|
|
226
|
+
* `pageWriter.timeoutMs`, which only that mode read.)
|
|
221
227
|
*
|
|
222
|
-
* **Absent means `session`, not off
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
* the product. The cost of the default being wrong is one extra block beside
|
|
226
|
-
* the wake, at most twice a day, deferred rather than truncated when the
|
|
227
|
-
* ceiling has no room for it — and `"mode": "off"` is one line.
|
|
228
|
+
* **Absent means `session`, not off**: S2 is how a new user's page forms at
|
|
229
|
+
* all (plan §3), and a mechanism that only works for people who found a
|
|
230
|
+
* configuration key is not the product. `"mode": "off"` is one line.
|
|
228
231
|
*
|
|
229
|
-
* **Read LENIENTLY
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
* allowlist, so a typo cannot resolve to `host` under a lenient reading
|
|
233
|
-
* either. Strictness bought nothing and cost the owner his memory for one
|
|
234
|
-
* misspelling in an optional block. The fallback is PINNED to `session`, each
|
|
235
|
-
* bad field names itself in `ignored`, and doctor's Page writer line says so.
|
|
232
|
+
* **Read LENIENTLY** (S2 review, 2026-09-20): a bad field costs that field,
|
|
233
|
+
* the fallback is `session`, each bad field names itself in `ignored`, and
|
|
234
|
+
* doctor's Page writer line says so.
|
|
236
235
|
*/
|
|
237
236
|
readonly pageWriter?: {
|
|
238
237
|
readonly mode: PageWriterMode;
|
|
239
|
-
/** The watchdog for that child, ms. Absent ⇒ `TUNABLES.PAGE_WRITER_MS`. */
|
|
240
|
-
readonly timeoutMs?: number;
|
|
241
238
|
/** What this file could not read inside the block, phrased for a person.
|
|
242
239
|
* Empty is absent. A REPORT, not a stance — doctor is what puts it in
|
|
243
240
|
* front of somebody. */
|
|
@@ -323,7 +320,7 @@ export function loadConfig(raw: unknown): LoadedConfig {
|
|
|
323
320
|
embedder?: { enabled: boolean; kind?: EmbedderKind };
|
|
324
321
|
parallel?: { enabled: boolean };
|
|
325
322
|
snapshots?: { dir?: string; keep?: number; mirror?: string; ignored?: string[] };
|
|
326
|
-
pageWriter?: { mode: PageWriterMode;
|
|
323
|
+
pageWriter?: { mode: PageWriterMode; ignored?: string[] };
|
|
327
324
|
dreaming?: { model?: string; timeoutMs?: number; maxTurns?: number; ignored?: string[] };
|
|
328
325
|
retired?: string[];
|
|
329
326
|
owner?: boolean;
|
|
@@ -467,20 +464,27 @@ export function loadConfig(raw: unknown): LoadedConfig {
|
|
|
467
464
|
// That is precisely the failure the F2 ruling moved `snapshots` out of
|
|
468
465
|
// strictness to avoid.
|
|
469
466
|
//
|
|
470
|
-
// So it falls back,
|
|
471
|
-
//
|
|
472
|
-
//
|
|
473
|
-
// it. Nothing in here ever sets `unreadable`.
|
|
467
|
+
// So it falls back, to `session`. Each bad field names itself in `ignored`,
|
|
468
|
+
// and doctor's Page writer line prints it. Nothing in here ever sets
|
|
469
|
+
// `unreadable`.
|
|
474
470
|
const pageWriter = rec["pageWriter"];
|
|
475
471
|
if (pageWriter !== undefined) {
|
|
476
472
|
out.pageWriter = readPageWriter(pageWriter);
|
|
477
|
-
// THE
|
|
478
|
-
//
|
|
479
|
-
// "runs a command named by config" finding
|
|
480
|
-
//
|
|
473
|
+
// THREE KEYS FROM THE REMOVED HOST MODE, each read as an OLD SETTING —
|
|
474
|
+
// ignored and named, never a reason to refuse the file. `command` went on
|
|
475
|
+
// 2026-09-24 (a "runs a command named by config" finding); `mode: "host"`
|
|
476
|
+
// and `timeoutMs`, its child's watchdog, went with the mode on 2026-09-29.
|
|
481
477
|
const w = pageWriter as Record<string, unknown> | null;
|
|
482
|
-
if (typeof w === "object" && w !== null && !Array.isArray(w)
|
|
483
|
-
|
|
478
|
+
if (typeof w === "object" && w !== null && !Array.isArray(w)) {
|
|
479
|
+
if (w["command"] !== undefined) {
|
|
480
|
+
retired.push(`"pageWriter.command" is no longer used — the page writer runs inside the nightly run`);
|
|
481
|
+
}
|
|
482
|
+
if (w["mode"] === "host") {
|
|
483
|
+
retired.push(`"pageWriter.mode" "host" is no longer used — the page writer runs inside the nightly run (mode session)`);
|
|
484
|
+
}
|
|
485
|
+
if (w["timeoutMs"] !== undefined) {
|
|
486
|
+
retired.push(`"pageWriter.timeoutMs" is no longer used — the nightly run's watchdog is "dreaming.timeoutMs"`);
|
|
487
|
+
}
|
|
484
488
|
}
|
|
485
489
|
}
|
|
486
490
|
// THE THIRD LENIENT BLOCK (2026-09-29): the headless nightly run's model pin
|
|
@@ -530,26 +534,25 @@ export function loadConfig(raw: unknown): LoadedConfig {
|
|
|
530
534
|
}
|
|
531
535
|
|
|
532
536
|
/**
|
|
533
|
-
* THE FALLBACK MODE
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
* "fall back to the default" happen to be the same value today; they are
|
|
538
|
-
* written as one constant so they stay the same value if the default moves.
|
|
537
|
+
* THE FALLBACK MODE: what a block this could not read resolves to. "Fall back
|
|
538
|
+
* to the safe thing" and "fall back to the default" happen to be the same value
|
|
539
|
+
* today; they are written as one constant so they stay the same value if the
|
|
540
|
+
* default moves.
|
|
539
541
|
*/
|
|
540
542
|
export const PAGE_WRITER_FALLBACK_MODE: PageWriterMode = "session";
|
|
541
543
|
|
|
542
544
|
/**
|
|
543
545
|
* The `pageWriter` block, read leniently — every rejection names the field,
|
|
544
|
-
* what was in it, and what is being used instead.
|
|
546
|
+
* what was in it, and what is being used instead. The removed host mode's keys
|
|
547
|
+
* (`mode: "host"`, `timeoutMs`, `command`) are named by `loadConfig` among the
|
|
548
|
+
* old settings instead, and not twice.
|
|
545
549
|
*/
|
|
546
550
|
function readPageWriter(raw: unknown): {
|
|
547
551
|
mode: PageWriterMode;
|
|
548
|
-
timeoutMs?: number;
|
|
549
552
|
ignored?: string[];
|
|
550
553
|
} {
|
|
551
554
|
const raws: string[] = [];
|
|
552
|
-
const out: { mode: PageWriterMode
|
|
555
|
+
const out: { mode: PageWriterMode } = {
|
|
553
556
|
mode: PAGE_WRITER_FALLBACK_MODE,
|
|
554
557
|
};
|
|
555
558
|
const done = (): typeof out & { ignored?: string[] } =>
|
|
@@ -562,20 +565,14 @@ function readPageWriter(raw: unknown): {
|
|
|
562
565
|
const mode = w["mode"];
|
|
563
566
|
if (typeof mode === "string" && (PAGE_WRITER_MODES as readonly string[]).includes(mode)) {
|
|
564
567
|
out.mode = mode as PageWriterMode;
|
|
565
|
-
} else if (mode !== undefined) {
|
|
568
|
+
} else if (mode !== undefined && mode !== "host") {
|
|
566
569
|
raws.push(
|
|
567
570
|
`"pageWriter.mode" was ${JSON.stringify(mode)}, which is not ${PAGE_WRITER_MODES.join(", ")}; using ${PAGE_WRITER_FALLBACK_MODE}`,
|
|
568
571
|
);
|
|
569
572
|
}
|
|
570
|
-
const timeoutMs = w["timeoutMs"];
|
|
571
|
-
if (typeof timeoutMs === "number" && Number.isFinite(timeoutMs) && timeoutMs > 0) {
|
|
572
|
-
out.timeoutMs = timeoutMs;
|
|
573
|
-
} else if (timeoutMs !== undefined) {
|
|
574
|
-
raws.push(`"pageWriter.timeoutMs" was ${JSON.stringify(timeoutMs)}; using the default watchdog`);
|
|
575
|
-
}
|
|
576
573
|
// A key nobody here knows is named rather than passed over: a person who
|
|
577
574
|
// typed `"modes"` gets told so instead of watching the block do nothing.
|
|
578
|
-
// (`command`
|
|
575
|
+
// (`command` and `timeoutMs` are named by `loadConfig`, among the old settings.)
|
|
579
576
|
for (const key of Object.keys(w)) {
|
|
580
577
|
if (key !== "mode" && key !== "command" && key !== "timeoutMs") {
|
|
581
578
|
raws.push(`"pageWriter.${key}" is not a setting this reads; it was ignored`);
|