@dibssoftware/dibs 0.0.178 → 0.0.179

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/src/acquire.mjs CHANGED
@@ -12,7 +12,7 @@ import { jobSize } from './simpool.mjs';
12
12
  import { sized, grewLine, grewPlain, treeOf } from './measure.mjs';
13
13
  import { isQuota, quotaProblem, quotaBlock, takeQuota } from './quota.mjs';
14
14
  import { capWaiter } from './override.mjs';
15
- import { verdict, forecast, expected, remaining, byRank, holdingOf, PRIORITY_SHIFT, PRIORITIES, NEEDS_REASON, used, overBy, STALL, neverFits, explicitAsk, capToMachine } from './schedule.mjs';
15
+ import { verdict, forecast, expected, remaining, byRank, holdingOf, PRIORITY_SHIFT, PRIORITIES, NEEDS_REASON, used, overBy, STALL, neverFits, explicitAsk, capToMachine, quickPass } from './schedule.mjs';
16
16
  import { event } from './events.mjs';
17
17
  import { startLine } from './overlap.mjs';
18
18
  import { dur, clock, die, say, sleep, now, ms, gb, SIGNALS, signalExit, KEY_SPLIT, noSpace, OFF_LIMITS, callerPid } from './util.mjs';
@@ -309,9 +309,11 @@ export function decide(s, w) {
309
309
  // When its dibs last looked, so the board can tell a waiter that could start from one nobody
310
310
  // is deciding for. Once a minute at most: a poll that changes nothing leaves the state file alone.
311
311
  if (!(now() - (cur.polledAt || 0) < POLLED_EVERY)) cur.polledAt = now();
312
+ // Kept on the entry, so other waiters rank it at the front too (src/schedule.mjs quickPass).
313
+ if (quickPass(cur, hist, cfg)) cur.quickPass = true; else delete cur.quickPass;
312
314
  let v = verdict(s, cur, cfg, hist);
313
- // A rate limit that would stop it anyway is checked before pausing anyone for it.
314
- if (!v.ok && v.rule === 'slot') v = quotaBlock(s, cur, cfg, hist) || preempt(s, cur, cfg, hist) || v;
315
+ // A rate limit that would stop it anyway is checked before pausing anyone for it. The quick lane never pauses anyone.
316
+ if (!v.ok && v.rule === 'slot' && !cur.quickPass) v = quotaBlock(s, cur, cfg, hist) || preempt(s, cur, cfg, hist) || v;
315
317
  if (v.ok) v = quotaBlock(s, cur, cfg, hist) || v;
316
318
  // What held it and for how long, for its start event: on 2026-10-24 a 2-second test waited
317
319
  // 3 minutes with 11 GB of disk free, and the log said only that it waited. Kept in the
@@ -357,6 +359,7 @@ export function decide(s, w) {
357
359
  if (v.covered.length) lease.covered = v.covered;
358
360
  if (v.alongside) lease.alongside = v.alongside;
359
361
  if (v.trial) lease.trial = true;
362
+ if (v.quick) lease.quick = true;
360
363
  if (cur.repo) lease.repo = cur.repo;
361
364
  if (v.loadPast) Object.assign(lease, { loadPast: true, loadWaited: v.loadWaited });
362
365
  // The stall breaker's clock (schedule.mjs) runs from the last start the gates allowed.
@@ -587,12 +590,11 @@ export async function acquire(o, kind, cfg) {
587
590
  if (!nested) capToMachine(cfg, size);
588
591
  const { mem, cpu, disk, asked, askedCpu, usual } = size;
589
592
  const grew = grewPlain({ mem, cpu, asked, askedCpu, usual }, key.split('|')[1]);
593
+ // Booked at what it really used, not at its ask: dibs's own bookkeeping, kept
594
+ // in the history and said to nobody. On 2026-11-03 these were 6 of 35 notices,
595
+ // and "typecheck used up to 4 cores, pass --cpu 4" came on every merge.
590
596
  if (grew) {
591
- say(grew);
592
- // Once per command per agent, through the hook too: an agent that reads only
593
- // its tool's result still learns that its --mem was overruled, and why its job waits.
594
- notify({ sessionId: process.env.CLAUDE_CODE_SESSION_ID, who: id.who, agentId: o.agentId }, `sized:${key}:${Math.round(mem / 2 ** 30)}`,
595
- `${grew} dibs booked it at that, not at what you asked for. To have your own number match, pass --mem ${Math.ceil((usual ?? mem) / 2 ** 30)}G${askedCpu != null ? ` --cpu ${cpu}` : ''}.`);
597
+ event({ kind: 'sized', key, who: id.who, mem, cpu, ...(asked != null && { asked }), ...(askedCpu != null && { askedCpu }), ...(usual != null && { usual }) });
596
598
  }
597
599
  // Running the same request again soon after a timed-out wait keeps your place.
598
600
  const ticket = `${id.spid || id.who}|${res.join(',')}|${cmd}`;
@@ -639,6 +641,7 @@ export async function acquire(o, kind, cfg) {
639
641
  capWaiter(s, q);
640
642
  if (o.by) q.by = o.by;
641
643
  if (o.est) q.est = o.est;
644
+ if (o.quick) q.quick = true; // trusted the first time; its runs decide after (quickPass)
642
645
  if (o.cost != null) q.cost = o.cost;
643
646
  if (o.mem != null) q.declared = true; // a size to go on before dibs has measured it (src/overlap.mjs)
644
647
  if (o.cpu != null) q.cpuDeclared = true; // asked for in so many words, which alone can make it never fit (neverFits)
package/src/alerts.mjs CHANGED
@@ -63,14 +63,33 @@ const SERVICES_EVERY = MIN;
63
63
  export const RESOLVED_SHOWN = 2 * HOUR;
64
64
  // The first read of the event log starts this far from its end, not at its start: the log runs to 20 MB.
65
65
  const FIRST_READ = 2 * 1024 ** 2;
66
- // The rules a waiter is held by when memory, not a turn, is in the way.
67
- const MEMORY_RULES = new Set(['pressure', 'swap', 'swaproom', 'ram', 'oversize']);
66
+ // The rules a waiter is held by when the machine's memory, not a turn or dibs's budget, is in the way.
67
+ const PRESSURE = new Set(['pressure', 'swap', 'swaproom', 'ram', 'oversize']);
68
+ // Bumped when what makes an alert changes, so an upgrade rebuilds the open ones instead of closing them.
69
+ const RULES = 2;
70
+ // The same command failing this many times in a row, with no pass between, is worth the person's attention.
71
+ const REPEATS = 3;
68
72
  // Exit codes a stopped command dies with: Ctrl-C, SIGKILL, SIGTERM.
69
73
  const STOPPED = new Set([130, 137, 143]);
70
74
 
75
+ // A time as the person reads it: the clock today, with the weekday within a
76
+ // week either way, with the date further off. "at 6:40 PM" from yesterday
77
+ // read as a time still to come.
78
+ export function stamp(at, t = now()) {
79
+ const d = new Date(at);
80
+ if (d.toDateString() === new Date(t).toDateString()) return clock(at);
81
+ const day = Math.abs(t - at) < 6 * DAY ? d.toLocaleDateString([], { weekday: 'short' }) : d.toLocaleDateString([], { month: 'short', day: 'numeric' });
82
+ return `${day} ${clock(at)}`;
83
+ }
84
+
71
85
  const what = x => (x.purpose || x.cmd || (x.res || []).join(', ') || 'a job').replace(/\s+/g, ' ').slice(0, 70);
72
86
  const job = x => `${x.who}'s #${x.id} (${what(x)})`;
73
87
  const personWaits = q => q.prio === 'urgent' || q.prio === 'high' || typeof q.by === 'number';
88
+ const isDeploy = res => (res || []).some(r => r === 'deploy' || r.startsWith('deploy-') || r.startsWith('deploy:'));
89
+ // A failure the person cares about: a deploy, or a job they were waiting on.
90
+ // Held by the machine's memory: pressure or swap, or a job that fits dibs's budget but not what's really free.
91
+ const pressed = v => PRESSURE.has(v.rule) || (v.rule === 'memory' && (v.pressure || v.real));
92
+ const matters = x => isDeploy(x.res) || x.prio === 'urgent' || x.prio === 'high' || typeof x.due === 'number';
74
93
 
75
94
  function load() {
76
95
  try { return { seen: {}, open: {}, resolved: [], dismissed: {}, waits: {}, ended: [], svc: {}, restarts: [], hook: [], ...JSON.parse(fs.readFileSync(FILE, 'utf8')) }; }
@@ -131,8 +150,9 @@ function readEvents(st, t) {
131
150
  // A later success of the same command closes its failures.
132
151
  if (e.code === 0 && e.key) for (const x of st.ended) if (x.key === e.key && !x.fixedAt) x.fixedAt = e.at;
133
152
  const by = stops.get(e.id);
134
- if (by || STOPPED.has(e.code)) st.ended.push({ kind: 'stopped', at: e.at, id: e.id, who: e.who, res: e.res, cmd: e.cmd, purpose: e.purpose, key: e.key, code: e.code, by: by || null });
135
- else if (e.code != null && e.code !== 0) st.ended.push({ kind: 'failed', at: e.at, id: e.id, who: e.who, res: e.res, cmd: e.cmd, purpose: e.purpose, key: e.key, code: e.code });
153
+ 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 };
154
+ if (by || STOPPED.has(e.code)) st.ended.push({ kind: 'stopped', ...x, by: by || null });
155
+ else if (e.code != null && e.code !== 0) st.ended.push({ kind: 'failed', ...x });
136
156
  } 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 });
137
157
  }
138
158
  st.ended = st.ended.filter(x => t - x.at < EVENT_KEEP);
@@ -186,7 +206,7 @@ export function memoryUsers(s, procs, use) {
186
206
 
187
207
  function appOf(p, sessions) {
188
208
  const a = p.args || '';
189
- if (/\blaunchd_sim\b|\/CoreSimulator\/Devices\//.test(a)) return 'the iOS Simulator';
209
+ if (/\blaunchd_sim\b|\/CoreSimulator\/Devices\/|\.simruntime\//.test(a)) return 'the iOS Simulator';
190
210
  if (/com\.apple\.WebKit\.(WebContent|GPU|Networking)/.test(a)) return 'Safari and other web pages';
191
211
  if (/(^|\/)claude(\s|$)/.test(a)) {
192
212
  const x = sessions.get(p.pid);
@@ -194,9 +214,14 @@ function appOf(p, sessions) {
194
214
  }
195
215
  const app = a.match(/\/([^/]+)\.app\//);
196
216
  if (app) return app[1];
197
- return path.basename(a.split(/\s+/)[0] || `pid ${p.pid}`);
217
+ // A script under an interpreter is the script: "node" alone says nothing about which.
218
+ const [cmd, ...args] = a.split(/\s+/);
219
+ const name = path.basename(cmd || `pid ${p.pid}`);
220
+ const script = INTERPRETERS.test(name) && args.find(x => !x.startsWith('-'));
221
+ return script ? `${name} ${path.basename(script)}` : name;
198
222
  }
199
223
 
224
+ const INTERPRETERS = /^(node|bun|deno|python3?(\.\d+)?|ruby|perl)$/;
200
225
  const sized = g => `${g.name} (${gb(g.bytes).replace(/G$/, ' GB')}${g.n > 1 && g.name.startsWith('Safari') ? `, ${g.n} pages` : ''})`;
201
226
 
202
227
  // Every alert the state calls for now: { id, cause, level, title, fix, after?, at? }.
@@ -213,25 +238,24 @@ export function detect({ s, cfg, hist, m, t, st, users }) {
213
238
  const usual = Math.max(0, ...q.res.map(r => median(st.waits[r] || [])));
214
239
  const waited = t - q.enq;
215
240
  if (waited < Math.max(WAIT_FLOOR, WAIT_TIMES * usual)) continue;
216
- out.push({ id: `wait:#${q.id}`, cause: 'wait', level: personWaits(q) ? 'urgent' : 'warn', job: q.id, who: q.who,
217
- 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 ${clock(q.by)}` : q.prio}` : ''}`,
218
- why: v.why, fix: waitFix(s, q, v, t) });
241
+ out.push({ id: `wait:#${q.id}`, cause: 'wait', level: personWaits(q) ? 'urgent' : 'warn', job: q.id, who: q.who, at: q.enq,
242
+ ...(pressed(v) && !users && { want: 'users' }),
243
+ 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}` : ''}`,
244
+ why: v.why, fix: waitFix(s, q, v, t, users) });
219
245
  }
220
246
 
221
247
  // Memory holding new jobs back.
222
- const held = waiting.filter(q => { const v = verdicts.get(q.id); return MEMORY_RULES.has(v.rule) || (v.rule === 'memory' && (v.pressure || v.real)); });
248
+ const held = waiting.filter(q => pressed(verdicts.get(q.id)));
223
249
  if (held.length) {
224
250
  const swap = held.some(q => /^swap/.test(verdicts.get(q.id).rule));
225
251
  const list = users || [];
226
252
  const close = list.filter(g => !g.dibs);
227
253
  const ours = list.filter(g => g.dibs);
228
- out.push({ id: 'memory', cause: 'memory', level: 'urgent', after: PRESSURE_AFTER,
254
+ out.push({ id: 'memory', cause: 'memory', level: 'urgent', after: PRESSURE_AFTER, at: Math.min(...held.map(q => q.enq)), ...(!users && { want: 'users' }),
229
255
  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' : ''})`,
230
256
  why: verdicts.get(held[0].id).why,
231
257
  detail: list.length ? `Using the most memory: ${list.map(sized).join(', ')}.` : '',
232
- fix: close.length
233
- ? `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}.` : ''}`
234
- : ours.length ? `dibs's own jobs use it: dibs stop ${ours[0].id} frees the most.` : 'Close apps you aren\'t using; dibs won\'t close what it didn\'t start.' });
258
+ fix: memoryFix(list) });
235
259
  }
236
260
 
237
261
  // A slot held by a run that has used no CPU for a long while someone waits for it.
@@ -240,38 +264,51 @@ export function detect({ s, cfg, hist, m, t, st, users }) {
240
264
  if (!idle) continue;
241
265
  const behind = waiting.filter(q => q.res.some(r => l.res.includes(r)));
242
266
  if (!behind.length) continue;
243
- out.push({ id: `idle:#${l.id}`, cause: 'idle', level: behind.some(personWaits) ? 'urgent' : 'warn', job: l.id, who: l.who,
267
+ out.push({ id: `idle:#${l.id}`, cause: 'idle', level: behind.some(personWaits) ? 'urgent' : 'warn', job: l.id, who: l.who, at: l.idleSince,
244
268
  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'}`,
245
269
  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.` });
246
270
  }
247
271
 
248
- // Jobs that failed, were stopped, or were lost, and dibs's own crashes.
272
+ // Jobs that failed, were stopped, or were lost, and dibs's own crashes. An
273
+ // agent's test run failing while it works is normal: on 2026-11-03 one
274
+ // session's 53 failed test runs filled the list. What's loud is what the
275
+ // person cares about: a deploy, a job a person waits on (high, urgent or
276
+ // --by), the same command failing REPEATS times in a row, a lost job and a
277
+ // crash. The rest is quiet: in dibs alerts --all only.
249
278
  const failed = new Map();
250
279
  for (const x of st.ended) {
251
280
  if (x.fixedAt) continue;
252
- if (x.kind === 'failed') {
253
- const k = x.key || `${x.who}|${x.cmd}`;
281
+ if (x.kind === 'failed' && matters(x)) {
282
+ out.push({ id: `failed:#${x.id}`, cause: 'ended', level: 'warn', at: x.at, job: x.id, who: x.who,
283
+ title: `${job(x)} failed at ${stamp(x.at, t)} (exit ${x.code})${x.due ? `, and it was due by ${stamp(x.due, t)}` : x.prio === 'urgent' || x.prio === 'high' ? `, and it was ${x.prio}` : ''}`,
284
+ fix: `${x.who} is the one to fix it; this closes when the same command passes.` });
285
+ } else if (x.kind === 'failed') {
286
+ // Failures of the exact same command, all since its last pass (a pass closes the ones before it).
287
+ const k = `${x.who}|${x.cmd || (x.res || []).join(',')}`;
254
288
  const g = failed.get(k) || { ...x, n: 0, first: x.at };
255
289
  g.n++; g.at = Math.max(g.at, x.at); g.code = x.code;
256
290
  failed.set(k, g);
257
291
  } else if (x.kind === 'stopped') {
258
- out.push({ id: `stopped:#${x.id}`, cause: 'ended', level: 'note', at: x.at, job: x.id, who: x.who,
259
- title: `${job(x)} was stopped${x.by ? ` by ${x.by}` : ''} at ${clock(x.at)}${x.code != null ? ` (exit ${x.code})` : ''}`,
292
+ // Stopped on purpose (exit 143 or 137, or dibs stop): on record in dibs alerts --all, nowhere louder.
293
+ out.push({ id: `stopped:#${x.id}`, cause: 'ended', level: 'note', at: x.at, job: x.id, who: x.who, quiet: true,
294
+ title: `${job(x)} was stopped${x.by ? ` by ${x.by}` : ''} at ${stamp(x.at, t)}${x.code != null ? ` (exit ${x.code})` : ''}`,
260
295
  fix: `If it should finish, ${x.who} runs it again; nothing else waits on it.` });
261
296
  } else if (x.kind === 'lost') {
262
297
  out.push({ id: `lost:${x.at}`, cause: 'ended', level: 'urgent', at: x.at, who: x.who,
263
- title: `${x.who}'s job was lost${x.code === 77 ? ' after it started' : ' before it started'} at ${clock(x.at)}: ${x.why || x.cmd}`,
298
+ 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}`,
264
299
  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.' });
265
300
  } else if (x.kind === 'crash') {
266
301
  out.push({ id: `crash:${x.at}`, cause: 'dibs', level: 'urgent', at: x.at, who: x.who,
267
- title: `dibs crashed at ${clock(x.at)} running dibs ${x.verb || ''} for ${x.who}`,
302
+ title: `dibs crashed at ${stamp(x.at, t)} running dibs ${x.verb || ''} for ${x.who}`,
268
303
  fix: `It's a bug in dibs. Report it: dibs ask "crash in dibs ${x.verb || ''}"` });
269
304
  }
270
305
  }
271
- for (const [k, g] of failed)
272
- out.push({ id: `failed:${hash(k)}`, cause: 'ended', level: 'note', at: g.first, who: g.who,
273
- title: `${g.who}'s ${what(g)} failed${g.n > 1 ? ` ${g.n} times, last` : ''} at ${clock(g.at)} (exit ${g.code})`,
306
+ for (const [k, g] of failed) {
307
+ const loud = g.cmd && g.n >= REPEATS;
308
+ out.push({ id: `failed:${hash(k)}`, cause: 'ended', level: loud ? 'warn' : 'note', at: g.first, last: g.at, who: g.who, ...(!loud && { quiet: true }),
309
+ 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})`,
274
310
  fix: `${g.who} is the one to fix it; this closes when the same command passes.` });
311
+ }
275
312
 
276
313
  // dibs itself.
277
314
  for (const [k, h] of Object.entries(st.svc || {}))
@@ -283,13 +320,13 @@ export function detect({ s, cfg, hist, m, t, st, users }) {
283
320
  const rs = st.restarts.filter(r => r.k === k);
284
321
  const last = rs[rs.length - 1];
285
322
  out.push({ id: `restart:${k}`, cause: 'dibs', level: 'warn', at: rs[0].at,
286
- 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 ${clock(last.at)}`,
323
+ 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)}`,
287
324
  fix: `Look in ~/.dibs/${k}.log for why, and report it: dibs ask "the ${k} service keeps exiting with ${last.exit}"` });
288
325
  }
289
326
  if (st.hook?.length) {
290
327
  const last = st.hook[st.hook.length - 1];
291
328
  out.push({ id: 'hook', cause: 'dibs', level: 'warn', at: st.hook[0].at,
292
- title: `The Claude Code hook failed ${st.hook.length} time${st.hook.length > 1 ? 's' : ''} in the last hour, last at ${clock(last.at)}: ${last.msg}`,
329
+ 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}`,
293
330
  fix: `Those tool calls ran without dibs's checks. Report it: dibs ask "hook: ${last.msg.slice(0, 60)}"` });
294
331
  }
295
332
 
@@ -303,7 +340,7 @@ export function detect({ s, cfg, hist, m, t, st, users }) {
303
340
  }
304
341
 
305
342
  // The one thing that lets a long-waiting job start, by what holds it.
306
- function waitFix(s, q, v, t) {
343
+ function waitFix(s, q, v, t, users) {
307
344
  const boost = `dibs boost ${q.id} urgent -m "why"`;
308
345
  if (v.rule === 'slot' || v.rule === 'files' || v.rule === 'together') {
309
346
  // With one deploy per project (the per-repo lock), the one in the way is this project's.
@@ -313,7 +350,12 @@ function waitFix(s, q, v, t) {
313
350
  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.`;
314
351
  }
315
352
  if (v.rule === 'ahead' && v.ahead) return `${job(v.ahead)} is ahead. If this one matters more: ${boost}.`;
316
- if (MEMORY_RULES.has(v.rule) || v.rule === 'memory') return 'Free memory: the memory alert says what uses the most.';
353
+ // What uses the memory, said here: an alert that points at another one that isn't there is no help.
354
+ if (pressed(v)) return memoryFix(users || []);
355
+ if (v.rule === 'memory') {
356
+ const big = (s.leases || []).filter(l => l.mem).sort((a, b) => b.mem - a.mem).slice(0, 3);
357
+ 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}.`;
358
+ }
317
359
  if (v.rule === 'disk' || v.rule === 'drain') return diskFix();
318
360
  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".`;
319
361
  if (v.rule === 'idle') return `It's idle-priority work, which waits for everything else: dibs boost ${q.id} normal.`;
@@ -321,6 +363,14 @@ function waitFix(s, q, v, t) {
321
363
  return `${v.why}. If it can't wait: ${boost}.`;
322
364
  }
323
365
 
366
+ // What to close, from the biggest memory users on the machine.
367
+ function memoryFix(list) {
368
+ const close = list.filter(g => !g.dibs), ours = list.filter(g => g.dibs);
369
+ 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}.` : ''}`;
370
+ if (ours.length) return `dibs's own jobs use it: dibs stop ${ours[0].id} frees the most.`;
371
+ return "Close apps you aren't using; dibs won't close what it didn't start.";
372
+ }
373
+
324
374
  function diskFix() {
325
375
  return `Free disk: build output, caches and scratch folders${hogHint()}.`;
326
376
  }
@@ -332,11 +382,12 @@ const hash = k => { let h = 5381; for (const c of String(k)) h = ((h << 5) + h +
332
382
  export function merge(st, found, t) {
333
383
  const live = new Set();
334
384
  for (const c of found) {
335
- if (c.after && t - (st.seen[c.id] ??= t) < c.after) continue;
385
+ // Since when the problem itself began (the job queued, the first failure), not this scan.
386
+ if (c.after && t - (st.seen[c.id] ??= c.at ?? t) < c.after) continue;
336
387
  if (st.dismissed[c.id]) continue;
337
388
  live.add(c.id);
338
- const { after, ...a } = c;
339
- st.open[c.id] = { ...a, since: st.open[c.id]?.since ?? c.at ?? (c.after ? st.seen[c.id] : t), resolvedAt: null };
389
+ const { after, want, at, ...a } = c;
390
+ st.open[c.id] = { ...a, since: at ?? st.open[c.id]?.since ?? (after ? st.seen[c.id] : t), resolvedAt: null };
340
391
  }
341
392
  const pending = new Set(found.map(c => c.id));
342
393
  for (const id of Object.keys(st.seen)) if (!pending.has(id)) delete st.seen[id];
@@ -358,13 +409,15 @@ export function scan({ s, cfg, hist, m = machine(), t = now(), force = false } =
358
409
  if (!force && was.at && t - was.at < SCAN_EVERY) return shown(was, t);
359
410
  const st = locked(() => {
360
411
  const st = load();
412
+ // Alerts made by older rules aren't resolved, only no longer said that way: start the open list over.
413
+ if (st.rules !== RULES) { st.open = {}; st.seen = {}; st.rules = RULES; }
361
414
  readEvents(st, t);
362
415
  readHook(st, t);
363
416
  readServices(st, t);
364
417
  let users = st.top && t - st.top.at < TOP_EVERY ? st.top.list : null;
365
418
  let found = detect({ s, cfg, hist, m, t, st, users });
366
419
  // The machine-wide reading only once memory is what holds jobs back.
367
- if (!users && found.some(a => a.id === 'memory')) {
420
+ if (!users && found.some(a => a.want === 'users')) {
368
421
  users = memoryUsers(s, processes(), memoryUse());
369
422
  st.top = { at: t, list: users };
370
423
  found = detect({ s, cfg, hist, m, t, st, users });
@@ -386,8 +439,8 @@ export function scan({ s, cfg, hist, m = machine(), t = now(), force = false } =
386
439
  // Open alerts, worst first, then the ones resolved in the last RESOLVED_SHOWN.
387
440
  const RANK = { urgent: 0, warn: 1, note: 2 };
388
441
  export function shown(st, t = now(), all = false) {
389
- const open = Object.values(st.open || {}).sort((a, b) => RANK[a.level] - RANK[b.level] || b.since - a.since);
390
- const gone = (st.resolved || []).filter(a => all || t - a.resolvedAt < RESOLVED_SHOWN).sort((a, b) => b.resolvedAt - a.resolvedAt);
442
+ const open = Object.values(st.open || {}).filter(a => all || !a.quiet).sort((a, b) => RANK[a.level] - RANK[b.level] || b.since - a.since);
443
+ const gone = (st.resolved || []).filter(a => all || (!a.quiet && t - a.resolvedAt < RESOLVED_SHOWN)).sort((a, b) => b.resolvedAt - a.resolvedAt);
391
444
  return [...open, ...gone];
392
445
  }
393
446
 
@@ -403,15 +456,21 @@ export function dismiss(which, t = now()) {
403
456
  }) || [];
404
457
  }
405
458
 
459
+ // The plain board is what agents read between steps: a failure, a stop or a
460
+ // lost job is on it for this long after it happened, then only in the alerts
461
+ // (the page, the app, dibs alerts), which the person reads.
462
+ export const BOARD_KEEP = 30 * MIN;
463
+ export const onBoard = (a, t = now()) => a.cause !== 'ended' || t - (a.last ?? a.since) < BOARD_KEEP;
464
+
406
465
  // The board's lines for the alerts: each open one with its fix, worst first,
407
466
  // then the ones resolved lately, with when.
408
467
  export function alertLines(list, t = now()) {
409
468
  const out = [];
410
469
  for (const a of list) {
411
- if (a.resolvedAt) out.push(dim(`Resolved at ${clock(a.resolvedAt)}${a.dismissed ? ' (dismissed)' : ''}: ${a.title}.`));
470
+ if (a.resolvedAt) out.push(dim(`Resolved at ${stamp(a.resolvedAt, t)}${a.dismissed ? ' (dismissed)' : ''}: ${a.title}.`));
412
471
  else {
413
472
  const paint = a.level === 'urgent' ? red : a.level === 'warn' ? amber : x => x;
414
- out.push(paint(`${a.level === 'note' ? '' : '! '}${a.title} (since ${clock(a.since)}).`), wrap(` Fix: ${a.fix}`, ' '));
473
+ out.push(paint(`${a.level === 'note' ? '' : '! '}${a.title} (since ${stamp(a.since, t)}).`), wrap(` Fix: ${a.fix}`, ' '));
415
474
  }
416
475
  }
417
476
  return out;
@@ -430,8 +489,11 @@ export function alerts(args, cfg) {
430
489
  let list = scan({ s, cfg, hist: history(), t, force: true });
431
490
  if (args.includes('--all')) list = shown(load(), t, true);
432
491
  if (args.includes('--json')) return console.log(JSON.stringify(list, null, 1));
433
- if (!list.length) return console.log('Nothing is wrong that dibs can see. Open problems and what fixes them show here, and on the board.');
492
+ const quiet = args.includes('--all') ? 0 : Object.values(load().open).filter(a => a.quiet).length;
493
+ const more = quiet ? dim(`${quiet} more not worth your attention (agents' own test runs failing, jobs stopped on purpose): dibs alerts --all`) : '';
494
+ if (!list.length) return console.log(['Nothing is wrong that dibs can see. Open problems and what fixes them show here, and on the board.', more].filter(Boolean).join('\n'));
434
495
  console.log(alertLines(list, t).join('\n'));
496
+ if (more) console.log(`\n${more}`);
435
497
  const open = list.filter(a => !a.resolvedAt);
436
498
  if (open.length) console.log(dim(`\nIds, for dibs alerts dismiss <id>: ${open.map(a => a.id).join(', ')}`));
437
499
  }
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', ...['guard', 'files', 'questions', 'later', 'machines', 'simulators', 'scheduling', 'relay'].map(d => `docs/${d}.md`)];
10
+ const DOCS = ['skills/dibs/SKILL.md', 'README.md', ...['reference', '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;
@@ -24,7 +24,7 @@ const words = text => text.toLowerCase().match(/[a-z0-9][a-z0-9:_-]*/g)?.filter(
24
24
  function pieces(block) {
25
25
  const lines = block.split('\n');
26
26
  if (lines.every(l => l.startsWith('|'))) return lines.filter(l => !/^\|[\s:|-]+\|$/.test(l)).slice(1);
27
- // The README's paste-in block for agents is one fence of bullets: each bullet answers on its own.
27
+ // docs/reference.md's paste-in block for agents is one fence of bullets: each bullet answers on its own.
28
28
  if (lines[0] === '```markdown') return lines.filter(l => l.startsWith('- '));
29
29
  if (!/^(- |\d+\. )/.test(lines[0])) return [block];
30
30
  const items = [];
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 } from './acquire.mjs';
6
- import { forecast, byRank, remaining, used, overBy, verdict, memUsed, cpuUsed, shownFree, swapGrowing, diskSqueeze, BREAKER_LINE } from './schedule.mjs';
6
+ import { forecast, byRank, remaining, used, overBy, verdict, memUsed, cpuUsed, shownFree, swapGrowing, diskSqueeze, BREAKER_LINE, QUICK_LINE } 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';
@@ -55,7 +55,7 @@ export function boardOf(s, cfg, hist, t = now(), me = null) {
55
55
  held: [...s.leases].sort((a, b) => a.start - b.start).map(l => ({
56
56
  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),
57
57
  stuck: s.queue.some(q => q.pid) && stuckFor(l, t) > 0,
58
- prio: l.prio, paused: pauseLabel(l) || null, alongside: alongsideLabel(l) || (l.breaker ? BREAKER_LINE : null), owner: ownerLabel(l) || null, purpose: l.purpose, cmd: l.cmd ? l.cmd.slice(0, 40) : null,
58
+ 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,
59
59
  mem: l.mem, use: l.use?.mem ?? null, over: overBy(l) > 0, grew: grewLine(l) || null, ...you(l) })),
60
60
  waiting: [...s.queue].sort(byRank(hist, t)).map(q => ({
61
61
  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,
package/src/commands.mjs CHANGED
@@ -19,7 +19,7 @@ import { bold, dim, amber, columns, wrap, quoted } from './style.mjs';
19
19
  import { quotasNow, isQuota } from './quota.mjs';
20
20
  import { agentsNow } from './agents.mjs';
21
21
  import { forYou } from './questions.mjs';
22
- import { notesForYou } from './talk.mjs';
22
+ import { notesForYou, listeners } from './talk.mjs';
23
23
  import { remoteConf, shortHost } from './remote.mjs';
24
24
  import { sample, sized, grewLine, grewPlain, tellOverAsk } from './measure.mjs';
25
25
  import { clash, isFiles, short, takeAgent, callKey, sameAgent, fileKey, shellRes, projectKey } from './files.mjs';
@@ -28,11 +28,11 @@ import { laterBoard, laterLines, laterPlain } from './later.mjs';
28
28
  import { noticeScan, NOTICE_EVERY, twinOf } from './notices.mjs';
29
29
  import { answer, ISSUES } from './answers.mjs';
30
30
  import { event } from './events.mjs';
31
- import { scan as scanAlerts, alertLines } from './alerts.mjs';
31
+ import { scan as scanAlerts, alertLines, onBoard } from './alerts.mjs';
32
32
 
33
33
  const REQUESTS = path.join(HOME, 'requests.jsonl');
34
34
  // Exit codes dibs gives its own meaning (AGENTS.md).
35
- const DIBS_CODES = new Set([1, 2, 70, 74, 75, 76, 77, 127]);
35
+ const DIBS_CODES = new Set([1, 2, 3, 70, 74, 75, 76, 77, 127]);
36
36
  const json = x => console.log(JSON.stringify(x, null, 1));
37
37
 
38
38
  export function freePort() {
@@ -133,6 +133,7 @@ export async function run(o, cfg) {
133
133
  };
134
134
  const stopAll = sig => { stopTree(child.pid, sig); if (OS !== 'windows') for (const g of groups) stopTree(g, sig); };
135
135
  let finished = false, tracker = null, ran = null;
136
+ let took = null; // how long a run the quick lane let in really took
136
137
  const finish = code => {
137
138
  if (finished) return;
138
139
  finished = true;
@@ -153,6 +154,7 @@ export async function run(o, cfg) {
153
154
  s.leases = s.leases.filter(x => x.id !== lease.id);
154
155
  // A failing run is often the one that ran out of memory: its size counts too.
155
156
  if (l && (code === 0 || l.peak?.mem)) record(l.key, now() - l.start - pausedFor(l), l.who, l.peak, code !== 0);
157
+ if (l?.quick) took = now() - l.start - pausedFor(l);
156
158
  tellOverAsk(l);
157
159
  });
158
160
  } catch (e) {
@@ -163,6 +165,9 @@ export async function run(o, cfg) {
163
165
  else say(`dibs hit a bug recording that this job ended (${e.message}). Your command's exit code comes back anyway, and the next dibs command cleans up. Report it: dibs ask "..."`);
164
166
  }
165
167
  if (again) return runAgain(o, lease, again);
168
+ // Over the quick lane's limit: its next runs wait their turn until one comes in under (src/schedule.mjs quickPass).
169
+ const under = cfg.quickUnder == null ? null : ms(cfg.quickUnder);
170
+ if (took != null && under != null && took >= under) say(`this took ${dur(took)}, over the ${dur(under)} the quick lane is for, so its next runs wait their turn until one finishes in under ${dur(under)}.`);
166
171
  // A failing command's code can look like one of dibs's own (75, 74, 127), so say whose it is.
167
172
  if (code && code < 128) say(`${path.basename(o.cmd[0])} exited with code ${code}${DIBS_CODES.has(code) ? ". That's your command's code, not dibs's" : ''}.`);
168
173
  // One line that says it all, for an agent that has lost the output above (a compacted context).
@@ -686,6 +691,8 @@ export function boardJson(s, cfg, { hist = history(), m = machine(), t = now(),
686
691
  agents: agentsNow(cfg),
687
692
  questions: forYou(cfg, t),
688
693
  notes: notesForYou(),
694
+ // Agents waiting on dibs listen for a message: dibs tell reaches them within seconds.
695
+ listening: listeners(),
689
696
  caps: s.caps || {},
690
697
  later: laterBoard(t),
691
698
  // What's wrong, each with its fix (src/alerts.mjs): open ones, then those resolved lately.
@@ -713,7 +720,7 @@ export async function status(o, cfg) {
713
720
  const out = [`${others ? `${rc.name} (this one) ` : ''}${cfg.pace ? `pace ${cfg.pace}, ` : ''}${handedOut(b)} `
714
721
  + `machine: ${m.memFree}% memory free, disk ${m.diskFree == null ? 'unknown' : `${gb(m.diskFree)} free`}, swap ${gb(m.swapUsed)}, load ${m.load.toFixed(1)}`
715
722
  + `${cfg.maxLoad != null ? ` (ceiling ${cfg.maxLoad})` : ''}`];
716
- out.unshift(...alertLines(scanAlerts({ s, cfg, hist, m, t }), t));
723
+ out.unshift(...alertLines(scanAlerts({ s, cfg, hist, m, t }).filter(a => onBoard(a, t)), t));
717
724
  const asks = forYou(cfg, t), notes = notesForYou();
718
725
  const plural = (n, w) => `${n} ${w}${n > 1 ? 's' : ''}`;
719
726
  if (asks || notes) out.unshift(`${[asks && plural(asks, 'question'), notes && plural(notes, 'note')].filter(Boolean).join(' and ')} for you: dibs ${notes ? 'threads' : 'questions'}`);
@@ -742,7 +749,7 @@ function plainStatus(s, cfg, hist, m, t, rc, away, broken, me) {
742
749
  const agent = !!me.agent;
743
750
  const out = [bold(headline(p))];
744
751
  // What's wrong comes before anything else, so it can't be missed.
745
- const alerted = alertLines(scanAlerts({ s, cfg, hist, m, t }), t);
752
+ const alerted = alertLines(scanAlerts({ s, cfg, hist, m, t }).filter(a => onBoard(a, t)), t);
746
753
  if (alerted.length) out.push('', ...alerted, '');
747
754
  // An agent reading the board wants its own place first.
748
755
  if (agent) {
@@ -757,6 +764,8 @@ function plainStatus(s, cfg, hist, m, t, rc, away, broken, me) {
757
764
  const count = (n, w) => `${n} ${w}${n > 1 ? 's' : ''}`;
758
765
  if (asks && !notes) out.push(amber(`${count(asks, 'question')} ${asks > 1 ? 'are' : 'is'} waiting for your answer: dibs questions`));
759
766
  else if (notes) out.push(amber(`${[asks && count(asks, 'question'), count(notes, 'note')].filter(Boolean).join(' and ')} ${asks + notes > 1 ? 'are' : 'is'} waiting for you: dibs threads`));
767
+ const ears = listeners();
768
+ if (ears.length) out.push(dim(`Listening for messages (dibs tell reaches them within seconds): ${ears.join(', ')}`));
760
769
  const { busy, free } = lineParts(p);
761
770
  out.push('', ...columns([...busy.map(b => [b.label, b.now, b.next]), ...(free.length ? [['Free', dim(freeText(p, free))]] : [])]));
762
771
 
package/src/config.mjs CHANGED
@@ -27,6 +27,7 @@ export const DEFAULT_CONFIG = {
27
27
  minFreeMem: 15, // jobs of 2G+ wait while the OS reports less than this % of memory free
28
28
  minDisk: '5G', // nothing starts below this much free disk
29
29
  starveAfter: '3m', // after this long at the head of the line, nobody jumps it
30
+ quickUnder: '15s', // a command that runs under this goes in the quick lane: it starts at once (src/schedule.mjs quickPass)
30
31
  roomyMemFree: 35, // with at least this % of memory free...
31
32
  roomyLoad: 0.6, // ...and load under this share of the cores, the memory and CPU budgets don't apply
32
33
  coolLoad: 8, // `dibs throttle` acts when the 1-minute load average is above this
@@ -75,8 +76,9 @@ export const DEFAULT_CONFIG = {
75
76
  test: { slots: 3, mem: '2G', cpu: 3, pausable: true, rerun: true },
76
77
  // One deploy at a time per project, up to across at once (exclusiveBy: src/schedule.mjs roomFor):
77
78
  // two projects' deploys don't touch each other, and a 6-second web deploy waited behind another
78
- // project's TestFlight upload (2026-11-03). slots is per project, so a config's slots: 1 reads so too.
79
- deploy: { slots: 1, mem: '0.5G', cpu: 1, pausable: false, exclusive: true, exclusiveBy: 'repo', across: 3 },
79
+ // project's TestFlight upload (2026-11-03). slots is per project, so a config's slots: 1 reads so too. A quick deploy of
80
+ // another project may go past across (quickAlongside).
81
+ deploy: { slots: 1, mem: '0.5G', cpu: 1, pausable: false, exclusive: true, exclusiveBy: 'repo', across: 3, quickAlongside: 'other-repo' },
80
82
  heavy: { slots: 1, mem: '4G', cpu: 4, disk: '10G', pausable: true, rerun: true },
81
83
  },
82
84
  // A name dibs doesn't know is often someone's lock ("one migration at a time"), so it never overlaps.
@@ -109,7 +111,9 @@ export function loadConfig() {
109
111
  if (v.onReleaseTimeout != null) ms(v.onReleaseTimeout);
110
112
  if (v.exclusiveBy != null && v.exclusiveBy !== 'repo') die(`resources.${k}.exclusiveBy in ${paths.config} is "repo" (one at a time per project), or null`);
111
113
  if (v.across != null && !(Number.isInteger(v.across) && v.across > 0)) die(`resources.${k}.across in ${paths.config} is how many projects may use it at once, a whole number above 0`);
114
+ if (v.quickAlongside != null && v.quickAlongside !== 'other-repo') die(`resources.${k}.quickAlongside in ${paths.config} is "other-repo" (a quick job of another repo starts beside this one's jobs), or null`);
112
115
  }
116
+ if (merged.quickUnder != null && !(ms(merged.quickUnder) >= 0)) die(`quickUnder in ${paths.config} is a duration like 15s, or null for no quick lane`);
113
117
  merged.profiles = checkProfiles(c.profiles, merged.resources);
114
118
  if (c.pace) Object.assign(merged, paced(c).knobs);
115
119
  // The person's own word wins; else the pace's; else one job per slot.