gcf-aif-ext 0.27.0 → 0.28.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.
package/lib/devices.js ADDED
@@ -0,0 +1,133 @@
1
+ // The devices a target can play on (docs/Handoff-Plan.md d5, proposal §4): its `devices` command
2
+ // prints one JSON line per device, `{"id", "name", "device", "os", "os_version"?, "model"?,
3
+ // "state", "note"?}`, or one `{"unavailable": "<why>"}`. Asked only on request: the Play panel and
4
+ // `gcf playtest devices`. Its output goes to a file, not a pipe: a daemon the script starts (adb)
5
+ // would hold an inherited pipe open on Windows.
6
+ import { mkdir, open, readFile } from 'node:fs/promises';
7
+ import path from 'node:path';
8
+ import { readConfig } from './gcf-paths.js';
9
+ import { NOT_SET_UP, playOf } from './play.js';
10
+ import { runCommand } from './verify.js';
11
+
12
+ const DEVICES_MS = 30000;
13
+ /** A device id goes into a shell command: only these characters (no quote escapes on Windows). */
14
+ // A word character first: `-x` would be an option of the device tool (`adb -s -x`).
15
+ export const DEVICE_ID_RE = /^\w[\w.:-]*$/;
16
+
17
+ /** Whether target `t` serves a row of build `build`: every field of its `for` is the row's. */
18
+ export const serves = (t, build, row) =>
19
+ t.build === build && Object.entries(t.for ?? {}).every(([k, v]) => row[k] === v);
20
+
21
+ /** -1, 0, 1: two versions as numbers with dots. */
22
+ export function versionCmp(a, b) {
23
+ const x = String(a).split('.').map(Number);
24
+ const y = String(b).split('.').map(Number);
25
+ for (let i = 0; i < Math.max(x.length, y.length); i++) {
26
+ const d = (x[i] ?? 0) - (y[i] ?? 0);
27
+ if (d) return Math.sign(d);
28
+ }
29
+
30
+ return 0;
31
+ }
32
+
33
+ /** Why device `d` does not fit row `r`, or null when it does. */
34
+ function misfit(d, r) {
35
+ if (d.device !== r.device || (r.os && d.os !== r.os) || (r.model && d.model !== r.model))
36
+ return 'another kind';
37
+ if (!r.os_min) return null;
38
+ if (!d.os_version) return `needs ${r.os ?? 'the os'} ${r.os_min}: the version is unknown`;
39
+
40
+ return versionCmp(d.os_version, r.os_min) < 0 ? `needs ${r.os ?? 'the os'} ${r.os_min}` : null;
41
+ }
42
+
43
+ /** The row a device fits, or why none. */
44
+ function placeOf(d, rows) {
45
+ if (!d.device || !d.os) return { row: null, fits: false, why: 'could not be matched' };
46
+ const results = rows.map((r, i) => ({ i, why: misfit(d, r) }));
47
+ const fit = results.find((x) => x.why === null);
48
+ if (fit) return { row: fit.i, fits: true, why: null };
49
+ const near = results.find((x) => x.why !== 'another kind');
50
+
51
+ return {
52
+ row: near?.i ?? null,
53
+ fits: false,
54
+ why: near?.why ?? 'no row of this build is its kind',
55
+ };
56
+ }
57
+
58
+ /** A line of the script's output as a device, checked. */
59
+ function deviceOf(v, rows) {
60
+ const text = (k) => (typeof v[k] === 'string' ? v[k] : null);
61
+ const d = {
62
+ id: text('id'),
63
+ name: text('name') ?? String(v.id ?? '?'),
64
+ device: text('device'),
65
+ os: text('os'),
66
+ os_version: v.os_version == null ? null : String(v.os_version),
67
+ model: text('model'),
68
+ state: text('state') ?? 'unknown',
69
+ note: text('note'),
70
+ };
71
+ const place = placeOf(d, rows);
72
+ const idOk = d.id !== null && DEVICE_ID_RE.test(d.id);
73
+
74
+ return {
75
+ ...d,
76
+ ...place,
77
+ ...(idOk ? {} : { why: 'the id does not fit', fits: false }),
78
+ play: idOk && place.fits && d.state === 'ready',
79
+ };
80
+ }
81
+
82
+ const tailOf = (text) => text.trimEnd().split(/\r?\n/).slice(-20).join('\n');
83
+
84
+ /**
85
+ * `gcf playtest devices <target>`: what the target's script finds, each device placed under a row
86
+ * of `plays_on` it fits, or why not.
87
+ * @returns {Promise<{target: string, rows: object[], devices: object[], unavailable?: string,
88
+ * problem?: string, tail?: string}>}
89
+ */
90
+ export async function devicesOf(projectDir, targetName, { ms = DEVICES_MS } = {}) {
91
+ const dir = path.resolve(projectDir);
92
+ const play = playOf(await readConfig(path.join(dir, 'gcf')));
93
+ if (!play) throw new Error(NOT_SET_UP);
94
+ const t = Object.hasOwn(play.targets, targetName) ? play.targets[targetName] : null;
95
+ if (!t) throw new Error(`no target ${targetName}: ${Object.keys(play.targets).join(', ')}`);
96
+ const rows = play.builds[t.build].plays_on.filter((r) => serves(t, t.build, r));
97
+ const base = { target: targetName, rows, devices: [] };
98
+ if (!t.devices) return { ...base, problem: `${targetName} has no devices command` };
99
+
100
+ const log = path.join(dir, '.gcf-session', `devices-${targetName}.log`);
101
+ await mkdir(path.dirname(log), { recursive: true });
102
+ const fh = await open(log, 'w');
103
+ let res;
104
+ try {
105
+ res = await runCommand(t.devices, dir, ['ignore', fh.fd, fh.fd], ms);
106
+ } finally {
107
+ await fh.close();
108
+ }
109
+
110
+ return { ...base, ...parsed(t.devices, res, await readFile(log, 'utf8'), rows) };
111
+ }
112
+
113
+ /** The script's answer: its devices, its "unavailable", or why it failed with its tail. */
114
+ function parsed(command, res, text, rows) {
115
+ const fail = (why) => ({ problem: `devices ${why}: ${command}`, tail: tailOf(text) });
116
+ if (res.timedOut) return fail(`timed out after ${DEVICES_MS / 1000} s`);
117
+ if (res.error || res.status !== 0)
118
+ return fail(`failed (${res.error?.message ?? `exit ${res.status}`})`);
119
+ const lines = text.split(/\r?\n/).filter((l) => l.trim());
120
+ const values = [];
121
+ for (const line of lines) {
122
+ try {
123
+ values.push(JSON.parse(line));
124
+ } catch {
125
+ return fail(`printed a line that is no JSON (${line.slice(0, 80)})`);
126
+ }
127
+ }
128
+
129
+ const off = values.find((v) => typeof v?.unavailable === 'string');
130
+ if (off) return { unavailable: off.unavailable };
131
+
132
+ return { devices: values.map((v) => deviceOf(v, rows)) };
133
+ }
package/lib/domain.js CHANGED
@@ -44,7 +44,7 @@ const GATE_HELP = {
44
44
  const REASON = { key: 'reason', label: 'Reason', kind: 'longtext', required: true };
45
45
  const REMOVE = { key: 'remove', label: 'Removal item for its code', kind: 'remove' };
46
46
  const CONSTRAINT = { key: 'constraint', label: 'Constraint lines', kind: 'list' };
47
- // Where the operator played it: lines of game.md's platforms, a note for the history (Plan, C).
47
+ // Where the operator played it: names of play.builds, a note for the history (Handoff-Plan d8).
48
48
  const PLAYED_ON = { key: 'played_on', flag: 'played-on', label: 'Played on', kind: 'list' };
49
49
  // close and submit need a green gcf verify of the code as it is now; the operator may say why
50
50
  // they go without one, and the reason goes into the move's commit.
@@ -785,6 +785,15 @@ const BLOCK_SPECS = {
785
785
  text('start', 'Start command: {dir} the build, {port} a free port, {lan} this machine'),
786
786
  text('open', 'What to open: a URL or words'),
787
787
  text('stop', 'Command after the player stops'),
788
+ // docs/Handoff-Plan.md t1: the rows the build plays on, and what the target serves of them.
789
+ {
790
+ key: 'plays_on',
791
+ flag: 'plays-on',
792
+ label: 'Rows the build plays on, one a line: device: phone, os: android, os_min: 10',
793
+ kind: 'list',
794
+ },
795
+ text('for', 'The rows the target serves: device: phone, os: android'),
796
+ text('devices', 'Command that lists its devices, a JSON line each'),
788
797
  ],
789
798
  propose: true,
790
799
  },
