@dibssoftware/dibs 0.0.181 → 0.0.195

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 (105) hide show
  1. package/CHANGELOG.md +103 -1
  2. package/README.md +10 -8
  3. package/bin/dibs.mjs +370 -73
  4. package/docs/agents.md +303 -0
  5. package/docs/council.md +88 -0
  6. package/docs/files.md +3 -3
  7. package/docs/guard.md +86 -11
  8. package/docs/json.md +211 -0
  9. package/docs/later.md +5 -5
  10. package/docs/machines.md +6 -6
  11. package/docs/questions.md +104 -3
  12. package/docs/reference.md +124 -30
  13. package/docs/relay.md +120 -9
  14. package/docs/releasing.md +7 -1
  15. package/docs/scheduling.md +28 -6
  16. package/docs/secrets.md +53 -0
  17. package/docs/simulators.md +3 -3
  18. package/package.json +1 -1
  19. package/skills/dibs/SKILL.md +79 -149
  20. package/src/about.mjs +341 -0
  21. package/src/acquire.mjs +111 -27
  22. package/src/after.mjs +127 -0
  23. package/src/agents.mjs +2 -1
  24. package/src/alerts.mjs +95 -42
  25. package/src/answers.mjs +2 -2
  26. package/src/board.mjs +21 -16
  27. package/src/broker.mjs +23 -7
  28. package/src/carry.mjs +287 -0
  29. package/src/codex.mjs +132 -0
  30. package/src/commands.mjs +243 -82
  31. package/src/config.mjs +85 -14
  32. package/src/connect.mjs +4 -2
  33. package/src/cool.mjs +27 -11
  34. package/src/council.mjs +482 -0
  35. package/src/cwd.mjs +9 -0
  36. package/src/decisions.mjs +250 -0
  37. package/src/declare.mjs +96 -0
  38. package/src/diskreport.mjs +306 -0
  39. package/src/diskuse.mjs +420 -0
  40. package/src/diskwarn.mjs +68 -13
  41. package/src/doctor.mjs +149 -0
  42. package/src/doors.mjs +547 -0
  43. package/src/durable.mjs +143 -0
  44. package/src/envs.mjs +372 -0
  45. package/src/events.mjs +7 -2
  46. package/src/files.mjs +118 -6
  47. package/src/guard.mjs +239 -86
  48. package/src/guardd.mjs +8 -1
  49. package/src/halt.mjs +63 -0
  50. package/src/handoffs.mjs +362 -0
  51. package/src/history.mjs +34 -4
  52. package/src/hogs.mjs +36 -8
  53. package/src/jobprogress.mjs +283 -0
  54. package/src/later.mjs +21 -10
  55. package/src/lock.mjs +33 -9
  56. package/src/measure.mjs +42 -11
  57. package/src/media.mjs +240 -0
  58. package/src/news.mjs +31 -0
  59. package/src/notes.mjs +49 -8
  60. package/src/notices.mjs +126 -43
  61. package/src/ondemand.mjs +25 -2
  62. package/src/outcome.mjs +163 -0
  63. package/src/overlap.mjs +2 -2
  64. package/src/override.mjs +149 -79
  65. package/src/owner.mjs +15 -2
  66. package/src/people.mjs +236 -0
  67. package/src/pickup.mjs +72 -0
  68. package/src/picture.mjs +321 -0
  69. package/src/plain.mjs +84 -18
  70. package/src/platform.mjs +19 -0
  71. package/src/preempt.mjs +123 -15
  72. package/src/primer.mjs +91 -20
  73. package/src/prints.mjs +99 -0
  74. package/src/proc.mjs +1 -1
  75. package/src/progress.mjs +49 -3
  76. package/src/proof.mjs +102 -0
  77. package/src/push.mjs +271 -0
  78. package/src/questions.mjs +328 -57
  79. package/src/quota.mjs +1 -1
  80. package/src/recap.mjs +205 -0
  81. package/src/relay.mjs +139 -20
  82. package/src/remote.mjs +23 -10
  83. package/src/reviewgate.mjs +268 -0
  84. package/src/reviews.mjs +377 -0
  85. package/src/route.mjs +263 -0
  86. package/src/rules.mjs +216 -0
  87. package/src/schedule.mjs +238 -44
  88. package/src/schema.mjs +62 -0
  89. package/src/scratch.mjs +2 -2
  90. package/src/serve.mjs +3 -2
  91. package/src/signed.mjs +97 -0
  92. package/src/simpool.mjs +46 -1
  93. package/src/spend.mjs +375 -0
  94. package/src/state.mjs +43 -17
  95. package/src/talk.mjs +1078 -133
  96. package/src/thin.sh +2 -0
  97. package/src/trail.mjs +290 -0
  98. package/src/trailnote.mjs +209 -0
  99. package/src/util.mjs +7 -0
  100. package/src/vault.mjs +435 -0
  101. package/src/vendors.mjs +327 -0
  102. package/src/version.mjs +1 -1
  103. package/src/web.mjs +353 -60
  104. package/src/work.mjs +487 -0
  105. package/src/worker.mjs +7 -1
package/src/alerts.mjs CHANGED
@@ -7,10 +7,11 @@
7
7
  // list; the app turns a new one into a notification, at most one per cause
8
8
  // every 30 minutes.
9
9
  //
10
- // Seven causes:
10
+ // Eight causes:
11
11
  // wait a job waiting far longer than usual, worst when a person waits on it
12
12
  // memory memory pressure or swap holding new jobs back, with what to close
13
13
  // idle a slot held by a job that has done nothing for a long time
14
+ // slow a job far off its own pace, or running several times its usual time (src/jobprogress.mjs)
14
15
  // ended jobs that failed, were stopped, or were lost on another machine
15
16
  // dibs dibs itself: a service down or restarting, a crash, the hook failing
16
17
  // disk free disk under the floor
@@ -26,8 +27,9 @@
26
27
  import fs from 'node:fs';
27
28
  import path from 'node:path';
28
29
  import { HOME, paths, machine } from './config.mjs';
29
- import { verdict } from './schedule.mjs';
30
- import { stuckFor, minutes, andList } from './plain.mjs';
30
+ import { verdict, keptFree } from './schedule.mjs';
31
+ import { stuckFor, minutes, andList, waitingText, slowText } from './plain.mjs';
32
+ import { slowness } from './jobprogress.mjs';
31
33
  import { processesNow, memoryUse } from './platform.mjs';
32
34
  import { treeOf } from './measure.mjs';
33
35
  import { withState, history } from './state.mjs';
@@ -36,9 +38,13 @@ import { sessionFiles } from './proc.mjs';
36
38
  import { EVENTS } from './events.mjs';
37
39
  import { serviceHealth, logName } from './service.mjs';
38
40
  import { hogHint } from './hogs.mjs';
41
+ import { useHint } from './diskuse.mjs';
42
+ import { reportHint } from './diskreport.mjs';
39
43
  import { underLock, heldBy } from './lock.mjs';
44
+ import { writeWhole, parsed } from './durable.mjs';
40
45
  import { now, bytes, clock, gb, die } from './util.mjs';
