shipmates 0.2.0 → 0.4.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,6 +1,6 @@
1
1
  import { type DB } from './store.js';
2
2
  import { type ProcessIdentity, type ProcessProbe } from './liveness.js';
3
- import { type ArchiveMark, type AttentionItem, type Message, type Ownership, type SpawnVia, type StopRequest, type Origin, type Presence, type Question, type Relay, type SessionState } from './types.js';
3
+ import { type ArchiveMark, type AttentionItem, type Message, type Ownership, type SpawnVia, type StopRequest, type Origin, type Presence, type Question, type Relay, type SessionSetting, type SessionState } from './types.js';
4
4
  export interface ShipmatesOptions {
5
5
  stateDir?: string;
6
6
  probe?: ProcessProbe;
@@ -19,7 +19,14 @@ export interface PresencePatch {
19
19
  waitingOn?: string | null;
20
20
  branch?: string | null;
21
21
  cwd?: string | null;
22
+ /** Kept per transcript file, across unregister and register (D40). */
22
23
  wake?: boolean;
24
+ /**
25
+ * The session declared `waiting-for-human` (ADR 0006) and has not run since.
26
+ * Kept per transcript file like `wake`; `register` restores the state from it
27
+ * (D40). It does not set `state`: pass both.
28
+ */
29
+ declaredWaiting?: boolean;
23
30
  }
24
31
  export interface ListFilter {
25
32
  cwd?: string;
@@ -131,7 +138,23 @@ export declare class Shipmates {
131
138
  protected tx<T>(fn: () => T): T;
132
139
  register(input: RegisterInput): Presence;
133
140
  update(sessionFile: string, patch: PresencePatch): void;
141
+ /**
142
+ * D40: the session's own choices, by transcript file. A row exists only while
143
+ * one differs from the default, so the table holds the few sessions that set
144
+ * something. Called inside a write.
145
+ */
146
+ private writeSetting;
134
147
  unregister(sessionFile: string): void;
148
+ /**
149
+ * D40: every session whose own settings differ from the defaults, live or
150
+ * not, most recently changed first. A host uses it to show what a session
151
+ * that is not loaded chose (wherever's sidebar keeps "waiting for the human"
152
+ * for an unloaded session that declared it, which `list()` cannot show).
153
+ * Rows exist only for non-defaults, so this is the few that set something.
154
+ */
155
+ settings(): SessionSetting[];
156
+ /** D40: one session's settings; the defaults (`updatedAt` null) when it set none. */
157
+ setting(sessionFile: string): SessionSetting;
135
158
  presence(sessionFile: string): Presence | null;
136
159
  isLive(sessionFile: string): boolean;
137
160
  list(filter?: ListFilter): Presence[];
@@ -217,12 +240,51 @@ export declare class Shipmates {
217
240
  inbox(): AttentionItem[];
218
241
  /**
219
242
  * The human answered an item. Callers must only call this for a real human act
220
- * (a slash command, the CLI at a terminal, a host's authenticated UI): ADR 0003.
243
+ * (a slash command, the CLI at a terminal, a host's authenticated UI, a human
244
+ * turn in the asking session): ADR 0003.
245
+ *
246
+ * The answer goes to the asking session as a message of origin `human`, unless
247
+ * `deliver` is false: the human said it in that session's own turn, so their
248
+ * words are already in its transcript and a second copy would repeat them (D39).
221
249
  */
222
250
  answerItem(itemId: string, text: string, opts: {
223
251
  channel: string;
252
+ deliver?: true;
224
253
  }): Message;
225
- withdrawItem(from: string, itemId: string): void;
254
+ answerItem(itemId: string, text: string, opts: {
255
+ channel: string;
256
+ deliver: boolean;
257
+ }): Message | null;
258
+ /**
259
+ * The human replied in the session that raised these items (D39): every item
260
+ * of `sessionFile` still open, except `except`, is answered with their words
261
+ * on `opts.channel` (by convention `session`). Returns the items it closed.
262
+ *
263
+ * With `notice`, the session also gets one `notice` message (origin agent,
264
+ * from shipmates) naming the items the reply closed: the human's words are in
265
+ * its turn, but nothing else would tell the agent which questions they
266
+ * closed, and it may still be waiting on one of them.
267
+ */
268
+ answerOpenItemsOf(sessionFile: string, text: string, opts: {
269
+ channel: string;
270
+ deliver?: boolean;
271
+ except?: string[];
272
+ notice?: boolean;
273
+ }): AttentionItem[];
274
+ /** Inside a write: mark an open item answered, and send the answer unless told not to. */
275
+ private closeItem;
276
+ /**
277
+ * Withdraw an item this session raised and that is still open. Refused for
278
+ * another session's item: only the asker knows the question no longer stands.
279
+ * Returns the item as it now is (unchanged when it was already answered).
280
+ */
281
+ withdrawItem(from: string, itemId: string): AttentionItem;
282
+ /**
283
+ * Items that closed (answered or withdrawn) at or after `since`, oldest
284
+ * first: what a host reads to update its own copy of an item it pushed to
285
+ * the human (a Telegram message that must stop looking open, D39).
286
+ */
287
+ itemsFinishedSince(since: number): AttentionItem[];
226
288
  /** The human's answers to this session's items, newest first. */
227
289
  humanAnswers(sessionFile: string): AttentionItem[];
228
290
  /**
@@ -328,8 +390,15 @@ export declare class Shipmates {
328
390
  * arrived after their last stop, and are not archived. One cached query,
329
391
  * since every session's poller asks on every change. Measured: 3 µs for a
330
392
  * session that owns nothing, 42 µs with 5 children and one to wake, against
331
- * about 500 µs as separate reads per child. Liveness is left to the caller:
393
+ * about 500 µs as separate reads per child; with the settings join (D40),
394
+ * 1.2 µs and 17 µs on a later run of the same case. Liveness is left to the caller:
332
395
  * it is a process probe, not SQL.
396
+ *
397
+ * The child's own settings apply, as `planDelivery` would apply them were it
398
+ * up (D40): never with wake off, and while it declared waiting-for-human only
399
+ * for a message of origin `human` (D37). Without that, a child whose
400
+ * human_ask timed out was restarted by its owner's next message, which that
401
+ * run then delivered before the human answered.
333
402
  */
334
403
  wakeCandidates(owner: string): Ownership[];
335
404
  /**
@@ -385,6 +454,12 @@ export declare class Shipmates {
385
454
  * once the undo window has passed. Called inside prune's transaction.
386
455
  */
387
456
  private pruneOwnership;
457
+ /**
458
+ * D40: a session's settings are kept while its transcript exists, as D25 keeps
459
+ * ownership: they go when the file is gone, nobody runs it, and they were last
460
+ * changed over 30 days ago. Called inside prune's transaction.
461
+ */
462
+ private pruneSettings;
388
463
  /** Prune when the last prune is a day old. Cheap enough to call on every open. */
389
464
  pruneIfDue(): boolean;
390
465
  protected identityOf(row: {
@@ -1 +1 @@
1
- {"version":3,"file":"shipmates.d.ts","sourceRoot":"","sources":["../src/shipmates.ts"],"names":[],"mappings":"AACA,OAAO,EAAiC,KAAK,EAAE,EAAC,MAAM,YAAY,CAAC;AACnE,OAAO,EAAU,KAAK,eAAe,EAAE,KAAK,YAAY,EAAC,MAAM,eAAe,CAAC;AAC/E,OAAO,EAEN,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AC,cAAc;IA0BtB;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAWrB,kFAAkF;IAClF,UAAU,IAAI,OAAO;IASrB,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE;QACzB,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;KACpB,GAAG,eAAe;IASnB,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE;IAQhD,OAAO,CAAC,UAAU;CAmBlB;AAED,wBAAgB,aAAa,CAAC,IAAI,GAAE,gBAAqB,GAAG,SAAS,CAEpE"}
package/dist/shipmates.js CHANGED
@@ -3,6 +3,15 @@ import { defaultStateDir, openDb, write } from './store.js';
3
3
  import { OsProbe } from './liveness.js';
4
4
  import { ShipmatesError, } from './types.js';
5
5
  import { newId } from './ids.js';
6
+ const toSetting = (r) => ({
7
+ sessionFile: r.session_file,
8
+ wake: r.wake === 1,
9
+ declaredWaiting: r.declared_waiting === 1,
10
+ updatedAt: r.updated_at,
11
+ });
12
+ /** Presence with the session's own settings (D40); a session with no row has the defaults. */
13
+ const PRESENCE_SELECT = `SELECT p.*, COALESCE(s.wake, 1) AS s_wake, COALESCE(s.declared_waiting, 0) AS s_declared_waiting
14
+ FROM presence p LEFT JOIN session_setting s ON s.session_file = p.session_file`;
6
15
  /** D14: message text is short; content stays in git and messages point at it. */
7
16
  const DAY = 86_400_000;
8
17
  export const MAX_TEXT_BYTES = 8 * 1024;
@@ -59,6 +68,7 @@ function toItem(r) {
59
68
  answer: r.answer,
60
69
  answerChannel: r.answer_channel,
61
70
  createdAt: r.created_at,
71
+ finishedAt: r.finished_at,
62
72
  };
63
73
  }
64
74
  /** D8: lower-case words joined by `._:/-`, e.g. `template-tree/push` or `orchestrator:template-tree`. */
@@ -91,16 +101,22 @@ export class Shipmates {
91
101
  const me = this.probe.self();
92
102
  const t = this.now();
93
103
  this.tx(() => {
104
+ // A session that declared it waits for the human still does after an
105
+ // unload or a resume: it has not run since (D40).
106
+ const declared = this.db
107
+ .prepare(`SELECT declared_waiting FROM session_setting WHERE session_file = ?`)
108
+ .get(input.sessionFile);
109
+ const state = declared?.declared_waiting === 1 ? 'waiting-for-human' : 'idle';
94
110
  this.db
95
111
  .prepare(`INSERT INTO presence(session_file, session_id, cwd, branch, state, pid, start_time, boot_id, host, registered_at, updated_at)
96
- VALUES(?, ?, ?, ?, 'idle', ?, ?, ?, ?, ?, ?)
112
+ VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
97
113
  ON CONFLICT(session_file) DO UPDATE SET
98
114
  session_id = excluded.session_id, cwd = excluded.cwd,
99
115
  branch = COALESCE(excluded.branch, presence.branch),
100
116
  pid = excluded.pid, start_time = excluded.start_time, boot_id = excluded.boot_id,
101
117
  host = excluded.host, updated_at = excluded.updated_at,
102
- state = CASE WHEN presence.pid = excluded.pid THEN presence.state ELSE 'idle' END`)
103
- .run(input.sessionFile, input.sessionId ?? null, input.cwd ?? null, input.branch ?? null, me.pid, me.startTime, me.bootId, me.host, t, t);
118
+ state = CASE WHEN presence.pid = excluded.pid THEN presence.state ELSE excluded.state END`)
119
+ .run(input.sessionFile, input.sessionId ?? null, input.cwd ?? null, input.branch ?? null, state, me.pid, me.startTime, me.bootId, me.host, t, t);
104
120
  });
105
121
  return this.presence(input.sessionFile);
106
122
  }
@@ -126,15 +142,34 @@ export class Shipmates {
126
142
  put('branch', patch.branch);
127
143
  if (patch.cwd !== undefined)
128
144
  put('cwd', patch.cwd);
129
- if (patch.wake !== undefined)
130
- put('wake', patch.wake ? 1 : 0);
131
145
  put('updated_at', this.now());
146
+ const setting = patch.wake !== undefined || patch.declaredWaiting !== undefined;
132
147
  this.tx(() => {
133
148
  this.db
134
149
  .prepare(`UPDATE presence SET ${sets.join(', ')} WHERE session_file = ?`)
135
150
  .run(...vals, sessionFile);
151
+ if (setting)
152
+ this.writeSetting(sessionFile, patch);
136
153
  });
137
154
  }
155
+ /**
156
+ * D40: the session's own choices, by transcript file. A row exists only while
157
+ * one differs from the default, so the table holds the few sessions that set
158
+ * something. Called inside a write.
159
+ */
160
+ writeSetting(sessionFile, patch) {
161
+ const bit = (v) => v === undefined ? null : v ? 1 : 0;
162
+ this.db
163
+ .prepare(`INSERT INTO session_setting(session_file, wake, declared_waiting, updated_at)
164
+ VALUES(?, COALESCE(?, 1), COALESCE(?, 0), ?)
165
+ ON CONFLICT(session_file) DO UPDATE SET
166
+ wake = COALESCE(?, wake), declared_waiting = COALESCE(?, declared_waiting),
167
+ updated_at = excluded.updated_at`)
168
+ .run(sessionFile, bit(patch.wake), bit(patch.declaredWaiting), this.now(), bit(patch.wake), bit(patch.declaredWaiting));
169
+ this.db
170
+ .prepare(`DELETE FROM session_setting WHERE session_file = ? AND wake = 1 AND declared_waiting = 0`)
171
+ .run(sessionFile);
172
+ }
138
173
  unregister(sessionFile) {
139
174
  const me = this.probe.self();
140
175
  this.tx(() => {
@@ -145,9 +180,26 @@ export class Shipmates {
145
180
  .run(sessionFile, me.pid);
146
181
  });
147
182
  }
183
+ /**
184
+ * D40: every session whose own settings differ from the defaults, live or
185
+ * not, most recently changed first. A host uses it to show what a session
186
+ * that is not loaded chose (wherever's sidebar keeps "waiting for the human"
187
+ * for an unloaded session that declared it, which `list()` cannot show).
188
+ * Rows exist only for non-defaults, so this is the few that set something.
189
+ */
190
+ settings() {
191
+ return this.cached(`SELECT * FROM session_setting ORDER BY updated_at DESC, session_file`).all().map(toSetting);
192
+ }
193
+ /** D40: one session's settings; the defaults (`updatedAt` null) when it set none. */
194
+ setting(sessionFile) {
195
+ const row = this.cached(`SELECT * FROM session_setting WHERE session_file = ?`).get(sessionFile);
196
+ return row
197
+ ? toSetting(row)
198
+ : { sessionFile, wake: true, declaredWaiting: false, updatedAt: null };
199
+ }
148
200
  presence(sessionFile) {
149
201
  const row = this.db
150
- .prepare(`SELECT * FROM presence WHERE session_file = ?`)
202
+ .prepare(`${PRESENCE_SELECT} WHERE p.session_file = ?`)
151
203
  .get(sessionFile);
152
204
  return row ? this.toPresence(row) : null;
153
205
  }
@@ -156,7 +208,7 @@ export class Shipmates {
156
208
  }
157
209
  list(filter = {}) {
158
210
  const rows = this.db
159
- .prepare(`SELECT * FROM presence ORDER BY updated_at DESC`)
211
+ .prepare(`${PRESENCE_SELECT} ORDER BY p.updated_at DESC`)
160
212
  .all();
161
213
  return rows
162
214
  .map((r) => this.toPresence(r))
@@ -526,47 +578,111 @@ export class Shipmates {
526
578
  .all();
527
579
  return rows.map(toItem);
528
580
  }
581
+ answerItem(itemId, text, opts) {
582
+ // Checked inside the write: the session's input handler and another
583
+ // channel (the CLI, a host) may answer the same item at the same moment,
584
+ // and only one of them may win (D39).
585
+ const id = this.tx(() => {
586
+ const item = this.item(itemId);
587
+ if (!item)
588
+ throw new ShipmatesError(`no item ${itemId}`, 'not-found');
589
+ if (item.state !== 'open')
590
+ throw new ShipmatesError(`item ${itemId} is already ${item.state}`, item.state);
591
+ return this.closeItem(item, text, opts);
592
+ });
593
+ return id ? this.message(id) : null;
594
+ }
529
595
  /**
530
- * The human answered an item. Callers must only call this for a real human act
531
- * (a slash command, the CLI at a terminal, a host's authenticated UI): ADR 0003.
596
+ * The human replied in the session that raised these items (D39): every item
597
+ * of `sessionFile` still open, except `except`, is answered with their words
598
+ * on `opts.channel` (by convention `session`). Returns the items it closed.
599
+ *
600
+ * With `notice`, the session also gets one `notice` message (origin agent,
601
+ * from shipmates) naming the items the reply closed: the human's words are in
602
+ * its turn, but nothing else would tell the agent which questions they
603
+ * closed, and it may still be waiting on one of them.
532
604
  */
533
- answerItem(itemId, text, opts) {
534
- const item = this.item(itemId);
535
- if (!item)
536
- throw new ShipmatesError(`no item ${itemId}`, 'not-found');
537
- if (item.state !== 'open')
538
- throw new ShipmatesError(`item ${itemId} is already ${item.state}`, item.state);
605
+ answerOpenItemsOf(sessionFile, text, opts) {
606
+ const skip = new Set(opts.except ?? []);
607
+ const open = () => this.db
608
+ .prepare(`SELECT * FROM item WHERE session_file = ? AND state = 'open' ORDER BY created_at`)
609
+ .all(sessionFile).filter((r) => !skip.has(r.id));
610
+ // Read first: the write lock only when there is something to close
611
+ // (every human input calls this; most sessions have no open item).
612
+ if (!open().length)
613
+ return [];
614
+ return this.tx(() => {
615
+ const rows = open();
616
+ for (const r of rows)
617
+ this.closeItem(toItem(r), text, opts);
618
+ if (opts.notice && rows.length)
619
+ this.insertMessage({
620
+ from: null,
621
+ fromLabel: 'shipmates',
622
+ to: { kind: 'session', target: sessionFile },
623
+ kind: 'notice',
624
+ text: `The human's reply in this session closed ${rows.length === 1 ? 'your inbox item' : `${rows.length} of your inbox items`} (answered with their words, channel ${opts.channel}): ${rows.map((r) => `${r.id} "${r.question.slice(0, 120)}"`).join('; ')}. If it did not answer one of them, ask again.`,
625
+ origin: 'agent',
626
+ });
627
+ return rows.map((r) => r.id);
628
+ }).map((id) => this.item(id));
629
+ }
630
+ /** Inside a write: mark an open item answered, and send the answer unless told not to. */
631
+ closeItem(item, text, opts) {
539
632
  const t = this.now();
633
+ const r = this.db
634
+ .prepare(`UPDATE item SET state = 'answered', answer = ?, answer_channel = ?, finished_at = ? WHERE id = ? AND state = 'open'`)
635
+ .run(text, opts.channel, t, item.id);
636
+ if (Number(r.changes) !== 1)
637
+ throw new ShipmatesError(`item ${item.id} is no longer open`, 'answered');
638
+ if (opts.deliver === false)
639
+ return null;
540
640
  const relay = {
541
641
  text,
542
642
  channel: opts.channel,
543
643
  session: null,
544
- itemId,
644
+ itemId: item.id,
545
645
  at: t,
546
646
  };
547
- const id = this.tx(() => {
548
- this.db
549
- .prepare(`UPDATE item SET state = 'answered', answer = ?, answer_channel = ?, finished_at = ? WHERE id = ?`)
550
- .run(text, opts.channel, t, itemId);
551
- return this.insertMessage({
552
- from: null,
553
- fromLabel: 'human',
554
- to: { kind: 'session', target: item.session },
555
- kind: 'answer',
556
- text,
557
- origin: 'human',
558
- relay,
559
- itemId,
560
- });
647
+ return this.insertMessage({
648
+ from: null,
649
+ fromLabel: 'human',
650
+ to: { kind: 'session', target: item.session },
651
+ kind: 'answer',
652
+ text,
653
+ origin: 'human',
654
+ relay,
655
+ itemId: item.id,
561
656
  });
562
- return this.message(id);
563
657
  }
658
+ /**
659
+ * Withdraw an item this session raised and that is still open. Refused for
660
+ * another session's item: only the asker knows the question no longer stands.
661
+ * Returns the item as it now is (unchanged when it was already answered).
662
+ */
564
663
  withdrawItem(from, itemId) {
664
+ const item = this.item(itemId);
665
+ if (!item)
666
+ throw new ShipmatesError(`no item ${itemId}`, 'not-found');
667
+ if (item.session !== from)
668
+ throw new ShipmatesError(`item ${itemId} was raised by ${this.labelOf(item.session)}, not by you`, 'not-yours');
565
669
  this.tx(() => {
566
670
  this.db
567
671
  .prepare(`UPDATE item SET state = 'withdrawn', finished_at = ? WHERE id = ? AND session_file = ? AND state = 'open'`)
568
672
  .run(this.now(), itemId, from);
569
673
  });
674
+ return this.item(itemId);
675
+ }
676
+ /**
677
+ * Items that closed (answered or withdrawn) at or after `since`, oldest
678
+ * first: what a host reads to update its own copy of an item it pushed to
679
+ * the human (a Telegram message that must stop looking open, D39).
680
+ */
681
+ itemsFinishedSince(since) {
682
+ const rows = this.db
683
+ .prepare(`SELECT * FROM item WHERE state != 'open' AND finished_at >= ? ORDER BY finished_at, rowid`)
684
+ .all(since);
685
+ return rows.map(toItem);
570
686
  }
571
687
  /** The human's answers to this session's items, newest first. */
572
688
  humanAnswers(sessionFile) {
@@ -869,20 +985,31 @@ export class Shipmates {
869
985
  * arrived after their last stop, and are not archived. One cached query,
870
986
  * since every session's poller asks on every change. Measured: 3 µs for a
871
987
  * session that owns nothing, 42 µs with 5 children and one to wake, against
872
- * about 500 µs as separate reads per child. Liveness is left to the caller:
988
+ * about 500 µs as separate reads per child; with the settings join (D40),
989
+ * 1.2 µs and 17 µs on a later run of the same case. Liveness is left to the caller:
873
990
  * it is a process probe, not SQL.
991
+ *
992
+ * The child's own settings apply, as `planDelivery` would apply them were it
993
+ * up (D40): never with wake off, and while it declared waiting-for-human only
994
+ * for a message of origin `human` (D37). Without that, a child whose
995
+ * human_ask timed out was restarted by its owner's next message, which that
996
+ * run then delivered before the human answered.
874
997
  */
875
998
  wakeCandidates(owner) {
876
999
  const rows = this.cached(`SELECT o.* FROM ownership o
877
1000
  LEFT JOIN (SELECT session_file, max(at) AS at FROM stop_request GROUP BY session_file) s
878
1001
  ON s.session_file = o.session_file
1002
+ LEFT JOIN session_setting st ON st.session_file = o.session_file
879
1003
  WHERE o.owner = ? AND o.via = 'headless' AND o.session_file IS NOT NULL
1004
+ AND COALESCE(st.wake, 1) = 1
880
1005
  AND NOT EXISTS (SELECT 1 FROM archive a WHERE a.session_file = o.session_file)
881
1006
  AND (EXISTS (SELECT 1 FROM message m WHERE m.state = 'pending' AND m.to_kind = 'session'
882
- AND m.to_target = o.session_file AND m.created_at > COALESCE(s.at, -1))
1007
+ AND m.to_target = o.session_file AND m.created_at > COALESCE(s.at, -1)
1008
+ AND (COALESCE(st.declared_waiting, 0) = 0 OR m.origin = 'human'))
883
1009
  OR EXISTS (SELECT 1 FROM role r JOIN message m ON m.state = 'pending' AND m.to_kind = 'role'
884
1010
  AND m.to_target = r.role
885
- WHERE r.session_file = o.session_file AND m.created_at > COALESCE(s.at, -1)))
1011
+ WHERE r.session_file = o.session_file AND m.created_at > COALESCE(s.at, -1)
1012
+ AND (COALESCE(st.declared_waiting, 0) = 0 OR m.origin = 'human')))
886
1013
  ORDER BY o.created_at`).all(owner);
887
1014
  return rows.map((r) => this.toOwnership(r));
888
1015
  }
@@ -1025,6 +1152,7 @@ export class Shipmates {
1025
1152
  .prepare(`DELETE FROM stop_request WHERE handled_at IS NOT NULL AND handled_at < ?`)
1026
1153
  .run(finished);
1027
1154
  this.pruneOwnership(t);
1155
+ this.pruneSettings(t);
1028
1156
  for (const row of dead)
1029
1157
  if (!this.probe.isAlive(this.identityOf(row)))
1030
1158
  this.db
@@ -1064,6 +1192,21 @@ export class Shipmates {
1064
1192
  .prepare(`DELETE FROM archive WHERE session_file = ?`)
1065
1193
  .run(session_file);
1066
1194
  }
1195
+ /**
1196
+ * D40: a session's settings are kept while its transcript exists, as D25 keeps
1197
+ * ownership: they go when the file is gone, nobody runs it, and they were last
1198
+ * changed over 30 days ago. Called inside prune's transaction.
1199
+ */
1200
+ pruneSettings(t) {
1201
+ const old = this.db
1202
+ .prepare(`SELECT session_file FROM session_setting WHERE updated_at < ?`)
1203
+ .all(t - 30 * DAY);
1204
+ for (const { session_file } of old)
1205
+ if (!fs.existsSync(session_file) && !this.isLive(session_file))
1206
+ this.db
1207
+ .prepare(`DELETE FROM session_setting WHERE session_file = ?`)
1208
+ .run(session_file);
1209
+ }
1067
1210
  /** Prune when the last prune is a day old. Cheap enough to call on every open. */
1068
1211
  pruneIfDue() {
1069
1212
  const row = this.db
@@ -1098,7 +1241,8 @@ export class Shipmates {
1098
1241
  status: r.status,
1099
1242
  refs: r.refs ? JSON.parse(r.refs) : [],
1100
1243
  waitingOn: r.waiting_on,
1101
- wake: r.wake === 1,
1244
+ wake: r.s_wake === 1,
1245
+ declaredWaiting: r.s_declared_waiting === 1,
1102
1246
  live: this.probe.isAlive(this.identityOf(r)),
1103
1247
  pid: r.pid,
1104
1248
  updatedAt: r.updated_at,