shipmates 0.3.0 → 0.5.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.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GACvB,SAAS,GAAG,mBAAmB,GAAG,qBAAqB,GAAG,MAAM,CAAC;AAClE,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,eAAe,CAAC;AACzD,4FAA4F;AAC5F,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AACzE,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,YAAY,GAAG,WAAW,CAAC;AAEhF,MAAM,WAAW,QAAQ;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,iFAAiF;IACjF,IAAI,EAAE,OAAO,CAAC;IACd,yDAAyD;IACzD,IAAI,EAAE,OAAO,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,2FAA2F;AAC3F,MAAM,WAAW,KAAK;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,GAAG,IAAI,C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B,GAAG,SAAS,CAAC;AAmEhD,MAAM,OAAO,cAAe,SAAQ,KAAK;IAG9B;IACA;IAHV,YACC,OAAe,EACN,IAAY,EACZ,OAAiB;QAE1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHN,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAU;QAG1B,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC9B,CAAC;CACD"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAyFA;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAgHhD,MAAM,OAAO,cAAe,SAAQ,KAAK;IAG9B;IACA;IAHV,YACC,OAAe,EACN,IAAY,EACZ,OAAiB;QAE1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHN,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAU;QAG1B,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC9B,CAAC;CACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shipmates",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Sessions that know about each other: presence, roles, messages with provenance, questions and an attention inbox for agent sessions (pi and friends), on SQLite",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
package/src/cli-run.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import {Shipmates} from './shipmates.js';
2
2
  import {readTail} from './tail.js';
3
+ import {formatStatusFacts} from './facts.js';
3
4
  import {ShipmatesError, type AttentionItem, type Presence} from './types.js';
4
5
 