41
46
  import { dim, red, amber, wrap } from './style.mjs';
47
+ import { described } from './declare.mjs';
42
48
 
43
49
  export const FILE = path.join(HOME, 'alerts.json');
44
50
  // The throttle watcher's notes on the machine (src/cool.mjs noteCpu).
@@ -83,7 +89,7 @@ const FIRST_READ = 2 * 1024 ** 2;
83
89
  // The rules a waiter is held by when the machine's memory, not a turn or dibs's budget, is in the way.
84
90
  const PRESSURE = new Set(['pressure', 'swap', 'swaproom', 'ram', 'oversize']);
85
91
  // Bumped when what makes an alert changes, so an upgrade rebuilds the open ones instead of closing them.
86
- const RULES = 2;
92
+ const RULES = 3;
87
93
  // The same command failing this many times in a row, with no pass between, is worth the person's attention.
88
94
  const REPEATS = 3;
89
95
  // Exit codes a stopped command dies with: Ctrl-C, SIGKILL, SIGTERM.
@@ -99,8 +105,12 @@ export function stamp(at, t = now()) {
99
105
  return `${day} ${clock(at)}`;
100
106
  }
101
107
 
102
- const what = x => (x.purpose || x.cmd || (x.res || []).join(', ') || 'a job').replace(/\s+/g, ' ').slice(0, 70);
103
- const job = x => `${x.who}'s #${x.id} (${what(x)})`;
108
+ const what = x => described(x).replace(/\s+/g, ' ').slice(0, 70);
109
+ // A job as the person reads it: the agent, then its work in its own words. The number
110
+ // and the command to type go in run, for agents: the phone and the page show title, why
111
+ // and fix to the person, and on 2026-11-27 its Inbox read "alex-d5's #26745 (...)
112
+ // ... CPU budget: 2.6 of 10 cores in use, you need 9 ... dibs boost 26745 high".
113
+ const job = x => `${x.who}'s "${what(x)}"`;
104
114
  const personWaits = q => q.prio === 'urgent' || q.prio === 'high' || typeof q.by === 'number';
105
115
  const isDeploy = res => (res || []).some(r => r === 'deploy' || r.startsWith('deploy-') || r.startsWith('deploy:'));
106
116
  // A failure the person cares about: a deploy, or a job they were waiting on.
@@ -114,9 +124,7 @@ function load() {
114
124
  }
115
125
 
116
126
  function save(st) {
117
- const tmp = `${FILE}.${process.pid}`;
118
- fs.writeFileSync(tmp, JSON.stringify(st));
119
- fs.renameSync(tmp, FILE);
127
+ writeWhole(FILE, JSON.stringify(st));
120
128
  }
121
129
 
122
130
  // One scan at a time. Whoever finds the lock taken shows what the file already
@@ -166,7 +174,8 @@ function readEvents(st, t) {
166
174
  const x = { at: e.at, id: e.id, who: e.who, res: e.res, cmd: e.cmd, purpose: e.purpose, key: e.key, code: e.code, prio: e.prio, due: e.due };
167
175
  if (by || STOPPED.has(e.code)) st.ended.push({ kind: 'stopped', ...x, by: by || null });
168
176
  else if (e.code != null && e.code !== 0) st.ended.push({ kind: 'failed', ...x });
169
- } else if (e.kind === 'lockstuck') st.ended.push({ kind: e.kind, at: e.at, key: e.key, pid: e.pid, cmd: e.cmd, held: e.held });
177
+ } else if (e.kind === 'recovered') st.ended.push({ kind: e.kind, at: e.at, file: e.file, saved: e.saved, from: e.from, kept: e.kept, using: e.using });
178
+ else if (e.kind === 'lockstuck') st.ended.push({ kind: e.kind, at: e.at, key: e.key, pid: e.pid, cmd: e.cmd, held: e.held });
170
179
  else if (e.kind === 'lost' || e.kind === 'crash') st.ended.push({ kind: e.kind, at: e.at, who: e.who, cmd: e.cmd, code: e.code, why: e.why, verb: e.verb });
171
180
  }
172
181
  st.ended = st.ended.filter(x => t - x.at < EVENT_KEEP);
@@ -210,7 +219,7 @@ export function memoryUsers(s, procs, use) {
210
219
  const bytes = use.get(p.pid);
211
220
  if (!bytes) continue;
212
221
  const l = owner.get(p.pid);
213
- const [name, cmd] = l ? [`dibs job #${l.id} (${l.who})`] : appOf(p, sessions);
222
+ const [name, cmd] = l ? [job(l)] : appOf(p, sessions);
214
223
  const g = groups.get(name) || { name, bytes: 0, n: 0, dibs: !!l, ...(l && { id: l.id }), ...(cmd && { cmd: true }) };
215
224
  g.bytes += bytes; g.n++;
216
225
  groups.set(name, g);
@@ -257,7 +266,7 @@ export function detect({ s, cfg, hist, m, t, st, users }) {
257
266
  out.push({ id: `wait:#${q.id}`, cause: 'wait', level: personWaits(q) ? 'urgent' : 'warn', job: q.id, who: q.who, at: q.enq,
258
267
  ...(pressed(v) && !users && { want: 'users' }),
259
268
  title: `${job(q)} has waited ${minutes(waited)}${usual >= MIN ? `, where ${q.res[0]} usually takes ${minutes(usual)}` : ''}${personWaits(q) ? `, and it's ${typeof q.by === 'number' ? `due by ${stamp(q.by, t)}` : q.prio}` : ''}`,
260
- why: v.why, fix: waitFix(s, q, v, t, users) });
269
+ why: `Waiting for ${waitingText(s, q, v, cfg, hist, t, m)}`, ...waitFix(s, q, v, t, users) });
261
270
  }
262
271
 
263
272
  // Memory holding new jobs back.
@@ -268,10 +277,11 @@ export function detect({ s, cfg, hist, m, t, st, users }) {
268
277
  const close = list.filter(g => !g.dibs);
269
278
  const ours = list.filter(g => g.dibs);
270
279
  out.push({ id: 'memory', cause: 'memory', level: 'urgent', after: PRESSURE_AFTER, at: Math.min(...held.map(q => q.enq)), ...(!users && { want: 'users' }),
271
- title: `${swap ? 'Swap' : 'Memory pressure'} is holding back ${held.length} job${held.length > 1 ? 's' : ''} (${andList(held.slice(0, 3).map(q => `#${q.id}`))}${held.length > 3 ? ' and more' : ''})`,
272
- why: verdicts.get(held[0].id).why,
280
+ // The person reads agents and their work, not job numbers (2026-11-27).
281
+ title: `${swap ? 'Swap' : 'Memory'} is holding back ${andList(held.slice(0, 2).map(job))}${held.length > 2 ? ` and ${held.length - 2} more` : ''}`,
282
+ why: `Waiting for ${waitingText(s, held[0], verdicts.get(held[0].id), cfg, hist, t, m)}`,
273
283
  detail: list.length ? `Using the most memory: ${list.map(sized).join(', ')}.` : '',
274
- fix: memoryFix(list) });
284
+ ...memoryFix(list) });
275
285
  }
