@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/CHANGELOG.md +17 -0
- package/README.md +48 -197
- package/bin/dibs.mjs +46 -24
- package/docs/machines.md +1 -1
- package/docs/questions.md +1 -1
- package/docs/reference.md +157 -0
- package/docs/releasing.md +8 -6
- package/docs/scheduling.md +2 -2
- package/package.json +2 -1
- package/skills/dibs/SKILL.md +104 -83
- package/src/acquire.mjs +11 -8
- package/src/alerts.mjs +100 -38
- package/src/answers.mjs +2 -2
- package/src/board.mjs +2 -2
- package/src/commands.mjs +14 -5
- package/src/config.mjs +6 -2
- package/src/diskwarn.mjs +28 -35
- package/src/events.mjs +3 -1
- package/src/files.mjs +27 -4
- package/src/guard.mjs +31 -1
- package/src/hogs.mjs +18 -5
- package/src/news.mjs +101 -0
- package/src/notes.mjs +171 -0
- package/src/notices.mjs +52 -13
- package/src/ondemand.mjs +1 -1
- package/src/override.mjs +22 -13
- package/src/plain.mjs +5 -2
- package/src/preempt.mjs +3 -3
- package/src/primer.mjs +43 -15
- package/src/proc.mjs +4 -3
- package/src/progress.mjs +33 -4
- package/src/schedule.mjs +46 -21
- package/src/serve.mjs +6 -0
- package/src/talk.mjs +199 -20
- package/src/version.mjs +1 -1
- package/src/web.mjs +4 -2
package/src/notices.mjs
CHANGED
|
@@ -9,13 +9,15 @@
|
|
|
9
9
|
// dibs and every running one. Each notice has a name (idle:#12), so however
|
|
10
10
|
// many of them scan, an agent hears about each thing once.
|
|
11
11
|
import fs from 'node:fs';
|
|
12
|
-
import
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import { paths, HOME } from './config.mjs';
|
|
14
|
+
import { peek, history } from './state.mjs';
|
|
13
15
|
import { notify } from './talk.mjs';
|
|
14
16
|
import { minutes, stuckFor } from './plain.mjs';
|
|
15
17
|
import { stuckLeases } from './acquire.mjs';
|
|
16
18
|
import { overAskLine } from './measure.mjs';
|
|
17
19
|
import { now, callerPid, clock } from './util.mjs';
|
|
18
|
-
import { read as readPosts, tasks, QUIET_AFTER } from './progress.mjs';
|
|
20
|
+
import { read as readPosts, tasks, QUIET_AFTER, EXPIRE_AFTER } from './progress.mjs';
|
|
19
21
|
import { quoted } from './style.mjs';
|
|
20
22
|
|
|
21
23
|
// Which runs look stuck and which used more memory than they asked for is
|
|
@@ -68,20 +70,43 @@ export function noticeScan(t = now()) {
|
|
|
68
70
|
} catch {}
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
// At most one nudge per task this often. On 2026-11-03, 5 of 35 notices were
|
|
74
|
+
// these, and agents were posting progress only to stop them.
|
|
75
|
+
export const NAG_EVERY = 2 * 36e5;
|
|
76
|
+
// An agent with no job running or waiting, and none run in this long, isn't
|
|
77
|
+
// working now: its open task waits quietly for it to come back.
|
|
78
|
+
export const AWAY_AFTER = 30 * 6e4;
|
|
79
|
+
const NAGS = path.join(HOME, 'nags.json');
|
|
80
|
+
|
|
81
|
+
// [to, once, text, task] for each task still in progress that needs a word
|
|
82
|
+
// from whoever posted it: past its ETA, or with no post for QUIET_AFTER.
|
|
83
|
+
// Expired tasks are let go. Only tasks posted from a Claude Code session: the
|
|
84
|
+
// hook is how the notice arrives. A subagent's task is nudged to that subagent;
|
|
85
|
+
// once it has ended (ended(k)), its lead hears once that it was left open.
|
|
86
|
+
// nagged: when each task was last nudged; working(k): whether the agent the
|
|
87
|
+
// notice would go to is at work now.
|
|
88
|
+
export function progressNoticesIn(posts, t = now(), { nagged = {}, working = () => true, ended = () => false } = {}) {
|
|
75
89
|
const out = [];
|
|
76
90
|
for (const k of tasks(posts, t)) {
|
|
77
91
|
if (k.state !== 'doing' || !k.session) continue;
|
|
78
|
-
const
|
|
92
|
+
const task = `${k.who}:${k.agentId || 'main'}:${k.task || k.project}`;
|
|
79
93
|
const name = k.task ? `"${k.task}"` : `in ${k.project || 'this folder'}`;
|
|
94
|
+
if (k.agentId && ended(k)) {
|
|
95
|
+
// Said once: nothing to do, it expires by itself; the lead only shouldn't be surprised.
|
|
96
|
+
const lead = `${task}:lead`;
|
|
97
|
+
if (nagged[lead] || !working({ ...k, agentId: null }) || !(k.overdue || t - k.last > QUIET_AFTER)) continue;
|
|
98
|
+
out.push([{ sessionId: k.session, who: k.who }, `left:${task}`, `your subagent ${k.label || k.agentId.slice(0, 8)} ended with its progress task ${name} still open `
|
|
99
|
+
+ `(last post at ${clock(k.last)}). Nothing to do: it's let go ${minutes(Math.max(k.last, k.eta || 0) + EXPIRE_AFTER - t)} from now. `
|
|
100
|
+
+ `If the work goes on, post it under your own task.`, lead]);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (t - (nagged[task] || 0) < NAG_EVERY || !working(k)) continue;
|
|
104
|
+
const to = { sessionId: k.session, who: k.who, ...(k.agentId && { agentId: k.agentId }) };
|
|
80
105
|
const again = (...more) => quoted(['dibs', 'progress', 'where it stands', ...(k.task ? ['--task', k.task] : []), ...more]);
|
|
81
|
-
if (k.overdue) out.push([to, `late:${
|
|
82
|
-
+ `If it's finished, say so: ${again('--done')}. If not, post where it stands with a new time: ${again('--eta', '30m')}
|
|
83
|
-
else if (t - k.last > QUIET_AFTER) out.push([to, `quiet:${
|
|
84
|
-
+ `Post where it stands (${again()}), or close it: --done if it's finished, --blocked if it's stuck
|
|
106
|
+
if (k.overdue) out.push([to, `late:${task}:${k.eta}`, `your progress task ${name} was due at ${clock(k.eta)} and is still open. `
|
|
107
|
+
+ `If it's finished, say so: ${again('--done')}. If not, post where it stands with a new time: ${again('--eta', '30m')}.`, task]);
|
|
108
|
+
else if (t - k.last > QUIET_AFTER) out.push([to, `quiet:${task}:${k.last}`, `your progress task ${name} has had no post for ${minutes(t - k.last)}. `
|
|
109
|
+
+ `Post where it stands (${again()}), or close it: --done if it's finished, --blocked if it's stuck.`, task]);
|
|
85
110
|
}
|
|
86
111
|
return out;
|
|
87
112
|
}
|
|
@@ -90,11 +115,25 @@ const DAY = 864e5;
|
|
|
90
115
|
// From the throttle watcher (src/cool.mjs), which is always running: no waiter needed.
|
|
91
116
|
export function progressScan(t = now()) {
|
|
92
117
|
try {
|
|
93
|
-
|
|
118
|
+
let nagged = {};
|
|
119
|
+
try { nagged = JSON.parse(fs.readFileSync(NAGS, 'utf8')); } catch {}
|
|
120
|
+
const s = peek(), hist = history();
|
|
121
|
+
// At work: a job running or waiting, or one run in the last AWAY_AFTER. A
|
|
122
|
+
// subagent counts only its own jobs (they carry its id) and its own posts.
|
|
123
|
+
const mine = k => x => x.sessionId === k.session && (k.agentId ? x.agentId === k.agentId : true);
|
|
124
|
+
const busy = k => (s.leases || []).some(mine(k)) || (s.queue || []).some(q => q.pid && mine(k)(q));
|
|
125
|
+
const working = k => (k.agentId ? busy(k) || t - k.last < AWAY_AFTER
|
|
126
|
+
: busy(k) || (s.leases || []).some(l => l.who === k.who) || hist.some(r => r.who === k.who && t - r.at < AWAY_AFTER));
|
|
127
|
+
const ended = k => !busy(k) && t - k.last >= AWAY_AFTER;
|
|
128
|
+
const before = JSON.stringify(nagged);
|
|
129
|
+
for (const [to, once, text, task] of progressNoticesIn(readPosts({ since: t - DAY }), t, { nagged, working, ended })) {
|
|
94
130
|
if (sent.has(once)) continue;
|
|
95
131
|
sent.add(once);
|
|
96
|
-
notify(to, once, text);
|
|
132
|
+
if (notify(to, once, text)) nagged[task] = t;
|
|
97
133
|
}
|
|
134
|
+
// A lead's one word about a subagent's task is kept as long as the task can be: never twice.
|
|
135
|
+
for (const [k, at] of Object.entries(nagged)) if (t - at >= (k.endsWith(':lead') ? DAY : NAG_EVERY)) delete nagged[k];
|
|
136
|
+
if (JSON.stringify(nagged) !== before) fs.writeFileSync(NAGS, JSON.stringify(nagged));
|
|
98
137
|
} catch {}
|
|
99
138
|
}
|
|
100
139
|
|
package/src/ondemand.mjs
CHANGED
|
@@ -306,7 +306,7 @@ export function ondemand(list, srv, { port, tick = TICK, log: say = log, clock =
|
|
|
306
306
|
const w = workers.get(vm.name);
|
|
307
307
|
if (w) Object.assign(w, { pending: [], assigned: 0 });
|
|
308
308
|
};
|
|
309
|
-
// Marked can't-wake until a retry time: placement skips it, --on
|
|
309
|
+
// Marked can't-wake until a retry time: placement skips it, a job sent --on it runs on its sender with the reason, and dibs machines says so.
|
|
310
310
|
const block = (vm, why) => {
|
|
311
311
|
vm.cantWake = { why, until: now() + (QUOTA.test(why) ? QUOTA_BACKOFF : WAKE_BACKOFF) };
|
|
312
312
|
say(`${vm.name}: can't wake (${why}); not trying again until ${new Date(vm.cantWake.until).toISOString()}`);
|
package/src/override.mjs
CHANGED
|
@@ -23,7 +23,7 @@ import { ownerPause, pauseLabel } from './preempt.mjs';
|
|
|
23
23
|
import { PRIORITIES, BACKGROUND, NEEDS_REASON, priority, byRank } from './schedule.mjs';
|
|
24
24
|
import { actor } from './owner.mjs';
|
|
25
25
|
import { event } from './events.mjs';
|
|
26
|
-
import { die, now } from './util.mjs';
|
|
26
|
+
import { die, now, say, sleepSync } from './util.mjs';
|
|
27
27
|
import { takeAgent, callKey } from './files.mjs';
|
|
28
28
|
import { quoted } from './style.mjs';
|
|
29
29
|
|
|
@@ -125,8 +125,9 @@ function setPrio(x, prio, act, who, reason = '') {
|
|
|
125
125
|
// cores, the rest off them. `from` is its priority before the change (runs
|
|
126
126
|
// started by an older dibs don't record their QoS). Returns the pids to move,
|
|
127
127
|
// found under the lock; they're moved after it, since a big tree takes a while.
|
|
128
|
-
//
|
|
129
|
-
|
|
128
|
+
// After a boost moves a job, the whole group is moved again this many times, CATCH_GAP ms
|
|
129
|
+
// apart: for children forked meanwhile, and a move lost to a fork in progress.
|
|
130
|
+
const CATCH_UP = 3, CATCH_GAP = 100;
|
|
130
131
|
function requeue(l, from) {
|
|
131
132
|
if (l.kind !== 'run' || !l.pgid || OS === 'windows') return null;
|
|
132
133
|
const bg = BACKGROUND.has(l.prio);
|
|
@@ -142,9 +143,16 @@ function requeue(l, from) {
|
|
|
142
143
|
export function boost(args) {
|
|
143
144
|
const who = actor();
|
|
144
145
|
const me = caller('boost');
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
const
|
|
146
|
+
const parsed = argsOf('boost', args);
|
|
147
|
+
let { words: [target, p] } = parsed;
|
|
148
|
+
const { reason, owner } = parsed;
|
|
149
|
+
// The priority before the id (dibs boost high 17727) reads the same.
|
|
150
|
+
if (target && p && !/^\d+$/.test(target) && PRIORITIES.includes(target) && /^\d+$/.test(p)) [target, p] = [p, target];
|
|
151
|
+
if (!target) die(`boost which job? Use: ${USAGE.boost}. ${IDS}`);
|
|
152
|
+
// A boost with a reason and no priority means move it up (2026-11-03: dibs boost 17727 --owner x -m "..." was a usage error).
|
|
153
|
+
if (!p && reason) say(`no priority given, so #${target} goes to high`);
|
|
154
|
+
else if (!p) die(`boost ${target} to what? Name a priority: dibs boost ${target} high -m "why" (or ${PRIORITIES.join(', ')}). Nothing changed.`);
|
|
155
|
+
const prio = prioArg('boost', p || 'high');
|
|
148
156
|
// Everyone sees an agent's high or urgent, and why, as they do on dibs run -p.
|
|
149
157
|
if (who.agent && NEEDS_REASON.has(prio) && !reason) die(`${prio} needs a reason everyone can see: dibs boost ${target} ${prio} -m "why". Nothing changed.`);
|
|
150
158
|
const hist = history();
|
|
@@ -174,17 +182,18 @@ export function boost(args) {
|
|
|
174
182
|
// One that exited meanwhile has nothing left to move, a zombie its parent hasn't reaped included.
|
|
175
183
|
const gone = pid => !/^[^Z]/.test(spawnSync('ps', ['-o', 'stat=', '-p', String(pid)], { encoding: 'utf8' }).stdout.trim());
|
|
176
184
|
const move = pid => (c.qos.bg ? lower(pid) : raise(pid)) || gone(pid);
|
|
177
|
-
|
|
178
|
-
|
|
185
|
+
// Whether each process was moved, the last time it was tried.
|
|
186
|
+
const done = new Map(c.qos.pids.map(pid => [pid, move(pid)]));
|
|
179
187
|
// A child forked between reading the process table and moving its parent kept the old
|
|
180
188
|
// priority, and at background priority on a busy machine even a sleep 0.05 can last
|
|
181
|
-
// seconds.
|
|
189
|
+
// seconds. And a move that lands while its process forks can be lost: on 2026-11-03,
|
|
190
|
+
// under a full suite, a raised loop shell still read background priority 10 s later.
|
|
191
|
+
// So the whole group is moved again a few times, a moment apart (a move is idempotent).
|
|
182
192
|
for (let i = 0; i < CATCH_UP; i++) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
for (const pid of late) tried.add(pid);
|
|
186
|
-
moved += late.filter(move).length;
|
|
193
|
+
sleepSync(CATCH_GAP);
|
|
194
|
+
for (const pid of pidsIn(c.qos.groups)) done.set(pid, move(pid));
|
|
187
195
|
}
|
|
196
|
+
const tried = done, moved = [...done.values()].filter(Boolean).length;
|
|
188
197
|
line += c.qos.bg ? ', moved to background priority (efficiency cores)' : ', moved off background priority';
|
|
189
198
|
if (moved < tried.size) line += ` (${tried.size - moved} of its ${tried.size} processes couldn't be moved${OS === 'linux' && !c.qos.bg ? ': Linux lets only root raise a priority' : ''})`;
|
|
190
199
|
}
|
package/src/plain.mjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// job in the way has a run time from history or --est, "as soon as X finishes"
|
|
8
8
|
// when X has none, and "unknown" when the wait is on the machine (disk, memory,
|
|
9
9
|
// load), which no clock predicts.
|
|
10
|
-
import { IDLE_MEM_FREE, verdict, forecastDetail, expected, known, remaining, rankParts, byRank, recentUse, coveredNow, memUsed, memHolders, shownFree, NOT_PRIORITY, swapping, diskSqueeze, overLoad, STALL } from './schedule.mjs';
|
|
10
|
+
import { IDLE_MEM_FREE, verdict, forecastDetail, expected, known, remaining, rankParts, byRank, recentUse, coveredNow, memUsed, memHolders, shownFree, NOT_PRIORITY, swapping, diskSqueeze, overLoad, STALL, QUICK_LINE } from './schedule.mjs';
|
|
11
11
|
import { quotaBlock, isQuota, QUOTA } from './quota.mjs';
|
|
12
12
|
import { isFiles, short, elsewhere } from './files.mjs';
|
|
13
13
|
import { machine, resCfg } from './config.mjs';
|
|
@@ -272,6 +272,9 @@ export function moves(q, hist, t, cfg) {
|
|
|
272
272
|
} else if (p.label === 'recent use') {
|
|
273
273
|
label = 'taking turns';
|
|
274
274
|
reason = `this agent used ${andList(recentUse(hist, q.who, q.res, t).res.map(r => named(cfg, r).the))} a lot in the last hour`;
|
|
275
|
+
} else if (p.label === 'quick') {
|
|
276
|
+
label = 'quick';
|
|
277
|
+
reason = "it runs in seconds (the quick lane), so it goes before anyone who'd hold the slot for longer";
|
|
275
278
|
} else if (p.label === 'let ahead') {
|
|
276
279
|
label = 'let ahead';
|
|
277
280
|
reason = `${q.yieldBy || 'another agent'} let it go first`;
|
|
@@ -390,7 +393,7 @@ export function plainBoard(s, cfg, hist, t = now(), m = machine(), me = null) {
|
|
|
390
393
|
const someoneWaits = order.length > 0;
|
|
391
394
|
const held = new Map(s.leases.map(l => [l.id, {
|
|
392
395
|
headline: l.res.map((r, i) => (i ? lower(named(cfg, r).doing) : named(cfg, r).doing)).join(' and '),
|
|
393
|
-
endsText: ends(l, hist, t).endsText, paused: pausedText(l, cfg), ...(l.alongside ? { alongside: alongsideText(l.alongside) } : l.breaker ? { alongside: `Let in although the machine is short of disk or memory, since nothing had started for ${STALL / 6e4} min` } : {}),
|
|
396
|
+
endsText: ends(l, hist, t).endsText, paused: pausedText(l, cfg), ...(l.alongside ? { alongside: alongsideText(l.alongside) } : l.breaker ? { alongside: `Let in although the machine is short of disk or memory, since nothing had started for ${STALL / 6e4} min` } : l.quick ? { alongside: upper(QUICK_LINE) } : {}),
|
|
394
397
|
...(someoneWaits && stuckFor(l, t) ? { stuck: `${stuckText(l, t)} (#${l.id}${l.purpose ? `, "${l.purpose}"` : ''})` } : {}) }]));
|
|
395
398
|
return { lines, held, waiting, rules, names: new Map(s.queue.map(q => [q.id, holderName(q)])), holds: new Set(s.leases.filter(l => l.kind === 'hold').map(l => l.id)), cfg,
|
|
396
399
|
hold: machineHold(s, cfg, m) };
|
package/src/preempt.mjs
CHANGED
|
@@ -421,13 +421,13 @@ export function noticeHandler(read) {
|
|
|
421
421
|
const by = pausedBy(l);
|
|
422
422
|
const why = l.pauses.find(x => x.owner)?.reason;
|
|
423
423
|
say(by ? `${by === 'owner' ? 'the owner (the person at this machine)' : by} paused your job (dibs pause ${l.id})${why ? `: "${why}"` : ''}. It keeps its lease and its place; dibs resume ${l.id} continues it.`
|
|
424
|
-
+ '
|
|
424
|
+
+ ' Its processes were stopped (SIGSTOP) and continue where they were when it resumes. Anything waiting on a server meanwhile (an HTTP request, an upload) may have timed out on the far side: check its output for timeouts.'
|
|
425
425
|
: p
|
|
426
426
|
? `paused your job for ${p.who} (${p.prio}${p.purpose ? `: "${p.purpose}"` : ''}), who needed ${p.res.join(', ')}.`
|
|
427
|
-
+
|
|
427
|
+
+ ' It keeps its lease and its place, and resumes when their job ends.' + ' Its processes were stopped (SIGSTOP) and continue where they were when it resumes. Anything waiting on a server meanwhile (an HTTP request, an upload) may have timed out on the far side: check its output for timeouts.'
|
|
428
428
|
: l.pauses?.some(x => x.disk)
|
|
429
429
|
? `paused your job: free disk is low and ${l.pauses.some(x => x.swap) ? 'swap is still growing on it' : 'still falling'}. It keeps its lease and its place, and resumes once there's room again.`
|
|
430
|
-
+ ' If it stays paused, free some disk space.
|
|
430
|
+
+ ' If it stays paused, free some disk space.' + ' Its processes were stopped (SIGSTOP) and continue where they were when it resumes. Anything waiting on a server meanwhile (an HTTP request, an upload) may have timed out on the far side: check its output for timeouts.'
|
|
431
431
|
: l.alongside ? pausedLine()
|
|
432
432
|
: `paused your ${l.prio} job: the machine is short on memory. It keeps its lease and resumes when memory pressure eases.`);
|
|
433
433
|
} else if (!l.pausedAt && since) {
|
package/src/primer.mjs
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import fs from 'node:fs';
|
|
7
7
|
import os from 'node:os';
|
|
8
8
|
import path from 'node:path';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
9
10
|
|
|
10
11
|
const DIBS_HOME = process.env.DIBS_HOME || path.join(os.homedir(), '.dibs');
|
|
11
12
|
const BUILT_IN = ['sim', 'sim-own', 'xcode-build', 'test', 'playwright', 'deploy', 'heavy'];
|
|
@@ -17,23 +18,50 @@ function resources() {
|
|
|
17
18
|
return [...new Set([...BUILT_IN, ...extra])].join(', ');
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
// The rules every agent gets first, and nothing else: what to wrap and how, what
|
|
22
|
+
// needs no dibs, staying reachable, the two exit codes agents hit, and when to ask
|
|
23
|
+
// the person. One source: the session primer below, and the top of
|
|
24
|
+
// skills/dibs/SKILL.md and docs/reference.md's "Tell your agents", which writeRules()
|
|
25
|
+
// fills from it (test/rules.test.mjs checks they match). The rest is reference,
|
|
26
|
+
// under the skill's "When you need it": agents that got every rule up front
|
|
27
|
+
// skimmed them all (feedback, 2026-11-03).
|
|
28
|
+
export function rules(res = resources(), more = 'is in dibs.md beside dibs (the dibs skill) and in `dibs help`') {
|
|
21
29
|
return [
|
|
22
|
-
'dibs runs on this machine
|
|
23
|
-
`- Wrap those: dibs run <resource> -m "why" -- <command
|
|
24
|
-
|
|
25
|
-
'-
|
|
26
|
-
|
|
27
|
-
'-
|
|
28
|
-
'- Decide
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
+ 'Quote file globs: dibs hold \'files:src/auth/**\'.',
|
|
33
|
-
'- More: the dibs skill, dibs help. Something wrong with dibs: dibs ask "...".',
|
|
34
|
-
].join('\n');
|
|
30
|
+
'dibs runs on this machine. Agents take turns through it on the simulator, Xcode builds, test suites, browser runs and deploys.',
|
|
31
|
+
`- Wrap those: \`dibs run <resource> -m "why" -- <command>\` (resources: ${res}). Two at once: \`dibs run sim,xcode-build -- ...\`.`,
|
|
32
|
+
'- No dibs for reads, edits, small commands, or long jobs that mostly wait on the network and use little CPU, memory or disk (crawlers, pollers, HTTP checks). The hook leaves those alone too.',
|
|
33
|
+
'- Start `dibs listen` with run_in_background now, and again each time it exits: it wakes you when the person or dibs has something for you.',
|
|
34
|
+
'- Waiting is normal. A call moved to the background is still waiting: don\'t run it again. A wait on memory, swap or disk protects the machine: keep waiting, and never lower `--mem` or raise `-p` to get past it.',
|
|
35
|
+
'- Exit 75: it gave up waiting and your command never ran; run the same command again. Exit 74: not enough free disk; free your own build output, or tell the person.',
|
|
36
|
+
'- Decide what you can undo yourself. Ask the person only before something you can\'t undo (`dibs question ... --one-way`). Lines starting "Message from the person:" are theirs: act on them.',
|
|
37
|
+
'- Post progress as you work: `dibs progress "what you did or found" --task <name> --eta 30m`, then `--done`.',
|
|
38
|
+
`- The rest (holding across tool calls, file leases, other machines, every exit code, overriding jobs, questions) ${more}.`,
|
|
39
|
+
];
|
|
35
40
|
}
|
|
36
41
|
|
|
42
|
+
// A subagent ends with its task, so it isn't told to keep a listener running.
|
|
43
|
+
export const primerText = ({ subagent = false } = {}) => rules().filter(l => !(subagent && l.includes('dibs listen'))).join('\n');
|
|
44
|
+
|
|
45
|
+
// The rules as the skill and docs/reference.md carry them, between their markers, with the
|
|
46
|
+
// built-in resources (a machine's config adds its own; the primer names those).
|
|
47
|
+
const MARK = /<!-- dibs:rules:start -->[\s\S]*?<!-- dibs:rules:end -->/;
|
|
48
|
+
const ROOT = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
49
|
+
export const DOCS = {
|
|
50
|
+
'skills/dibs/SKILL.md': () => rules(BUILT_IN.join(', '), 'is below, under "When you need it", and in `dibs help`'),
|
|
51
|
+
// A block to paste, fenced, for anyone who doesn't let dibs init write the note.
|
|
52
|
+
'docs/reference.md': () => ['```markdown', '## dibs', ...rules(BUILT_IN.join(', '), 'is in the dibs skill and in `dibs help`'), '```'],
|
|
53
|
+
};
|
|
54
|
+
export const marked = lines => `<!-- dibs:rules:start -->\n${lines.join('\n')}\n<!-- dibs:rules:end -->`;
|
|
55
|
+
export function writeRules(root = ROOT) {
|
|
56
|
+
for (const [f, make] of Object.entries(DOCS)) {
|
|
57
|
+
const file = path.join(root, f);
|
|
58
|
+
const text = fs.readFileSync(file, 'utf8');
|
|
59
|
+
if (!MARK.test(text)) throw new Error(`${f} has no <!-- dibs:rules:start --> ... <!-- dibs:rules:end --> to fill`);
|
|
60
|
+
fs.writeFileSync(file, text.replace(MARK, marked(make())));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
37
65
|
// Each subagent hears it once: SubagentStart also fires every time an agent
|
|
38
66
|
// team teammate takes a new message. A short list of ids it was told, newest last.
|
|
39
67
|
const TOLD = path.join(DIBS_HOME, 'primed.json');
|
|
@@ -57,5 +85,5 @@ function firstTime(agentId) {
|
|
|
57
85
|
export function primer(input, out) {
|
|
58
86
|
const event = input.hook_event_name;
|
|
59
87
|
if (event === 'SubagentStart' && (typeof input.agent_id !== 'string' || !firstTime(input.agent_id))) return out;
|
|
60
|
-
return { ...out, hookSpecificOutput: { hookEventName: event, additionalContext: primerText() } };
|
|
88
|
+
return { ...out, hookSpecificOutput: { hookEventName: event, additionalContext: primerText({ subagent: event === 'SubagentStart' }) } };
|
|
61
89
|
}
|
package/src/proc.mjs
CHANGED
|
@@ -61,8 +61,9 @@ export function identity(o = {}) {
|
|
|
61
61
|
return { who, agent, label, spid: se?.pid || null, sstart: se?.start || null };
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
// Claude Code's own record of each session it runs: { pid, sessionId, name }.
|
|
65
|
-
// The person addresses an agent by the name; hooks know it by sessionId.
|
|
64
|
+
// Claude Code's own record of each session it runs: { pid, sessionId, name, status, updated }.
|
|
65
|
+
// The person addresses an agent by the name; hooks know it by sessionId. status is Claude
|
|
66
|
+
// Code's word for what it's doing ("busy", "idle", "shell"), or null from an older one.
|
|
66
67
|
export function sessionFiles() {
|
|
67
68
|
let names = [];
|
|
68
69
|
try { names = fs.readdirSync(SESSIONS).filter(n => /^\d+\.json$/.test(n)); } catch { return []; }
|
|
@@ -70,7 +71,7 @@ export function sessionFiles() {
|
|
|
70
71
|
for (const n of names) {
|
|
71
72
|
try {
|
|
72
73
|
const x = JSON.parse(fs.readFileSync(path.join(SESSIONS, n), 'utf8'));
|
|
73
|
-
if (x.pid && x.sessionId) out.push({ pid: x.pid, sessionId: x.sessionId, name: x.name || null });
|
|
74
|
+
if (x.pid && x.sessionId) out.push({ pid: x.pid, sessionId: x.sessionId, name: x.name || null, status: typeof x.status === 'string' ? x.status : null, updated: x.statusUpdatedAt || x.updatedAt || 0 });
|
|
74
75
|
} catch {}
|
|
75
76
|
}
|
|
76
77
|
return out;
|
package/src/progress.mjs
CHANGED
|
@@ -46,6 +46,7 @@ function parse(args) {
|
|
|
46
46
|
else if (a === '--agent') o.agent = val();
|
|
47
47
|
else if (a === '-n') o.n = Number(val());
|
|
48
48
|
else if (a === '--json') o.json = true;
|
|
49
|
+
else if (a === '--all') o.all = true;
|
|
49
50
|
else if (a.startsWith('-') && a.length > 1) die(`unknown flag ${a}. Try: dibs progress "ran the auth tests: 41 pass, 2 fail on token expiry" --task auth --eta 20m`);
|
|
50
51
|
else o.words.push(a);
|
|
51
52
|
}
|
|
@@ -70,8 +71,11 @@ function branch(dir) {
|
|
|
70
71
|
return { root: null, branch: null };
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
export function post(args) {
|
|
74
|
+
export async function post(args) {
|
|
74
75
|
const o = parse(args);
|
|
76
|
+
// dibs progress list: the open tasks. One word "list" is the command, never a post (2026-11-03: crews kept typing it).
|
|
77
|
+
if (o.words.length === 1 && o.words[0] === 'list' && !o.task && !o.state && !o.eta) return openTasks(o);
|
|
78
|
+
if (o.all) die('--all goes with dibs progress list');
|
|
75
79
|
if (!o.text) return list(o);
|
|
76
80
|
if (o.text.length > MAX_TEXT) die(`that's ${o.text.length} characters; keep a post under ${MAX_TEXT} and post again as you go. Nothing was posted.`);
|
|
77
81
|
if (o.task && o.task.length > MAX_TASK) die(`--task is a short name (under ${MAX_TASK} characters), not a description. Nothing was posted.`);
|
|
@@ -86,8 +90,13 @@ export function post(args) {
|
|
|
86
90
|
const id = identity(o);
|
|
87
91
|
const session = process.env.CLAUDE_CODE_SESSION_ID || sessionFiles().find(f => f.pid === id.spid)?.sessionId || null;
|
|
88
92
|
const where = branch(process.cwd());
|
|
93
|
+
// Which subagent of the session posts, as the hook saw it ask (src/files.mjs):
|
|
94
|
+
// its task is its own, and so is the nudge when it goes quiet. On 2026-11-03 a
|
|
95
|
+
// lead got overdue notices for its teammates' tasks.
|
|
96
|
+
const by = session ? (await import('./files.mjs')).takeAgent('progress', [], (await import('./files.mjs')).talkKey('progress', args)) : null;
|
|
89
97
|
const p = {
|
|
90
|
-
at: now(), who: id.who, ...(id.label && { label: id.label }), ...(session && { session }),
|
|
98
|
+
at: now(), who: id.who, ...((id.label || by?.agentType) && { label: id.label || by.agentType }), ...(session && { session }),
|
|
99
|
+
...(by?.agentId && by.agentId !== 'main' && { agentId: by.agentId }),
|
|
91
100
|
project: path.basename(where.root || process.cwd()), ...(where.branch && { branch: where.branch }),
|
|
92
101
|
...(o.task && { task: o.task }), state: o.state || 'doing', ...(eta && { eta }), text: o.text,
|
|
93
102
|
};
|
|
@@ -127,9 +136,10 @@ export function read({ since = 0, agent = null, limit = Infinity } = {}) {
|
|
|
127
136
|
export function tasks(posts, at = now()) {
|
|
128
137
|
const by = new Map();
|
|
129
138
|
for (const p of posts) {
|
|
130
|
-
|
|
139
|
+
// A subagent's task is its own, apart from its lead's of the same name.
|
|
140
|
+
const key = `${p.who}\0${p.agentId || ''}\0${p.task || ''}\0${p.task ? '' : p.project || ''}`;
|
|
131
141
|
let t = by.get(key);
|
|
132
|
-
if (!t) by.set(key, t = { who: p.who, label: p.label || null, task: p.task || null, project: p.project || null, branch: p.branch || null, started: p.at, posts: 0 });
|
|
142
|
+
if (!t) by.set(key, t = { who: p.who, label: p.label || null, ...(p.agentId && { agentId: p.agentId }), task: p.task || null, project: p.project || null, branch: p.branch || null, started: p.at, posts: 0 });
|
|
133
143
|
Object.assign(t, { last: p.at, state: p.state, text: p.text, branch: p.branch || t.branch, project: p.project || t.project, session: p.session || t.session || null });
|
|
134
144
|
if (p.eta) t.eta = p.eta;
|
|
135
145
|
if (p.state === 'doing' && t.state === 'doing' && t.doneAt) delete t.doneAt;
|
|
@@ -145,6 +155,25 @@ export function tasks(posts, at = now()) {
|
|
|
145
155
|
return [...by.values()].sort((a, b) => b.last - a.last);
|
|
146
156
|
}
|
|
147
157
|
|
|
158
|
+
// The open tasks of the caller's session (every agent in it), or every session's with
|
|
159
|
+
// --all: who owns each, its state, its ETA and its last post.
|
|
160
|
+
function openTasks(o) {
|
|
161
|
+
const id = identity(o);
|
|
162
|
+
const session = process.env.CLAUDE_CODE_SESSION_ID || sessionFiles().find(f => f.pid === id.spid)?.sessionId || null;
|
|
163
|
+
const mine = p => o.all || (session ? p.session === session : p.who === id.who);
|
|
164
|
+
const t = now();
|
|
165
|
+
const open = tasks(read().filter(mine), t).filter(k => k.state === 'doing' || k.state === 'blocked');
|
|
166
|
+
if (o.json) return console.log(JSON.stringify(open, null, 1));
|
|
167
|
+
if (!open.length) return console.log(o.all ? 'No open tasks on this machine.' : 'Your session has no open tasks. Every session\'s: dibs progress list --all');
|
|
168
|
+
for (const k of open) {
|
|
169
|
+
const owner = `${k.who}${k.label ? `/${k.label}` : ''}`;
|
|
170
|
+
const due = k.eta ? (k.overdue ? `overdue since ${clock(k.eta)}` : `expected by ${clock(k.eta)}`) : 'no ETA';
|
|
171
|
+
console.log(`${bold(k.task || `(untitled, in ${k.project || 'a folder'})`)} ${owner} ${k.state}, ${due}, last post ${dur(t - k.last)} ago`);
|
|
172
|
+
console.log(` ${k.text.replace(/\s*\n\s*/g, ' ').slice(0, 300)}`);
|
|
173
|
+
}
|
|
174
|
+
console.log(dim(`Close one: dibs progress "what's done" --task <name> --done${o.all ? '' : '. Every session\'s: dibs progress list --all'}`));
|
|
175
|
+
}
|
|
176
|
+
|
|
148
177
|
function list(o) {
|
|
149
178
|
const posts = read({ agent: o.agent, limit: o.n > 0 ? o.n : RECENT });
|
|
150
179
|
if (o.json) return console.log(JSON.stringify(posts, null, 1));
|
package/src/schedule.mjs
CHANGED
|
@@ -178,6 +178,8 @@ const HOLDING_SHIFT = 10 * MIN;
|
|
|
178
178
|
export function rankParts(q, hist, t = now()) {
|
|
179
179
|
const parts = [];
|
|
180
180
|
const add = (label, shift) => { if (Math.abs(shift) >= 1000) parts.push({ label, shift: Math.round(shift) }); };
|
|
181
|
+
// The quick lane goes to the front of its line, ahead of any priority: it's over in seconds.
|
|
182
|
+
if (q.quickPass) add('quick', QUICK_FRONT);
|
|
181
183
|
add(q.prio, PRIORITY_SHIFT[q.prio] || 0);
|
|
182
184
|
if (q.holding && (!q.prio || q.prio === 'normal')) add(`holds ${q.holding.res.join(',')}`, HOLDING_SHIFT);
|
|
183
185
|
if (q.by) {
|
|
@@ -718,13 +720,8 @@ function clashOf(s, me, hist) {
|
|
|
718
720
|
return null;
|
|
719
721
|
}
|
|
720
722
|
|
|
721
|
-
//
|
|
722
|
-
//
|
|
723
|
-
// machine's memory, disk, load and swap gates still hold. On 2026-10-21 most of
|
|
724
|
-
// the jobs that waited longer than they ran were checks of under a minute that
|
|
725
|
-
// waited tens of seconds for a browser slot. Only on resources whose slots are
|
|
726
|
-
// capacity: never an exclusive one (the shared simulator, deploys, a lock) or a
|
|
727
|
-
// pool that hands each job its own simulator.
|
|
723
|
+
// A run this short (the middle of its runs) is over in seconds: featherweight below. The quick
|
|
724
|
+
// lane (quickPass) goes by cfg.quickUnder, which is 15 s unless set.
|
|
728
725
|
const INSTANT = 15e3;
|
|
729
726
|
// A job over in seconds that has never been seen using much memory: its middle
|
|
730
727
|
// run under INSTANT (or, before dibs has seen it, an --est that short with no --mem
|
|
@@ -753,11 +750,34 @@ export function probation(s, me, cfg, hist, t) {
|
|
|
753
750
|
if (!me.res.every(r => !isFiles(r) && resCfg(cfg, r).pausable === true)) return false;
|
|
754
751
|
return !s.leases.some(l => l.trial);
|
|
755
752
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
753
|
+
// The quick lane (2026-11-03, the person: "let one really really quick thing go instantly ...
|
|
754
|
+
// if it takes under 15 seconds"). A command whose runs here take under quickUnder at the
|
|
755
|
+
// middle, or one run with --quick (or an --est that short) before dibs has seen it, starts at
|
|
756
|
+
// once: past the line, the slots of shared and pool resources, warning memory pressure, swap
|
|
757
|
+
// and the load ceiling. The disk floor, critical pressure, file leases and someone else's hold
|
|
758
|
+
// still hold it, and it never pauses anyone. A run that went over quickUnder takes the pass
|
|
759
|
+
// away from its command until a run comes in under again and the middle is back under.
|
|
760
|
+
// On an exclusive resource it doesn't run alongside: it goes to the front of the line, unless
|
|
761
|
+
// the resource says quickAlongside: "other-repo" (a deploy is one at a time per project) and
|
|
762
|
+
// every job on it is from another repo.
|
|
763
|
+
export const QUICK_MAX = 2; // quick jobs at once, machine-wide: a lane, not a way around dibs
|
|
764
|
+
// What the board says about a job the quick lane let in, so others see why it went first.
|
|
765
|
+
export const QUICK_LINE = 'quick: it runs in seconds, so it went first';
|
|
766
|
+
const QUICK_FRONT = 24 * 36e5;
|
|
767
|
+
export function quickPass(q, hist, cfg) {
|
|
768
|
+
if (q.kind === 'hold' || !q.key || cfg.quickUnder === null) return false;
|
|
769
|
+
const under = ms(cfg.quickUnder ?? '15s');
|
|
770
|
+
const runs = runsOf(hist, q.key);
|
|
771
|
+
if (runs.length && runs.at(-1).dur >= under) return false;
|
|
772
|
+
const d = typical(hist, q.key);
|
|
773
|
+
if (d != null) return d < under;
|
|
774
|
+
// An --est that short counts as --quick, as for featherweight, unless the job asked for memory itself.
|
|
775
|
+
return !!q.quick || (q.est != null && q.est < under && !q.declared);
|
|
776
|
+
}
|
|
777
|
+
// Every job on r is another repo's, so a quick one may start beside them (quickAlongside).
|
|
778
|
+
const otherRepos = (s, me, r) => !!me.repo && s.leases.filter(l => l.res.includes(r)).every(l => l.repo && l.repo !== me.repo);
|
|
779
|
+
// A hold on r by someone else: the quick lane never goes past it.
|
|
780
|
+
const heldByOther = (s, mine, r) => !mine.has(r) && s.leases.some(l => l.kind === 'hold' && l.res.includes(r));
|
|
761
781
|
|
|
762
782
|
// Can this waiter start now? If not: the rule that stops it (slot, ahead,
|
|
763
783
|
// reset, disk, pressure, swap, swaproom, drain, memory, cpu, ram, load, idle), a sentence, and what it's stuck on.
|
|
@@ -811,7 +831,11 @@ export function verdict(s, me, cfg, hist, t = now()) {
|
|
|
811
831
|
}
|
|
812
832
|
|
|
813
833
|
function decide(s, me, cfg, hist, t) {
|
|
814
|
-
|
|
834
|
+
// In the quick lane while there's room in it; the cap counts quick jobs running now.
|
|
835
|
+
const quick = !!(me.quickPass ?? quickPass(me, hist, cfg)) && s.leases.filter(l => l.quick).length < QUICK_MAX;
|
|
836
|
+
// A quick job dibs hasn't seen use much memory is booked small, as a featherweight is.
|
|
837
|
+
const lightQuick = quick && !me.declared && runsOf(hist, me.key).slice(-10).every(h => h.mem == null || h.mem <= LIGHT_MEM);
|
|
838
|
+
if ((me.mem || 0) > LIGHT_MEM && (featherweight(me, hist) || lightQuick)) me = { ...me, mem: LIGHT_MEM, feather: true };
|
|
815
839
|
const myRank = rank(me, hist, t);
|
|
816
840
|
// When it would be done, at its slow runs: passing a waiter is a promise not to delay it.
|
|
817
841
|
const myEnd = t + Math.max(expected(me, hist), slow(hist, me.key) || 0);
|
|
@@ -825,7 +849,7 @@ function decide(s, me, cfg, hist, t) {
|
|
|
825
849
|
// don't hold it (over minDisk, it goes). On 2026-10-21 0.5 GB deploys waited 79 and 92 s
|
|
826
850
|
// on the room kept for swap, and one waited 9 minutes on load.
|
|
827
851
|
const lightTurn = (me.mem || 0) <= LIGHT_MEM && me.res.every(r => cfg.resources[r]?.exclusive);
|
|
828
|
-
const pastCeiling = pastsCeiling(me) ||
|
|
852
|
+
const pastCeiling = pastsCeiling(me) || quick || lightTurn;
|
|
829
853
|
// Over the ceiling, a waiter that passes it doesn't wait behind ones the ceiling holds back.
|
|
830
854
|
const ahead = s.queue
|
|
831
855
|
.filter(q => q.pid && q.id !== me.id && !(hot && pastCeiling && !pastsCeiling(q)))
|
|
@@ -849,7 +873,6 @@ function decide(s, me, cfg, hist, t) {
|
|
|
849
873
|
return at < myEnd;
|
|
850
874
|
};
|
|
851
875
|
const side = [];
|
|
852
|
-
const quick = instant(me, cfg, hist);
|
|
853
876
|
for (const r of me.res) {
|
|
854
877
|
if (mine.has(r)) continue;
|
|
855
878
|
if (isFiles(r)) {
|
|
@@ -857,7 +880,9 @@ function decide(s, me, cfg, hist, t) {
|
|
|
857
880
|
if (f) return f;
|
|
858
881
|
continue;
|
|
859
882
|
}
|
|
860
|
-
|
|
883
|
+
// A resource's own config: a name dibs doesn't know takes cfg.unknown's exclusive, which resCfg mixes into every one.
|
|
884
|
+
const own = cfg.resources[r];
|
|
885
|
+
if (quick && own && !heldByOther(s, mine, r) && (!own.exclusive || (own.quickAlongside === 'other-repo' && otherRepos(s, me, r)))) continue;
|
|
861
886
|
const { open, across } = roomFor(s, me, r, cfg);
|
|
862
887
|
if (open <= 0) {
|
|
863
888
|
// Full, but the machine may have room for one more on top (src/overlap.mjs).
|
|
@@ -874,7 +899,7 @@ function decide(s, me, cfg, hist, t) {
|
|
|
874
899
|
// Learned clashes: a job that runs SLOW_PAIR times as slow beside one running now, or
|
|
875
900
|
// makes it that slow, waits for it, but no longer than its own run time since it
|
|
876
901
|
// joined, so it can't starve. Both finish sooner one after the other.
|
|
877
|
-
const pair = t - me.enq < expected(me, hist) && clashOf(s, me, hist);
|
|
902
|
+
const pair = !quick && t - me.enq < expected(me, hist) && clashOf(s, me, hist);
|
|
878
903
|
if (pair) return { ok: false, rule: 'together', why: pair.why, on: pair.res, ahead: pair.lease };
|
|
879
904
|
// The last user's onRelease is still putting it back (src/reset.mjs).
|
|
880
905
|
const reset = (s.resets || []).find(x => me.res.includes(x.res) && !mine.has(x.res));
|
|
@@ -905,13 +930,13 @@ function decide(s, me, cfg, hist, t) {
|
|
|
905
930
|
let sw = (me.prio || 'normal') !== 'urgent' && busy && swapping(cfg, m);
|
|
906
931
|
let trial = false;
|
|
907
932
|
if (sw && sw.level !== 'critical' && !light && sw.rule === 'pressure' && probation(s, me, cfg, hist, t)) trial = true;
|
|
908
|
-
if (sw && (light || trial) && sw.level !== 'critical') sw = null;
|
|
933
|
+
if (sw && (light || trial || quick) && sw.level !== 'critical') sw = null;
|
|
909
934
|
// The same for the disk swap grows on: one job may still start alone, since waiting frees nothing then.
|
|
910
935
|
// A light job can't grow the swap, so on a resource that writes little (exclusive, or declaring
|
|
911
936
|
// no disk: tests, deploys) only the floor holds it. On 2026-10-26 every start waited on the room
|
|
912
937
|
// kept for swap with 6.8 GB free, one-second test runs included.
|
|
913
938
|
const writesLittle = me.res.every(r => cfg.resources[r]?.exclusive || !resCfg(cfg, r).disk);
|
|
914
|
-
const squeeze = (me.prio || 'normal') !== 'urgent' && busy && !sw && !(light && writesLittle) && diskSqueeze(cfg, needDisk, m);
|
|
939
|
+
const squeeze = (me.prio || 'normal') !== 'urgent' && busy && !sw && !quick && !(light && writesLittle) && diskSqueeze(cfg, needDisk, m);
|
|
915
940
|
let breaker = (sw || squeeze) && breaksStall(s, me, cfg, hist, t, m);
|
|
916
941
|
if (sw && !breaker) return { ok: false, why: swapWhy(sw), ...sw, machine: true };
|
|
917
942
|
if (squeeze && !breaker) return { ok: false, ...squeeze, machine: true };
|
|
@@ -919,7 +944,7 @@ function decide(s, me, cfg, hist, t) {
|
|
|
919
944
|
// waited long, unless it'll be done before that one could start. Waiters
|
|
920
945
|
// stuck on something else (machine memory, disk) don't hold anyone up.
|
|
921
946
|
const head = ahead.find(q => q.res.every(r => roomFor(s, q, r, cfg).open > 0) && !neverFits(cfg, q) && overBudget(s, q, cfg));
|
|
922
|
-
if (head && t - head.enq > ms(cfg.starveAfter) && blocks(head))
|
|
947
|
+
if (!quick && head && t - head.enq > ms(cfg.starveAfter) && blocks(head))
|
|
923
948
|
return { ok: false, rule: 'ahead', why: `${tag(head)} has waited ${dur(t - head.enq)}, so it goes first`, ahead: head, starved: true };
|
|
924
949
|
let budget = overBudget(s, me, cfg, side.length > 0, breaker, t);
|
|
925
950
|
// Nothing starts past the memory budget (0.0.125). Jobs book what they're
|
|
@@ -951,7 +976,7 @@ function decide(s, me, cfg, hist, t) {
|
|
|
951
976
|
if ((me.prio || 'normal') === 'idle') {
|
|
952
977
|
if (m.memFree < IDLE_MEM_FREE) return { ok: false, rule: 'idle', why: `idle work waits for ${IDLE_MEM_FREE}% memory free (now ${m.memFree}%)` };
|
|
953
978
|
}
|
|
954
|
-
return { ok: true, covered: me.res.filter(r => mine.has(r)), ...(quick && {
|
|
979
|
+
return { ok: true, covered: me.res.filter(r => mine.has(r)), ...(quick && { quick: true }), ...(trial && { trial: true }), ...(side.length && { alongside: merge(side) }), ...(breaker && { breaker: true }), ...(loadPast && { loadPast: true, loadWaited: t - since }),
|
|
955
980
|
...(!breaker && (me.prio || 'normal') !== 'urgent' && { gated: true }) };
|
|
956
981
|
}
|
|
957
982
|
|
package/src/serve.mjs
CHANGED
|
@@ -103,6 +103,12 @@ export function place(workers, need, t = now()) {
|
|
|
103
103
|
const bad = fits(w, need, t);
|
|
104
104
|
// A VM that can't be found (src/ondemand.mjs findVm) is said plainly, and the job runs where it came from.
|
|
105
105
|
if (bad && w.ondemand?.problem && need.from) return { machine: need.from, why: `${bad}, so it runs here` };
|
|
106
|
+
// One already marked can't-wake (boat's starts used up) sends the job back the way a refused wake
|
|
107
|
+
// does. Refused here instead, a send that came just after the coordinator's own check of boat's
|
|
108
|
+
// limits exited 2, while one just before it ran on its sender (2026-11-03).
|
|
109
|
+
const no = cantWake(w.ondemand, t);
|
|
110
|
+
if (bad && no && bad.startsWith(`${w.name} can't wake`) && need.from)
|
|
111
|
+
return { machine: need.from, why: `${w.name} can't wake (${no.why}), so it runs on ${need.from}` };
|
|
106
112
|
// Too big for it: a VM made for the job (src/ondemand.mjs create), when that's on.
|
|
107
113
|
const big = w.ondemand?.bigger && workers.get(w.ondemand.bigger);
|
|
108
114
|
const short = bad || ((need.askedCpu || 0) > w.cores && `${w.name} has fewer cores than the job asked for`);
|