5
6
  export interface CliIo {
@@ -58,7 +59,8 @@ function speaker(
58
59
  return {kind: 'script'};
59
60
  }
60
61
 
61
- function presenceLine(p: Presence): string {
62
+ /** With `k`, the derived lines beside the status (D41): the human reads them too. */
63
+ function presenceLine(p: Presence, k?: Shipmates): string {
62
64
  const bits = [
63
65
  p.roles.join(',') || '(no role)',
64
66
  p.state,
@@ -66,7 +68,10 @@ function presenceLine(p: Presence): string {
66
68
  p.branch,
67
69
  p.status ? `status: ${p.status}` : null,
68
70
  ].filter(Boolean);
69
- return `${p.sessionFile}\n ${bits.join(' · ')}`;
71
+ const facts = k
72
+ ? formatStatusFacts(k.statusFacts(p.sessionFile, p.status))
73
+ : [];
74
+ return `${p.sessionFile}\n ${bits.join(' · ')}${facts.map((l) => `\n ${l}`).join('')}`;
70
75
  }
71
76
 
72
77
  function itemLine(i: AttentionItem): string {
@@ -110,7 +115,7 @@ export function runCli(argv: string[], io: CliIo): number {
110
115
  else
111
116
  io.stdout(
112
117
  list.length
113
- ? list.map(presenceLine).join('\n') + '\n'
118
+ ? list.map((p) => presenceLine(p, k)).join('\n') + '\n'
114
119
  : 'No live sessions.\n',
115
120
  );
116
121
  return 0;
@@ -126,7 +131,12 @@ export function runCli(argv: string[], io: CliIo): number {
126
131
  const tail = readTail(r.session);
127
132
  io.stdout(
128
133
  [
129
- p ? presenceLine(p) + (p.live ? '' : ' (GONE)') : r.session,
134
+ p
135
+ ? presenceLine(p, k) + (p.live ? '' : ' (GONE)')
136
+ : [
137
+ r.session,
138
+ ...formatStatusFacts(k.statusFacts(r.session, null)),
139
+ ].join('\n '),
130
140
  qs.length
131
141
  ? 'open questions:\n' +
132
142
  qs
package/src/delivery.ts CHANGED
@@ -30,6 +30,13 @@ export interface SessionView {
30
30
  * from the inbox (or a host such as wherever) sat there until the human also
31
31
  * typed into the session, which they had no reason to do. Still held while the
32
32
  * human types into the session (it joins that run) or with waking off.
33
+ *
34
+ * A running session gets the human's message at the next turn end, as if it
35
+ * were urgent (D41): `human_ask` with `blocking: false` tells the agent to go
36
+ * on working and that the answer arrives as a message, and at `at-settle` it
37
+ * arrived only once that work was over. On 2026-11-28 an answer given at 11:23
38
+ * was still pending an hour later, in one long run, while the session's status
39
+ * said, truthfully for what it knew, that it was waiting for the human.
33
40
  */
34
41
  export type DeliveryPlan =
35
42
  'at-settle' | 'at-turn-end' | 'wake' | 'hold-for-human';
@@ -40,7 +47,7 @@ export function planDelivery(
40
47
  ): DeliveryPlan {
41
48
  if (view.phase === 'running') {
42
49
  if (view.uiPrompt) return 'at-turn-end';
43
- return message.urgent ? 'at-turn-end' : 'at-settle';
50
+ return message.urgent || message.fromHuman ? 'at-turn-end' : 'at-settle';
44
51
  }
45
52
  if (view.editorBusy || !view.wake) return 'hold-for-human';
46
53
  if (view.declared === 'waiting-for-human' && !message.fromHuman)
package/src/facts.ts ADDED
@@ -0,0 +1,54 @@
1
+ import type {ItemStatus, StatusFacts, StatusRef} from './types.js';
2
+
3
+ /** A time as readers on any machine read it: UTC, to the minute. */
4
+ function at(t: number | null): string {
5
+ return t === null ? '' : ` ${new Date(t).toISOString().slice(0, 16)}Z`;
6
+ }
7
+
8
+ /**
9
+ * One id a status line names that is no longer open (D41), in words that say
10
+ * whether the asking session has the answer yet. "Answered" alone misleads
11
+ * the other way: on 2026-11-28 the asker had not read it, and was not acting
12
+ * on it.
13
+ */
14
+ export function formatStatusRef(ref: StatusRef): string {
15
+ if (ref.state === 'unknown')
16
+ return `${ref.id}: no such ${ref.kind === 'item' ? 'inbox item' : 'question'} (mistyped, or pruned)`;
17
+ if (ref.kind === 'question') return `${ref.id} ${ref.state}${at(ref.at)}`;
18
+ if (ref.state === 'withdrawn') return `${ref.id} withdrawn${at(ref.at)}`;
19
+ const who = ref.own ? 'this session' : 'the session that asked';
20
+ return `${ref.id} answered by the human${at(ref.at)}${ref.channel ? ` on ${ref.channel}` : ''}, ${ref.answerPending ? `answer not yet delivered to ${who}` : `answer read by ${who}`}`;
21
+ }
22
+
23
+ /** An outstanding item (D41): open, or answered and not yet read by its session. */
24
+ export function formatItemFact(i: ItemStatus): string {
25
+ if (i.state === 'open')
26
+ return `${i.id} open${i.blocking ? ' (blocking)' : ''}, asked${at(i.createdAt)}`;
27
+ return `${i.id} answered${at(i.finishedAt)}${i.answerChannel ? ` on ${i.answerChannel}` : ''}, answer not yet delivered`;
28
+ }
29
+
30
+ /**
31
+ * The derived facts as lines for a presence block (D41): what the human owes
32
+ * this session, and the ids its status names that no longer hold. Empty when
33
+ * there is nothing to say.
34
+ */
35
+ export function formatStatusFacts(f: StatusFacts): string[] {
36
+ const lines: string[] = [];
37
+ if (f.stale.length) {
38
+ // The warning only where the status may say the opposite of the facts: an
39
+ // answer its session may not have read, or an id shipmates does not know. A
40
+ // status naming an answer it has read, or its own withdrawal, may well be
41
+ // up to date, and would carry the warning on every list.
42
+ const lag = f.stale.some(
43
+ (r) =>
44
+ r.state === 'unknown' ||
45
+ (r.state === 'answered' && (r.kind === 'question' || r.answerPending)),
46
+ );
47
+ lines.push(
48
+ `status names: ${f.stale.map(formatStatusRef).join('; ')}${lag ? ' (the status is its own words and may lag)' : ''}`,
49
+ );
50
+ }
51
+ if (f.items.length)
52
+ lines.push(`its inbox items: ${f.items.map(formatItemFact).join('; ')}`);
53
+ return lines;
54
+ }
package/src/index.ts CHANGED
@@ -23,6 +23,7 @@ export * from './types.js';
23
23
  export {readTail} from './tail.js';
24
24
  export type {Tail, TailMessage, TailOptions} from './tail.js';
25
25
  export {planDelivery} from './delivery.js';
26
+ export {formatItemFact, formatStatusFacts, formatStatusRef} from './facts.js';
26
27
  export type {SessionView, DeliveryPlan} from './delivery.js';
27
28
  export {watchChanges} from './watch.js';
28
29
  export {
package/src/shipmates.ts CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  ShipmatesError,
6
6
  type ArchiveMark,
7
7
  type AttentionItem,
8
+ type ItemStatus,
8
9
  type Message,
9
10
  type Ownership,
10
11
  type SpawnVia,
@@ -13,7 +14,10 @@ import {
13
14
  type Presence,
14
15
  type Question,
15
16
  type Relay,
17
+ type SessionSetting,
16
18
  type SessionState,
19
+ type StatusFacts,
20
+ type StatusRef,
17
21
  } from './types.js';
18
22
  import {newId} from './ids.js';
19
23
 
@@ -37,7 +41,14 @@ export interface PresencePatch {
37
41
  waitingOn?: string | null;
38
42
  branch?: string | null;
39
43
  cwd?: string | null;
44
+ /** Kept per transcript file, across unregister and register (D40). */
40
45
  wake?: boolean;
46
+ /**
47
+ * The session declared `waiting-for-human` (ADR 0006) and has not run since.
48
+ * Kept per transcript file like `wake`; `register` restores the state from it
49
+ * (D40). It does not set `state`: pass both.
50
+ */
51
+ declaredWaiting?: boolean;
41
52
  }
42
53
 
43
54
  export interface ListFilter {
@@ -56,7 +67,9 @@ type PresenceRow = {
56
67
  status: string | null;
57
68
  refs: string | null;
58
69
  waiting_on: string | null;
59
- wake: number;
70
+ /** From session_setting (D40), not presence's own unused column. */
71
+ s_wake: number;
72
+ s_declared_waiting: number;
60
73
  pid: number;
61
74
  start_time: string | null;
62
75
  boot_id: string | null;
@@ -65,6 +78,24 @@ type PresenceRow = {
65
78
  settled_at: number | null;
66
79
  };
67
80
 
81
+ type SettingRow = {
82
+ session_file: string;
83
+ wake: number;
84
+ declared_waiting: number;
85
+ updated_at: number;
86
+ };
87
+
88
+ const toSetting = (r: SettingRow): SessionSetting => ({
89
+ sessionFile: r.session_file,
90
+ wake: r.wake === 1,
91
+ declaredWaiting: r.declared_waiting === 1,
92
+ updatedAt: r.updated_at,
93
+ });
94
+
95
+ /** Presence with the session's own settings (D40); a session with no row has the defaults. */
96
+ const PRESENCE_SELECT = `SELECT p.*, COALESCE(s.wake, 1) AS s_wake, COALESCE(s.declared_waiting, 0) AS s_declared_waiting
97
+ FROM presence p LEFT JOIN session_setting s ON s.session_file = p.session_file`;
98
+
68
99
  /** D14: message text is short; content stays in git and messages point at it. */
69
100
  const DAY = 86_400_000;
70
101
 
@@ -176,8 +207,12 @@ type QuestionRow = {
176
207
  answer_relay: string | null;
177
208
  answered_by: string | null;
178
209
  created_at: number;
210
+ finished_at: number | null;
179
211
  };
180
212
 
213
+ /** An `h_` or `q_` id as `newId` makes them: the prefix and 8 base64url characters. */
214
+ const REF_ID = /(?<![\w-])([hq])_([A-Za-z0-9_-]{8})(?![\w-])/g;
215
+
181
216
  function toQuestion(r: QuestionRow): Question {
182
217
  return {
183
218
  id: r.id,
@@ -192,6 +227,7 @@ function toQuestion(r: QuestionRow): Question {
192
227
  answerRelay: r.answer_relay ? (JSON.parse(r.answer_relay) as Relay) : null,
193
228
  answeredBy: r.answered_by,
194
229
  createdAt: r.created_at,
230
+ finishedAt: r.finished_at,
195
231
  };
196
232
  }
197
233
 
@@ -298,22 +334,32 @@ export class Shipmates {
298
334
  const me = this.probe.self();
299
335
  const t = this.now();
300
336
  this.tx(() => {
337
+ // A session that declared it waits for the human still does after an
338
+ // unload or a resume: it has not run since (D40).
339
+ const declared = this.db
340
+ .prepare(
341
+ `SELECT declared_waiting FROM session_setting WHERE session_file = ?`,
342
+ )
343
+ .get(input.sessionFile) as {declared_waiting: number} | undefined;
344
+ const state: SessionState =
345
+ declared?.declared_waiting === 1 ? 'waiting-for-human' : 'idle';
301
346
  this.db
302
347
  .prepare(
303
348
  `INSERT INTO presence(session_file, session_id, cwd, branch, state, pid, start_time, boot_id, host, registered_at, updated_at)
304
- VALUES(?, ?, ?, ?, 'idle', ?, ?, ?, ?, ?, ?)
349
+ VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
305
350
  ON CONFLICT(session_file) DO UPDATE SET
306
351
  session_id = excluded.session_id, cwd = excluded.cwd,
307
352
  branch = COALESCE(excluded.branch, presence.branch),
308
353
  pid = excluded.pid, start_time = excluded.start_time, boot_id = excluded.boot_id,
309
354
  host = excluded.host, updated_at = excluded.updated_at,
310
- state = CASE WHEN presence.pid = excluded.pid THEN presence.state ELSE 'idle' END`,
355
+ state = CASE WHEN presence.pid = excluded.pid THEN presence.state ELSE excluded.state END`,
311
356
  )
312
357
  .run(
313
358
  input.sessionFile,
314
359
  input.sessionId ?? null,
315
360
  input.cwd ?? null,
316
361
  input.branch ?? null,
362
+ state,
317
363
  me.pid,
318
364
  me.startTime,
319
365
  me.bootId,
@@ -342,17 +388,53 @@ export class Shipmates {
342
388
  if (patch.waitingOn !== undefined) put('waiting_on', patch.waitingOn);
343
389
  if (patch.branch !== undefined) put('branch', patch.branch);
344
390
  if (patch.cwd !== undefined) put('cwd', patch.cwd);
345
- if (patch.wake !== undefined) put('wake', patch.wake ? 1 : 0);
346
391
  put('updated_at', this.now());
392
+ const setting =
393
+ patch.wake !== undefined || patch.declaredWaiting !== undefined;
347
394
  this.tx(() => {
348
395
  this.db
349
396
  .prepare(
350
397
  `UPDATE presence SET ${sets.join(', ')} WHERE session_file = ?`,
351
398
  )
352
399
  .run(...vals, sessionFile);
400
+ if (setting) this.writeSetting(sessionFile, patch);
353
401
  });
354
402
  }
355
403
 
404
+ /**
405
+ * D40: the session's own choices, by transcript file. A row exists only while
406
+ * one differs from the default, so the table holds the few sessions that set
407
+ * something. Called inside a write.
408
+ */
409
+ private writeSetting(
410
+ sessionFile: string,
411
+ patch: {wake?: boolean; declaredWaiting?: boolean},
412
+ ): void {
413
+ const bit = (v: boolean | undefined) =>
414
+ v === undefined ? null : v ? 1 : 0;
415
+ this.db
416
+ .prepare(
417
+ `INSERT INTO session_setting(session_file, wake, declared_waiting, updated_at)
418
+ VALUES(?, COALESCE(?, 1), COALESCE(?, 0), ?)
419
+ ON CONFLICT(session_file) DO UPDATE SET
420
+ wake = COALESCE(?, wake), declared_waiting = COALESCE(?, declared_waiting),
421
+ updated_at = excluded.updated_at`,
422
+ )
423
+ .run(
424
+ sessionFile,
425
+ bit(patch.wake),
426
+ bit(patch.declaredWaiting),
427
+ this.now(),
428
+ bit(patch.wake),
429
+ bit(patch.declaredWaiting),
430
+ );
431
+ this.db
432
+ .prepare(
433
+ `DELETE FROM session_setting WHERE session_file = ? AND wake = 1 AND declared_waiting = 0`,
434
+ )
435
+ .run(sessionFile);
436
+ }
437
+
356
438
  unregister(sessionFile: string): void {
357
439
  const me = this.probe.self();
358
440
  this.tx(() => {
@@ -364,9 +446,34 @@ export class Shipmates {
364
446
  });
365
447
  }
366
448
 
449
+ /**
450
+ * D40: every session whose own settings differ from the defaults, live or
451
+ * not, most recently changed first. A host uses it to show what a session
452
+ * that is not loaded chose (wherever's sidebar keeps "waiting for the human"
453
+ * for an unloaded session that declared it, which `list()` cannot show).
454
+ * Rows exist only for non-defaults, so this is the few that set something.
455
+ */
456
+ settings(): SessionSetting[] {
457
+ return (
458
+ this.cached(
459
+ `SELECT * FROM session_setting ORDER BY updated_at DESC, session_file`,
460
+ ).all() as SettingRow[]
461
+ ).map(toSetting);
462
+ }
463
+
464
+ /** D40: one session's settings; the defaults (`updatedAt` null) when it set none. */
465
+ setting(sessionFile: string): SessionSetting {
466
+ const row = this.cached(
467
+ `SELECT * FROM session_setting WHERE session_file = ?`,
468
+ ).get(sessionFile) as SettingRow | undefined;
469
+ return row
470
+ ? toSetting(row)
471
+ : {sessionFile, wake: true, declaredWaiting: false, updatedAt: null};
472
+ }
473
+
367
474
  presence(sessionFile: string): Presence | null {
368
475
  const row = this.db
369
- .prepare(`SELECT * FROM presence WHERE session_file = ?`)
476
+ .prepare(`${PRESENCE_SELECT} WHERE p.session_file = ?`)
370
477
  .get(sessionFile) as PresenceRow | undefined;
371
478
  return row ? this.toPresence(row) : null;
372
479
  }
@@ -377,7 +484,7 @@ export class Shipmates {
377
484
 
378
485
  list(filter: ListFilter = {}): Presence[] {
379
486
  const rows = this.db
380
- .prepare(`SELECT * FROM presence ORDER BY updated_at DESC`)
487
+ .prepare(`${PRESENCE_SELECT} ORDER BY p.updated_at DESC`)
381
488
  .all() as PresenceRow[];
382
489
  return rows
383
490
  .map((r) => this.toPresence(r))
@@ -1050,6 +1157,93 @@ export class Shipmates {
1050
1157
  return rows.map(toItem);
1051
1158
  }
1052
1159
 
1160
+ /**
1161
+ * Where an item's answer stands (D41): the item, and whether the human's
1162
+ * answer is still pending to the session that raised it.
1163
+ */
1164
+ itemStatus(id: string): ItemStatus | null {
1165
+ const item = this.item(id);
1166
+ return item ? {...item, answerPending: this.answerPending(item)} : null;
1167
+ }
1168
+
1169
+ /**
1170
+ * What the human owes this session, and what it has not read yet (D41): the
1171
+ * items it raised that are open, and the answered ones whose answer is still
1172
+ * pending to it. Derived, so a reader can trust it over a status line.
1173
+ */
1174
+ outstandingItems(sessionFile: string): ItemStatus[] {
1175
+ // Both halves use an index (item_open, message_pending): session_list asks
1176
+ // this for every live session.
1177
+ const open = this.cached(
1178
+ `SELECT * FROM item WHERE state = 'open' AND session_file = ?`,
1179
+ ).all(sessionFile) as ItemRow[];
1180
+ const unread = this.cached(
1181
+ `SELECT item.* FROM item JOIN message ON message.item_id = item.id
1182
+ WHERE message.state = 'pending' AND message.to_kind = 'session' AND message.to_target = ?
1183
+ AND message.kind = 'answer' AND item.session_file = ?`,
1184
+ ).all(sessionFile, sessionFile) as ItemRow[];
1185
+ // Disjoint: an open item has no answer yet.
1186
+ return [
1187
+ ...open.map((r) => ({...toItem(r), answerPending: false})),
1188
+ ...unread.map((r) => ({...toItem(r), answerPending: true})),
1189
+ ].sort((a, b) => a.createdAt - b.createdAt);
1190
+ }
1191
+
1192
+ /**
1193
+ * The derived facts beside a session's status line (D41): its outstanding
1194
+ * items, and the `h_`/`q_` ids its status names that are no longer open. A
1195
+ * status is the session's own words: on 2026-11-28 one still said "pending
1196
+ * human h_..." an hour after the human answered, because the answer had not
1197
+ * reached it, and a reader told the human they still owed an answer.
1198
+ */
1199
+ statusFacts(sessionFile: string, status?: string | null): StatusFacts {
1200
+ const text =
1201
+ status === undefined
1202
+ ? (this.presence(sessionFile)?.status ?? null)
1203
+ : status;
1204
+ const stale: StatusRef[] = [];
1205
+ const named = new Set<string>();
1206
+ for (const m of text?.matchAll(REF_ID) ?? []) {
1207
+ const id = m[0];
1208
+ if (named.has(id)) continue;
1209
+ named.add(id);
1210
+ const ref =
1211
+ m[1] === 'h' ? this.itemRef(id, sessionFile) : this.questionRef(id);
1212
+ if (ref) stale.push(ref);
1213
+ }
1214
+ return {items: this.outstandingItems(sessionFile), stale};
1215
+ }
1216
+
1217
+ private itemRef(id: string, sessionFile: string): StatusRef | null {
1218
+ const i = this.itemStatus(id);
1219
+ if (!i) return {kind: 'item', id, state: 'unknown'};
1220
+ if (i.state === 'open') return null;
1221
+ return {
1222
+ kind: 'item',
1223
+ id,
1224
+ state: i.state,
1225
+ at: i.finishedAt,
1226
+ channel: i.answerChannel,
1227
+ own: i.session === sessionFile,
1228
+ answerPending: i.answerPending,
1229
+ };
1230
+ }
1231
+
1232
+ private questionRef(id: string): StatusRef | null {
1233
+ const q = this.question(id);
1234
+ if (!q) return {kind: 'question', id, state: 'unknown'};
1235
+ if (q.state === 'open') return null;
1236
+ return {kind: 'question', id, state: q.state, at: q.finishedAt};
1237
+ }
1238
+
1239
+ private answerPending(item: AttentionItem): boolean {
1240
+ if (item.state !== 'answered') return false;
1241
+ return !!this.cached(
1242
+ `SELECT 1 AS x FROM message WHERE state = 'pending' AND to_kind = 'session' AND to_target = ?
1243
+ AND kind = 'answer' AND item_id = ?`,
1244
+ ).get(item.session, item.id);
1245
+ }
1246
+
1053
1247
  /**
1054
1248
  * Record a turn a human really typed into this session (ADR 0003): TUI input,
1055
1249
  * or a host's `shipmates:human-input` mark. Never call this for agent text.
@@ -1454,21 +1648,32 @@ export class Shipmates {
1454
1648
  * arrived after their last stop, and are not archived. One cached query,
1455
1649
  * since every session's poller asks on every change. Measured: 3 µs for a
1456
1650
  * session that owns nothing, 42 µs with 5 children and one to wake, against
1457
- * about 500 µs as separate reads per child. Liveness is left to the caller:
1651
+ * about 500 µs as separate reads per child; with the settings join (D40),
1652
+ * 1.2 µs and 17 µs on a later run of the same case. Liveness is left to the caller:
1458
1653
  * it is a process probe, not SQL.
1654
+ *
1655
+ * The child's own settings apply, as `planDelivery` would apply them were it
1656
+ * up (D40): never with wake off, and while it declared waiting-for-human only
1657
+ * for a message of origin `human` (D37). Without that, a child whose
1658
+ * human_ask timed out was restarted by its owner's next message, which that
1659
+ * run then delivered before the human answered.
1459
1660
  */
1460
1661
  wakeCandidates(owner: string): Ownership[] {
1461
1662
  const rows = this.cached(
1462
1663
  `SELECT o.* FROM ownership o
1463
1664
  LEFT JOIN (SELECT session_file, max(at) AS at FROM stop_request GROUP BY session_file) s
1464
1665
  ON s.session_file = o.session_file
1666
+ LEFT JOIN session_setting st ON st.session_file = o.session_file
1465
1667
  WHERE o.owner = ? AND o.via = 'headless' AND o.session_file IS NOT NULL
1668
+ AND COALESCE(st.wake, 1) = 1
1466
1669
  AND NOT EXISTS (SELECT 1 FROM archive a WHERE a.session_file = o.session_file)
1467
1670
  AND (EXISTS (SELECT 1 FROM message m WHERE m.state = 'pending' AND m.to_kind = 'session'
1468
- AND m.to_target = o.session_file AND m.created_at > COALESCE(s.at, -1))
1671
+ AND m.to_target = o.session_file AND m.created_at > COALESCE(s.at, -1)
1672
+ AND (COALESCE(st.declared_waiting, 0) = 0 OR m.origin = 'human'))
1469
1673
  OR EXISTS (SELECT 1 FROM role r JOIN message m ON m.state = 'pending' AND m.to_kind = 'role'
1470
1674
  AND m.to_target = r.role
1471
- WHERE r.session_file = o.session_file AND m.created_at > COALESCE(s.at, -1)))
1675
+ WHERE r.session_file = o.session_file AND m.created_at > COALESCE(s.at, -1)
1676
+ AND (COALESCE(st.declared_waiting, 0) = 0 OR m.origin = 'human')))
1472
1677
  ORDER BY o.created_at`,
1473
1678
  ).all(owner) as OwnershipRow[];
1474
1679
  return rows.map((r) => this.toOwnership(r));
@@ -1641,6 +1846,7 @@ export class Shipmates {
1641
1846
  )
1642
1847
  .run(finished);
1643
1848
  this.pruneOwnership(t);
1849
+ this.pruneSettings(t);
1644
1850
  for (const row of dead)
1645
1851
  if (!this.probe.isAlive(this.identityOf(row)))
1646
1852
  this.db
@@ -1688,6 +1894,22 @@ export class Shipmates {
1688
1894
  .run(session_file);
1689
1895
  }
1690
1896
 
1897
+ /**
1898
+ * D40: a session's settings are kept while its transcript exists, as D25 keeps
1899
+ * ownership: they go when the file is gone, nobody runs it, and they were last
1900
+ * changed over 30 days ago. Called inside prune's transaction.
1901
+ */
1902
+ private pruneSettings(t: number): void {
1903
+ const old = this.db
1904
+ .prepare(`SELECT session_file FROM session_setting WHERE updated_at < ?`)
1905
+ .all(t - 30 * DAY) as {session_file: string}[];
1906
+ for (const {session_file} of old)
1907
+ if (!fs.existsSync(session_file) && !this.isLive(session_file))
1908
+ this.db
1909
+ .prepare(`DELETE FROM session_setting WHERE session_file = ?`)
1910
+ .run(session_file);
1911
+ }
1912
+
1691
1913
  /** Prune when the last prune is a day old. Cheap enough to call on every open. */
1692
1914
  pruneIfDue(): boolean {
1693
1915
  const row = this.db
@@ -1731,7 +1953,8 @@ export class Shipmates {
1731
1953
  status: r.status,
1732
1954
  refs: r.refs ? (JSON.parse(r.refs) as string[]) : [],
1733
1955
  waitingOn: r.waiting_on,
1734
- wake: r.wake === 1,
1956
+ wake: r.s_wake === 1,
1957
+ declaredWaiting: r.s_declared_waiting === 1,
1735
1958
  live: this.probe.isAlive(this.identityOf(r)),
1736
1959
  pid: r.pid,
1737
1960
  updatedAt: r.updated_at,
package/src/store.ts CHANGED
@@ -163,6 +163,21 @@ CREATE TABLE stop_request(
163
163
  outcome TEXT -- 'stopped' | 'not-running'
164
164
  );
165
165
  CREATE INDEX stop_open ON stop_request(session_file, handled_at);
166
+ `,
167
+ // 3: what a session chose for itself, kept per transcript file (D40).
168
+ `
169
+ -- presence.wake is no longer read: a presence row is deleted when its process
170
+ -- unregisters (a host unloading an idle session, a quit before a resume), and
171
+ -- the choice went with it. A row exists only while a setting differs from the
172
+ -- default; it is pruned like ownership, once the transcript is gone (D40).
173
+ CREATE TABLE session_setting(
174
+ session_file TEXT PRIMARY KEY,
175
+ wake INTEGER NOT NULL DEFAULT 1, -- /shipmates wake off
176
+ declared_waiting INTEGER NOT NULL DEFAULT 0, -- declared waiting-for-human, until its next run
177
+ updated_at INTEGER NOT NULL
178
+ );
179
+ INSERT INTO session_setting(session_file, wake, updated_at)
180
+ SELECT session_file, 0, updated_at FROM presence WHERE wake = 0;
166
181
  `,
167
182
  ];
168
183
 
package/src/types.ts CHANGED
@@ -17,6 +17,11 @@ export interface Presence {
17
17
  waitingOn: string | null;
18
18
  /** Whether a message may start a turn here (`/shipmates wake off` clears it). */
19
19
  wake: boolean;
20
+ /**
21
+ * It declared `waiting-for-human` (ADR 0006) and has not run since. Like
22
+ * `wake`, kept per transcript file across an unload or a resume (D40).
23
+ */
24
+ declaredWaiting: boolean;
20
25
  /** False once the process that registered it is gone. */
21
26
  live: boolean;
22
27
  pid: number;
@@ -25,6 +30,18 @@ export interface Presence {
25
30
  settledAt: number | null;
26
31
  }
27
32
 
33
+ /**
34
+ * What a session chose for itself, kept per transcript file whether or not it
35
+ * is live (D40): `/shipmates wake off`, and a declared `waiting-for-human`
36
+ * with no run since. `updatedAt` is null for a session that set nothing.
37
+ */
38
+ export interface SessionSetting {
39
+ sessionFile: string;
40
+ wake: boolean;
41
+ declaredWaiting: boolean;
42
+ updatedAt: number | null;
43
+ }
44
+
28
45
  /** The human words a human-relayed message carries, verbatim, and where they were said. */
29
46
  export interface Relay {
30
47
  text: string;
@@ -66,6 +83,8 @@ export interface Question {
66
83
  answerRelay: Relay | null;
67
84
  answeredBy: string | null;
68
85
  createdAt: number;
86
+ /** When it was answered or withdrawn; null while open. */
87
+ finishedAt: number | null;
69
88
  }
70
89
 
71
90
  /**
@@ -94,6 +113,51 @@ export interface AttentionItem {
94
113
  finishedAt: number | null;
95
114
  }
96
115
 
116
+ /**
117
+ * An item with where its answer stands for the session that raised it (D41):
118
+ * `answerPending` while the human's answer is not yet in that session's
119
+ * transcript. An answered item is not an item the asker knows is answered: a
120
+ * session in a long run reads it only at a boundary, and its status line can
121
+ * say "pending" honestly in the meantime (seen on 2026-11-28).
122
+ */
123
+ export interface ItemStatus extends AttentionItem {
124
+ answerPending: boolean;
125
+ }
126
+
127
+ /**
128
+ * An `h_...` or `q_...` id a status line names, once it is no longer open
129
+ * (D41): the status is the session's own words and may lag behind it.
130
+ */
131
+ export type StatusRef =
132
+ | {
133
+ kind: 'item';
134
+ id: string;
135
+ state: 'answered' | 'withdrawn';
136
+ at: number | null;
137
+ channel: string | null;
138
+ /** Raised by the session whose status names it. */
139
+ own: boolean;
140
+ answerPending: boolean;
141
+ }
142
+ | {
143
+ kind: 'question';
144
+ id: string;
145
+ state: 'answered' | 'withdrawn';
146
+ at: number | null;
147
+ }
148
+ | {kind: 'item' | 'question'; id: string; state: 'unknown'};
149
+
150
+ /**
151
+ * What shipmates knows about a session that its status line may not say (D41),
152
+ * derived from the store rather than declared.
153
+ */
154
+ export interface StatusFacts {
155
+ /** Items it raised that are open, or answered with the answer still pending to it; oldest first. */
156
+ items: ItemStatus[];
157
+ /** Ids its status names that are no longer open, in the order named. */
158
+ stale: StatusRef[];
159
+ }
160
+
97
161
  /** How a session came to be owned (D23): through a host, or the terminal default (D19). */
98
162
  export type SpawnVia = 'host' | 'zellij' | 'headless' | 'recorded';
99
163