276
286
 
277
287
  // A slot held by a run that has used no CPU for a long while someone waits for it.
@@ -282,7 +292,22 @@ export function detect({ s, cfg, hist, m, t, st, users }) {
282
292
  if (!behind.length) continue;
283
293
  out.push({ id: `idle:#${l.id}`, cause: 'idle', level: behind.some(personWaits) ? 'urgent' : 'warn', job: l.id, who: l.who, at: l.idleSince,
284
294
  title: `${job(l)} has held ${l.res.join(', ')} for ${minutes(t - l.start)} and used no CPU for ${minutes(idle)}, while ${behind.length} job${behind.length > 1 ? 's wait' : ' waits'}`,
285
- fix: `If it's stuck, stop it: dibs stop ${l.id} --owner ${l.who}. If it's working somewhere dibs can't see, leave it.` });
295
+ fix: "A job waiting on the network or another machine uses no CPU either. Stopping it ends it and lets the next job start.", run: `dibs stop ${l.id}` });
296
+ }
297
+
298
+ // A job far below its own earlier rate, or running several times as long as the same
299
+ // command usually takes (src/jobprogress.mjs slowness, which needs real history and a
300
+ // big gap). On 2026-11-27 a solver held the machine 7 hours at a sixth of its speed
301
+ // while a test waited 6 behind it, and nobody knew. dibs never stops it: whoever owns it decides.
302
+ for (const l of s.leases || []) {
303
+ const sl = slowness(l, hist, t);
304
+ if (!sl) continue;
305
+ const behind = waiting.filter(q => q.res.some(r => l.res.includes(r)));
306
+ const names = andList([...behind.slice(0, 2).map(job), ...(behind.length > 2 ? [`${behind.length - 2} more`] : [])]);
307
+ out.push({ id: `slow:#${l.id}`, cause: 'slow', level: behind.some(personWaits) ? 'urgent' : behind.length ? 'warn' : 'note', job: l.id, who: l.who,
308
+ title: `${job(l)} ${slowText(sl)}${behind.length ? `, while ${names} ${behind.length > 1 ? 'wait' : 'waits'} behind it` : ''}`,
309
+ fix: `dibs won't stop it. ${l.who} decides: if it's stuck or no longer worth the wait, stopping it lets ${behind.length ? 'the next one' : 'other work'} start; if it's working, leave it.`,
310
+ run: `dibs stop ${l.id}` });
286
311
  }
287
312
 
288
313
  // Jobs that failed, were stopped, or were lost, and dibs's own crashes. An
@@ -308,10 +333,10 @@ export function detect({ s, cfg, hist, m, t, st, users }) {
308
333
  // Stopped on purpose (exit 143 or 137, or dibs stop): on record in dibs alerts --all, nowhere louder.
309
334
  out.push({ id: `stopped:#${x.id}`, cause: 'ended', level: 'note', at: x.at, job: x.id, who: x.who, quiet: true,
310
335
  title: `${job(x)} was stopped${x.by ? ` by ${x.by}` : ''} at ${stamp(x.at, t)}${x.code != null ? ` (exit ${x.code})` : ''}`,
311
- fix: `If it should finish, ${x.who} runs it again; nothing else waits on it.` });
336
+ fix: `Nothing else waits on it. It runs again only if ${x.who} starts it again.` });
312
337
  } else if (x.kind === 'lost') {
313
338
  out.push({ id: `lost:${x.at}`, cause: 'ended', level: 'urgent', at: x.at, who: x.who,
314
- title: `${x.who}'s job was lost${x.code === 77 ? ' after it started' : ' before it started'} at ${stamp(x.at, t)}: ${x.why || x.cmd}`,
339
+ title: `${x.who}'s job was lost${x.code === 77 ? ' after it started' : ' before it started'} at ${stamp(x.at, t)}: ${x.why || what(x)}`,
315
340
  fix: x.code === 77 ? 'It may have run. Check what it changed before running it again.' : 'It never ran, so it\'s safe to run again.' });
316
341
  } else if (x.kind === 'lockstuck') {
317
342
  // Open while that same holder still has the lock; it closes the moment it lets go.
@@ -319,17 +344,36 @@ export function detect({ s, cfg, hist, m, t, st, users }) {
319
344
  if (now?.key !== x.key) continue;
320
345
  out.push({ id: `lockstuck:${x.key}`, cause: 'dibs', level: 'urgent', at: x.at - x.held,
321
346
  title: `dibs is stuck behind pid ${x.pid}${x.cmd ? ` (${x.cmd.slice(0, 80)})` : ''}: it has held the state lock for ${minutes(now.held)}, and every dibs command waits for it`,
322
- fix: `If pid ${x.pid} is hung, end it and everyone goes on at once: kill ${x.pid}` });
347
+ fix: `Ending pid ${x.pid} frees the lock, and every dibs command goes on at once.`, run: `kill ${x.pid}` });
348
+ } else if (x.kind === 'recovered') {
349
+ // A state file that didn't parse, put right (src/durable.mjs heal): what came back, what didn't.
350
+ const name = path.basename(x.file);
351
+ if (x.using) {
352
+ // The person's config.json, never written over: open until it parses again.
353
+ let fixed = false;
354
+ try { fixed = !!parsed(fs.readFileSync(x.file, 'utf8')); } catch {}
355
+ if (!fixed) out.push({ id: `recovered:${x.at}`, cause: 'dibs', level: 'warn', at: x.at,
356
+ title: `${name} isn't valid JSON since ${stamp(x.at, t)}, so dibs runs on its copy from ${stamp(x.from, t)}: changes made to it since aren't used`,
357
+ fix: `Fix ${x.file}, or remove it to get the defaults back. This closes once it reads.` });
358
+ continue;
359
+ }
360
+ out.push({ id: `recovered:${x.at}`, cause: 'dibs', level: 'warn', at: x.at,
361
+ title: x.from
362
+ ? `${name} was broken at ${stamp(x.at, t)}, and dibs put back its copy from ${stamp(x.from, t)}${x.kept ? ` (${x.kept})` : ''}: whatever changed after that is lost`
363
+ : `${name} was broken at ${stamp(x.at, t)}, and with no earlier copy dibs started it empty: what it held is lost`,
364
+ fix: `${name !== 'state.json' ? '' : x.from ? 'A running job missing from the copy keeps running untracked, and a waiter missing from it was told to run again (exit 75). '
365
+ : 'Running jobs keep running untracked, and waiters were told to run again (exit 75). '}`
366
+ + `The broken file is kept at ${x.saved}. dibs doctor checks every other file.`, run: 'dibs doctor' });
323
367
  } else if (x.kind === 'crash') {
324
368
  out.push({ id: `crash:${x.at}`, cause: 'dibs', level: 'urgent', at: x.at, who: x.who,
325
369
  title: `dibs crashed at ${stamp(x.at, t)} running dibs ${x.verb || ''} for ${x.who}`,
326
- fix: `It's a bug in dibs. Report it: dibs ask "crash in dibs ${x.verb || ''}"` });
370
+ fix: "It's a bug in dibs, not in the agent's work. Report it.", run: `dibs ask "crash in dibs ${x.verb || ''}"` });
327
371
  }
