@dibssoftware/dibs 0.0.0-stage → 0.0.178

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 (72) hide show
  1. package/CHANGELOG.md +577 -0
  2. package/LICENSE +670 -0
  3. package/README.md +234 -2
  4. package/bin/dibs-guard.mjs +7 -0
  5. package/bin/dibs.mjs +526 -0
  6. package/docs/benchmarks.md +193 -0
  7. package/docs/files.md +30 -0
  8. package/docs/guard.md +91 -0
  9. package/docs/later.md +43 -0
  10. package/docs/machines.md +147 -0
  11. package/docs/questions.md +78 -0
  12. package/docs/relay.md +196 -0
  13. package/docs/releasing.md +25 -0
  14. package/docs/scheduling.md +163 -0
  15. package/docs/simulators.md +17 -0
  16. package/package.json +44 -4
  17. package/skills/dibs/SKILL.md +162 -0
  18. package/src/acquire.mjs +697 -0
  19. package/src/admin.mjs +145 -0
  20. package/src/agents.mjs +145 -0
  21. package/src/alerts.mjs +437 -0
  22. package/src/answers.mjs +65 -0
  23. package/src/board.mjs +202 -0
  24. package/src/broker.mjs +369 -0
  25. package/src/commands.mjs +801 -0
  26. package/src/config.mjs +320 -0
  27. package/src/connect.mjs +106 -0
  28. package/src/cool.mjs +160 -0
  29. package/src/diskwarn.mjs +161 -0
  30. package/src/events.mjs +94 -0
  31. package/src/files.mjs +1100 -0
  32. package/src/guard.mjs +583 -0
  33. package/src/history.mjs +247 -0
  34. package/src/hogs.mjs +214 -0
  35. package/src/later.mjs +487 -0
  36. package/src/measure.mjs +262 -0
  37. package/src/nodecheck.mjs +17 -0
  38. package/src/notices.mjs +121 -0
  39. package/src/ondemand.mjs +572 -0
  40. package/src/overlap.mjs +151 -0
  41. package/src/override.mjs +351 -0
  42. package/src/owner.mjs +30 -0
  43. package/src/plain.mjs +467 -0
  44. package/src/platform.mjs +357 -0
  45. package/src/preempt.mjs +438 -0
  46. package/src/primer.mjs +61 -0
  47. package/src/proc.mjs +98 -0
  48. package/src/progress.mjs +158 -0
  49. package/src/qr.mjs +204 -0
  50. package/src/questions.mjs +389 -0
  51. package/src/quota.mjs +81 -0
  52. package/src/reads.mjs +54 -0
  53. package/src/relay.mjs +779 -0
  54. package/src/remote.mjs +584 -0
  55. package/src/reset.mjs +127 -0
  56. package/src/schedule.mjs +995 -0
  57. package/src/scratch.mjs +61 -0
  58. package/src/serve.mjs +736 -0
  59. package/src/service.mjs +221 -0
  60. package/src/shard.mjs +59 -0
  61. package/src/simctl.mjs +42 -0
  62. package/src/simpool.mjs +258 -0
  63. package/src/state.mjs +201 -0
  64. package/src/stats.mjs +328 -0
  65. package/src/style.mjs +44 -0
  66. package/src/talk.mjs +523 -0
  67. package/src/thin.sh +130 -0
  68. package/src/trust.mjs +152 -0
  69. package/src/util.mjs +184 -0
  70. package/src/version.mjs +2 -0
  71. package/src/web.mjs +1117 -0
  72. package/src/worker.mjs +318 -0