@@ -842,7 +851,7 @@ const FIELDS = [
842
851
  { key: 'run_mode', label: 'run mode', kind: 'text', edit: 'mode' },
843
852
  { key: 'skip_gates', label: 'gates', kind: 'text', help: "Its card's gates", edit: 'gates' },
844
853
  { key: 'gate_why', label: 'why its own stop', kind: 'text' },
845
- { key: 'play_on', label: 'play on', kind: 'list', help: 'Where to play it: lines of platforms' },
854
+ { key: 'play_on', label: 'play on', kind: 'list', help: 'Builds to play it on' },
846
855
  { key: 'tune_count', label: 'tune', kind: 'text', help: 'Tune verdicts so far', card: true },
847
856
  {
848
857
  key: 'waits_for',
@@ -1010,6 +1019,7 @@ const CHANGES = [
1010
1019
  'playtest start',
1011
1020
  'playtest stop',
1012
1021
  'playtest setup',
1022
+ 'playtest cancel',
1013
1023
  ];
1014
1024
 
1015
1025
  // The project chat of a GCF project (AD-5, AD-6): its skill, and the commands it asks for.
package/lib/handoff.js ADDED
@@ -0,0 +1,291 @@
1
+ // A card's handoff to play (docs/Handoff-Plan.md d4): read live, not stored. The core's blocks come
2
+ // from the card, its plan, its build, the queue, the questions and its submit commit; the agent's
3
+ // fields from the plan's `## Play notes` (lib/play-notes.js). Devices are not asked here (d5):
4
+ // only the Play panel and `gcf playtest devices` run a target's script.
5
+ import { spawnSync } from 'node:child_process';
6
+ import path from 'node:path';
7
+ import { firstBullet, readConfig, scalarOf } from './gcf-paths.js';
8
+ import { buildLedger } from './ledger.js';
9
+ import { buildOf, lanAddress, playOf, queueOf } from './play.js';
10
+ import { planPasses, planTicks } from './plan-check.js';
11
+ import { listQuestions } from './questions.js';
12
+ import { recordsOf } from './verdict-fs.js';
13
+ import { serves } from './devices.js';
14
+ import { planTextOf, playNotesOf, playNotesProblems, rowsFor } from './play-notes.js';
15
+
16
+ /** A row's state without asking devices: what is set up and built (the panel asks the rest). */
17
+ function rowOf(play, build, built, row) {
18
+ const entry = Object.entries(play.targets).find(([, t]) => serves(t, build, row));
19
+ const base = {
20
+ device: row.device,
21
+ os: row.os ?? null,
22
+ os_min: row.os_min ?? null,
23
+ input: row.input ?? [],
24
+ target: entry?.[0] ?? null,
25
+ devices: [],
26
+ note: row.note ?? null,
27
+ };
28
+ if (!entry) return { ...base, status: 'not set up' };
29
+ if (!built?.ok) return { ...base, status: 'not built' };
30
+ const t = entry[1];
31
+ if (t.devices) return { ...base, status: 'built' };
32
+ // This computer plays what has no devices script.
33
+ if (row.device === 'pc')
34
+ return {
35
+ ...base,
36
+ status: 'ready',
37
+ devices: [{ id: null, name: 'this computer', state: 'ready', play: true }],
38
+ };
39
+
40
+ return { ...base, status: 'not detected', address: t.open.replaceAll('{lan}', lanAddress()) };
41
+ }
42
+
43
+ /** Play by platform (block 2): each build of the card's `play_on` by each row of its `plays_on`. */
44
+ function playBlock(play, item, build, notes) {
45
+ if (!play) return [];
46
+ const all = Object.keys(play.builds);
47
+ const playOn = item.data.play_on ?? [];
48
+ const names = playOn.some((b) => all.includes(b)) ? playOn.filter((b) => all.includes(b)) : all;
49
+ const noteOf = (b, r) =>
50
+ notes?.rows.find((n) => n.build === b && n.device === r.device && n.os === (r.os ?? null))
51
+ ?.note || null;
52
+
53
+ return names.map((b) => {
54
+ // Step 1 has one build: the card's build is of it.
55
+ const built = build?.ok ? { profile: null, ok: true } : null;
56
+ const rows = play.builds[b].plays_on;
57
+
58
+ return {
59
+ build: b,
60
+ built,
61
+ rows: rows.length
62
+ ? rows.map((r) => rowOf(play, b, built, { ...r, note: noteOf(b, r) }))
63
+ : targetRows(play, b, built),
64
+ };
65
+ });
66
+ }
67
+
68
+ /**
69
+ * A build with no `plays_on` yet (a setup from before them): a row per target of it, so Play
70
+ * stays where the Play bar had it. `device: any`: no row of the core's says which.
71
+ */
72
+ function targetRows(play, build, built) {
73
+ return Object.entries(play.targets)
74
+ .filter(([, t]) => t.build === build)
75
+ .map(([name, t]) => ({
76
+ device: 'any',
77
+ os: null,
78
+ os_min: null,
79
+ input: [],
80
+ target: name,
81
+ devices: [],
82
+ note: null,
83
+ status: !built?.ok ? 'not built' : t.devices ? 'built' : 'ready',
84
+ }));
85
+ }
86
+
87
+ /** The outcome (block 0): where the card stands, its build, a ticket that waits for it. */
88
+ function outcomeOf(item, play, build, queue) {
89
+ const name = play ? Object.keys(play.builds)[0] : null;
90
+ const ticket = queue.find((q) => q.job.build === item.data.id);
91
+
92
+ return {
93
+ word: item.data.status,
94
+ build: build && {
95
+ name,
96
+ profile: null,
97
+ ok: build.ok,
98
+ built_at: build.built_at,
99
+ building: build.building,
100
+ // A snapshot there, and a later attempt that failed: what is played is the old one.
101
+ stale: build.ok && Boolean(build.problem),
102
+ problem: build.problem,
103
+ },
104
+ queued: ticket ? ticket.ticket : null,
105
+ };
106
+ }
107
+
108
+ /** What the agent said in its Outcome that the gates did not let it do: in its submit's subject. */
109
+ function saidOf(projectDir, id) {
110
+ const res = spawnSync(
111
+ 'git',
112
+ ['log', '-1', '--format=%s', '--fixed-strings', `--grep=gcf(submit): ${id}`],
113
+ { cwd: projectDir, encoding: 'utf8' },
114
+ );
115
+ const m = /\((agent: [^)]*)\)\s*$/.exec(res.stdout?.trim() ?? '');
116
+
117
+ return m ? m[1] : null;
118
+ }
119
+
120
+ /** What waits for the operator's word (block 6): the run's assumptions, its questions, its say. */
121
+ async function waitsOf(dir, id) {
122
+ const qs = await listQuestions(path.join(dir, 'gcf')).catch(() => []);
123
+ const blocksIt = (q) =>
124
+ String(q.blocks ?? '')
125
+ .split(/[\s,[\]]+/)
126
+ .includes(id);
127
+ const said = saidOf(dir, id);
128
+
129
+ return [
130
+ ...qs
131
+ .filter((q) => q.class === 'D2' && q.lens === id && q.assumed && !q.answer)
132
+ .map((q) => ({ kind: 'assume', id: q.id, text: `${q.question}: ${q.assumed}` })),
133
+ ...qs
134
+ .filter((q) => blocksIt(q) && !q.answer)
135
+ .map((q) => ({ kind: 'question', id: q.id, text: q.question, blocks: id })),
136
+ ...(said ? [{ kind: 'said', text: said }] : []),
137
+ ];
138
+ }
139
+
140
+ /** `play:` of the project, or null when it has none or a broken one (its own command says so). */
141
+ async function playIn(dir, config) {
142
+ try {
143
+ return playOf(config ?? (await readConfig(path.join(dir, 'gcf'))));
144
+ } catch {
145
+ return null;
146
+ }
147
+ }
148
+
149
+ /** The main question (block 1): the card's criterion word for word; a decision's is its intent. */
150
+ function questionOf(item, notes, decision) {
151
+ const criterion = scalarOf(item.body, 'miss_criterion') || null;
152
+
153
+ return {
154
+ criterion: decision ? (criterion ?? (firstBullet(item.body, 'intent') || null)) : criterion,
155
+ has_criterion: Boolean(criterion),
156
+ notes: notes?.question ?? [],
157
+ };
158
+ }
159
+
160
+ /** Block 7, folded: what a person rarely reads, kept for the one who does. */
161
+ function technicalOf(c) {
162
+ const ticks = planTicks(c.dir, c.item.data);
163
+
164
+ return {
165
+ commit: c.item.data.since ?? null,
166
+ code: c.build?.key ?? null,
167
+ unticked: ticks.tasks === null ? null : ticks.tasks - ticks.done,
168
+ passes: planPasses(c.text),
169
+ notes: c.notes?.notes || null,
170
+ };
171
+ }
172
+
173
+ /** Blocks 2, 4 and 5 with what the agent wrote; a decision has no Play and no Try. */
174
+ function playedBlocks(c) {
175
+ const n = c.notes;
176
+
177
+ return {
178
+ play: c.decision ? null : playBlock(c.play, c.item, c.build, n),
179
+ try: c.decision ? null : (n?.try ?? []),
180
+ try_from_behavior: recordsOf(c.item.body, 'behavior')
181
+ .map((r) => r.input)
182
+ .filter(Boolean),
183
+ attention: n?.watch_out ?? [],
184
+ };
185
+ }
186
+
187
+ /** What the handoff lacks: the agent's notes, the card's criterion. */
188
+ function warningsOf(c, question) {
189
+ const warnings = c.decision
190
+ ? []
191
+ : playNotesProblems(c.notes, rowsFor(c.play, c.item.data.play_on));
192
+ if (!question.has_criterion)
193
+ warnings.push("the card has no miss criterion: the question is the agent's");
194
+
195
+ return warnings;
196
+ }
197
+
198
+ /** A row of block 2 as words, and the command the board has a button for. */
199
+ function rowLines(id, build, r) {
200
+ const where = [r.device, r.os, r.os_min && `${r.os_min}+`].filter(Boolean).join(' ');
201
+ const lines = [` ${build} ${where}: ${r.status}${r.note ? ` — ${r.note}` : ''}`];
202
+ const wait = r.status === 'not built' ? ' --wait' : '';
203
+ if (r.target && r.status !== 'not set up')
204
+ lines.push(` ai-factory gcf playtest start ${id} --target ${r.target}${wait}`);
205
+ if (r.address) lines.push(` then open ${r.address}`);
206
+ if (r.status === 'built') lines.push(` devices: ai-factory gcf playtest devices ${r.target}`);
207
+
208
+ return lines;
209
+ }
210
+
211
+ const list = (head, items) => (items?.length ? [head, ...items.map((x) => ` - ${x}`)] : []);
212
+
213
+ /** The outcome line (block 0). */
214
+ function outcomeLine(o) {
215
+ const b = o.build;
216
+ const build = !b
217
+ ? 'no build'
218
+ : b.building
219
+ ? 'building'
220
+ : b.ok
221
+ ? `build ${b.name} ${b.built_at ?? ''}${b.stale ? ` (old: ${b.problem})` : ''}`
222
+ : `no build: ${b.problem}`;
223
+
224
+ return `outcome: ${o.word} · ${build}${o.queued ? ` · ticket ${o.queued} waits` : ''}`;
225
+ }
226
+
227
+ /** The technical line (block 7, folded to one line). */
228
+ function technicalLine(t) {
229
+ const parts = [
230
+ t.commit && `code at ${String(t.commit).slice(0, 7)}`,
231
+ t.unticked !== null && `unticked ${t.unticked}`,
232
+ t.passes.length && `plan passes ${t.passes.length}`,
233
+ t.notes,
234
+ ].filter(Boolean);
235
+
236
+ return parts.length ? [`technical: ${parts.join(' · ')}`] : [];
237
+ }
238
+
239
+ /** The handoff as the terminal reads it: blocks 0-6, then the technical one in a line. */
240
+ export function handoffLines(id, h) {
241
+ const q = h.question;
242
+
243
+ return [
244
+ outcomeLine(h.outcome),
245
+ `question: ${q.criterion ?? '(the card has no miss criterion)'}`,
246
+ ...q.notes.map((n) => ` - ${n}`),
247
+ ...(h.play?.length ? ['play:'] : []),
248
+ ...(h.play ?? []).flatMap((p) => p.rows.flatMap((r) => rowLines(id, p.build, r))),
249
+ ...list('changed:', h.changed),
250
+ ...list('try:', h.try?.length ? h.try : h.try === null ? [] : h.try_from_behavior),
251
+ ...list('watch out:', h.attention),
252
+ ...list(
253
+ 'waits for you:',
254
+ h.waits.map((w) => (w.kind === 'question' ? `${w.id}: ${w.text}` : w.text)),
255
+ ),
256
+ ...technicalLine(h.technical),
257
+ ...list('warnings:', h.warnings),
258
+ ];
259
+ }
260
+
261
+ /**
262
+ * Blocks 0-7 of card `id`'s handoff, or null when it has none (it waits for nothing). `links`:
263
+ * the snapshots' links, read once for a whole board.
264
+ */
265
+ export async function handoffOf(projectDir, id, { ledger = null, config = null, links } = {}) {
266
+ const dir = path.resolve(projectDir);
267
+ const item = (ledger ?? (await buildLedger(dir))).item(id);
268
+ if (!item || !String(item.data.status).startsWith('awaiting-')) return null;
269
+ const text = planTextOf(dir, item);
270
+ const decision = item.data.status === 'awaiting-decision';
271
+ const c = {
272
+ dir,
273
+ item,
274
+ text,
275
+ decision,
276
+ play: await playIn(dir, config),
277
+ notes: playNotesOf(text),
278
+ build: decision ? null : buildOf(dir, id, item.data.status, links),
279
+ };
280
+ const question = questionOf(item, c.notes, decision);
281
+
282
+ return {
283
+ outcome: outcomeOf(item, c.play, c.build, queueOf(dir)),
284
+ question,
285
+ changed: (item.data.live?.changes ?? []).map((x) => x.summary).filter(Boolean),
286
+ ...playedBlocks(c),
287
+ waits: await waitsOf(dir, id),
288
+ technical: technicalOf(c),
289
+ warnings: warningsOf(c, question),
290
+ };
291
+ }
package/lib/main-lock.js CHANGED
@@ -71,21 +71,45 @@ export function lockedItem(projectDir, id) {
71
71
  * A move on that item from anywhere else would race the run's own record of it.
72
72
  */
73
73
  export function runHolder(projectDir, id) {
74
+ const other = (pid) => Number.isInteger(pid) && pid > 0 && pid !== process.pid && alive(pid);
74
75
  try {
75
76
  const file = path.join(path.resolve(projectDir), '.gcf-session', 'runs', `${id}.lock`);
76
77
  const pid = Number(readFileSync(file, 'utf8').split('\n')[0]);
78
+ if (other(pid)) return pid;
79
+ } catch {
80
+ // No lock: a builder a yield let in may still hold the checkout.
81
+ }
82
+
83
+ const builder = id === MAIN_RUN ? builderPid(projectDir) : null;
84
+
85
+ return other(builder) ? builder : null;
86
+ }
77
87
 
78
- return Number.isInteger(pid) && pid > 0 && pid !== process.pid && alive(pid) ? pid : null;
88
+ /**
89
+ * The builder a main run's yield let in (lib/build-queue.js): a second holder of the checkout,
90
+ * live even when its run died (docs/Handoff-Plan.md d6). Read here: that module needs this one.
91
+ */
92
+ function builderPid(projectDir) {
93
+ try {
94
+ const file = path.join(path.resolve(projectDir), '.gcf-session', `${MAIN_RUN}.yield`);
95
+
96
+ return Number(JSON.parse(readFileSync(file, 'utf8')).builder) || null;
79
97
  } catch {
80
98
  return null;
81
99
  }
82
100
  }
83
101
 
102
+ /** The builder of the yield beside a main run lock (`<dir>/.gcf-session/runs/.main-run.lock`). */
103
+ const builderAt = (file) => builderPid(path.dirname(path.dirname(path.dirname(file))));
104
+
84
105
  /** The lock's text when its holder is gone, else null. The file appears whole: see `take`. */
85
106
  async function staleText(file) {
86
107
  try {
87
108
  const text = await readFile(file, 'utf8');
88
109
  const pid = Number(text.split('\n')[0]);
110
+ // The main run's lock lives on while the builder its yield let in does.
111
+ const builder = path.basename(file) === `${MAIN_RUN}.lock` ? builderAt(file) : null;
112
+ if (builder && alive(builder)) return null;
89
113
  if (Number.isInteger(pid) && pid > 0) return alive(pid) ? null : text;
90
114
 
91
115
  // Not ours to read: a lock in some other shape counts as dead only once it is old.