328
372
  }
329
373
  for (const [k, g] of failed) {
330
374
  const loud = g.cmd && g.n >= REPEATS;
331
375
  out.push({ id: `failed:${hash(k)}`, cause: 'ended', level: loud ? 'warn' : 'note', at: g.first, last: g.at, who: g.who, ...(!loud && { quiet: true }),
332
- title: `${g.who}'s ${what(g)} failed${g.n > 1 ? ` ${g.n} times in a row, last` : ''} at ${stamp(g.at, t)} (exit ${g.code})`,
376
+ title: `${g.who}'s run "${what(g)}" failed${g.n > 1 ? ` ${g.n} times in a row, last` : ''} at ${stamp(g.at, t)} (exit ${g.code})`,
333
377
  fix: `${g.who} is the one to fix it; this closes when the same command passes.` });
334
378
  }
335
379
 
@@ -338,19 +382,19 @@ export function detect({ s, cfg, hist, m, t, st, users }) {
338
382
  if (!h.running)
339
383
  out.push({ id: `service:${k}`, cause: 'dibs', level: 'urgent',
340
384
  title: `dibs's ${k} service isn't running${h.exit ? ` (it last exited with code ${h.exit})` : ''}: ${h.what}`,
341
- fix: `Start it again: dibs service install ${k}. Why it stopped is in ~/.dibs/${logName(k)}.` });
385
+ fix: `Start it again. Why it stopped is in ~/.dibs/${logName(k)}.`, run: `dibs service install ${k}` });
342
386
  for (const k of new Set((st.restarts || []).map(r => r.k))) {
343
387
  const rs = st.restarts.filter(r => r.k === k);
344
388
  const last = rs[rs.length - 1];
345
389
  out.push({ id: `restart:${k}`, cause: 'dibs', level: 'warn', at: rs[0].at,
346
390
  title: `dibs's ${k} service crashed (exit ${last.exit}) and launchd started it again${rs.length > 1 ? `, ${rs.length} times in the last hour` : ''}, last at ${stamp(last.at, t)}`,
347
- fix: `Look in ~/.dibs/${logName(k)} for why, and report it: dibs ask "the ${k} service keeps exiting with ${last.exit}"` });
391
+ fix: `Why is in ~/.dibs/${logName(k)}. Report it.`, run: `dibs ask "the ${k} service keeps exiting with ${last.exit}"` });
348
392
  }
349
393
  if (st.hook?.length) {
350
394
  const last = st.hook[st.hook.length - 1];
351
395
  out.push({ id: 'hook', cause: 'dibs', level: 'warn', at: st.hook[0].at,
352
396
  title: `The Claude Code hook failed ${st.hook.length} time${st.hook.length > 1 ? 's' : ''} in the last hour, last at ${stamp(last.at, t)}: ${last.msg}`,
353
- fix: `Those tool calls ran without dibs's checks. Report it: dibs ask "hook: ${last.msg.slice(0, 60)}"` });
397
+ fix: "Those tool calls ran without dibs's checks. Report it.", run: `dibs ask "hook: ${last.msg.slice(0, 60)}"` });
354
398
  }
355
399
 
356
400
  // The hard stop (src/preempt.mjs hardStop): a job paused under 1 GB free, whatever it was.
@@ -370,52 +414,61 @@ export function detect({ s, cfg, hist, m, t, st, users }) {
370
414
  for (const o of cpu.orphans || [])
371
415
  out.push({ id: `orphan:${o.pid}`, cause: 'machine', level: 'warn',
372
416
  title: `${o.name} ${o.pid} has run ${Math.round(o.age / HOUR)} hours outside dibs, using ${Math.round(o.cpu / HOUR)} CPU-hours, and its script ${o.script} is gone`,
373
- fix: `Likely left behind by a session that ended. dibs leaves it running; if nobody needs it, end it: kill ${o.pid}` });
417
+ fix: "Its script is gone, as happens when the session that started it has ended. dibs didn't start it, so it leaves it running.", run: `kill ${o.pid}` });
374
418
  }
375
419
 
376
420
  // Disk under the floor: nothing new starts.
377
421
  const floor = bytes(cfg.minDisk || '0');
378
422
  if (floor && m.diskFree != null && m.diskFree < floor)
379
423
  out.push({ id: 'disk', cause: 'disk', level: 'urgent',
380
- title: `Free disk is ${gb(m.diskFree).replace(/G$/, ' GB')}, under the ${gb(floor).replace(/G$/, ' GB')} dibs keeps free, so only jobs that write next to nothing start; the rest wait for room`,
424
+ title: `Free disk is ${gb(m.diskFree).replace(/G$/, ' GB')}, and dibs keeps ${keptFree(cfg)}, so only jobs that write next to nothing start; the rest wait for room`,
381
425
  fix: diskFix() });
382
426
  return out;
383
427
  }
384
428
 
