counterparts 0.2.0 → 0.3.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.
Files changed (96) hide show
  1. package/README.md +87 -367
  2. package/docs/QUICKSTART.md +83 -1584
  3. package/docs/README.md +86 -0
  4. package/docs/module-map.md +1 -0
  5. package/package.json +5 -2
  6. package/src/adapters/claude-code/CONTRACT.md +151 -18
  7. package/src/adapters/claude-code/INTERFACE-GAPS.md +138 -2
  8. package/src/adapters/claude-code/NOTES.md +452 -0
  9. package/src/adapters/claude-code/bin/hook.ts +221 -49
  10. package/src/adapters/claude-code/bin/runner.ts +220 -101
  11. package/src/adapters/claude-code/config.ts +202 -279
  12. package/src/adapters/claude-code/doctor.ts +713 -421
  13. package/src/adapters/claude-code/embed-client.ts +165 -557
  14. package/src/adapters/claude-code/hooks.ts +409 -116
  15. package/src/adapters/claude-code/index.ts +7 -59
  16. package/src/adapters/claude-code/page-writer.ts +24 -4
  17. package/src/adapters/claude-code/spawn.ts +6 -7
  18. package/src/adapters/claude-code/transcript.ts +204 -10
  19. package/src/adapters/claude-code/vectors.ts +108 -24
  20. package/src/adapters/cli/CONTRACT.md +123 -3
  21. package/src/adapters/cli/INTERFACE-GAPS.md +45 -2
  22. package/src/adapters/cli/NOTES.md +265 -1
  23. package/src/adapters/cli/bin/counterparts.ts +9 -9
  24. package/src/adapters/cli/commands.ts +494 -436
  25. package/src/adapters/cli/help.ts +22 -27
  26. package/src/adapters/cli/index.ts +0 -2
  27. package/src/adapters/cli/install.ts +102 -89
  28. package/src/adapters/cli/removal.ts +1 -1
  29. package/src/adapters/cli/report.ts +25 -2
  30. package/src/adapters/cli/uninstall.ts +182 -34
  31. package/src/adapters/cli/wire.ts +232 -35
  32. package/src/adapters/dashboard/INTERFACE-GAPS.md +14 -2
  33. package/src/adapters/dashboard/activity.ts +4 -1
  34. package/src/adapters/dashboard/bin/dashboard.ts +1 -1
  35. package/src/adapters/dashboard/registries.ts +16 -1
  36. package/src/adapters/dashboard/resolve.ts +4 -4
  37. package/src/adapters/dashboard/source.ts +8 -2
  38. package/src/adapters/dashboard/web/flow.ts +6 -0
  39. package/src/adapters/dashboard/web/narrate.ts +66 -14
  40. package/src/adapters/dashboard/web/reveal.ts +6 -6
  41. package/src/adapters/dashboard/web/views.ts +12 -4
  42. package/src/adapters/fired.ts +20 -5
  43. package/src/adapters/mcp/CONTRACT.md +73 -1
  44. package/src/adapters/mcp/INTERFACE-GAPS.md +51 -1
  45. package/src/adapters/mcp/NOTES.md +389 -0
  46. package/src/adapters/mcp/bin/serve.ts +24 -35
  47. package/src/adapters/mcp/deliberate.ts +22 -0
  48. package/src/adapters/mcp/index.ts +26 -2
  49. package/src/adapters/mcp/server.ts +425 -49
  50. package/src/adapters/mcp/tools.ts +32 -7
  51. package/src/adapters/mcp/write-up.ts +454 -0
  52. package/src/adapters/sessions.ts +1353 -0
  53. package/src/core/counterpart.ts +32 -8
  54. package/src/core/embed/CONTRACT.md +85 -0
  55. package/src/core/embed/NOTES.md +93 -0
  56. package/src/core/embed/static.ts +622 -0
  57. package/src/core/encode/INTERFACE-GAPS.md +17 -0
  58. package/src/core/encode/NOTES.md +78 -0
  59. package/src/core/encode/secrets.ts +309 -9
  60. package/src/core/handoff/INTERFACE-GAPS.md +13 -1
  61. package/src/core/recall/CONTRACT.md +15 -3
  62. package/src/core/recall/INTERFACE-GAPS.md +94 -0
  63. package/src/core/recall/NOTES.md +49 -0
  64. package/src/core/recall/activate.ts +37 -3
  65. package/src/core/recall/index.ts +22 -1
  66. package/src/core/recall/session.ts +32 -0
  67. package/src/core/recall/tunables.ts +99 -2
  68. package/src/core/remember/CONTRACT.md +51 -7
  69. package/src/core/remember/INTERFACE-GAPS.md +111 -1
  70. package/src/core/remember/NOTES.md +221 -1
  71. package/src/core/remember/index.ts +28 -0
  72. package/src/core/remember/owes.ts +532 -0
  73. package/src/core/remember/owner-strike-seam.ts +34 -2
  74. package/src/core/remember/proposals.ts +25 -6
  75. package/src/core/remember/retention.ts +154 -0
  76. package/src/core/remember/spans.ts +53 -12
  77. package/src/core/remember/tunables.ts +8 -0
  78. package/src/core/remember/write-up-seam.ts +104 -0
  79. package/src/core/self/CONTRACT.md +16 -13
  80. package/src/core/self/INTERFACE-GAPS.md +8 -1
  81. package/src/core/self/NOTES.md +123 -1
  82. package/src/core/self/calendar.ts +81 -0
  83. package/src/core/self/episodes.ts +158 -36
  84. package/src/core/self/identity.ts +2 -2
  85. package/src/core/self/index.ts +88 -20
  86. package/src/core/self/tunables.ts +18 -46
  87. package/src/core/self/writer.ts +58 -9
  88. package/src/core/store/CONTRACT.md +16 -1
  89. package/src/core/store/NOTES.md +293 -0
  90. package/src/core/store/cache.ts +585 -27
  91. package/src/core/store/db.ts +97 -0
  92. package/src/core/store/index.ts +570 -13
  93. package/tools/install-loop/run.sh +52 -71
  94. package/src/adapters/claude-code/credentials.ts +0 -199
  95. package/src/adapters/claude-code/interpret-client.ts +0 -395
  96. package/src/adapters/cli/keys.ts +0 -503
