counterparts 0.3.28 → 0.3.29

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 (55) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/CONSTITUTION.md +7 -5
  3. package/docs/module-map.md +12 -5
  4. package/package.json +1 -1
  5. package/src/adapters/claude-code/CONTRACT.md +3 -1
  6. package/src/adapters/claude-code/doctor-self-page.ts +71 -0
  7. package/src/adapters/claude-code/doctor.ts +9 -0
  8. package/src/adapters/claude-code/index.ts +3 -1
  9. package/src/adapters/claude-code/night-catch-up.ts +18 -19
  10. package/src/adapters/claude-code/night-run.ts +179 -59
  11. package/src/adapters/cli/CONTRACT.md +4 -2
  12. package/src/adapters/cli/catch-up.ts +10 -17
  13. package/src/adapters/cli/dream-core.ts +12 -0
  14. package/src/adapters/cli/mechanisms.ts +4 -0
  15. package/src/adapters/dashboard/CONTRACT.md +2 -0
  16. package/src/adapters/dashboard/NOTES.md +31 -0
  17. package/src/adapters/dashboard/web/narrate.ts +1 -1
  18. package/src/adapters/dashboard/web/pages/self/index.js +3 -1
  19. package/src/adapters/dashboard/web/pages/self/sections/layers.js +160 -0
  20. package/src/adapters/dashboard/web/pages/self/self.css +11 -0
  21. package/src/adapters/dashboard/web/views/mechanisms.ts +4 -0
  22. package/src/adapters/dashboard/web/views/mind.ts +9 -0
  23. package/src/adapters/log/CONTRACT.md +2 -0
  24. package/src/adapters/mcp/CONTRACT.md +3 -1
  25. package/src/adapters/mcp/server-self-tools.ts +15 -2
  26. package/src/adapters/mcp/server-words.ts +1 -1
  27. package/src/adapters/mcp/server.ts +22 -0
  28. package/src/adapters/mcp/tools.ts +16 -4
  29. package/src/adapters/mechanism-evidence.ts +51 -7
  30. package/src/adapters/sidebar-status.ts +4 -3
  31. package/src/core/associate/CONTRACT.md +2 -0
  32. package/src/core/counterpart.ts +11 -2
  33. package/src/core/coverage/CONTRACT.md +2 -0
  34. package/src/core/dream/CONTRACT.md +28 -7
  35. package/src/core/dream/NOTES.md +39 -0
  36. package/src/core/dream/reflect.ts +152 -47
  37. package/src/core/dream/unmarked.ts +135 -0
  38. package/src/core/embed/CONTRACT.md +2 -0
  39. package/src/core/encode/CONTRACT.md +2 -0
  40. package/src/core/fit/CONTRACT.md +2 -0
  41. package/src/core/handoff/CONTRACT.md +2 -0
  42. package/src/core/physics/CONTRACT.md +7 -1
  43. package/src/core/prospective/CONTRACT.md +2 -0
  44. package/src/core/recall/CONTRACT.md +3 -1
  45. package/src/core/remember/CONTRACT.md +2 -0
  46. package/src/core/schemas/CONTRACT.md +11 -5
  47. package/src/core/seat.ts +93 -0
  48. package/src/core/self/CONTRACT.md +11 -5
  49. package/src/core/self/NOTES.md +71 -0
  50. package/src/core/self/index.ts +59 -4
  51. package/src/core/self/measures.ts +208 -0
  52. package/src/core/self/page.ts +211 -0
  53. package/src/core/self/tunables.ts +4 -1
  54. package/src/core/sleep/CONTRACT.md +2 -0
  55. package/src/core/store/CONTRACT.md +2 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.29 — 2026-10-21