385
- // The one thing that lets a long-waiting job start, by what holds it.
429
+ // What a boost does to a waiter, said as a fact: whether to use it is the person's call or its agent's.
430
+ const BOOST_MOVES = 'High priority moves a waiter 1 hour ahead in line, urgent 2 hours.';
431
+
432
+ // What holds a long-waiting job and what would let it start: { fix } in plain
433
+ // words for the person, and { run }, the command an agent types for it.
386
434
  function waitFix(s, q, v, t, users) {
387
- const boost = `dibs boost ${q.id} urgent -m "why"`;
435
+ const boost = { run: `dibs boost ${q.id} urgent -m "why"` };
388
436
  if (v.rule === 'slot' || v.rule === 'files' || v.rule === 'together') {
389
437
  // With one deploy per project (the per-repo lock), the one in the way is this project's.
390
438
  const on = (s.leases || []).filter(x => x.res.includes(v.on));
391
439
  const l = on.find(x => q.repo && x.repo === q.repo) || on[0] || v.ahead;
392
- if (l && stuckFor(l, t)) return `${job(l)} holds ${v.on} and has done nothing for ${minutes(stuckFor(l, t))}: stop it with dibs stop ${l.id} --owner ${l.who}.`;
393
- if (l) return `${job(l)} has held ${v.on} for ${minutes(t - l.start)}. If ${q.who}'s job can't wait, ${boost} puts it first in line; ${l.who} decides whether to stop theirs.`;
440
+ if (l && stuckFor(l, t)) return { fix: `${job(l)} holds ${v.on} and has done nothing for ${minutes(stuckFor(l, t))}: stopping it lets this one start.`, run: `dibs stop ${l.id}` };
441
+ // The yield protocol (src/preempt.mjs): a --pausable job steps aside for urgent work by itself; any other is never stopped by dibs.
442
+ if (l) return { fix: `${job(l)} has had ${v.on} for ${minutes(t - l.start)}. High priority moves a waiter 1 hour ahead in line, urgent 2 hours. ${l.pausable
443
+ ? 'It was started with --pausable: for urgent or high work, dibs pauses it, or has it save its progress and step aside, and picks it up again after.'
444
+ : "dibs doesn't stop a job not started with --pausable."}`, ...boost };
394
445
  }
395
- if (v.rule === 'ahead' && v.ahead) return `${job(v.ahead)} is ahead. If this one matters more: ${boost}.`;
446
+ if (v.rule === 'ahead' && v.ahead) return { fix: `${job(v.ahead)} is ahead of it. ${BOOST_MOVES}`, ...boost };
396
447
  // What uses the memory, said here: an alert that points at another one that isn't there is no help.
397
448
  if (pressed(v)) return memoryFix(users || []);
398
449
  if (v.rule === 'memory') {
399
450
  const big = (s.leases || []).filter(l => l.mem).sort((a, b) => b.mem - a.mem).slice(0, 3);
400
- return `dibs's memory budget is handed out to running jobs${big.length ? `, the biggest ${andList(big.map(l => `${job(l)} with ${gb(l.mem).replace(/G$/, ' GB')}`))}` : ''}. It starts as they end; if it can't wait: ${boost}.`;
451
+ return { fix: `dibs's memory is handed out to running jobs${big.length ? `, the biggest ${andList(big.map(l => `${job(l)} with ${gb(l.mem).replace(/G$/, ' GB')}`))}` : ''}. It starts as they end; if it can't wait, move it up.`, ...boost };
401
452
  }
402
- if (v.rule === 'disk' || v.rule === 'drain') return diskFix();
403
- if (v.rule === 'load' || v.rule === 'cpu') return `The machine is busy. If a person waits on this: dibs boost ${q.id} high -m "why".`;
404
- if (v.rule === 'idle') return `It's idle-priority work, which waits for everything else: dibs boost ${q.id} normal.`;
405
- if (v.rule === 'reset') return `${v.on} is being reset after the last job; if that takes too long, check its onRelease in ~/.dibs/config.json.`;
406
- return `${v.why}. If it can't wait: ${boost}.`;
453
+ if (v.rule === 'disk' || v.rule === 'drain') return { fix: diskFix() };
454
+ if (v.rule === 'load') return { fix: 'The machine is past its load limit, where normal and lower work waits. High and urgent work starts past it.', run: `dibs boost ${q.id} high -m "why"` };
455
+ if (v.rule === 'cpu') return { fix: `The cores dibs hands out are in use, and waiters get them as they free up, in line order. ${BOOST_MOVES}`, run: `dibs boost ${q.id} high -m "why"` };
456
+ if (v.rule === 'idle') return { fix: 'It runs at idle priority, which waits while anyone else waits. At normal priority it takes its turn in arrival order.', run: `dibs boost ${q.id} normal` };
457
+ if (v.rule === 'reset') return { fix: `${v.on} is being reset after the last job; if that takes too long, check its onRelease in ~/.dibs/config.json.` };
458
+ return { fix: BOOST_MOVES, ...boost };
407
459
  }
408
460
 
409
461
  // What to close, from the biggest memory users on the machine.
410
462
  function memoryFix(list) {
411
463
  const close = list.filter(g => !g.dibs), ours = list.filter(g => g.dibs);
412
- if (close.length) return `Close what you can of ${andList(close.slice(0, 3).map(sized))}. dibs won't close apps it didn't start.${ours.length ? ` Or stop a dibs job: dibs stop ${ours[0].id}.` : ''}`;
413
- if (ours.length) return `dibs's own jobs use it: dibs stop ${ours[0].id} frees the most.`;
414
- return "Close apps you aren't using; dibs won't close what it didn't start.";
464
+ if (close.length) return { fix: `Close what you can of ${andList(close.slice(0, 3).map(sized))}. dibs won't close apps it didn't start.${ours.length ? ` Or stop ${ours[0].name}.` : ''}`,
465
+ ...(ours.length && { run: `dibs stop ${ours[0].id}` }) };
466
+ if (ours.length) return { fix: `dibs's own jobs use it: stopping ${ours[0].name} frees the most.`, run: `dibs stop ${ours[0].id}` };
467
+ return { fix: "Close apps you aren't using; dibs won't close what it didn't start." };
415
468
  }
416
469
 
417
470
  function diskFix() {
418
- return `Free disk: build output, caches and scratch folders${hogHint()}.`;
471
+ return `Free disk: build output, caches and scratch folders${hogHint()}${useHint()}${reportHint()}.`;
419
472
  }
420
473
 
421
474
  const median = xs => { if (!xs.length) return 0; const a = [...xs].sort((x, y) => x - y); return a[Math.floor(a.length / 2)]; };
@@ -515,7 +568,7 @@ export function alertLines(list, t = now()) {
515
568
  if (a.resolvedAt) out.push(dim(`Resolved at ${stamp(a.resolvedAt, t)}${a.dismissed ? ' (dismissed)' : ''}: ${a.title}.`));
516
569
  else {
517
570
  const paint = a.level === 'urgent' ? red : a.level === 'warn' ? amber : x => x;
518
- out.push(paint(`${a.level === 'note' ? '' : '! '}${a.title} (since ${stamp(a.since, t)}).`), wrap(` Fix: ${a.fix}`, ' '));
571
+ out.push(paint(`${a.level === 'note' ? '' : '! '}${a.title} (since ${stamp(a.since, t)}).`), wrap(` Fix: ${a.fix}${a.run ? ` (${a.run})` : ''}`, ' '));
519
572
  }
520
573
  }
521
574
  return out;
package/src/answers.mjs CHANGED
@@ -7,7 +7,7 @@ import path from 'node:path';
7
7
  import { fileURLToPath } from 'node:url';
8
8
 
9
9
  const ROOT = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
10
- const DOCS = ['skills/dibs/SKILL.md', 'README.md', ...['reference', 'guard', 'files', 'questions', 'later', 'machines', 'simulators', 'scheduling', 'relay'].map(d => `docs/${d}.md`)];
10
+ const DOCS = ['skills/dibs/SKILL.md', 'README.md', ...['reference', 'agents', 'json', 'guard', 'files', 'questions', 'later', 'machines', 'simulators', 'scheduling', 'relay'].map(d => `docs/${d}.md`)];
11
11
  export const ISSUES = 'https://github.com/dibssoftware/dibs/issues';
12
12
  // Two passages answer most questions; more is reading the docs.
13
13
  const SHOW = 2;
@@ -16,7 +16,7 @@ const MAX_CHARS = 600;
16
16
  const STOP = new Set(('the a an and or but to of in on for with is are was be it this that how do does i my me you your can why what when '
17
17
  + 'should would could not no if at as by from so get got use using run dibs it\'s don\'t doesn\'t there their they them about into just').split(' '));
18
18
 
19
- const words = text => text.toLowerCase().match(/[a-z0-9][a-z0-9:_-]*/g)?.filter(w => (w.length > 2 || /^\d+$/.test(w)) && !STOP.has(w)) || [];
19
+ export const words = text => text.toLowerCase().match(/[a-z0-9][a-z0-9:_-]*/g)?.filter(w => (w.length > 2 || /^\d+$/.test(w)) && !STOP.has(w)) || [];
20
20
 