@@ -3,22 +3,22 @@
3
3
  *
4
4
  * This file is where scar §2.18 lives — "a guarantee carried by something you
5
5
  * don't own is not a guarantee". v1 encoded one host's 9,000-byte injection
6
- * cliff as though it were physiology, discovered its socket ceiling by watching
7
- * calls die, and inherited a credential from whatever shell happened to launch
8
- * the session. All three are host facts. Here they are named, reported, and
6
+ * cliff as though it were physiology and discovered its socket ceiling by
7
+ * watching calls die. Both are host facts. Here they are named, reported, and
9
8
  * CHECKABLE — and the core is told what they are rather than assuming them.
10
9
  *
11
- * Two rules the CONTRACT states and this file mechanizes:
10
+ * The rule the CONTRACT states and this file mechanizes:
12
11
  *
13
12
  * §4 G4 — every host-dependent limit is discovered or asserted at runtime and
14
13
  * surfaced as a checkable value. `capabilities()` returns one row per limit
15
14
  * with `reported: false` where the host said nothing, so "we never asked" and
16
15
  * "the host said zero" are different records (scar §2.4).
17
16
  *
18
- * §4 (drops) / scar §2.15 — every model SEAT has its own knob, holds a pinned
19
- * identifier, and a placeholder EXPIRES. v1's single `models.maintainer` knob
20
- * fed three call sites, so a decision that had been made could not be
21
- * implemented; and its inert placeholder became production by silence.
17
+ * KEYLESS (owner, 2026-09-24). The package reads no API key and calls no model
18
+ * API of its own: the Anthropic write-up of crashed sessions, the Voyage
19
+ * embedder, the credentials file and the model seats that fed them were
20
+ * removed. A configuration that still names one of them is read, not refused —
21
+ * the setting is ignored and named in `retired` (see `loadConfig`).
22
22
  *
23
23
  * And one from observer-mode G5: an unreadable configuration resolves to
24
24
  * OBSERVER, never to "encode anyway". `loadConfig` never throws.
@@ -29,15 +29,12 @@ import { PAGE_WRITER_MODES } from "../../core/self/index.js";
29
29
  import type { PageWriterMode } from "../../core/self/index.js";
30
30
  import { DEFAULT_KEEP as SNAPSHOT_DEFAULT_KEEP } from "../snapshots.js";
31
31
 
32
- import type { CredentialLoad } from "./credentials.js";
33
-
34
32
 
35
33
  /** Every host-dependent limit this adapter depends on. One row each. */
36
34
  export const CAPABILITIES = [
37
35
  "injectionBudgetBytes",
38
36
  "executionCeilingMs",
39
37
  "socketLifetimeMs",
40
- "credential",
41
38
  ] as const;
42
39
  export type CapabilityName = (typeof CAPABILITIES)[number];
43
40
 
@@ -47,86 +44,8 @@ export interface CapabilityReport {
47
44
  readonly reported: boolean;
48
45
  readonly value: number | boolean | null;
49
46
  readonly why: string;
50
- /**
51
- * WHICH SOURCE ANSWERED, name-level only. On the credential row: `"env"` when
52
- * the process environment carried the name, `"file"` when the configured
53
- * credentials file filled the gap, `"absent"` when nothing did. Never a value,
54
- * never a hash of one.
55
- */
56
- readonly detail?: string;
57
47
  }
58
48
 