4
+
5
+ Personal news now travels between your folders: each night the reflection looks at up to 24 memories nobody marked (it was 5), the personal-looking ones first, and marks the ones about you or the two of you so every folder's wake can show them, while work notes stay in the folder they came from; the morning share names what it re-marked and how to have one marked back, and nothing written in a folder you set off or paused is offered or carried out. In the plugin's sidebar the fox goes to work while Claude's turn runs and sits back down when it ends. The self page now keeps which memories each sentence rests on, doctor gains two reading-only lines ("Self page claims" and "Core"), and the dashboard's Self page shows the page in layers across its kept versions. The mechanism counts now include a dream's folds and band rises, so Consolidation and Interference read higher and Reconsolidation lower than before. Most of these are experiments, to be checked in a few days. Update the plugin with this release for the working fox and for sidebar mechanism counts that match the dashboard's; a 0.3.28 plugin keeps working beside this core, with the older counts. No store-format change (store v13, cache v7) and no wiring change: nothing to run after upgrading from 0.3.28, and `counterparts connect` is not needed.
6
+
7
+ - **A dream's folds count as Consolidation and Interference.** A fold gathers memories that
8
+ belong together into what they add up to; it now counts under both, as a dream's merges do,
9
+ on the dashboard, in `counterparts mechanisms` and in the sidebar. The settles a fold writes
10
+ over its parts count once, as the fold, and no longer under Reconsolidation.
11
+ - **"Rose a band" counts.** A memory that moves up a band now counts under Consolidation,
12
+ whichever pass recorded it. Before, the count looked only for a pass that never records a
13
+ crossing, so it was always 0. The crossing into the core is still counted once, as "became
14
+ core".
15
+ - **The exact-copy merge is worded for what reaches it**: "exact copy merged into the one
16
+ already held". A repeat in the same folder is turned away when it is written, which leaves no
17
+ row to count. A copy written from a second folder is merged at sleep, and a new test proves
18
+ that happens. Near-copies are still merged only in a dream; merging them at sleep too is
19
+ open.
20
+ - **The self page keeps what each claim rests on.** The nightly reflection can now cite memories
21
+ per sentence (`page.claims`) as well as for the whole page. The cites are kept beside the page,
22
+ and the page's words are unchanged. A sentence with no memory behind it is a hypothesis: it
23
+ is shown as one, never removed. An experiment.
24
+ - **Two new doctor lines, both readings only.** "Self page claims": how many claims the page
25
+ makes, how many memories it cites and how many of those are live, archived or missing, and how
26
+ many claims have no memory behind them. "Core": how many core elements there are, how many
27
+ have only one episode behind them, and the range of days and contexts their support spans.
28
+ `counterparts core --list` shows each element's returns, derivations and links.
29
+ - **The dashboard's Self page shows the page in layers.** It shows how each section read across
30
+ the page's kept versions, and how far back those versions reach. Below that it lists the
31
+ page's hypotheses. It is a view only; nothing is kept longer.
32
+ - **Personal news reaches your other folders more often.** The nightly reflection now looks
33
+ at up to 24 unmarked memories a night (it was 5), the ones that look personal first: a
34
+ feeling, someone's name, a weekend or a visit. When it marks one as about you or the two
35
+ of you, every folder's wake can show it. Work notes stay in the folder they were written
36
+ in. The morning share says what it re-marked: up to three by name; past that, two by
37
+ name and the rest as a count, and how to have one marked back. A memory written in a
38
+ folder you set off or paused is never offered, and never carried out of it by a mark.
39
+ An experiment.
40
+ - **The `about` field says what the mark does.** On `remember` and `session_end`: mark
41
+ anything personal owner or us, and it reaches every folder. Work belongs to its folder,
42
+ though sessions elsewhere may see its title. Left unmarked, a fact counts as this
43
+ folder's work.
44
+ - **The nightly run asks a seat.** For anyone embedding Counterparts: the package entry now
45
+ exports `Seat`, one interface for the model work the memory asks for at night (writing up
46
+ missed sessions, the dream, the reflection), with Claude Code's own night as its first
47
+ implementation. Nothing changes in how the night runs on Claude Code.
48
+ - **The sidebar's fox is at work while Claude's turn runs, as an experiment.** Send a prompt
49
+ and he gets up and goes to work: an alert face, with a tail wag, an ear twitch or a glance
50
+ every few seconds. He never lies down or naps mid-turn, and a dream or a saved memory still
51
+ plays and hands back to work. When the turn ends, for any reason, he blinks back to sitting
52
+ and lies down at 45 seconds and naps at 2 minutes, as before. In terminals that draw the
53
+ finer sextant fox, and on the desktop, he redraws about three times as often during a turn.
54
+
3
55
  ## 0.3.28 — 2026-10-20
4
56
 