21
21
  // A list or a table is one paragraph but many answers: shown whole and cut to its
22
22
  // start, the item that matched was often past the cut. Each item and each table
package/src/board.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  import { resCfg } from './config.mjs';
4
4
  import { tag, isMine } from './proc.mjs';
5
5
  import { idleFor, UNPOLLED } from './acquire.mjs';
6
- import { forecast, byRank, remaining, used, overBy, verdict, memUsed, cpuUsed, shownFree, swapGrowing, diskSqueeze, BREAKER_LINE, QUICK_LINE } from './schedule.mjs';
6
+ import { forecast, byRank, remaining, used, overBy, verdict, memUsed, cpuUsed, shownFree, swapGrowing, diskSqueeze, BREAKER_LINE, QUICK_LINE, EASED_LINE, fairShare } from './schedule.mjs';
7
7
  import { grewLine, cappedLine } from './measure.mjs';
8
8
  import { pauseLabel } from './preempt.mjs';
9
9
  import { alongsideLabel } from './overlap.mjs';
@@ -13,7 +13,9 @@ import { agentsNow } from './agents.mjs';
13
13
  import { remoteConf, call } from './remote.mjs';
14
14
  import { bytes, dur, gb, clock, now, holder, when } from './util.mjs';
15
15
  import { short, isFiles, sameAgent } from './files.mjs';
16
- import { named, about, minutes, usingText, nextText, stuckFor, heldByLoad } from './plain.mjs';
16
+ import { named, about, minutes, usingText, nextText, stuckFor, heldByLoad, doneText, slowText } from './plain.mjs';
17
+ import { progressOf, slowness } from './jobprogress.mjs';
18
+ import { described } from './declare.mjs';
17
19
 
18
20
  // Why a waiter isn't running, short enough for its board row: the rule and
19
21
  // what it's stuck on (a file lease's path, a bucket's name). Disk says the
@@ -21,6 +23,7 @@ import { named, about, minutes, usingText, nextText, stuckFor, heldByLoad } from
21
23
  // `dibs --json` carries it as is ("slot: xcode-build", "behind web-app").
22
24
  export const waitReason = v => (v.ok ? null : v.rule === 'ahead' && v.ahead ? `behind ${tag(v.ahead)}`
23
25
  : v.rule === 'load' && v.since != null ? heldByLoad(v)
26
+ : v.rule === 'halt' ? `held by ${v.by || 'the person'} ${v.until != null ? `until ${clock(v.until)}` : "until it's lifted"} (dibs halt)`
24
27
  : v.rule === 'disk' ? v.why.replace('you need', 'needs')
25
28
  : `${v.rule}${v.on ? `: ${short(v.on).replace(/^(files|quota):/, '')}` : ''}`);
26
29
  const blockedBy = v => { const r = waitReason(v); return r && !/^(behind|held by) /.test(r) ? `blocked by ${r}` : r; };