59
- /**
60
- * One model seat. `id` is a PINNED identifier held in configuration, never an
61
- * alias resolved at call time, and never shared with another seat.
62
- */
63
- export interface ModelSeat {
64
- readonly id: string;
65
- /**
66
- * True while this id is a stand-in nobody has decided on. A placeholder MUST
67
- * carry `expires`; past that date `seatStatus()` reports `expired`, so
68
- * "never decided" cannot masquerade as "decided" (scar §2.15c).
69
- */
70
- readonly placeholder?: boolean;
71
- /** ISO date. Required when `placeholder` is true. */
72
- readonly expires?: string;
73
- }
74
-
75
- export type SeatStatus = "pinned" | "placeholder" | "expired" | "unbounded-placeholder";
76
-
77
- export interface SeatVerdict {
78
- readonly seat: string;
79
- readonly id: string;
80
- readonly status: SeatStatus;
81
- readonly usable: boolean;
82
- }
83
-
84
- /**
85
- * The default interpreter seat. It is the crash fallback's only model call, and
86
- * the fallback is the path that must not lose the day, so it gets the strongest
87
- * tier rather than the cheapest. PINNED, not an alias — recorded here so the
88
- * decision has a place, per scar §2.15's first clause.
89
- */
90
- export const DEFAULT_INTERPRET_MODEL = "claude-opus-5";
91
-
92
- /**
93
- * The default EMBED seat. Its own knob, its own pinned id, its own provider —
94
- * scar §2.15b is exactly the case where one knob fed several call sites, and an
95
- * embedding model and an interpreter model are not interchangeable in any sense
96
- * (different vendor, different credential, different failure mode).
97
- *
98
- * PINNED, not an alias: `voyage-3` and `voyage-3-large` are different spaces, and
99
- * a store's vectors are only comparable to vectors from the generation that
100
- * wrote them. The id is therefore part of the data's identity, not a preference.
101
- */
102
- export const DEFAULT_EMBED_MODEL = "voyage-3-large";
103
-
104
- /** The Messages API, raw. No SDK, no runtime dependency (constitution 10). */
105
- export const ANTHROPIC_ENDPOINT = "https://api.anthropic.com/v1/messages";
106
- export const ANTHROPIC_VERSION = "2023-06-01";
107
-
108
- /** Voyage's embeddings endpoint, raw. Same rule: no SDK, no dependency. */
109
- export const VOYAGE_ENDPOINT = "https://api.voyageai.com/v1/embeddings";
110
-
111
- /**
112
- * The ONE environment variable a credential may come from — and, when the
113
- * environment is silent, the one file `credentialsFile` NAMES. See that knob for
114
- * the whole rule; the short form is: the environment first, a file the config
115
- * names second, a file found by convention never.
116
- */
117
- export const API_KEY_ENV = "ANTHROPIC_API_KEY";
118
-
119
- /**
120
- * The embedder's ONE environment variable — the same name v1 reads, so an owner
121
- * who already has a key in their environment does not learn a second name.
122
- * v1 also accepted a `.env` FILE found by CONVENTION (`resolveVoyageKey`, in
123
- * whatever directory the process happened to sit in); that half stays dropped.
124
- * §2.18: the credential comes from one configured source the package names, and
125
- * a file the process happens to FIND is not one — while a file the package's own
126
- * configuration NAMES is (`credentialsFile`).
127
- */
128
- export const EMBED_KEY_ENV = "VOYAGE_API_KEY";
129
-
130
49
  /**
131
50
  * The adapter's own tunables, in one visible place (the shape every core module
132
51
  * uses). Nothing here is a memory property; all of it is host trivia.
@@ -143,9 +62,6 @@ export const TUNABLES = {
143
62
  * worker's it is not validated against `remember/`'s claim staleness, because
144
63
  * it claims no spans. */
145
64
  PAGE_WRITER_MS: 10 * 60_000,
146
- /** Output headroom for the interpreter. A truncated JSON response is a
147
- * failure, not data (scar E2) — headroom is how you stop paying for one. */
148
- MAX_OUTPUT_TOKENS: 16_000,
149
65
  /** Reference resolution at a session-ending boundary (recall §9.2), ms. The
150
66
  * resolver stops between candidates past it and the row says so
151
67
  * (`recall.credit` reason `budget-exceeded`); nothing is truncated silently. */
@@ -153,47 +69,45 @@ export const TUNABLES = {
153
69
  /** Identical consecutive spawn failures before the worker ESCALATES instead
154
70
  * of re-logging the same line forever (scar E4's widening). */
155
71
  ESCALATE_AFTER: 3,
156
- /** Texts per embeddings request. The provider's documented ceiling, and the
157
- * unit of FAILURE ISOLATION: one poisoned input fails its own chunk and
158
- * leaves every sibling chunk's vectors standing (scar E1). v1 used the same
159
- * 128. */
160
- EMBED_BATCH_SIZE: 128,
161
- // The Stop ask's pacing is NOT here any more, and that is the point: it was a
162
- // second pacer beside `self/`'s, and two pacers on one blocked moment is how
163
- // 13 owner turns drew about a dozen asks (2026-09-04). The one pair lives in
164
- // `self/tunables.ts` — REASK_TURNS / REASK_BYTES — which is also where the
165
- // numbers below were copied from when this knob was introduced.
72
+ /**
73
+ * THE NEXT-SESSION WRITE-UP (roadmap C2, owner 2026-09-23). How many sessions
74
+ * may be pointed at an ended session's words in one calendar day (local
75
+ * time, `self/calendar.ts`). A sibling of the page writer's
76
+ * `PAGE_WRITER_ASKS_PER_DAY` and the same number: the owner's ruling is that
77
+ * the write-up SHARES the day's allowance rather than growing a pacer of its
78
+ * own — and nothing here is at the Stop, where §13 G3's one pacer lives.
79
+ */
80
+ WRITE_UP_ASKS_PER_DAY: 2,
81
+ /**
82
+ * The host's cap on a hook's whole output, in characters. The host's own
83
+ * words: "Hook output strings, including `additionalContext`, `systemMessage`,
84
+ * and plain stdout, are capped at 10,000 characters. Output that exceeds this
85
+ * limit is saved to a file and replaced with a preview and file path." Past
86
+ * it, what the session would read is a preview — of the WAKE — so the
87
+ * write-up pointer is measured so the wake, every ask and itself stay under
88
+ * this. With no owner notice the hook prints PLAIN text, so there is no JSON
89
+ * escaping to leave room for (PR #192 review, MAJOR 1); with one,
90
+ * `bin/hook.ts#hostDelivery` drops the notice before it lets the envelope
91
+ * pass `ENVELOPE_MAX_CHARS`. It is also why the words themselves travel
92
+ * through the MCP door.
93
+ */
94
+ WRITE_UP_HOST_OUTPUT_CHARS: 10_000,
95
+ // The Stop ask's pacing is NOT here: two pacers on one blocked moment drew
96
+ // about a dozen asks in 13 owner turns (2026-09-04). The one pacer lives in
97
+ // `self/tunables.ts` (FIRST_ASK_* / REASK_*).
166
98
  } as const;
167
99
 