@@ -0,0 +1,193 @@
1
+ # Does dibs speed work up or slow it down?
2
+
3
+ Measured on 2026-10-14, on the owner's 10-core (4 performance, 6 efficiency), 16 GB Mac, with 0.0.72 and with this branch. Everything here can be rerun: the commands are under each section.
4
+
5
+ ## Short answer
6
+
7
+ Before this branch, on a busy night, dibs made most work wait for a machine that had room. Tonight agents waited about 10 hours in all over 97 minutes, and for 72% of that waiting dibs's own running jobs were measured using few enough cores, with at least 25% of memory free, that the waiter would have fit. Three things held them, in this order:
8
+
9
+ 1. **A memory budget counting what jobs asked for, not what they held.** Running leases were handed out 6.0G of memory on average while their measured peaks added up to 3.4G (holds aren't measured, so part of the gap is simulator holds). 45% of all waiting traces back to the memory budget, mostly by standing in line behind a job the budget held.
10
+ 2. **One command planned at 14.1G.** An Xcode build measured 14.1G (15.1 GB) at its peak, which is bigger than the 11G budget, so every later run of the same command could run only "when nothing else is", and 0.0.72 counted every lease as something: its own agent's simulator hold and other agents' hour-long file leases. It could never start, and after 3 minutes (`starveAfter`) everyone behind it stopped passing it. At 00:32 and again at 00:53 this held seven or eight agents' work while the Mac showed 62 to 66% memory free.
11
+ 3. **The load ceiling** (pace normal, `maxLoad` 10) reading a load average swollen by swapping: 14% of waiting directly, 7% more behind it. The median load reading was 8.4 and peaked at 173 while processes used 1 to 1.3 cores. 0.0.72 already fixed this (the ceiling reads cores in use).
12
+
13
+ What the branch changes: own holds and file leases no longer stop an oversized job; a job that can't start yet only blocks jobs that wouldn't finish before it could; the CPU budget counts measured cores; and `pace max` uses 1.5 measured cores per core and never skips the memory budget. In the simulator, with six agents on a model of this Mac, the same work finishes **26% sooner than tonight's settings** (34.8 minutes against 47.0), **34% sooner than no dibs**, with no swapping and no failed jobs. On tonight's own recorded work, the slowest 10% of jobs finish in 2.5 minutes instead of 11.1. On real processes (CPU-bound jobs on the efficiency cores), the old settings took 31 to 69% longer than no dibs, and the new CPU budget brought that to 2%.
14
+
15
+ Most of that is already on main: 0.0.73 (oversized jobs) and 0.0.74 (roomy reads cores in use) bring the owner's settings to 42.4 minutes, and pace max on main to 35.4. What's left on the branch is worth 1 to 3% of speed and all of pace max's swapping; see "Each proposal against main".
16
+
17
+ The comparison with no dibs depends on how bad swapping is, which no safe benchmark can measure on a shared Mac. If swapping cost nothing, no dibs would finish 25% sooner than dibs, and the OS would still have killed about 9 jobs for running out of swap. See "How much the model matters".
18
+
19
+ ## 1. Tonight's waits
20
+
21
+ ```bash
22
+ node bench/waits.mjs ~/.dibs # read only; replays the event log through the scheduler
23
+ node bench/waits.mjs ~/.dibs path/to/0.0.72/src # with the scheduler that ran then
24
+ ```
25
+
26
+ The event log covered 03:15 to 04:52 UTC (23:15 to 00:52 on the Mac), 125 waits. Every 5 seconds of every wait was replayed through the real `verdict()` with the leases, queue and nearest load sample of that moment, and the rule that held it was counted. "Ahead" waits were followed to the waiter in front, up to 5 deep, to name what held the front of the line.
27
+
28
+ | what held the waiter | waiting | share |
29
+ |---|---|---|
30
+ | behind someone, who waited on the memory budget | 203m | 34% |
31
+ | load ceiling | 84m | 14% |
32
+ | replay says it could start (rules the replay can't see: nesting, the exact load) | 67m | 11% |
33
+ | memory budget | 66m | 11% |
34
+ | behind someone who could start (one poll late, or a wrong forecast) | 43m | 7% |
35
+ | behind someone, who waited on the load ceiling | 38m | 6% |
36
+ | behind someone, who waited on the CPU budget | 35m | 6% |
37
+ | CPU budget | 34m | 6% |
38
+ | slot (resource in use) | 27m | 5% |
39
+
40
+ For 433 of the 597 waiting minutes (72%), dibs's running jobs were measured using few enough cores that the waiter would fit on 10, and memory was at least 25% free. Load samples: median 8.4, max 173. Memory free: median 50%, min 32%. Peak swap on the machine during the evening: 6.7G.
41
+
42
+ The `dibs history` totals the lead quoted (test busy 29 minutes, waited 1h40m; xcode-build busy 16 minutes, waited 54 minutes) come from the same log.
43
+
44
+ ## 2. The simulator
45
+
46
+ ```bash
47
+ node bench/sim.mjs # 6 synthetic agents, 3 seeds, every scenario
48
+ node bench/sim.mjs --agents 8 --seeds 5
49
+ node bench/sim.mjs --workload bench/workloads/tonight.json # tonight's recorded work
50
+ node bench/sim.mjs --src ../other/src # the same with another scheduler
51
+ ```
52
+
53
+ `bench/sim.mjs` runs dibs's real scheduler (`verdict()`, `sized()`, `jobSize()` and the config loading, imported from `src/`) against a model of the Mac, every 2 seconds of simulated time. It takes about a second per scenario and touches nothing.
54
+
55
+ The model, and what it assumes:
56
+
57
+ - 10 cores, 16 GB. Work outside dibs uses 2 cores and 6 GB (what the machine showed beyond dibs's jobs tonight).
58
+ - CPU is shared: past 10 runnable cores, every job slows by the same factor.
59
+ - A job's average CPU is 60% of the peak dibs measured, and it holds 80% of its measured peak memory for its whole run.
60
+ - Memory past 90% of RAM swaps. Swapping slows every job by `1 / (1 + 3 x swapped / RAM)`; past 8G of swap the largest job is killed.
61
+ - A run taking more than 3 times its length fails (a test timeout). An agent reruns a failed job up to twice.
62
+ - Agents wait for their own work: a job submitted after the same agent's earlier job ended arrives that same gap after it ends in the simulation. One step in five starts alongside the previous one.
63
+ - dibs measures each running job 10 seconds after it starts.
64
+
65
+ The synthetic workload: each agent does 10 things in a row with 15 to 75 seconds between them, picked from test suites (40%, 60 s, 4 cores peak, 1.4G), builds (22%, 90 s, 7 cores, 3G), clean builds (3%, 240 s, 9 cores, 7G), heavy jobs (10%), browser suites (10%), simulator holds (10%, 4 minutes) and deploys (5%). Half of agent 1's work is high priority. Shapes come from tonight's measured runs.
66
+
67
+ `bench/workloads/tonight.json` is tonight's event log (126 leases) with agents and commands renamed, made by `node bench/trace.mjs ~/.dibs`.
68
+
69
+ ### Six agents, synthetic, 5 seeds
70
+
71
+ Makespan is the time until every agent's work is done. Job time is arrival to finish, including reruns. "failed" counts jobs killed or timed out, per run.
72
+
73
+ | settings | scheduler | makespan | vs no dibs | p50 job | p90 job | p90 wait | high p90 wait | peak swap | failed |
74
+ |---|---|---|---|---|---|---|---|---|---|
75
+ | no dibs | | 53.0m | | 4.7m | 10.6m | 0s | 0s | 9.3G | 63.6 |
76
+ | owner's live settings | 0.0.72 | 47.0m | -11% | 3.5m | 8.3m | 6.3m | 3.0m | 0.5G | 0 |
77
+ | stock defaults | 0.0.72 | 44.8m | -15% | 3.2m | 7.3m | 4.6m | 4.1m | 3.6G | 1.2 |
78
+ | pace quiet | 0.0.72 | 1.4h | +55% | 7.6m | 14.0m | 12.2m | 5.4m | 0.0G | 0 |
79
+ | pace normal | 0.0.72 | 48.5m | -8% | 3.5m | 8.3m | 6.3m | 2.9m | 0.0G | 0 |
80
+ | pace max | 0.0.72 | 36.3m | -31% | 2.3m | 6.6m | 4.1m | 2.4m | 1.4G | 0 |
81
+ | owner's live settings | branch | 44.6m | -16% | 2.7m | 8.0m | 5.8m | 3.8m | 0.0G | 0 |
82
+ | stock defaults | branch | 44.5m | -16% | 3.5m | 6.8m | 4.4m | 4.5m | 4.2G | 1 |
83
+ | pace normal | branch | 48.2m | -9% | 3.7m | 8.6m | 6.4m | 2.1m | 0.2G | 0 |
84
+ | **pace max** | **branch** | **34.8m** | **-34%** | **1.9m** | **5.6m** | **2.9m** | **2.2m** | **0.0G** | **0** |
85
+ | pace max, owner's cores 10 and budget 11G pinned | branch | 40.8m | -23% | 2.2m | 7.3m | 4.9m | 2.3m | 0.0G | 0 |
86
+ | pace max, skipping budgets when roomy (0.9 load per core, 25% free) | branch | 34.9m | -34% | 1.8m | 5.4m | 2.8m | 1.9m | 1.1G | 0 |
87
+ | no budgets, slots only | branch | 34.2m | -36% | 2.4m | 5.3m | 2.3m | 2.3m | 3.6G | 0 |
88
+ | pace max, memory budget counts measured use | branch | 34.5m | -35% | 1.8m | 5.6m | 2.4m | 1.6m | 1.0G | 0 |
89
+ | like that, twice the slots (an overlap mode) | branch | 31.2m | -41% | 2.0m | 5.0m | 2.6m | 57s | 1.6G | 0 |
90
+ | pace max, test 4, heavy 2, playwright 3 slots | branch | 33.1m | -38% | 2.2m | 5.3m | 3.1m | 2.0m | 0.0G | 0 |
91
+ | pace max, starveAfter 10m | branch | 33.2m | -37% | 2.0m | 5.2m | 3.1m | 1.9m | 0.0G | 0 |
92
+
93
+ Four and eight agents tell the same story. With 4 agents, pace max on the branch takes 26.0m against 30.3m for the owner's settings and 28.9m for no dibs (7.2 failures, 5.8G swap). With 8, 45.3m against 56.5m and 1.1h (159 failures, 11.3G swap).
94
+
95
+ ### Tonight's recorded work
96
+
97
+ Tonight's work was light and long-chained (one 41-minute simulator hold, one 9-minute build), so total time barely moves: every setting finishes within 7% of no dibs. What moves is how long the slowest jobs take.
98
+
99
+ | settings | scheduler | p50 job | p90 job | p90 wait | peak swap | failed |
100
+ |---|---|---|---|---|---|---|
101
+ | no dibs | | 27s | 1.4m | 0s | 8.7G | 3 |
102
+ | owner's live settings | 0.0.72 | 53s | 11.1m | 1.5m | 4.8G | 0 |
103
+ | owner's live settings | branch | 46s | 8.5m | 1.2m | 5.5G | 0 |
104
+ | pace max | branch | 39s | 2.5m | 53s | 4.6G | 0 |
105
+ | pace max, owner's pins | branch | 47s | 3.6m | 1.2m | 4.6G | 0 |
106
+
107
+ The swap here is the 14.1G build: once it runs, nothing dibs does can stop the machine swapping.
108
+
109
+ ### How much the model matters
110
+
111
+ dibs's runs never swap much, so its numbers barely change with the swap model. No dibs changes a lot. Six agents, 5 seeds, pace max on the branch at 34.8m throughout:
112
+
113
+ | swap slowdown factor | swap before kills | no dibs makespan | no dibs failures |
114
+ |---|---|---|---|
115
+ | 0 (swapping is free) | 8G | 26.0m | 9 |
116
+ | 0 | 16G | 28.3m | 1.4 |
117
+ | 1 | 8G | 30.1m | 13 |
118
+ | 1 | 16G | 49.1m | 30 |
119
+ | 3 (used above) | 8G | 53.0m | 64 |
120
+ | 6 | 8G | 57.1m | 82 |
121
+
122
+ Run it with `SIM_SWAP_SLOW=1 SIM_SWAP_MAX=16 node bench/sim.mjs`. Tonight a build that takes 48 seconds took 9.4 minutes while the machine swapped, and the load average reached 173, so a factor of 1 or less looks optimistic.
123
+
124
+ ## 3. The real benchmark
125
+
126
+ ```bash
127
+ ~/bin/dibs run heavy -p low -m "dibs benchmark" -- node bench/run.mjs --reps 2
128
+ ```
129
+
130
+ `bench/run.mjs` starts 4 simulated agents, each running 5 jobs in a row (1 to 4 seconds apart) through this checkout's dibs in a temp `DIBS_HOME`, or with no dibs. Jobs are `bench/job.mjs`: real threads spinning through a fixed amount of work while holding real memory (40 to 350 MB), so a crowded machine stretches them. It measures makespan, job latency, CPU used, failures, and samples the real machine's load, swap and free memory every 2 seconds.
131
+
132
+ Run at `-p low` as it must be on this shared Mac, it lives on the 4 efficiency cores, so it measures a box of "4 slow cores and 2 GB": every scenario's numbers are scaled to that (cores x 0.4, memory / 8), and dibs is shown a fixed reading of that box (30% memory free, 1.5 cores busy) so other agents' work doesn't steer its decisions. It allocates at most about 1.5 GB at once and never grew swap.
133
+
134
+ Two reps per scenario, interleaved (each rep runs every scenario before the next starts) so drift on the machine hits them about equally. 20 jobs per run, 1 to 12 seconds of work each on this box. All on this branch's scheduler.
135
+
136
+ | settings (scaled) | makespan | vs no dibs | rep 1 / rep 2 | p50 job | p90 job | p90 wait | high p90 wait | CPU used | failed |
137
+ |---|---|---|---|---|---|---|---|---|---|
138
+ | no dibs | 61.6s | | 65.4s / 57.8s | 8.3s | 15.2s | 0.4s | 0.3s | 83% | 0 |
139
+ | stock defaults | 103.8s | +69% | 125.1s / 82.6s | 13.4s | 26.8s | 20.6s | 13.3s | 45% | 0 |
140
+ | owner's live settings | 80.5s | +31% | 88.3s / 72.6s | 9.7s | 15.4s | 8.0s | 4.4s | 52% | 0 |
141
+ | pace max | 89.7s | +46% | 122.4s / 57.0s | 8.3s | 33.8s | 6.7s | 6.4s | 44% | 0 |
142
+ | cores 1.5 per core, budget 75%, no ceiling | 62.9s | +2% | 68.8s / 56.9s | 9.0s | 12.2s | 3.3s | 2.2s | 72% | 0 |
143
+
144
+ What it says, and doesn't:
145
+
146
+ - **On CPU-only work that fits in memory, no dibs is the ceiling**, and the old settings cost 31 to 69% against it: their CPU budgets counted cores jobs asked for, not used, so CPU sat at 45 to 52% while jobs waited. With the CPU budget counting measured cores at 1.5 per core, dibs matched no dibs within 2% and cut the slowest jobs' time (12.2 against 15.2 seconds). This is the part of the simulator's result the real machine can check, and it agrees.
147
+ - **It can't show what dibs is for**: these jobs never come near running the box out of memory, because making them do that on this shared Mac would hurt everyone. That half rests on the simulator and on tonight's swap.
148
+ - **Noise is large.** pace max's first rep took 122 seconds while another agent's work pushed the Mac's load from 6 to 21; its second took 57, the same as the uncapped run. The swap the machine gained during the max and uncapped runs (0.9 to 1.9G in rep 2) arrived with that outside load; the benchmark itself held under 1.5G.
149
+ - **Very short jobs pay for dibs.** An earlier run with sub-second jobs (the calibration was off) had no dibs finishing 21 to 80% sooner: each dibs run costs a Node start and up to one 1.5-second poll before it goes. For a job under a few seconds, dibs is overhead; for the minute-long suites and builds it's meant for, it's noise.
150
+
151
+ The raw results are in `bench/results/2026-10-14-real.json`.
152
+
153
+ ## Each proposal against main (0.0.74)
154
+
155
+ 0.0.73 (oversized jobs) and 0.0.74 (the roomy rule reads cores in use) landed while this ran, and took most of the gain: the owner's settings on main finish six synthetic agents' work in 42.4 minutes, against 47.0 on 0.0.72. Each remaining change, applied alone to main's scheduler, 5 seeds:
156
+
157
+ | scheduler | settings | 6 agents | 8 agents | swap (6 / 8) | tonight's p90 job |
158
+ |---|---|---|---|---|---|
159
+ | main | owner's | 42.4m | 54.0m | 0.2G / 0.5G | 8.5m |
160
+ | main + CPU budget by measured cores | owner's | 41.0m | 52.7m | 0.0G / 0.4G | 8.5m |
161
+ | main + a stuck job's start walks lease ends | owner's | 42.4m | 54.0m | 0.2G / 0.7G | 8.5m |
162
+ | main | pace max as on main | 35.4m | 45.4m | 2.0G / 1.4G | 1.5m (8.5G swap, 3 jobs killed) |
163
+ | main + CPU budget by measured cores | pace max as on main | 34.7m | 44.9m | 1.9G / 1.6G | 1.5m |
164
+ | bench branch | pace max as proposed | 34.8m | 45.3m | 0.0G / 0.0G | 2.5m (4.6G swap, none killed) |
165
+
166
+ What that says:
167
+
168
+ - **The CPU budget by measured cores** is worth 1 to 3% in the simulator, where the roomy rule (now reading cores in use) already lifts the budgets much of the time. Where the budgets do apply, it's the difference that matters: the real benchmark, whose fixed reading (30% memory free) keeps the machine from ever looking roomy, went from +31 to +69% against no dibs to +2%. Worth shipping.
169
+ - **The stuck job's start walking lease ends** made no measurable difference. It's more correct (a job needing three leases to end can't start when the first does), but it has no evidence behind it here. Don't ship it on these numbers.
170
+ - **pace max never skipping the budgets** costs nothing (34.8 against 35.4 minutes) and removes all of max's swapping, including on tonight's work, where skipping them let the 14.1G build start beside others: 8.5G of swap and 3 jobs killed in the model. Its slowest jobs take 2.5 minutes instead of 1.5 for it. Worth shipping, with the 1.5 measured cores per core that goes with it.
171
+
172
+ ## What changed
173
+
174
+ The first item shipped in 0.0.73. The others are on the `bench` branch with tests, chosen by the section above. The stuck-job change it weighs (a start walking lease ends) made no difference and was taken out.
175
+
176
+ - **An oversized job runs beside its own holds and file leases** (0.0.73). "A job bigger than the whole budget runs when nothing else is" no longer counts the waiter's own holds or leases that cost nothing (file leases). Before, it waited for its own simulator hold to expire and for every file lease on the machine. Test (main's): `a job bigger than the budget runs when only its own hold and file leases are out, not when real work is`.
177
+ - **The CPU budget counts measured cores.** A running job counts the cores it was last measured using (every 10 seconds), and what it asked for until then. Memory still counts what was handed out: too many busy cores slows everyone a little, too little memory kills jobs. The board says `CPU 2.3/10 cores in use`. Test: `the CPU budget counts what a running job was measured using, not what it asked for`.
178
+ - **History keys keep kinds of runs apart.** A command's history key was its program and first word, so `xcodebuild -project App.xcodeproj ... build` and `... archive` shared run times and sizes, and so did `npm run lint` and `npm run build`. It's now the program and up to three words that aren't flags, cut to their last path part, and for xcodebuild the first word, scheme, configuration and action. History under the old key still counts until a command has its own. Tests: `history keeps a build, a test and an archive of one project apart, and a temp folder does not split a command`, `history from before the key grew counts until the command has its own`.
179
+ - **A plan is capped at the budget.** A command that has used more than the whole memory budget is planned at the budget, so it starts once the budget is empty, and the board and `dibs run` say `usually uses ~14G; planned at the 11G budget`. Asking for more with `--mem` is still honored. Tests: `a command that has used more than the whole budget is planned at the budget, and the board says so`, `a planned size is capped at the budget only when what it learned is over the budget`.
180
+ - **`pace max`: 1.5 measured cores per core, and the budgets always apply.** It was every core as asked for, with the budgets skipped below 0.9 load per core and 25% memory free. Skipping them bought nothing in the simulator (34.9 against 34.8 minutes) and was the only part of max that swapped (1.1G). The `maxLoad` ceiling (1.5 per core of cores in use) still caps the machine.
181
+
182
+ ## Recommendations
183
+
184
+ For the owner's Mac, now: `dibs pace max`, and take `cores` and `budget` out of `~/.dibs/config.json` (they're pinned at 10 and 11G, which override the pace). In the simulator that's 40.8 against 34.8 minutes for six agents. Keep the memory budget at 75% (12G).
185
+
186
+ Proposals, not done here:
187
+
188
+ - **Stock defaults** (no pace): `cores` 6 counted as measured is about right for a Mac someone works at. Changing a stock value is a migration, since every config.json dibs wrote holds the old stock numbers and `paced()` treats any non-stock value as pinned. Better: make `pace max` the suggestion for machines only agents use, in `dibs pace` and the README.
189
+ - **More slots** (test 4, heavy 2, playwright 3) bought 5% under max with no swap. Worth it once the overlap work lands, which subsumes it.
190
+ - **An overlap mode** (run side by side when measured use fits) would buy 7 to 13% more than max on synthetic work (31.2 against 34.8 minutes at six agents, 39.3 against 45.3 at eight) at 1 to 1.6G of swap.
191
+ - **Learned sizes: split the key, don't decay.** The 14.1G wasn't a one-off. The long runs of that command measured 6.6 to 7.2G through the evening, then 14.1, 13.1, 14.2 and 13.6G in four runs over 50 minutes, each 6 to 10 minutes long at 7 to 8 cores. The short runs of the same command took 13 to 50 seconds at 1 to 2.6G. They share a history key because the key is the program plus its first bare argument (`xcodebuild Shop.xcodeproj`), so a 20-second incremental build is planned like a 7-minute full build, and its typical run time is a median of both. The sampler counted only the build's own process groups (the shared simulator isn't a pool device, and indexing in Xcode.app isn't in the tree), and footprint counts compressed pages too, which is memory the build really demanded: the Mac swapped 6.7G while those builds ran. So capping or decaying "only raises" would mostly plan the next big build too small. Both fixes are now on the branch ("What changed"). Still open: the peak sample could note its three largest processes, so the next surprise can be checked.
192
+ - **`starveAfter`** 10 minutes was 5% faster than 3 under max with no swap, but high-priority p90 wait got worse at 8 agents (5.2 against 2.6 minutes). Leave it.
193
+ - **pace normal's ceiling** (one busy job per core) is what makes normal 38% slower than max for agents. That's its job when a person is at the Mac.
package/docs/files.md ADDED
@@ -0,0 +1,30 @@
1
+ # File leases
2
+
3
+ Parallel agents editing the same files is the other collision. Instead of pasting ownership lists into every prompt, take a lease:
4
+
5
+ ```bash
6
+ dibs hold 'files:src/auth/**' -m "auth refactor" # paths from the git root; * and ? stay in one folder, ** crosses folders
7
+ dibs hold files:src/a.ts,files:docs/api.md --for 30m # several at once
8
+ dibs run 'files:src/gen/**,test' -- ./codegen.sh # held for exactly as long as the command runs
9
+ dibs who files:src/auth/login.ts # who holds it, or anything overlapping it
10
+ ```
11
+
12
+ Braces name several files at once, as a shell would: `dibs hold 'files:src/blocks/{catalog.ts,__tests__/catalog.test.ts}'` holds both files, and its commas don't split the resource list. dibs's own globs are `*`, `?` and `**`.
13
+
14
+ Two leases conflict when any path could match both: the same file, a folder and anything under it, or globs some name could match both. When unsure, they conflict. A file lease waits in line like any hold, costs no memory or cores, ends the same ways (`--for`, `dibs release`, its session dying), and never waits on your own leases. Editing a path nobody leased needs no lease.
15
+
16
+ ## What the guard turns away
17
+
18
+ With the guard installed (`dibs guard install`, or the plugin), the hook turns away another session's Edit, Write, MultiEdit and NotebookEdit on a leased path, and Bash commands that obviously write one: `>` and `>>` redirects, `rm`, `mv`, `cp` and `ln` onto it (or into a folder, under the source's name), `tee`, `touch`, `truncate`, `sed -i`, `perl -pi`, `dd of=`, `git rm`, `git mv`, `git restore`, `git checkout -- path` and `git checkout .`, with or without `git -C dir`, and formatters run with their write flag (`prettier --write`, `eslint --fix`, `swiftformat`, `gofmt -w` and the like). `git apply`, `git am` and `patch -p<n>` write the files their patch names: dibs reads the patch or mailbox (named, `-i file` or `< file`) and treats each file in it as an edit. A patch it can't read (a pipe, `-`, a `$VAR`, a missing file, or `patch` without `-p`) counts as writing the whole repo (for `patch`, its folder), in every worktree. `git stash`, `git stash pop`, `git reset --hard`, `git clean`, `git checkout -f`, `git switch --discard-changes`, and `--autostash` pulls and rebases rewrite files nobody named, so they count as writing the whole repo (or folder). In a repo with several git worktrees, those, and `git checkout`, `git restore` and `git clean` of named paths, only change the worktree they run in, so they answer only to leases taken from that worktree: `git stash` in one worktree goes through while someone holds `src/a.ts` from another. Every other write, an edit included, still answers to a lease on the same file from any worktree of the repo. Prefixes like `sudo`, `timeout 60`, `npx` and `xargs` don't hide a write. Paths compare the way the disk does: on macOS `SRC/A.ts` is `src/a.ts`. The refusal names the holder, their `-m` reason, how long they've held it, and `dibs when files:<path>`.
19
+
20
+ Claude Code keeps each session's scratch files in `/private/tmp/claude-<uid>/<project folder>/<session id>/`. The guard turns away any delete or write there outside the calling session's own folder, whatever `guard.files` says, because it's the person's rule: another agent may be using those files right now. That covers `rm`, `find -delete` and `find -exec rm`, `xargs rm`, `rsync --delete`, `mv` away, `truncate`, `>` redirects, and Edit or Write. It also covers deleting the root itself, a project folder, or a glob that spans sessions (`/private/tmp/claude-503/*`), under any spelling (`/tmp/...`). Variables set earlier in the same command (`S=/path; find $S ...`, `export S=...`) or in the hook's environment are read, so a path in one is checked like one typed out. A `$VAR` path dibs still can't read is turned away when its literal start names another session's folder. A recursive delete whose whole target is a variable or `$(...)` it can't read (`rm -rf $S`, `rm -rf "$S"/*`, `find $S ... -delete`) is turned away everywhere: write the path out. A literal end (`"$S/build"`) is fine. Reads are fine anywhere, and so are writes and single-file deletes in your own session's folder.
21
+
22
+ Subagents share their session's folder, so inside it the guard also turns away a recursive delete (`rm -r`, `find -delete`, `find -exec rm`, `find | xargs rm`, `rsync --delete`, `rmdir -p`; a find's filters such as `-mindepth 1` or `-mmin +180` don't change that, since it can still reach everything) of the session folder itself or its `scratchpad`. For each folder at the top of the scratchpad, dibs remembers the first agent that wrote into it (in `~/.dibs/scratch/<session>`, gone once the session's folder is). A recursive delete of one is that agent's alone: another agent of the session is turned away and told who made it. A folder a program makes counts as made by the agent whose command named it before it existed (`xcodebuild -derivedDataPath <scratchpad>/dd`, `--out=<path>`, a relative path run from the scratchpad). A folder older than that record can go if it holds 20 files or fewer, or if the deleting agent's earlier commands named it; otherwise it's turned away, since dibs can't tell whose it is. Deleting a folder whole clears its record. Either way, ask whoever made it, or have the person delete it.
23
+
24
+ Reads are never blocked, and nothing it can't read is blocked either: a path built from `$VAR` or `$(...)`, a script that writes on its own. A refusal means wait or ask the holder, not find another way to write the file.
25
+
26
+ ## Which agent holds it
27
+
28
+ Leases belong to the agent that took them. Claude Code tells the hook which subagent or teammate makes each tool call, but tells the Bash command nothing, so when the hook sees an agent run `dibs hold`, `dibs run` or `dibs release` with `files:`, it leaves a note in `~/.dibs/agents` and that dibs stamps the lease with the agent (the main thread counts as one). Sibling subagents then wait for each other, can't edit each other's paths, and can't release each other's leases. A lease the main thread took covers its own subagents, since the usual pattern is a lead taking the lease and a subagent making the edit; a subagent's lease still keeps the main thread out. A lease the hook didn't see taken (no guard, `dibs` called from a script or through `$VAR`) belongs to its whole session.
29
+
30
+ On a machine limited with `dibs limit`, other machines' file leases show as `files:` without the path.
package/docs/guard.md ADDED
@@ -0,0 +1,91 @@
1
+ # The guard
2
+
3
+ Agents forget. You can tell every agent to wrap builds in `dibs run`, and an hour later one of them types a bare `xcodebuild`. The guard is a pre-tool hook that catches those commands before they run.
4
+
5
+ ## What it does
6
+
7
+ Before each Bash call it reads the command, without running it, and looks for anything heavy outside `dibs run`: `xcodebuild` builds and tests, `xcrun simctl` (except `list` and other reads: `ui` without a value, `status_bar list`, `getenv`, `listapps`, `appinfo`, `get_app_container` and the like, and managing devices that aren't running: `create`, `delete`, `erase` and `runtime`), `swift test`, Playwright, vitest, jest, `npm test` and friends, `node --test`, `wrangler deploy`, `vercel deploy`, `ship*.sh`/`deploy*.sh` and `npm run deploy`. Then:
8
+
9
+ - **In a `bypassPermissions` session it rewrites the command.** `cd ios && xcodebuild build` runs as `cd ios && dibs run xcode-build -m 'guard: xcodebuild build' -- xcodebuild build`. The session already runs everything without asking, so approving the new command grants nothing it didn't have.
10
+ - **Anywhere else it blocks the command** and tells the agent the exact `dibs run` line to use. The agent's retry goes through your normal permission checks. The hook never approves anything on your behalf.
11
+
12
+ It leaves alone `dibs` calls themselves, and commands after a `dibs hold` on the same line that the hold covers, but a heavy command elsewhere on a line with a `dibs` call still needs its turn (`xcodebuild build && dibs say done` is caught). It also leaves alone reads like `xcodebuild -list` or `-showBuildSettings`, words inside quotes, heredocs, `$(...)` and `bash -c` strings, and anything it can't parse. Any error inside the hook lets the command through unchanged and leaves one line in `~/.dibs/guard.log`. `DIBS_GUARD=off cmd` (or `env DIBS_GUARD=off cmd`) skips it for that command only, and `export DIBS_GUARD=off;` for the rest of the line; the words inside a quoted message don't count. It takes no lock and answers in about 50 ms, most of it Node starting.
13
+
14
+ ```bash
15
+ dibs guard check "cd app && npm test" # what it would do with a command, without a session
16
+ ```
17
+
18
+ ## Leased files
19
+
20
+ The hook also runs before Edit, Write, MultiEdit and NotebookEdit, and before Bash commands that obviously write a file. A write to a path another agent holds a `files:` lease on is denied, with who holds it, why and until when. See [files.md](files.md).
21
+
22
+ ## New sessions, messages and notices
23
+
24
+ On SessionStart, and the first SubagentStart of each subagent, the hook hands the agent a few lines on how to use dibs: wrap heavy work in `dibs run`, don't rerun a call that moved to the background, keep waiting on memory and disk, what each exit code says, quote file globs, that an agent may do anything the person can (and is logged doing it), and that a stopped job was stopped on purpose. Most agents never read the docs; this way they start with the rules.
25
+
26
+ Messages from the person (`dibs tell`) and dibs's own notices about an agent's jobs (stuck, over its memory, paused) reach the agent beside its next tool call. See [questions.md](questions.md).
27
+
28
+ ## The subagent limit
29
+
30
+ Fan-outs that start together hit the account's usage limit together and die mid-edit. So the hook also counts subagents running at once across every Claude Code session on the machine, through the Agent tool (Task in older Claude Code) and the SubagentStart and SubagentStop events. It's off unless you set a limit. Past `agents.slots`, a spawn is denied with who is running how many. A denied spawn started nothing and isn't a failure: wait for one of your own subagents to report back, then spawn again. A session with none running can always start one, so a big fan-out elsewhere can't starve it. The board shows `subagents: 5 of 8 running (web-app x3, api x2)`.
31
+
32
+ Turn it on in `~/.dibs/config.json` with `"agents": { "slots": 8 }`. `"agents": false`, the default, means no limit.
33
+
34
+ It keeps its own small file and lock (`~/.dibs/agents.json`), never the queue's, and gives up and allows the spawn after a second if the lock is busy. A subagent whose transcript hasn't changed in a long while, or whose session exited, stops counting.
35
+
36
+ ## Installing it
37
+
38
+ Pick one of these. Installing both runs the hook twice.
39
+
40
+ **Claude Code plugin.** In a session:
41
+
42
+ ```
43
+ /plugin marketplace add dibssoftware/dibs
44
+ /plugin install dibs@dibs
45
+ ```
46
+
47
+ or from a shell:
48
+
49
+ ```bash
50
+ claude plugin marketplace add dibssoftware/dibs
51
+ claude plugin install dibs@dibs
52
+ ```
53
+
54
+ The plugin brings the hook and a short `dibs` skill that tells agents how to queue, what exit 75 means, and how to trade places. It also puts its `bin/` folder on the Bash tool's PATH, so `dibs.mjs` works in sessions even before you install the CLI. `claude plugin disable dibs@dibs` turns it off. `dibs guard status` only looks at settings.json, so it reports a plugin install as "not installed".
55
+
56
+ **settings.json.** `dibs guard install` adds the hook to `~/.claude/settings.json` (PreToolUse for Bash and the edit tools, PreToolUse for Agent and Task, SubagentStart, SubagentStop, Stop and SessionStart), keeping everything else and the old file in `settings.json.dibs-backup`. Run it again after an upgrade: an older install that hooked fewer events is replaced, not added to, and `dibs guard status` says when yours is older. Install and remove are the person's: run them from Terminal. From inside Claude Code, your own `!` commands included, they're refused and nothing changes.
57
+
58
+ ```bash
59
+ dibs guard install
60
+ dibs guard status # installed? exit 1 if not
61
+ dibs guard remove
62
+ ```
63
+
64
+ **Codex.** Codex reads the same marketplace and plugin files:
65
+
66
+ ```bash
67
+ codex plugin marketplace add dibssoftware/dibs
68
+ codex plugin add dibs@dibs
69
+ ```
70
+
71
+ Codex sends the same hook input as Claude Code (`tool_name` is `Bash`, and `permission_mode` is set), so the guard rewrites in bypass mode and blocks everywhere else, as above. Codex doesn't trust a plugin's hooks until you review them: open `/hooks` in a Codex session and trust the dibs hook, and again after each update that changes it. The skill loads without that step. If Codex runs in a sandbox that can't write `~/.dibs`, `dibs run` fails there; give the sandbox that folder or run dibs outside it.
72
+
73
+ Other agents (Gemini CLI, Cursor, Factory, Copilot CLI) have pre-tool hooks in similar formats, but dibs doesn't ship adapters for them yet. `dibs run` itself works under any agent or a plain terminal.
74
+
75
+ ## Your own rules
76
+
77
+ Add rules or switch built-ins off in `~/.dibs/config.json`. A rule matches the command's first words (the first by basename, `*` as a wildcard) once `env`, `time`, `npx`, `xcrun` and the like are peeled off. `"rewrite"` is `"bypass"` (default), `"always"` or `"never"`:
78
+
79
+ ```json
80
+ "guard": {
81
+ "rewrite": "bypass",
82
+ "rules": {
83
+ "pytest": { "match": ["pytest", "python -m pytest"], "res": "test", "unless": ["--collect-only"] },
84
+ "vercel": false
85
+ }
86
+ }
87
+ ```
88
+
89
+ The built-in rule names are `xcodebuild`, `simctl`, `swift-test`, `playwright`, `vitest`, `jest`, `npm-test`, `node-test`, `wrangler`, `vercel` and `deploy-script`.
90
+
91
+ `"guard": false` switches off the rewriting and blocking of heavy commands, but edits to files another agent leased are still turned away. `"guard": { "files": false }` stops only those, and `"guard": { "commands": false, "files": false }` turns both off.
package/docs/later.md ADDED
@@ -0,0 +1,43 @@
1
+ # dibs later
2
+
3
+ Schedule a run for a time, or for when something else ends. `dibs later` records the command and returns at once with an id. When it's due, it joins the queue as `dibs run --wait` would, from the folder you scheduled it in, and gets the same guarantees: a lease, its place in the queue by priority, the process tree killed when it ends. When it ends, the person gets a note in your thread (`dibs threads`) saying how: `l3 (ios snapshot suite) finished: exit 0. Log: ~/.dibs/later/l3.log`.
4
+
5
+ ```bash
6
+ dibs later sim --at 02:00 -m "ios snapshot suite" -- ./snapshots.sh
7
+ dibs later test --in 3h -- npm test
8
+ dibs later test --after web-app -- npm run smoke # when everything web-app holds or waits for now has ended
9
+ dibs later test --after web-app:deploy -- npm run smoke # only its deploy
10
+ dibs later test --after 42 -- npm run smoke # #42 on the board
11
+ dibs later deploy --after-ok l3 -- ./ship.sh # after later job l3, only if it exited 0
12
+ dibs later list [--json]
13
+ dibs later cancel l3
14
+ ```
15
+
16
+ ## When
17
+
18
+ - `--at 02:00`, `--at 9pm`, `--at 2026-10-20T02:00`. A clock time already past today means tomorrow.
19
+ - `--in 90s`, `--in 3h`, `--in 2d`.
20
+ - `--after <what>`: a lease or waiter on the board (`42` or `#42`), an agent's name (`web-app`, or `web-app:deploy` for one resource), or an earlier later job (`l3`). It fires when that ends, however it ends.
21
+ - `--after-ok <what>`: the same, but only if it succeeded: exit 0, or a hold that ended. Otherwise the job is skipped, with the reason in `dibs later list`. A job after one that was cancelled or skipped is skipped too.
22
+
23
+ More than 7 days out is refused, and an `--after` job still waiting after 7 days is skipped. Plans that old should be made again.
24
+
25
+ ## What it runs with
26
+
27
+ Your flags (`-m`, `-p`, `--est`, `--mem`, `--cpu`, `--disk`, `--port`, `--as`, `--anywhere`, `--on`, `--bring`), the folder you were in, and from your environment only PATH, HOME, LANG, LC_ALL, USER, SHELL and TMPDIR. Pass anything else by name: `--env NPM_TOKEN` (its value now) or `--env STAGE=prod`. The file that keeps them (`~/.dibs/later/jobs.json`) is readable only by you.
28
+
29
+ It runs as you, as the agent that scheduled it: the board shows `web-app (later l3)`. If its folder is gone by then, it fails with that reason instead of running somewhere else.
30
+
31
+ ## Where it shows
32
+
33
+ - The board's Later rows (`LATER` on `dibs --detail`): what's scheduled, waiting in the queue and running.
34
+ - `dibs later list`: those, plus how each finished one ended: `done` with its exit code, `failed` (the command never started, or its folder was gone), `lost` (its `dibs run` was killed or the machine restarted: it isn't run again), `skipped`, `cancelled`. Kept for 7 days.
35
+ - `~/.dibs/later/<id>.log`: the command's stdout and stderr, with a first line saying when it started (and "ran late by 2h" if the machine was asleep at its time) and a last line with the exit code.
36
+
37
+ ## Who starts it
38
+
39
+ The worker service (`dibs service install worker`). It already runs under launchd or systemd and comes back after a crash or a reboot, and it runs scheduled jobs whether or not this machine ever joined a coordinator. A machine that was asleep at a job's time runs it on wake and says how late it was.
40
+
41
+ Without the service, `dibs later` starts a runner of its own that stays until nothing is left to run. It doesn't survive a restart, and the scheduling command says so.
42
+
43
+ Any number of runners can be up: each job is claimed under a lock by exactly one of them. A run outlives its runner (a service restart, say), and how it ended is still recorded.
@@ -0,0 +1,147 @@
1
+ # Several machines
2
+
3
+ One machine runs the coordinator. Every machine that takes jobs runs a worker. Any machine in the group can send work to the others, and plain `dibs` shows every machine's board.
4
+
5
+ ## Add a machine
6
+
7
+ ```bash
8
+ dibs service install serve worker # on the coordinator, once
9
+ dibs connect --machine # on the coordinator: a one-time code, e.g. K7QM-4XNA (dibs pair --machine is the same)
10
+ dibs join K7QM-4XNA # on the new machine: finds the coordinator and joins
11
+ dibs service install worker # on the new machine: takes jobs from now on, across reboots
12
+ dibs machines # anywhere in the group: every machine, its load and lines
13
+ ```
14
+
15
+ The code is 8 characters, works once, and lasts 10 minutes. Up to 5 can be open at once, and they live only in the coordinator's memory, so a restart ends them. `--name mini` makes a code for that name, which may replace a machine already called that; without it the new machine joins under its host name (or `dibs join <code> --name x`), and a name already in the group is refused.
16
+
17
+ `dibs join <code>` looks for the coordinator in three places:
18
+
19
+ - **The same network**: a UDP broadcast to the coordinator's port (7420 unless it serves on another). The coordinator listens for it only while a code is open, and answers at most 20 a second.
20
+ - **Tailscale**: every peer `tailscale status` shows online, at port 7420.
21
+ - **Anywhere else**: `--at <address>`.
22
+
23
+ The coordinator listens on 127.0.0.1 and on its Tailscale address (picked up within 30 seconds of Tailscale connecting). So a machine elsewhere on Tailscale joins as is; one on the same Wi-Fi without Tailscale needs the coordinator started with `--bind <its network address>`. Machine traffic is plain HTTP: on a network you don't trust, use Tailscale, which encrypts it. Machines never talk through the relay at app.dibs.cc, which carries the person's page only (64 KB calls; a worker needs working copies of up to 300 MB and live output).
24
+
25
+ Before the code goes anywhere, a machine that answered has to prove it holds it: the joiner sends 32 random bytes, and the coordinator answers with an HMAC over both sides' bytes, keyed by the code. Only then is the code sent and spent, and the machine gets a token of its own. After 10 wrong codes in 10 minutes, every try is refused until the window passes, the right code included.
26
+
27
+ `dibs connect --list` (or `dibs pair --list`) on the coordinator shows open codes and every machine in the group. `dibs pair --revoke <code id>` voids a code; `--revoke <machine>` removes a machine, as `dibs kick` does; `--revoke all` voids every open code and leaves the machines in.
28
+
29
+ Without codes: `dibs invite <name>` on the coordinator prints a line to run on the new machine, `dibs join <url> <token> --name <name>`. Inviting a name again replaces its old token.
30
+
31
+ ## Send work
32
+
33
+ ```bash
34
+ dibs run test --anywhere -- npm test # whichever machine would start it soonest, maybe this one
35
+ dibs run sim --on mini -- ./ui.sh # that machine
36
+ dibs run test --anywhere --bring coverage -- npm run cover # copy coverage/ back when it ends
37
+ dibs run test --shards 2 -- npx vitest run # split a suite across machines, output and exit codes merged
38
+ ```
39
+
40
+ **Where it goes.** The coordinator takes the machines reporting in that can run the job (sim and xcode-build need macOS, and the memory has to fit) and picks the one where it would wait least: the resource's line and slots there, load per core, low memory, jobs it was just sent. A machine that already has a free copy of your project, from an earlier job, gets a head start worth most of a job, so it wins unless a cold one would start a whole job sooner or is much less loaded. The machine you send from counts as the warmest of all and wins a near tie; if it wins, the job runs in place, exactly like a plain `dibs run`.
41
+
42
+ **What goes along.** The git working copy: tracked files, plus new files git doesn't ignore, uncommitted edits included. Outside git, the folder minus build output (`node_modules`, `DerivedData`, `build`, `dist`, `venv`, `__pycache__`, `Pods`, `target`) and hidden folders, except the ones builds read (`.github`, `.husky`, `.storybook`, `.swiftpm`, `.mvn`, `.yarn`, `.cargo`, `.devcontainer`, `.circleci`, `.changeset`, `.vscode`). Your home folder, or anything above it, is never sent: `--on` is refused and `--anywhere` runs here. A copy over 300 MB compressed is refused before anything is sent (exit 2): ignore build output in `.gitignore`.
43
+
44
+ **What never goes, even when tracked.** Secret-looking files: `.env*` and `*.env`, `.envrc`, `.dev.vars`, `.npmrc`, `.netrc` and the like, credentials, secrets and token files, cloud and Kubernetes configs, Terraform state and vars, private keys and certificates (`*.pem`, `*.key`, `*.p8`, `*.p12`, SSH keys), keychains, keystores, provisioning profiles, and everything in `.ssh`, `.aws`, `.gnupg` and `.dibs`. The full list is `SECRET` in src/remote.mjs. `GoogleService-Info.plist` does go: iOS builds need it, and Firebase treats it as public. Your environment doesn't go either; the job gets the worker's.
45
+
46
+ **On the other machine.** Each sender and project gets a folder in `~/.dibs/work`, kept between jobs so `node_modules` and build caches survive. Files you deleted are deleted there too. A folder unused for a week is removed, and every unused one goes when free disk falls under twice `minDisk`. The job runs through that machine's own `dibs run`, so it queues with that machine's agents and shows on its board as `you@yourmachine`.
47
+
48
+ **Coming back.** Output streams live (the coordinator keeps the last 16 MB of it), then the exit code. `--bring <path>` copies those files or folders back into your folder when the job ends; only the paths you named are unpacked.
49
+
50
+ **When it's lost.** Ctrl-C stops the remote job, and so does going away: nobody reading its output for 90 seconds. Two exit codes say a job was lost:
51
+
52
+ - **76, lost before it started.** The machine went quiet before picking it up and no other could take it, or the coordinator couldn't be reached. Nothing ran: send it again. With the coordinator unreachable, `--anywhere` runs here and `--on` another machine exits 76.
53
+ - **77, lost after it started.** The machine running it stopped reporting for 35 seconds or restarted, it was removed from the group mid-job, or the coordinator restarted and no machine took the job back within 2 minutes. It may have run, partly or fully, and may still be running. Check before running it again, above all a deploy. It's stopped when its worker comes back.
54
+
55
+ A coordinator restart (every dibs release does one) doesn't end jobs already running elsewhere: the worker keeps them going and holds their output and exit codes, and hands them over at its next check-in. Your `dibs run` says the coordinator restarted, waits up to 2 minutes, then carries on with every line once, in order. Jobs not yet started when it restarted are lost (76) and safe to send again.
56
+
57
+ **One board.** Plain `dibs` shows this machine's board first, then every other machine's leases and lines (who, what, the `-m` reason, priority, how long), then the jobs moving between them. Each worker sends its board with every check-in; one older than 20 seconds says so, and a machine that stopped reporting gets one line. Only what the board shows goes along: no pids, environment or full commands. If the coordinator doesn't answer within 1.5 seconds, you get this machine's board and one line saying the others couldn't be reached.
58
+
59
+ **Outside a group,** `--anywhere` runs here and says so, `--on` exits 2 with the line that sets a group up, and `dibs machines` says the machine isn't in a group (exit 0).
60
+
61
+ ## Leave
62
+
63
+ ```bash
64
+ dibs leave # on a machine that joined: it stops taking jobs and forgets the coordinator
65
+ dibs kick mini # on the coordinator: mini is out now, and its token stops working
66
+ ```
67
+
68
+ `dibs leave` stops the machine's worker (the service, and one started by hand) and deletes `~/.dibs/remote.json`. The coordinator lists it as not reporting until `dibs kick <name>` there takes it off. On the coordinator itself, `dibs leave` refuses while any other machine is in the group and names them: kick each first. Then it removes the serve and worker services; a `dibs serve` running in a terminal keeps going until you stop it. Outside a group, `dibs leave` exits 1.
69
+
70
+ `dibs kick` takes effect on the machine's next request. Its jobs end for their senders with a line saying it was removed: 77 if they had started, 76 if not. Jobs it sent are stopped. `dibs machines` lists it under "removed" for a day. Its worker logs one line and waits for a new `dibs join` instead of exiting, so launchd or systemd doesn't restart it in a loop.
71
+
72
+ ## Who may do what
73
+
74
+ - **One token per machine.** Each machine's token, from a code or `dibs invite`, works only for that name: it can't take jobs, read output or report results as another machine. The coordinator keeps the hashes in `~/.dibs/machines.json` (mode 600). Anyone holding a token can run commands on every worker, so an invite line goes only to the machine it names.
75
+ - **The coordinator's own token** (in its `~/.dibs/remote.json`) works only on the coordinator's machine, over loopback, and is the only one that can invite, kick or limit. From anywhere else it gets 401.
76
+ - **Anyone may run these.** `dibs join`, `leave`, `invite`, `kick`, `limit`, `service install` and `remove`, `guard install` and `remove`, and `serve --force` work from the person's terminal, the dibs app or an agent, and each goes in `dibs history` with who ran it. `join` logs the coordinator's address, never the token.
77
+ - **Limits**, on the coordinator:
78
+
79
+ ```bash
80
+ dibs limit borrowed --only test # borrowed takes only test jobs from other machines
81
+ dibs limit borrowed --sends none # and may send no jobs to other machines (or --sends test,heavy)
82
+ dibs limit borrowed --any # lift both
83
+ ```
84
+
85
+ Beyond `--sends`, `--on` another machine is refused and `--anywhere` runs on the sending machine. A machine with `--only` sees less of the others: the board and `dibs machines` show their work by resource, who and times, without commands, `-m` reasons, file lease paths or which projects they keep copies of. `dibs machines` shows each machine's limit, and invited machines that haven't joined yet.
86
+
87
+ ## Where a project may go
88
+
89
+ A `.dibs.json` at a repo's root, committed so every clone has it, names the machines its code may go to:
90
+
91
+ ```json
92
+ { "stayOn": ["my-mac-mini"] }
93
+ ```
94
+
95
+ The machine the job is sent from is always allowed, and `{"stayOn": []}` keeps the project home. Every `.dibs.json` in the folder you run from, the folders above it, and anywhere in the copy that would be sent applies; a job goes only where all of them agree. One that can't be read keeps the project home. A new machine is in no existing list, so it gets nothing until you add it.
96
+
97
+ The rule is checked three times: by the sender before anything is uploaded, by the coordinator when it places the job (and again if it moves one whose machine went quiet), and by the worker on the copy it unpacked, which refuses the job and deletes the copy if the rule rules it out. `--anywhere` with nowhere allowed runs here; `--on` a machine the rule or a limit rules out is refused, naming the rule, and nothing is sent.
98
+
99
+ ## Machines that sleep until a job needs them
100
+
101
+ A cloud VM bills every second it runs, so dibs can keep one asleep and wake it only for work. On the coordinator, in `~/.dibs/config.json`:
102
+
103
+ ```json
104
+ { "machines": { "ondemand": [{ "name": "boat-1", "provider": "boat", "registry": "~/boat/VMS.md", "match": "dibs", "owner": "alex-3b" }] } }
105
+ ```
106
+
107
+ **Which VM.** Never an id in config: VM ids change. The registry is a markdown table of who owns which VM, read by its column names (VM, Owner, Use, Notes; others are left alone). dibs takes the one row whose Use mentions `match` (and whose Owner is `owner`, when given) and checks that boat still has that VM. No row, more than one, or a VM boat doesn't have: `dibs machines` and the board say so, nothing is woken, and a job sent to it runs where it was sent from. dibs calls boat by id only and never touches another VM; the only VMs it makes or deletes are the temporary ones below. It keeps that row's Notes cell current ("Running dibs jobs ... since 20:14", "Stopped 20:31 by dibs (its queue is empty)"), rewriting only that cell and swapping the whole file into place.
108
+
109
+ **States.** `dibs machines` and the board show it `asleep`, `waking`, `running` or `stopping`. Asleep, it's a machine like any other for placement, except that a job there costs a wake.
110
+
111
+ **When it wakes.** `--on boat-1` always wakes it. `--anywhere` wakes it only when the job's wait on the best awake machine (about 3 minutes per job ahead) is longer than waking it (its last measured resume, or 45 seconds before the first) plus about 20 seconds of upload. With no awake machine to compare against, the job runs where it was sent from.
112
+
113
+ A job can also go there on its own, from any machine in the group, if the job can run there:
114
+
115
+ - It's been held 2 minutes by the machine it was sent from: its load, the memory or CPU budget, memory pressure, swap growth, the free disk swap needs, or a job ahead reserving memory.
116
+ - It's held for memory and dibs knows it usually uses more than that machine has: it goes at once.
117
+ - Its turn there is further off than 90 seconds plus its usual run time.
118
+
119
+ Jobs pack onto the VM while what's sent there fits its memory, less 1 GB. Jobs held for memory then go to the temporary VM made beside it (below), if that's on; the rest go only to a VM with room. A job never ships if it needs macOS (a macOS-only resource, a command naming a macOS tool, or a script that imports Apple frameworks such as Vision), if its project's `stayOn` keeps it here, if it runs from the home folder or a folder outside git, or if its command names a path on this machine (`/Users/...`, `~/...`, `/tmp/...`; `/usr/bin`, `/dev` and the like are fine). Without an on-demand machine in the config, none of this happens (docs/scheduling.md).
120
+
121
+ **Waking.** `boat resume`, then a reverse forward (`boat forward <id> --reverse --local <port>`), so the VM reaches the coordinator on its own 127.0.0.1, no Tailscale needed there. If the VM lacks Node v22.23.4 (pinned, checksum checked) or the coordinator's dibs version, they're installed. The VM gets a fresh token every wake, sent as a file, never on a command line, and a worker starts. boat's snapshot can bring back the VM's last worker on its old dibs; dibs stops it before starting its own, and an on-demand worker gets jobs only once it runs the coordinator's version. A first wake took 35 seconds on 2026-10-18 (resume 2.6 s, the rest installing Node and dibs); a later one, 19 seconds.
122
+
123
+ **Stopping.** Once nothing has run there or been sent to it for `idleStop` (30 seconds unless set, 3 minutes at most), the coordinator runs `boat stop`. boat's own one-hour auto-stop stays as the backstop, pushed back an hour every 30 minutes while a job runs. The VM's worker runs with `--ephemeral`: when it can't reach the coordinator for a minute (10 with a job running), it leaves. A coordinator that stops leaves a VM with jobs running up. One that starts and finds its VM up looks at what runs there (`boat ps`): its own worker with jobs, it takes the VM back; other work using CPU, it leaves the VM running and says so; nothing, it stops it. Every resume and stop is an event (`kind: "ondemand"`) with the seconds billed.
124
+
125
+ **Nothing kept.** Treat everything on the VM as gone after a stop: each job's copy there is deleted when the job ends, after `--bring` has sent back what you asked for. Node and dibs stay installed between wakes, since installing them again costs about 30 billed seconds. `.dibs.json` `stayOn` and machine limits apply as for any machine.
126
+
127
+ **When boat says no.** Before waking or making a VM, dibs reads `boat limits --json` (at most once a minute). With no starts left for the day or the hour, or `canStart` false, it doesn't try. A wake that fails anyway (a 429, say) is handled the same way: the jobs sent there go back to the machine that sent them when it takes jobs, and are lost (76) only when there's nowhere to go. The VM is marked `can't wake` with the reason and a time to try again: an hour for a quota or a 429, 5 minutes for anything else. Until then `dibs machines` shows `can't wake: <reason>`, `--anywhere` and jobs dibs ships on its own skip it, and `--on` it is refused with that line.
128
+
129
+ ### A VM made for a job too big for it
130
+
131
+ Off unless set. Add `"create": { "max": "large" }` to the entry (`small`, `default` or `large`: the biggest dibs may make):
132
+
133
+ ```json
134
+ { "machines": { "ondemand": [{ "name": "boat-1", "provider": "boat", "registry": "~/boat/VMS.md", "match": "dibs", "owner": "alex-3b", "create": { "max": "large" } }] } }
135
+ ```
136
+
137
+ - `dibs machines` then lists `boat-1-temp` beside `boat-1`. A job sent `--on boat-1` asking more `--mem` than it has (8 GB unless `mem` says) or more `--cpu` than its cores (4 unless `cores` says) goes to `boat-1-temp` instead, and so does `--anywhere` when that's the shorter wait. Only `--cpu` makes a VM, never a resource's own guess at cores.
138
+ - dibs makes the smallest size that takes every job waiting for it (`boat new --type small|default|large`: 2 cores and 4 GB, 4 and 8, 8 and 16), never with `--no-auto-stop`, and adds its row to the registry at once (Kind `temporary`, Owner `owner`). It's set up like a wake, Node included.
139
+ - Once its queue has been empty for `idleStop`, or anything fails, dibs deletes it (`boat delete <id> --yes`) and its row. If boat won't delete it, the row stays and says how to delete it by hand.
140
+ - A coordinator that starts deletes temporary VMs and rows of its own that a crash left behind. Nobody else's are touched.
141
+ - A job bigger than `max` is refused with the reason. One real run on 2026-10-19: a 3 GB job, a small VM made in 2 seconds and running in 35, deleted with its row 40 seconds after the job; 74 seconds billed.
142
+
143
+ `test/live/two-machines.sh` runs all this for real against the registry's VM: a coordinator on the VM through a boat forward, jobs each way, `--bring`, a worker killed mid-job (77), kick, then the VM woken on demand and stopped (`--temp` adds a temporary VM). It bills a few minutes, so it isn't part of the suite.
144
+
145
+ ## Running by hand
146
+
147
+ `dibs serve --listen 7420` and `dibs worker --name x` run them in a terminal instead of as services. `dibs serve` writes `~/.dibs/remote.json` only once it's listening, and on a machine joined to another coordinator it refuses unless you pass `--force`, which leaves that group. It listens on no interface besides 127.0.0.1 and Tailscale unless you pass `--bind`. `dibs service status` shows what's installed and `dibs service remove worker` takes one out. Services are launchd agents on macOS, `systemd --user` units on Linux and logon tasks on Windows; logs go to `~/.dibs/<service>.log`.