5
57
  The morning share now closes the open threads that are plainly done, and says which and why; say one isn't done and it is reopened. The session-start wake repeats nothing: each session is named once, and "Today, elsewhere" and a new "Here, also open" say by title what the other open sessions are working on. Saying "done" to a weekly reminder closes just this week; it comes back on its next date. Last night's dream and reflection open by their ids, and `counterparts night` reads them without changing anything. The nightly run keeps the self page within its 4,600-byte room, the reflection answers core memories that have waited a week for keep or retire, and facts list the next twenty matches by title. Most of these are experiments, to be checked in a few days. If you use the plugin, update it with this release: the wake's head is now one tag, and a plugin of 0.3.27 or earlier reads the meeting and the store as unknown until it is updated, so its sidebar footer offers the 5-minute intro again and it skips its store check. No store-format change (store v13, cache v7) and no wiring change: nothing to run after upgrading from 0.3.27, and `counterparts connect` is not needed.
package/CONSTITUTION.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # The Counterparts Constitution
2
2
 
3
- _Ratified by the owner 2026-08-25; last amended 2026-10-11 (this file's git history is
3
+ _Ratified by the owner 2026-08-25; last amended 2026-10-20 (this file's git history is
4
4
  the amendment log). This is the ONE page with standing authority — everything else,
5
- including owner answers given during the build, is a working default, revisable without
6
- ceremony when it fights this page. Changing THIS page is deliberate and rare._
5
+ including owner answers given during the build, is a working default, open to discussion
6
+ at any time and revisable without ceremony. Changing THIS page is deliberate and rare._
7
7
 
8
8
  **Thesis — why this exists**
9
9
 
@@ -56,8 +56,10 @@ ceremony when it fights this page. Changing THIS page is deliberate and rare._
56
56
  deliberate, named, and defended. (Reference shelf: the owner's memory field guide,
57
57
  mikelapeter.com/lab/memory.)
58
58
  13. **Decisions are defaults.** Only this page is scripture, including this line.
59
- Everything else is revisable without ceremony when it fights the thesis. Changing
60
- this page is deliberate and rare.
59
+ Everything else (contracts, rulings, tunables, owner answers) guides the work
60
+ without limiting it. Any of it can be raised for discussion at any time, and it is
61
+ revised without ceremony when a better way shows up or it fights the thesis.
62
+ Changing this page is deliberate and rare.
61
63
  14. **Port the scars, not the code.** Learnings travel as acceptance criteria, never as
62
64
  copy-paste.
63
65
  15. **Complexity is earned.** Start with the simplest brain-faithful rule that could
@@ -19,7 +19,7 @@ code and the `NOTES.md` / `INTERFACE-GAPS.md` next to it.*
19
19
  | `embed/` | — (a gist, not a reading) | Text in, vector out, on this machine, for nothing: the static embedding table (`static.ts`, potion-base-8M) that gives recall's semantic channel a source with no key. Zero code dependencies; its weights ship as the data-only package `counterparts-model-potion`, the one runtime dependency. The only embedder since 2026-09-24, when the paid Voyage seat was removed. **Added 2026-09-23 (roadmap C1).** |
20
20
  | `associate/` | Hebbian linking | Co-activation strengthens links; spreading activation at recall. **RESOLVED (owner, 2026-08-25): stays a module** — edge-level arithmetic keeps `physics/` one page; Hebbian plasticity/contiguity is its own mechanism in the field guide. |
21
21
  | `schemas/` | semantic memory | Entities and beliefs; birth by mention, death by decay; strength-weighted revision with row history. |
22
- | `self/` | autobiographical self | Identity documents, episodes, the wake briefing (v0's briefing, grown up). Governed: frozen self-reinforcement rules. |
22
+ | `self/` | autobiographical self | Identity documents, episodes, the wake briefing (v0's briefing, grown up). Governed: for now, the freeze guards only the crash-fallback sweep; the night is guarded by spacing, citations and visibility (self/CONTRACT §2(d)). |
23
23
  | `prospective/` | prospective memory | Future intentions, cued by time or context; fire / suppress / reference telemetry. |
24
24
  | `handoff/` | working context for a place | The per-directory handoff: where the work here stands, written as a field on the end-of-session ask, shown as a two-line pointer at the next wake in that directory, expiring in lived days. **Never a memory** — out of recall, out of credit, out of consolidation, out of identity. **Added 2026-09-20 (E1, spec §6.4 / §15 item 6).** |
25
25
  | `coverage/` | rehearsal debt | What is not written up yet, read in one place: per session, the unwritten stretch since its last claim in `coverage.jsonl`. The pacer's third ask (pieces and time), the one rule for what a session owes (retention, the next-session write-up), lapse after fourteen days of use (two until 2026-10-10), the handoff pointer's "how current", and one row per stretch per state. Changes nothing about how pieces are claimed. **Added 2026-09-30.** |
@@ -91,13 +91,15 @@ importers are pinned (`split-parts.test.ts`).
91
91
  ## Rulings — 2026-08-25 (check-in + adversarial review, all owner-ratified)
92
92
 
93
93
  Contracts are read subject to these; where a contract still says PROPOSED on a listed
94
- item, this section is the newer law.
94
+ item, this section is newer than the contracts, and like them open to discussion
95
+ (constitution line 13).
95
96
 
96
97
  1. `associate/` stays a module; observer is a mode (`docs/observer-mode.md`); `encode/`
97
98
  stays separate; `dashboard/` added as an adapter (constitution line 16, ratified).
98
99
  2. Physics: pressure-accumulator revision (§5.6 rewritten — field on target, one credited
99
100
  challenge/day, force = strength × sal, novelty at encoding only); nothing born into
100
- identity, N = 3 promotion at consolidation (§5.3 rewritten); bands 4→3 and one strength
101
+ identity, promotion through the core lanes (physics/CONTRACT.md §5.3, rewritten
102
+ 2026-09-26); bands 4→3 and one strength
101
103
  number both settled; decay is a three-way (flat/exponential/power-law) decided by
102
104
  replay; H = 90 is a TUNABLE default, not an owner ruling.
103
105
  3. Settled drops: identity-promotion surface, `protected.add` queue, model-seat pins,
@@ -112,7 +114,8 @@ item, this section is the newer law.
112
114
 
113
115
  Owner-decided (2026-08-25, bansai `docs/DECISIONS.md`): experiencer authorship with
114
116
  crash fallback; librarian-as-physics with zero standing model calls; strength-weighted
115
- revision (no ledger subsystem); only physics forgets; the three storage boxes;
117
+ revision (no ledger subsystem); only physics forgets (no model deletes; for now, a model
118
+ may archive, with a record and an undo); the three storage boxes;
116
119
  birth-by-mention entities; Amendment 15. Anything a CONTRACT drops beyond that list is
117
120
  marked **PROPOSED** and waits for the owner's check-in.
118
121
 
@@ -120,4 +123,8 @@ marked **PROPOSED** and waits for the owner's check-in.
120
123
  prose box is gone and the memory IS the row. That is the same owner, revising his own
121
124
  default — "going forward by 'readable' we mean if someone can view them" (2026-09-16),
122
125
  and `docs/storage-spec-2026-09-16.md` §15 item 9, "everything lives in the database for
123
- now; markdown is an export". The other seven entries above are untouched.*
126
+ now; markdown is an export". The other seven entries above were untouched by that change.*
127
+
128
+ *Everything here guides the work; it doesn't limit it. Anything here, RESOLVED items
129
+ included, can be raised for discussion at any time and revised when there's a better way
130
+ (constitution line 13).*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "counterparts",
3
- "version": "0.3.28",
3
+ "version": "0.3.29",
4
4
  "license": "MIT",
5
5
  "description": "Memory that turns AI tools into counterparts - a local-first, human-memory-modeled memory layer for AI.",
6
6
  "repository": {
@@ -1,5 +1,7 @@
1
1
  # `adapters/claude-code/` — CONTRACT
2
2
 
3
+ *This contract guides the work; it doesn't limit it. Anything here, RESOLVED items included, can be raised for discussion at any time and revised when there's a better way (constitution line 13).*
4
+
3
5
  ## 1. Purpose
4
6
 
5
7
  The launch adapter: wake injection at session start, the end-of-session write, and crash
@@ -147,7 +149,7 @@ credential — belongs here, discovered at runtime, never assumed by the core.
147
149
  2026-09-24 there are no keys at all (§1a), so there is nothing to rotate and no credential
148
150
  source to configure. (Until then credentials came from one configured source the package
149
151
  owned, never an inherited shell environment — scar §2.18.)
150
- - **Model-seat pins are dropped.** **PROPOSED** — owner call at check-in. Constitution
152
+ - **Model-seat pins are dropped.** **Decided, for now** (owner, 2026-10-20; settled by module-map Rulings 3 of 2026-08-25). Constitution
151
153
  line 2 says which seat runs which job is a design choice, never doctrine, and the model
152
154
  lineup will have moved. What is **kept** is the bake-off *method* (earned-mechanism #20:
153
155
  real archived inputs through the real path, blind-judged, including the losing tier as a
@@ -16,6 +16,8 @@ import {
16
16
  import type { DreamingSetting } from "../../core/dream/index.js";
17
17
  // The page's own reader, so this line cannot drift from what the wake prints.
18
18
  import { clearedMarker, findPageRow, readSelfPage } from "../../core/self/page.js";
19
+ import { coreSupport, pageTrace } from "../../core/self/measures.js";
20
+ import type { CoreSupportRow } from "../../core/self/measures.js";
19
21
  import {
20
22
  dayBefore,
21
23
  hasDayBefore,
@@ -266,6 +268,75 @@ export function selfPageFindings(store: Store): Finding[] {
266
268
  ];
267
269
  }
268
270
 
271
+ /**
272
+ * WHAT THE PAGE'S CLAIMS REST ON (2026-10-20, an experiment; `self/measures.ts`).
273
+ * A reading, always green: its claims (sentences), the memories it cites and
274
+ * where they stand now, and the claims with no memory behind them — hypotheses,
275
+ * shown as such, never removed. A page from before cites were kept with it says
276
+ * so rather than reading as all hypotheses. Silent with no page: the Self page
277
+ * line already says why.
278
+ */
279
+ export function selfPageTraceFindings(store: Store): Finding[] {
280
+ const page = readSelfPage(store);
281
+ if (page === null) return [];
282
+ const t = pageTrace(store, page);
283
+ const n = (k: number, one: string, many: string): string => `${String(k)} ${k === 1 ? one : many}`;
284
+ const cited =
285
+ t.source === "none"
286
+ ? `no cites kept with it (written by ${page.by ?? "an unrecorded door"})`
287
+ : `${t.source === "reflection" ? "its reflection's record cites" : "cites"} ${n(t.cites, "memory", "memories")}, ${String(t.live)} live, ${String(t.archivedOrMissing)} archived or missing`;
288
+ const perClaim =
289
+ t.uncited === null
290
+ ? t.source === "none"
291
+ ? ""
292
+ : "; cites were not kept per claim for this version"
293
+ : `; ${n(t.uncited, "claim", "claims")} with no memory behind ${t.uncited === 1 ? "it" : "them"}`;
294
+ return [
295
+ finding(
296
+ "self-page-trace",
297
+ "green",
298
+ "Self page claims",
299
+ `${n(t.claims, "claim", "claims")}; ${cited}${perClaim}`,
300
+ "",
301
+ { claims: t.claims, source: t.source, cites: t.cites, live: t.live, archivedOrMissing: t.archivedOrMissing, uncited: t.uncited },
302
+ ),
303
+ ];
304
+ }
305
+
306
+ /**
307
+ * WHAT STANDS BEHIND THE CORE (2026-10-20, an experiment; `self/measures.ts`).
308
+ * A reading, always green: nothing promotes or demotes on it. "One episode
309
+ * behind it" is an element whose returns and derivations all sit on one lived
310
+ * day; links are counted beside them and widen no span (review of #550). Reads every live row and every edge, so it stays out of the
311
+ * session-start reading.
312
+ */
313
+ export function coreSupportFindings(store: Store): Finding[] {
314
+ const s = coreSupport(store);
315
+ const els = s.elements;
316
+ if (els.length === 0) return [finding("core-support", "green", "Core", "no elements yet", "", { elements: 0 })];
317
+ const range = (pick: (e: CoreSupportRow) => number): string => {
318
+ const v = els.map(pick);
319
+ const lo = Math.min(...v);
320
+ const hi = Math.max(...v);
321
+ return lo === hi ? String(lo) : `${String(lo)}–${String(hi)}`;
322
+ };
323
+ return [
324
+ finding(
325
+ "core-support",
326
+ "green",
327
+ "Core",
328
+ `${String(els.length)} ${els.length === 1 ? "element" : "elements"}; ${String(s.oneEpisode)} with one episode behind ${s.oneEpisode === 1 ? "it" : "them"}; ` +
329
+ `span ${range((e) => e.days)} ${range((e) => e.days) === "1" ? "day" : "days"}, ${range((e) => e.contexts)} ${range((e) => e.contexts) === "1" ? "context" : "contexts"}; returns ${range((e) => e.returns)}, derivations ${range((e) => e.derivations)}, links ${range((e) => e.links)}`,
330
+ "",
331
+ {
332
+ elements: els.length,
333
+ oneEpisode: s.oneEpisode,
334
+ rows: els.map((e) => `${e.id}:${String(e.returns)}/${String(e.derivations)}/${String(e.links)}/${String(e.days)}d/${String(e.contexts)}c`).join(" "),
335
+ },
336
+ ),
337
+ ];
338
+ }
339
+
269
340
  /** How doctor names each rung the last wake printed the page on (`self/briefing.ts#PageRung`). */
270
341
  const PAGE_RUNG_WORDS: Readonly<Record<string, string>> = {
271
342
  whole: "it whole",
@@ -134,6 +134,8 @@ import {
134
134
  } from "./doctor-upgrades.js";
135
135
  import {
136
136
  selfPageFindings,
137
+ selfPageTraceFindings,
138
+ coreSupportFindings,
137
139
  pageWriterFindings,
138
140
  dreamingFindings,
139
141
  nightRunFindings,
@@ -168,6 +170,8 @@ export {
168
170
  dreamingFindings,
169
171
  nightRunFindings,
170
172
  selfPageFindings,
173
+ selfPageTraceFindings,
174
+ coreSupportFindings,
171
175
  pageWriterFindings,
172
176
  PAGE_WRITER_STALE_DAYS,
173
177
  } from "./doctor-self-page.js";
@@ -3358,6 +3362,11 @@ export function doctorFindings(input: DoctorInput): Finding[] {
3358
3362
  // line would grade a default nobody chose.
3359
3363
  ...(unread ? [] : [["snapshot", (): Finding[] => snapshotFindings(input, store)] as const]),
3360
3364
  ["self-page", () => selfPageFindings(store)],
3365
+ // 2026-10-20, two readings of the self (an experiment): the page's claims
3366
+ // and what they rest on, and what stands behind each core element. Never
3367
+ // amber. The second reads every live row and edge: not at session start.
3368
+ ["self-page-trace", () => selfPageTraceFindings(store)],
3369
+ ...(input.budgetMs !== undefined ? [] : [["core-support", (): Finding[] => coreSupportFindings(store)] as const]),
3361
3370
  ["page-writer", () => pageWriterFindings(store, input.config)],
3362
3371
  // C2's one line, `Write-ups` since 2026-09-30. Not in the session-start
3363
3372
  // reading: it is never red, which is all that notice prints, and it reads
@@ -89,6 +89,8 @@ export {
89
89
  NIGHT_MCP_SERVER,
90
90
  NIGHT_RUN_ENV,
91
91
  NIGHT_TOOLS,
92
+ claudeCodeSeat,
93
+ hostToolName,
92
94
  kindValue,
93
95
  nightChildrenTimeoutMs,
94
96
  nightMaxTurns,
@@ -102,7 +104,7 @@ export {
102
104
  readNightSpills,
103
105
  runNight,
104
106
  } from "./night-run.js";
105
- export type { NightChild, NightChildPlan, NightKind, NightRunInput, NightRunnerPlan, NightStarter } from "./night-run.js";
107
+ export type { ClaudeCodeAnswer, ClaudeCodeSeatInput, NightAnswer, NightChild, NightChildPlan, NightKind, NightRunInput, NightRunnerPlan, NightStarter } from "./night-run.js";
106
108
 
107
109
  export { DATA_DIR_ENV, NIGHT_CHILD_ENV, SCOPE_ENV, SESSION_ENV, WATCHDOG_ENV, planSpawn, spawnDetached } from "../spawn.js";
108
110
  export type { PlanInput, SpawnOutcome, SpawnPlan, SpawnRefusal, Spawner } from "../spawn.js";
@@ -47,8 +47,8 @@
47
47
  import { Buffer } from "node:buffer";
48
48
  import { randomBytes } from "node:crypto";
49
49
 
50
- import { NIGHT_WRITE_UP_EVENT } from "../../core/counterpart.js";
51
- import type { Counterpart, CounterpartEvent } from "../../core/counterpart.js";
50
+ import { NIGHT_WRITE_UP_EVENT, seatAsk } from "../../core/counterpart.js";
51
+ import type { Counterpart, CounterpartEvent, Seat } from "../../core/counterpart.js";
52
52
  import { calendarDate } from "../../core/self/index.js";
53
53
  import { TUNABLES } from "../config.js";
54
54
  import type { AdapterConfig } from "../config.js";
@@ -72,7 +72,6 @@ import {
72
72
  } from "../sessions.js";
73
73
  import type { WriteUpProgress } from "../sessions.js";
74
74
  import type { HeldSession } from "../../core/remember/index.js";
75
- import type { ChildPlan, ChildResult } from "./child.js";
76
75
 
77
76
  /** The one tool the catch-up child may call, as the host names it. */
78
77
  export const CATCH_UP_TOOLS = ["mcp__counterparts__session_end"] as const;
@@ -537,10 +536,9 @@ export interface CatchUpInput {
537
536
  /** Where the runners' records are filed: the launching session's directory,
538
537
  * or the store's own for the command. */
539
538
  readonly scope: string;
540
- /** Decides one child (`night-run.ts#planNightChild`, with this phase's tools,
541
- * turns and watchdog). */
542
- readonly plan: (input: { prompt: string; runner: string }) => ChildPlan & { readonly ok: boolean; readonly reason: string };
543
- readonly start: (plan: ChildPlan) => Promise<ChildResult>;
539
+ /** Who answers each batch's ask (`core/seat.ts`, 2026-10-20): Claude Code's
540
+ * own (`night-run.ts#claudeCodeSeat`) for the night and the command. */
541
+ readonly seat: Seat;
544
542
  readonly now: () => number;
545
543
  /** The run's sanity ceiling, parts: the night's `NIGHT_WRITE_UP_PARTS`,
546
544
  * the command's `CATCH_UP_COMMAND_PARTS`; absent, the night's. */
@@ -556,19 +554,20 @@ export interface CatchUpInput {
556
554
 
557
555
  /** One child, started and waited on: what became of it. */
558
556
  async function runChild(input: CatchUpInput, plan: CatchUpPlan, prompt: string): Promise<{ state: CatchUpReport["state"]; code: number | null }> {
559
- const child = input.plan({ prompt, runner: plan.runner });
560
- if (!child.ok) return { state: "could-not-start", code: null };
557
+ // THE ASK (2026-10-20): the batch's prompt, filed under its runner, with
558
+ // the write-up's own turns and watchdog.
559
+ const ask = seatAsk("catch-up", {
560
+ prompt,
561
+ run: input.run,
562
+ session: plan.runner,
563
+ scope: input.scope,
564
+ limits: { turns: TUNABLES.NIGHT_WRITE_UP_MAX_TURNS, ms: TUNABLES.NIGHT_WRITE_UP_MS },
565
+ });
561
566
  try {
562
- const result = await input.start(child);
563
- const state =
564
- result.spawnCode !== undefined || (result.code === null && !result.timedOut && result.error !== null)
565
- ? "could-not-start"
566
- : result.timedOut
567
- ? "timed-out"
568
- : result.code === 0
569
- ? "done"
570
- : "failed";
571
- return { state, code: result.code };
567
+ const answer = await input.seat.answer(ask);
568
+ if (answer.refused !== null) return { state: "could-not-start", code: null };
569
+ const state = !answer.started ? "could-not-start" : answer.timedOut ? "timed-out" : answer.code === 0 ? "done" : "failed";
570
+ return { state, code: answer.code };
572
571
  } catch {
573
572
  return { state: "could-not-start", code: null };
574
573
  }