100
+ /**
101
+ * The embedder `embedder.kind` can name — one since 2026-09-24, when the Voyage
102
+ * seat was removed. `"voyage"` in a configuration is read as this, with a note
103
+ * in `retired` (see `loadConfig`).
104
+ */
105
+ export type EmbedderKind = "static";
106
+ export const EMBEDDER_KINDS: readonly EmbedderKind[] = ["static"];
107
+
168
108
  export interface AdapterConfig {
169
109
  /** Where the memory lives. Pinned onto the child's environment LAST. */
170
110
  readonly dataDir?: string;
171
- /**
172
- * THE CREDENTIAL FILE, and it is the source only because THIS FILE NAMES IT.
173
- *
174
- * Measured on day 0 of the parallel run: this host's hook processes carry
175
- * neither documented name, even with both exported in the owner's shell rc —
176
- * the host's process environment is not the login shell's. So a `process.env`
177
- * that answers in a terminal answers nothing in a hook: the worker's sweep
178
- * would skip itself at every boundary and the embedder would never open.
179
- *
180
- * The rules, mechanized in `credentials.ts`:
181
- *
182
- * - the file is `KEY=value` lines (`export KEY=value`, quotes and CRLF
183
- * tolerated; blank and `#` lines skipped);
184
- * - ONLY the two documented names are honored — `API_KEY_ENV` and
185
- * `EMBED_KEY_ENV`. Anything else in the file is IGNORED AND COUNTED;
186
- * - a value already present in `process.env` WINS. The environment stays the
187
- * first source; the file only fills the gap;
188
- * - values are never logged, never emitted, never hashed. Names and counts
189
- * are the only things that leave.
190
- *
191
- * §2.18 permits exactly this and no more: "credentials come from one
192
- * configured source the package owns". A file the package's own configuration
193
- * NAMES is that source. A file found by CONVENTION — v1's `.env` in whatever
194
- * directory the process sat in — is not, and stays forbidden.
195
- */
196
- readonly credentialsFile?: string;
197
111
  /** The host's reported injection ceiling, in bytes. NO DEFAULT (scar §2.18). */
198
112
  readonly injectionBudgetBytes?: number;
199
113
  /** How long the host lets a foreground hook run, ms. Reported, not assumed. */
@@ -202,20 +116,20 @@ export interface AdapterConfig {
202
116
  readonly socketLifetimeMs?: number;
203
117
  /** The detached worker's watchdog, ms. */
204
118
  readonly watchdogMs?: number;
205
- /** One knob per seat (scar §2.15b). Two seats, two knobs, two providers. */
206
- readonly models?: { readonly interpret?: ModelSeat; readonly embed?: ModelSeat };
207
119
  /**
208
- * THE EGRESS KNOB, and it defaults to OFF.
120
+ * RECALL BY MEANING — the local potion-base-8M table (`core/embed/static.ts`):
121
+ * no key, no network, nothing leaves the machine. Its weights come from
122
+ * `COUNTERPARTS_STATIC_WEIGHTS_DIR` or the installed `counterparts-model-potion`
123
+ * package.
209
124
  *
210
- * Embedding means sending the text of a memory to a third party. v2's
211
- * "no-silent-egress" rescope (2026-08-25) is the reason this is a decision the
212
- * owner makes rather than a capability a key in the environment switches on:
213
- * a `VOYAGE_API_KEY` exported for some other tool must never be the thing that
214
- * starts shipping this store's contents anywhere. Absent ⇒ no client is built,
215
- * no socket is opened, and the brain runs exactly as it does today — blind,
216
- * and countably so (`novelty.reason = "no-chunk-vector"`).
125
+ * An ABSENT block reads as the table, on (`resolveEmbedder`, roadmap C3);
126
+ * `{ "enabled": false }` is how somebody says no. `kind` has one value,
127
+ * `"static"`, and may be left out. It had a second — `"voyage"`, a paid remote
128
+ * seat — until 2026-09-24; a configuration that still names it gets the local
129
+ * table and a note in `retired`. Any OTHER kind on an enabled block is still
130
+ * unreadable rather than guessed at.
217
131
  */
218
- readonly embedder?: { readonly enabled: boolean };
132
+ readonly embedder?: { readonly enabled: boolean; readonly kind?: EmbedderKind };
219
133
  /**
220
134
  * THE PARALLEL-RUN KNOB, and it defaults to ABSENT.
221
135
  *
@@ -294,12 +208,6 @@ export interface AdapterConfig {
294
208
  */
295
209
  readonly pageWriter?: {
296
210
  readonly mode: PageWriterMode;
297
- /**
298
- * The host CLI to launch in `host` mode. Absent ⇒ `claude`, resolved on the
299
- * child's PATH. Named here because the one machine this has to work on is
300
- * the owner's, and because a test proves the whole path against a stub.
301
- */
302
- readonly command?: string;
303
211
  /** The watchdog for that child, ms. Absent ⇒ `TUNABLES.PAGE_WRITER_MS`. */
304
212
  readonly timeoutMs?: number;
305
213
  /** What this file could not read inside the block, phrased for a person.
@@ -307,6 +215,14 @@ export interface AdapterConfig {
307
215
  * front of somebody. */
308
216
  readonly ignored?: readonly string[];
309
217
  };
218
+ /**
219
+ * SETTINGS THIS BUILD NO LONGER READS, phrased for a person — e.g.
220
+ * `"credentialsFile" is no longer used …`. Present only when the file named
221
+ * one. A REPORT, not a stance: the setting was ignored and nothing else
222
+ * changed. Doctor prints it as a quiet note, never a warning — a key the
223
+ * owner's configuration still carries from an older install is not a fault.
224
+ */
225
+ readonly retired?: readonly string[];
310
226
  /** Is this the owner's own session? Withholding is the safe direction. */
311
227
  readonly owner?: boolean;
312
228
  /** An instrument stands down. Fail direction: an unreadable config lands here. */
@@ -319,6 +235,13 @@ export interface LoadedConfig {
319
235
  readonly config: AdapterConfig;
320
236
  readonly ok: boolean;
321
237
  readonly reason: "loaded" | "absent" | "unreadable";
238
+ /**
239
+ * The keys that made it unreadable, where the reader can name them (today:
240
+ * `embedder.enabled`, `embedder.kind`). Absent when it cannot, or when
241
+ * nothing was wrong. A reason that names its key is one a person can fix
242
+ * without reading this file.
243
+ */
244
+ readonly unreadableKeys?: readonly string[];
322
245
  }
323
246
 
324
247
  /**
@@ -337,21 +260,26 @@ export function loadConfig(raw: unknown): LoadedConfig {
337
260
  const rec = raw as Record<string, unknown>;
338
261
  const out: {
339
262
  dataDir?: string;
340
- credentialsFile?: string;
341
263
  injectionBudgetBytes?: number;
342
264
  executionCeilingMs?: number;
343
265
  socketLifetimeMs?: number;
344
266
  watchdogMs?: number;
345
- models?: { interpret?: ModelSeat; embed?: ModelSeat };
346
- embedder?: { enabled: boolean };
267
+ embedder?: { enabled: boolean; kind?: EmbedderKind };
347
268
  parallel?: { enabled: boolean };
348
269
  snapshots?: { dir?: string; keep?: number; mirror?: string; ignored?: string[] };
349
- pageWriter?: { mode: PageWriterMode; command?: string; timeoutMs?: number; ignored?: string[] };
270
+ pageWriter?: { mode: PageWriterMode; timeoutMs?: number; ignored?: string[] };
271
+ retired?: string[];
350
272
  owner?: boolean;
351
273
  observer?: boolean;
352
274
  identity?: { name: string; aliases?: readonly string[] };
353
275
  } = {};
354
276
  let unreadable = false;
277
+ const badKeys: string[] = [];
278
+ // The settings the keyless build dropped (2026-09-24). Each is IGNORED and
279
+ // named — never a reason to stand the configuration down, because the owner's
280
+ // own live configuration carries `credentialsFile` from the install that
281
+ // wrote it, and an old key must not cost anybody their memory.
282
+ const retired: string[] = [];
355
283
 
356
284
  const num = (key: string): number | undefined => {
357
285
  const value = rec[key];
@@ -366,11 +294,26 @@ export function loadConfig(raw: unknown): LoadedConfig {
366
294
  if (typeof rec["dataDir"] === "string") out.dataDir = rec["dataDir"];
367
295
  else if (rec["dataDir"] !== undefined) unreadable = true;
368
296
 
369
- // Validated exactly like `dataDir`, and for the same reason: a path this
370
- // package will OPEN is either a string the owner wrote or a configuration we
371
- // did not understand, and the second one stands down rather than guessing.
372
- if (typeof rec["credentialsFile"] === "string") out.credentialsFile = rec["credentialsFile"];
373
- else if (rec["credentialsFile"] !== undefined) unreadable = true;
297
+ if (rec["credentialsFile"] !== undefined) {
298
+ const named = typeof rec["credentialsFile"] === "string" ? ` (${rec["credentialsFile"]})` : "";
299
+ retired.push(
300
+ `"credentialsFile" is no longer used — Counterparts reads no API keys; the file it names${named} can be deleted`,
301
+ );
302
+ }
303
+ if (rec["models"] !== undefined) {
304
+ retired.push(`"models" is no longer used — there is no model seat to configure; it was ignored`);
305
+ }
306
+ if (rec["crashWriteUp"] !== undefined && rec["crashWriteUp"] !== "next-session") {
307
+ retired.push(
308
+ `"crashWriteUp" is no longer used — a session that ended before it was written up is always written up by the next session in its project`,
309
+ );
310
+ }
311
+ // The Stop ask's switch (B1, 2026-09-23), retired the next day when the ask
312
+ // moved to the host's non-error route (`bin/hook.ts#HOST_STOP`). Any value —
313
+ // the owner's own configuration says `"stderr"` — is read, ignored and named.
314
+ if (rec["stopAskShape"] !== undefined) {
315
+ retired.push(`"stopAskShape" is no longer used — the end-of-session ask has one shape now, shown as hook feedback`);
316
+ }
374
317
 
375
318
  const injection = num("injectionBudgetBytes");
376
319
  if (injection !== undefined) out.injectionBudgetBytes = injection;
@@ -389,50 +332,46 @@ export function loadConfig(raw: unknown): LoadedConfig {
389
332
  if (typeof rec["observer"] !== "boolean") unreadable = true;
390
333
  else out.observer = rec["observer"];
391
334
  }
392
- // One parser, both seats: a second spelling of "what a seat is" is how the two
393
- // knobs drift apart while both look configured (scar §2.15b).
394
- const readSeat = (raw: unknown): ModelSeat | undefined => {
395
- if (raw === undefined) return undefined;
396
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
397
- unreadable = true;
398
- return undefined;
399
- }
400
- const s = raw as Record<string, unknown>;
401
- if (typeof s["id"] !== "string" || s["id"].length === 0) {
402
- unreadable = true;
403
- return undefined;
404
- }
405
- const parsed: { id: string; placeholder?: boolean; expires?: string } = { id: s["id"] };
406
- if (s["placeholder"] === true) parsed.placeholder = true;
407
- if (typeof s["expires"] === "string") parsed.expires = s["expires"];
408
- return parsed;
409
- };
410
-
411
- const models = rec["models"];
412
- if (models !== undefined) {
413
- if (typeof models !== "object" || models === null || Array.isArray(models)) {
414
- unreadable = true;
415
- } else {
416
- const interpret = readSeat((models as Record<string, unknown>)["interpret"]);
417
- const embed = readSeat((models as Record<string, unknown>)["embed"]);
418
- if (interpret !== undefined || embed !== undefined) {
419
- out.models = {
420
- ...(interpret === undefined ? {} : { interpret }),
421
- ...(embed === undefined ? {} : { embed }),
422
- };
423
- }
424
- }
425
- }
426
335
  const embedder = rec["embedder"];
427
336
  if (embedder !== undefined) {
428
337
  // The egress knob is read STRICTLY. A misspelled or half-written `embedder`
429
338
  // block must not resolve to "on" by accident, and the unreadable rule below
430
339
  // sends the whole configuration to observer rather than guessing.
431
- const e = embedder as Record<string, unknown>;
432
- if (typeof embedder !== "object" || embedder === null || Array.isArray(embedder) || typeof e["enabled"] !== "boolean") {
340
+ // `kind` is read INSIDE the object check (re-review MINOR A): `"embedder":
341
+ // null` reached `e["kind"]` first and threw, which stood a hook down with a
342
+ // TypeError and crashed doctor. Now it is what every other malformed block
343
+ // is — unreadable, the whole configuration to observer, the key named.
344
+ const e = (typeof embedder === "object" && embedder !== null && !Array.isArray(embedder)
345
+ ? embedder
346
+ : {}) as Record<string, unknown>;
347
+ // `"voyage"` NAMED THE REMOVED SEAT (2026-09-24): read as the local table,
348
+ // and said so, rather than standing the configuration down over a choice
349
+ // this build no longer offers.
350
+ const voyage = e["kind"] === "voyage";
351
+ if (voyage) {
352
+ retired.push(`"embedder.kind" "voyage" is no longer available — recall by meaning uses the local table, where nothing leaves this machine`);
353
+ }
354
+ const kind = voyage ? "static" : e["kind"];
355
+ const kindOk = kind === undefined || (typeof kind === "string" && (EMBEDDER_KINDS as readonly string[]).includes(kind));
356
+ if (typeof embedder !== "object" || embedder === null || Array.isArray(embedder)) {
357
+ unreadable = true;
358
+ badKeys.push("embedder");
359
+ } else if (typeof e["enabled"] !== "boolean") {
433
360
  unreadable = true;
361
+ badKeys.push("embedder.enabled");
362
+ } else if (e["enabled"] === false) {
363
+ // OFF MEANS OFF, WHATEVER `kind` SAYS (review of #190, MINOR 5). A typo in
364
+ // a knob that is switched off must not stand every memory down: `kind`
365
+ // chooses an embedder, and with none running there is nothing for it to
366
+ // choose. A valid kind is kept; an invalid one is dropped.
367
+ out.embedder = { enabled: false, ...(kind !== undefined && kindOk ? { kind: kind as EmbedderKind } : {}) };
368
+ } else if (!kindOk) {
369
+ // On, and naming no embedder this build knows: unreadable, never a
370
+ // default.
371
+ unreadable = true;
372
+ badKeys.push("embedder.kind");
434
373
  } else {
435
- out.embedder = { enabled: e["enabled"] };
374
+ out.embedder = { enabled: e["enabled"], ...(kind === undefined ? {} : { kind: kind as EmbedderKind }) };
436
375
  }
437
376
  }
438
377
  const parallel = rec["parallel"];
@@ -470,6 +409,14 @@ export function loadConfig(raw: unknown): LoadedConfig {
470
409
  const pageWriter = rec["pageWriter"];
471
410
  if (pageWriter !== undefined) {
472
411
  out.pageWriter = readPageWriter(pageWriter);
412
+ // THE CHILD'S COMMAND IS NOT CONFIGURABLE ANY MORE (2026-09-24): a
413
+ // configuration file that could name the program the worker starts was a
414
+ // "runs a command named by config" finding. The writer always starts
415
+ // `claude` (`page-writer.ts#DEFAULT_HOST_COMMAND`); an old key is ignored.
416
+ const w = pageWriter as Record<string, unknown> | null;
417
+ if (typeof w === "object" && w !== null && !Array.isArray(w) && w["command"] !== undefined) {
418
+ retired.push(`"pageWriter.command" is no longer used — the page writer always starts claude`);
419
+ }
473
420
  }
474
421
  // THE FIRST LENIENT BLOCK. See the `snapshots` knob above for why: a backup
475
422
  // preference that could not be read must cost the backup preference and
@@ -497,8 +444,16 @@ export function loadConfig(raw: unknown): LoadedConfig {
497
444
  if (unreadable) {
498
445
  // Everything we did read is discarded along with the stance: a partially
499
446
  // understood configuration is not a configuration.
500
- return { config: { observer: true }, ok: false, reason: "unreadable" };
447
+ return {
448
+ config: { observer: true },
449
+ ok: false,
450
+ reason: "unreadable",
451
+ ...(badKeys.length === 0 ? {} : { unreadableKeys: badKeys }),
452
+ };
501
453
  }
454
+ // A longer line cap than the lenient blocks': these phrases are this file's
455
+ // own words plus, at most, the one path the owner wrote.
456
+ if (retired.length > 0) out.retired = tidy(retired, RETIRED_LINE_CHARS);
502
457
  return { config: out, ok: true, reason: "loaded" };
503
458
  }
504
459
 
@@ -506,7 +461,7 @@ export function loadConfig(raw: unknown): LoadedConfig {
506
461
  * THE FALLBACK MODE, and it is never `host`.
507
462
  *
508
463
  * A block this could not read resolves to the mode that needs no background
509
- * process, no credential and no watchdog. "Fall back to the safe thing" and
464
+ * process and no watchdog. "Fall back to the safe thing" and
510
465
  * "fall back to the default" happen to be the same value today; they are
511
466
  * written as one constant so they stay the same value if the default moves.
512
467
  */
@@ -518,12 +473,11 @@ export const PAGE_WRITER_FALLBACK_MODE: PageWriterMode = "session";
518
473
  */
519
474
  function readPageWriter(raw: unknown): {
520
475
  mode: PageWriterMode;
521
- command?: string;
522
476
  timeoutMs?: number;
523
477
  ignored?: string[];
524
478
  } {
525
479
  const raws: string[] = [];
526
- const out: { mode: PageWriterMode; command?: string; timeoutMs?: number } = {
480
+ const out: { mode: PageWriterMode; timeoutMs?: number } = {
527
481
  mode: PAGE_WRITER_FALLBACK_MODE,
528
482
  };
529
483
  const done = (): typeof out & { ignored?: string[] } =>
@@ -541,11 +495,6 @@ function readPageWriter(raw: unknown): {
541
495
  `"pageWriter.mode" was ${JSON.stringify(mode)}, which is not ${PAGE_WRITER_MODES.join(", ")}; using ${PAGE_WRITER_FALLBACK_MODE}`,
542
496
  );
543
497
  }
544
- const command = w["command"];
545
- if (typeof command === "string" && command.trim().length > 0) out.command = command.trim();
546
- else if (command !== undefined) {
547
- raws.push(`"pageWriter.command" was ${JSON.stringify(command)}; using the default host command`);
548
- }
549
498
  const timeoutMs = w["timeoutMs"];
550
499
  if (typeof timeoutMs === "number" && Number.isFinite(timeoutMs) && timeoutMs > 0) {
551
500
  out.timeoutMs = timeoutMs;
@@ -554,6 +503,7 @@ function readPageWriter(raw: unknown): {
554
503
  }
555
504
  // A key nobody here knows is named rather than passed over: a person who
556
505
  // typed `"modes"` gets told so instead of watching the block do nothing.
506
+ // (`command` is named by `loadConfig`, among the retired settings.)
557
507
  for (const key of Object.keys(w)) {
558
508
  if (key !== "mode" && key !== "command" && key !== "timeoutMs") {
559
509
  raws.push(`"pageWriter.${key}" is not a setting this reads; it was ignored`);
@@ -575,6 +525,8 @@ function readPageWriter(raw: unknown): {
575
525
  /** How much of one ignored line, and how many lines, ever leave this function. */
576
526
  const IGNORED_LINE_CHARS = 120;
577
527
  const IGNORED_LINES = 8;
528
+ /** The cap for a `retired` line (see `loadConfig`). */
529
+ const RETIRED_LINE_CHARS = 240;
578
530
 
579
531
  /**
580
532
  * The `ignored` phrases, made safe to print.
@@ -586,12 +538,10 @@ const IGNORED_LINES = 8;
586
538
  * the list is capped — sanitized HERE, at the one place the phrases are made,
587
539
  * rather than at each of the surfaces that print them.
588
540
  */
589
- function tidy(lines: readonly string[]): string[] {
541
+ function tidy(lines: readonly string[], lineChars: number = IGNORED_LINE_CHARS): string[] {
590
542
  const clean = lines.map((line) => {
591
543
  const stripped = line.replace(/[\u0000-\u001f\u007f]/g, "");
592
- return stripped.length > IGNORED_LINE_CHARS
593
- ? `${stripped.slice(0, IGNORED_LINE_CHARS - 1)}…`
594
- : stripped;
544
+ return stripped.length > lineChars ? `${stripped.slice(0, lineChars - 1)}…` : stripped;
595
545
  });
596
546
  if (clean.length <= IGNORED_LINES) return clean;
597
547
  return [
@@ -660,17 +610,6 @@ function readSnapshots(raw: unknown): {
660
610
  return done();
661
611
  }
662
612
 
663
- /**
664
- * The capability report — one row per host-dependent limit, each saying whether
665
- * the host actually reported it. This is the "surfaced as a checkable value"
666
- * half of §4 G4; the "exceeding one is an event" half lives at the call sites.
667
- *
668
- * The credential row also says WHICH SOURCE ANSWERED. `load` is the result of
669
- * this process's `loadCredentials` call, passed in rather than looked up: the
670
- * provenance of a credential is a fact about one process's startup, and a module
671
- * that remembered it globally would leak between the runs of a test suite and
672
- * lie about which source answered.
673
- */
674
613
  /**
675
614
  * WHICH MODE THE NIGHTLY PAGE WRITER RUNS IN — the one place the default lives.
676
615
  *
@@ -685,16 +624,12 @@ export function pageWriterMode(config: AdapterConfig): PageWriterMode {
685
624
  return config.pageWriter?.mode ?? "session";
686
625
  }
687
626
 
688
- export function capabilities(
689
- config: AdapterConfig,
690
- env: NodeJS.ProcessEnv = process.env,
691
- load?: CredentialLoad,
692
- ): CapabilityReport[] {
693
- const key = env[API_KEY_ENV];
694
- const present = key !== undefined && key.trim().length > 0;
695
- // Name-level only. "Which source" is the whole answer; the value never
696
- // reaches this function's output in any form.
697
- const source = !present ? "absent" : load?.loaded.includes(API_KEY_ENV) === true ? "file" : "env";
627
+ /**
628
+ * The capability report — one row per host-dependent limit, each saying whether
629
+ * the host actually reported it. This is the "surfaced as a checkable value"
630
+ * half of §4 G4; the "exceeding one is an event" half lives at the call sites.
631
+ */
632
+ export function capabilities(config: AdapterConfig): CapabilityReport[] {
698
633
  return [
699
634
  {
700
635
  name: "injectionBudgetBytes",
@@ -714,65 +649,53 @@ export function capabilities(
714
649
  value: config.socketLifetimeMs ?? null,
715
650
  why: "Why long calls stream (scar E3, rescoped to the adapter that owns the host).",
716
651
  },
717
- {
718
- name: "credential",
719
- reported: key !== undefined,
720
- value: present,
721
- why: "The detached worker starved for two days on a credential it expected to inherit (scar E4).",
722
- detail: source,
723
- },
724
652
  ];
725
653
  }
726
654
 
727
- /** The seat, and whether its identifier is a decision or a silence. */
728
- export function seatStatus(
729
- name: string,
730
- seat: ModelSeat | undefined,
731
- today: string,
732
- /** The pinned id this seat falls back to when the host configured none. */
733
- fallbackId: string = DEFAULT_INTERPRET_MODEL,
734
- ): SeatVerdict {
735
- const resolved: ModelSeat = seat ?? { id: fallbackId };
736
- if (resolved.placeholder !== true) {
737
- return { seat: name, id: resolved.id, status: "pinned", usable: true };
738
- }
739
- if (resolved.expires === undefined) {
740
- // A placeholder with no expiry is precisely the thing that becomes
741
- // production by silence. It is refused, not warned about.
742
- return { seat: name, id: resolved.id, status: "unbounded-placeholder", usable: false };
743
- }
744
- if (today > resolved.expires) {
745
- return { seat: name, id: resolved.id, status: "expired", usable: false };
746
- }
747
- return { seat: name, id: resolved.id, status: "placeholder", usable: true };
748
- }
749
-
750
- /** The interpreter seat, resolved. One seat, one knob (scar §2.15b). */
751
- export function interpretSeat(config: AdapterConfig, today: string): SeatVerdict {
752
- return seatStatus("interpret", config.models?.interpret, today);
753
- }
754
-
755
- /** The embedder seat, resolved. Its own knob, its own pinned default. */
756
- export function embedSeat(config: AdapterConfig, today: string): SeatVerdict {
757
- return seatStatus("embed", config.models?.embed, today, DEFAULT_EMBED_MODEL);
758
- }
655
+ /** Where an effective embedder block came from (`resolveEmbedder`). */
656
+ export type EmbedderSource =
657
+ /** The configuration names one — on or off, either kind. Used as written. */
658
+ | "explicit"
659
+ /** No block: the local table, switched on. */
660
+ | "default-static"
661
+ /** No block, and the configuration is an observer's: nothing is assumed. */
662
+ | "absent-observer";
663
+
664
+ /** The local table, switched on — the block an absent one reads as. */
665
+ export const DEFAULT_EMBEDDER: { readonly enabled: true; readonly kind: "static" } = {
666
+ enabled: true,
667
+ kind: "static",
668
+ };
759
669
 
760
670
  /**
761
- * Is the embedder switched on, and is its credential present? Both halves are
762
- * REPORTED rather than inferred, so "the owner said no" and "the owner said yes
763
- * and the key is missing" are different records — the second is a refusal worth
764
- * an event, the first is not (scar §2.4).
671
+ * THE RUNTIME DEFAULT FOR AN ABSENT `embedder` BLOCK (roadmap C3, coordinator's
672
+ * ruling 2026-09-23).
673
+ *
674
+ * Absent used to mean OFF, for a privacy reason: the only embedder was a paid
675
+ * third party. The local table has no egress, so that reason is gone — and a
676
+ * configuration written before C3 has no block at all. So:
677
+ *
678
+ * - **A block the file writes is used exactly as written** (`explicit`),
679
+ * `{ "enabled": false }` included — that is how somebody says no.
680
+ * - **No block** → `{ enabled: true, kind: "static" }`.
681
+ * - **An observer** gets nothing assumed — it opens no embedder anyway, and
682
+ * an unreadable configuration resolves to one.
683
+ *
684
+ * (Until 2026-09-24 a saved Voyage key kept an absent block off; there are no
685
+ * keys any more, so there is no such exception.) `loadConfig` stays strict and
686
+ * pure; every entry point applies this after it.
765
687
  */
766
- export function embedderState(
688
+ export function resolveEmbedder(
767
689
  config: AdapterConfig,
768
- env: NodeJS.ProcessEnv = process.env,
769
- ): {
770
- readonly enabled: boolean;
771
- readonly credential: boolean;
772
- } {
773
- const key = env[EMBED_KEY_ENV];
774
- return {
775
- enabled: config.embedder?.enabled === true,
776
- credential: key !== undefined && key.trim().length > 0,
777
- };
690
+ ): { block: { enabled: boolean; kind?: EmbedderKind } | undefined; source: EmbedderSource } {
691
+ if (config.embedder !== undefined) return { block: config.embedder, source: "explicit" };
692
+ if (config.observer === true) return { block: undefined, source: "absent-observer" };
693
+ return { block: { ...DEFAULT_EMBEDDER }, source: "default-static" };
694
+ }
695
+
696
+ /** The configuration with its effective embedder block — `resolveEmbedder`,
697
+ * applied. What each entry point hands on after reading its configuration. */
698
+ export function withEmbedderDefault(config: AdapterConfig): AdapterConfig {
699
+ const { block, source } = resolveEmbedder(config);
700
+ return source === "explicit" || block === undefined ? config : { ...config, embedder: block };
778
701
  }