@@ -53,14 +56,16 @@ export function boardOf(s, cfg, hist, t = now(), me = null) {
53
56
  memUsed: memUsed(s), memBudget: bytes(cfg.budget), cpuUsed: cpuUsed(s), cores: cfg.cores,
54
57
  held: [...s.leases].sort((a, b) => a.start - b.start).map(l => ({
55
58
  res: l.res.map(r => short(r)), who: l.who, label: l.label, agentId: l.agentId, for: t - l.start, left: remaining(l, hist, t), idle: idleFor(l, t),
59
+ // How far the job says it is, and how it's off its pace, as words: other machines read them as they are.
60
+ done: progressOf(l, t) ? doneText(progressOf(l, t)) : null, slow: (sl => (sl ? slowText(sl) : null))(slowness(l, hist, t)),
56
61
  stuck: s.queue.some(q => q.pid) && stuckFor(l, t) > 0,
57
- prio: l.prio, paused: pauseLabel(l) || null, alongside: alongsideLabel(l) || (l.breaker ? BREAKER_LINE : l.quick ? QUICK_LINE : null), owner: ownerLabel(l) || null, purpose: l.purpose, cmd: l.cmd ? l.cmd.slice(0, 40) : null,
62
+ prio: l.prio, paused: pauseLabel(l) || null, alongside: alongsideLabel(l) || (l.eased ? EASED_LINE : l.breaker ? BREAKER_LINE : l.quick ? QUICK_LINE : null), owner: ownerLabel(l) || null, purpose: described(l, cfg), cmd: l.cmd ? l.cmd.slice(0, 40) : null,
58
63
  mem: l.mem, use: l.use?.mem ?? null, over: overBy(l) > 0, grew: grewLine(l) || null, ...you(l) })),
59
- waiting: [...s.queue].sort(byRank(hist, t)).map(q => ({
64
+ waiting: [...s.queue].sort(byRank(hist, t, fairShare(s, cfg, t))).map(q => ({
60
65
  res: q.res.map(r => short(r)), who: q.who, label: q.label, agentId: q.agentId, waited: t - q.enq, in: fc.has(q.id) ? fc.get(q.id) - t : null,
61
66
  prio: q.prio, owner: ownerLabel(q) || null, due: q.by ? q.by - t : null, yielded: q.yieldRank != null, kept: !q.pid, holds: q.holding?.res.map(r => short(r)) || null,
62
67
  blocked: q.pid ? waitingOn(s, q, cfg, hist, t) : null, capped: cappedLine(q) || null,
63
- purpose: q.purpose, ...you(q) })),
68
+ purpose: described(q, cfg), ...you(q) })),
64
69
  free: Object.keys(cfg.resources).map(r => {
65
70
  // A per-project resource is free for other projects up to its cap across them (src/schedule.mjs roomFor).
66
71
  const c = resCfg(cfg, r), slots = c.exclusiveBy === 'repo' ? c.across ?? c.slots : c.slots;
@@ -80,7 +85,9 @@ export function limitsLine(s, cfg, m) {
80
85
  const budget = bytes(cfg.budget), out = memUsed(s), free = shownFree(m);
81
86
  const mem = `memory ${GB(out)} of ${GB(budget)} taken (${out >= budget ? 'none' : GB(budget - out)} left)${free != null ? `, ${GB(free)} free or reclaimable on the machine` : ''}${m.vmPressure >= 1 ? ', pressure high' : ''}`;
82
87
  const floor = bytes(cfg.minDisk), sq = diskSqueeze(cfg, floor, m);
83
- const disk = m.diskFree == null ? 'disk unknown' : `disk ${GB(m.diskFree)} free (floor ${GB(sq?.rule === 'swaproom' ? sq.need : floor)}${sq?.rule === 'drain' ? `, falling ${GB(sq.fell)} in 5 min` : ''})`;
88
+ // The floor in force now, and the other one, so the number agents read is the one that holds them.
89
+ const room = cfg.swapRoom != null ? bytes(cfg.swapRoom) : 0;
90
+ const disk = m.diskFree == null ? 'disk unknown' : `disk ${GB(m.diskFree)} free (floor ${sq?.rule === 'swaproom' ? `${GB(sq.need)} while swapping, ${GB(floor)} otherwise` : `${GB(floor)}${room ? `, ${GB(floor + room)} while swapping` : ''}`}${sq?.rule === 'drain' ? `, falling ${GB(sq.fell)} in 5 min` : ''})`;
84
91
  const over = cfg.maxSwap != null && m.swapUsed > bytes(cfg.maxSwap);
85
92
  const swap = m.swapUsed == null ? '' : `swap ${GB(m.swapUsed)}${swapGrowing(m) ? `, growing (${GB(m.swapGrowth)} in 5 min)` : ', steady'}${over ? `, over maxSwap ${GB(bytes(cfg.maxSwap))}` : ''}`;
86
93
  return [mem, disk, swap].filter(Boolean).join('; ');
@@ -95,23 +102,20 @@ export function boardLines(b, t = now(), age = 0, yours = x => x.you) {
95
102
  if (b.held.length) {
96
103
  out.push('', 'HELD');
97
104
  for (const l of b.held)
98
- out.push(` ${l.res.join(',').padEnd(14)} ${holder(l, tag).padEnd(28)} ${dur(l.for + age).padStart(7)}`
99
- + `${l.left != null ? ` ~${dur(l.left - age)} left` : ''}${l.prio && l.prio !== 'normal' ? ` [${l.prio}]` : ''}${l.owner ? ` [${l.owner}]` : ''}${l.idle ? ` [idle ${dur(l.idle + age)}${l.stuck ? ', may be stuck' : ''}]` : ''}${l.paused ? ` [${l.paused}]` : ''}${l.alongside ? ` [${l.alongside}]` : ''}`
105
+ out.push(` ${l.res.join(',').padEnd(14)} ${holder(l, tag).padEnd(28)} ${dur(l.for + age).padStart(7)}${l.purpose ? ` "${l.purpose}"` : ''}`
106
+ + `${l.done ? ` ${l.done}` : ''}${l.left != null ? ` ~${dur(l.left - age)} left` : ''}${l.slow ? ` [${l.slow}]` : ''}${l.prio && l.prio !== 'normal' ? ` [${l.prio}]` : ''}${l.owner ? ` [${l.owner}]` : ''}${l.idle ? ` [idle ${dur(l.idle + age)}${l.stuck ? ', may be stuck' : ''}]` : ''}${l.paused ? ` [${l.paused}]` : ''}${l.alongside ? ` [${l.alongside}]` : ''}`
100
107
  + `${l.over ? ` [over: using ${gb(l.use)} of ${gb(l.mem)}]` : l.grew ? ` [${l.grew}]` : ''}`
101
- + `${l.purpose ? ` "${l.purpose}"` : ''}${l.cmd ? ` ${l.cmd}` : ' (hold)'}${you(l)}`);
108
+ + `${l.cmd ? ` ${l.cmd}` : ' (hold)'}${you(l)}`);
102
109
  }
103
110
  if (b.waiting.length) {
104
111
  out.push('', "QUEUE (in the order they'll go)");
105
112
  b.waiting.forEach((q, i) => {
106
113
  const flags = [q.prio && q.prio !== 'normal' ? q.prio : '', q.owner || '', q.holds ? `holds ${q.holds.join(',')}, goes first` : '', q.blocked || '', q.capped || '', q.due != null ? `due ${clock(t - age + q.due)}` : '',
107
114
  q.yielded ? 'let ahead' : '', q.kept ? 'place kept' : ''].filter(Boolean).join(', ');
108
- out.push(` ${String(i + 1).padStart(2)} ${q.res.join(',').padEnd(11)} ${holder(q, tag).padEnd(28)} waited ${dur(q.waited + age).padStart(6)}`
109
- + `${q.in != null ? ` starts ~${clock(t - age + q.in)}` : ''}${flags ? ` [${flags}]` : ''}${q.purpose ? ` "${q.purpose}"` : ''}${you(q)}`);
115
+ out.push(` ${String(i + 1).padStart(2)} ${q.res.join(',').padEnd(11)} ${holder(q, tag).padEnd(28)} waited ${dur(q.waited + age).padStart(6)}${q.purpose ? ` "${q.purpose}"` : ''}`
116
+ + `${q.in != null ? ` starts ~${clock(t - age + q.in)}` : ''}${flags ? ` [${flags}]` : ''}${you(q)}`);
110
117
  });
111
118
  }
112
- // An id typed from here can be someone else's: acting on it takes the owner by name (src/override.mjs).
113
- if ([...b.held, ...b.waiting].some(x => x.id != null && !yours(x)))
114
- out.push('', "Acting on a job that isn't yours (dibs boost, pause, resume, stop <id>): add --owner <the name before its #>.");
115
119
  out.push('', `free: ${b.free.join(' ') || 'nothing'}`);
116
120
  const caps = Object.entries(b.caps || {});
117
121
  if (caps.length) out.push(`capped: ${caps.map(([who, c]) => `${who} at ${c.prio}${c.by ? ` (by ${c.by})` : ''}`).join(', ')}`);
@@ -145,7 +149,8 @@ function remoteSentences(b, cfg, age) {
145
149
  // A hold's row has no command (null). A limited view blanks a run's command to '', so it still reads as a run.
146
150
  const held = b.held.filter(l => l.res.includes(r)).map(l => {
147
151
  const hold = l.cmd == null, left = l.left == null ? null : Math.max(l.left - age, 0);
148
- return { who: l.who, hold, endsIn: left, endsText: left == null ? 'time left unknown' : hold ? `up to ${minutes(left)} left` : `${about(left)} left` };
152
+ const time = left == null ? (l.done ? '' : 'time left unknown') : hold ? `up to ${minutes(left)} left` : `${about(left)} left`;
153
+ return { who: l.who, hold, endsIn: left, endsText: [l.done, time].filter(Boolean).join(', ') };
149
154
  });
150
155
  const next = live.filter(q => q.res.includes(r)).map(q => q.who);
151
156
  return `${named(cfg, r).label}: ${held.length ? usingText(held, named(cfg, r)) : 'free'}${next.length ? `. ${nextText(next)}` : ''}.`;
@@ -194,7 +199,7 @@ export function elsewhereLines(r, rc, me, t = now()) {
194
199
  out.push('', 'SENT BETWEEN MACHINES');
195
200
  for (const j of jobs)
196
201
  out.push(` ${j.res.join(',').padEnd(14)} ${(j.agent || j.who).padEnd(20)} ${`${j.from} -> ${j.machine}`.padEnd(24)} ${j.state.padEnd(9)} ${dur(r.now - j.created).padStart(6)}`
197
- + `${j.purpose ? ` "${j.purpose}"` : ''} ${j.cmd.join(' ').slice(0, 40)}`);
202
+ + ` "${described(j)}" ${j.cmd.join(' ').slice(0, 40)}`);
198
203
  }
199
204
  if (out.length) out.push('');
200
205
  return out;
package/src/broker.mjs CHANGED
@@ -16,8 +16,8 @@ import { pstart, makeAlive } from './proc.mjs';
16
16
  import { processes } from './platform.mjs';
17
17
  import { withState, history, kick, quiet, KEEP_PLACE } from './state.mjs';
18
18
  import { sweepLock } from './lock.mjs';
19
- import { decide, step, waiter, full, markIdle, saidText, abandon, POLL } from './acquire.mjs';
20
- import { byRank } from './schedule.mjs';
19
+ import { decide, step, waiter, full, markIdle, saidText, abandon, leftText, POLL } from './acquire.mjs';
20
+ import { byRank, fairShare } from './schedule.mjs';
21
21
  import { inversions, lift } from './override.mjs';
22
22
  import { noticeScan } from './notices.mjs';
23
23
  import { event } from './events.mjs';
@@ -111,7 +111,10 @@ function inlineCall(shell, fifo) {
111
111
  wait: w => {
112
112
  if (!process.execve) return 'stay';
113
113
  withState(s => { const q = s.queue.find(x => x.id === w.me.id && x.pid === shell); if (q) keepFor(q, shell); });
114
- process.execve('/bin/sh', ['/bin/sh', THIN_SH, BIN, ...process.argv.slice(2)], { ...process.env, DIBS_THIN_RESUME: '1' });
114
+ // What this wait has said and when it began go with it: the Node that gets in line again
115
+ // said the whole picture a second time, and logged a second wait (2026-11-28, #26960).
116
+ const carry = JSON.stringify({ started: w.started, talk: w.talk.save(), blocked: w.blocked, saidAhead: w.saidAhead, warnedHolding: w.warnedHolding });
117
+ process.execve('/bin/sh', ['/bin/sh', THIN_SH, BIN, ...process.argv.slice(2)], { ...process.env, DIBS_THIN_RESUME: '1', DIBS_THIN_WAIT: carry });
115
118
  },
116
119
  };
117
120
  }
@@ -145,7 +148,11 @@ export function ensureBroker() {
145
148
  fs.closeSync(log);
146
149
  }
147
150
  // This loop never yields, so a child that died is a zombie, not an exit event.
148
- const died = () => !/^[^Z]/.test(spawnSync('ps', ['-o', 'stat=', '-p', String(child.pid)], { encoding: 'utf8' }).stdout.trim());
151
+ // Where ps can't run (Codex's sandbox, 2026-11-26) there's no telling: it's waited out as a slow start.
152
+ const died = () => {
153
+ const r = spawnSync('ps', ['-o', 'stat=', '-p', String(child.pid)], { encoding: 'utf8' });
154
+ return r.stdout != null && !/^[^Z]/.test(r.stdout.trim());
155
+ };
149
156
  for (let t0 = now(), checked = t0; now() - t0 < START_WAIT; sleepSync(20)) {
150
157
  if (kick()) { try { fs.rmSync(BROKEN, { force: true }); } catch {} return true; }
151
158
  if (child && now() - checked > CRASH_CHECK) {
@@ -188,6 +195,7 @@ function keepFor(q, shell) {
188
195
  // up on the broker (why is keep: the place stays for its in-process retry).
189
196
  // id 0: interrupted before it knew its id; its place is the one under its pid.
190
197
  export function leaveLine(id, shell, why) {
198
+ let text = '';
191
199
  // A low job lifted for this waiter alone goes back down as it leaves (src/override.mjs inversions).
192
200
  lift(withState(s => {
193
201
  // Its place by id when it knows it, else by its pid. A place kept with nobody on it (for its own
@@ -196,11 +204,17 @@ export function leaveLine(id, shell, why) {
196
204
  || (why !== 'keep' && x.keptFor === shell));
197
205
  if (!q) return [];
198
206
  if (why === 'keep') { keepFor(q, shell); return []; }
199
- s.queue = s.queue.filter(x => x !== q);
207
+ // A signal: this shell's stderr is the caller's, so it hears why its command never ran,
208
+ // and the place stays KEEP_PLACE for the same command (src/acquire.mjs leftText).
209
+ text = leftText(s, q, why, { again: q.wake?.again, started: q.wake?.started, ppid: q.wake?.ppid ?? q.ppid }, history());
200
210
  if (q.wake?.notify) notified(q, signalExit(why));
201
211
  if (q.wake) event({ kind: 'left', id: q.id, res: q.res, who: q.who, prio: q.prio || 'normal', type: q.kind, ms: now() - q.enq, why });
212
+ Object.assign(q, { pid: null, keepUntil: now() + KEEP_PLACE });
213
+ delete q.wake;
214
+ delete q.keptFor;
202
215
  return inversions(s, loadConfig());
203
216
  }));
217
+ if (text) process.stderr.write(text);
204
218
  }
205
219
 
206
220
  // --notify's line for a thin wait that ended before its command started (src/commands.mjs notifyOnExit).
@@ -249,6 +263,9 @@ const thinWaiters = s => s.queue.filter(q => q.wake && q.pid && q.wake.pid === q
249
263
  export function broker() {
250
264
  fs.mkdirSync(WAKE, { recursive: true });
251
265
  const me = { pid: process.pid, pstart: pstart(process.pid) };
266
+ // The code it runs, read before it says it's the broker: read after, a release that landed in
267
+ // between went unnoticed and this broker never handed its waiters on (a flaky test, 2026-12-06).
268
+ const code = fs.readFileSync(path.join(SRC, 'version.mjs'), 'utf8');
252
269
  const mine = withState(s => {
253
270
  const b = s.broker;
254
271
  if (b && b.pid !== me.pid && now() - b.beat < HUNG && makeAlive([b.pid])(b.pid, b.pstart)) return false;
@@ -262,7 +279,6 @@ export function broker() {
262
279
  try { fs.unlinkSync(paths.ctl); } catch {}
263
280
  if (spawnSync('mkfifo', ['-m', '600', paths.ctl], { stdio: 'ignore' }).status !== 0) throw new Error(`couldn't make the control FIFO ${paths.ctl}`);
264
281
  const ctl = new net.Socket({ fd: fs.openSync(paths.ctl, O_RDWR | O_NONBLOCK), readable: true, writable: false });
265
- const code = fs.readFileSync(path.join(SRC, 'version.mjs'), 'utf8');
266
282
  const waits = new Map(); // queue id -> its wait (src/acquire.mjs waiter), with its FIFO as out
267
283
  let cfg = loadConfig(), hist = history(), histAt = 0, beat = 0, idleSince = now(), pending = false, forced = false, pruned = 0, seen = '', fullAt = 0;
268
284
 
@@ -316,7 +332,7 @@ export function broker() {
316
332
  if (s.broker && s.broker.pid !== me.pid) return null; // taken for hung and replaced: step aside
317
333
  if (t - beat > BEAT || !s.broker) s.broker = { ...me, beat: (beat = t) };
318
334
  markIdle(s);
319
- const thin = thinWaiters(s).sort(byRank(hist));
335
+ const thin = thinWaiters(s).sort(byRank(hist, undefined, fairShare(s, cfg)));
320
336
  for (const [id, w] of waits) if (!thin.some(q => q.id === id)) { w.out.close(); waits.delete(id); }
321
337
  return thin.map(q => {
322
338
  let w = waits.get(q.id);