@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.
- package/CHANGELOG.md +577 -0
- package/LICENSE +670 -0
- package/README.md +234 -2
- package/bin/dibs-guard.mjs +7 -0
- package/bin/dibs.mjs +526 -0
- package/docs/benchmarks.md +193 -0
- package/docs/files.md +30 -0
- package/docs/guard.md +91 -0
- package/docs/later.md +43 -0
- package/docs/machines.md +147 -0
- package/docs/questions.md +78 -0
- package/docs/relay.md +196 -0
- package/docs/releasing.md +25 -0
- package/docs/scheduling.md +163 -0
- package/docs/simulators.md +17 -0
- package/package.json +44 -4
- package/skills/dibs/SKILL.md +162 -0
- package/src/acquire.mjs +697 -0
- package/src/admin.mjs +145 -0
- package/src/agents.mjs +145 -0
- package/src/alerts.mjs +437 -0
- package/src/answers.mjs +65 -0
- package/src/board.mjs +202 -0
- package/src/broker.mjs +369 -0
- package/src/commands.mjs +801 -0
- package/src/config.mjs +320 -0
- package/src/connect.mjs +106 -0
- package/src/cool.mjs +160 -0
- package/src/diskwarn.mjs +161 -0
- package/src/events.mjs +94 -0
- package/src/files.mjs +1100 -0
- package/src/guard.mjs +583 -0
- package/src/history.mjs +247 -0
- package/src/hogs.mjs +214 -0
- package/src/later.mjs +487 -0
- package/src/measure.mjs +262 -0
- package/src/nodecheck.mjs +17 -0
- package/src/notices.mjs +121 -0
- package/src/ondemand.mjs +572 -0
- package/src/overlap.mjs +151 -0
- package/src/override.mjs +351 -0
- package/src/owner.mjs +30 -0
- package/src/plain.mjs +467 -0
- package/src/platform.mjs +357 -0
- package/src/preempt.mjs +438 -0
- package/src/primer.mjs +61 -0
- package/src/proc.mjs +98 -0
- package/src/progress.mjs +158 -0
- package/src/qr.mjs +204 -0
- package/src/questions.mjs +389 -0
- package/src/quota.mjs +81 -0
- package/src/reads.mjs +54 -0
- package/src/relay.mjs +779 -0
- package/src/remote.mjs +584 -0
- package/src/reset.mjs +127 -0
- package/src/schedule.mjs +995 -0
- package/src/scratch.mjs +61 -0
- package/src/serve.mjs +736 -0
- package/src/service.mjs +221 -0
- package/src/shard.mjs +59 -0
- package/src/simctl.mjs +42 -0
- package/src/simpool.mjs +258 -0
- package/src/state.mjs +201 -0
- package/src/stats.mjs +328 -0
- package/src/style.mjs +44 -0
- package/src/talk.mjs +523 -0
- package/src/thin.sh +130 -0
- package/src/trust.mjs +152 -0
- package/src/util.mjs +184 -0
- package/src/version.mjs +2 -0
- package/src/web.mjs +1117 -0
- package/src/worker.mjs +318 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Questions for the person
|
|
2
|
+
|
|
3
|
+
With five or ten agents running, the person who runs them is the scarcest thing on the machine. Each agent that stops to ask "ship it?" or "which name?" interrupts them, and an agent that stops dead waits until they notice. dibs queues those questions like any other resource: the agent asks, keeps working on whatever doesn't depend on the answer, and the person answers when they get to it, in order.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
dibs question "Ship build 123 to TestFlight now?" --options yes,no --recommend yes -m "tests pass, notes written" \
|
|
7
|
+
--one-way "testers get it at once; it can't be pulled back" --wait # blocks; prints only the answer
|
|
8
|
+
dibs question "Use port 5173 for the dev server?" --options yes,no --recommend yes -m "nothing else listens there"
|
|
9
|
+
# a two-way door: prints "yes" at once, logged, shown to the person as done
|
|
10
|
+
dibs questions # open first, by priority then age (--json for scripts and the Mac app)
|
|
11
|
+
dibs answer 4 yes # the person answers with an option...
|
|
12
|
+
dibs answer 4 "wait until Monday" # ...or in their own words
|
|
13
|
+
dibs questions dismiss 5 # or waves it off
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The board's first line says `3 questions for you: dibs questions` while any are open, and `dibs --json` has a `questions` count. `dibs questions --json` has an `open` count for a badge.
|
|
17
|
+
|
|
18
|
+
## For agents: one-way doors only
|
|
19
|
+
|
|
20
|
+
The person's standing rule: walk through two-way doors (anything you can undo) and show them after. Bring them one-way doors (anything that can't be undone) and taste calls only, one at a time, with your recommendation. dibs holds you to it:
|
|
21
|
+
|
|
22
|
+
- Every question needs `--recommend <option>` and `-m "why"`. With `--options`, the recommendation must be one of them.
|
|
23
|
+
- **Without `--one-way`**, nobody is asked. dibs prints your recommendation on stdout at once (exit 0, `--wait` or not), logs `decided by <you>: two-way door` in `dibs history`, and shows it in the person's threads as done. They message you if they want it otherwise.
|
|
24
|
+
- **With `--one-way "what can't be undone"`**, it's queued for the person, who sees the question, your recommendation and why, and what can't be undone.
|
|
25
|
+
- dibs refuses (exit 2, nothing recorded) a question that isn't a short sentence of at least three words (a bare "2"), one without a recommendation or a reason, and options that repeat.
|
|
26
|
+
|
|
27
|
+
1. Ask without `--wait`. It prints the id and returns. Carry on with the work that doesn't need the answer.
|
|
28
|
+
2. When you reach the step that does, run the same command again with `--wait`. It prints the answer on stdout, and only the answer, so `answer=$(dibs question ... --wait)` works.
|
|
29
|
+
3. Exit 75 means no answer: the person dismissed it, or your wait's `--timeout` (a duration: `30s`, `1m`, `2h`) passed. Nothing was decided. Don't take silence as a yes; carry on without that step and say so in your report. A question you asked in step 1 stays open for the person after a wait gives up: run the same command with `--wait` again later to collect it. One asked only with `--wait` stays open 2 minutes after its wait gives up, so the same command picks it back up.
|
|
30
|
+
|
|
31
|
+
- The person may answer in their own words instead of an option. Those words are the answer (on stdout with `--wait`), and they also reach you through the hook as `Message from the person: (answering your question #N) ...`.
|
|
32
|
+
- `-p urgent|high|normal|low|idle` places it like a job in line: urgent goes 2 hours ahead, high 1 hour, low 10 minutes back. Use urgent only when something is broken or the person is waiting on you right now.
|
|
33
|
+
- Asking the same text again from the same session is the same question, not a new one (a two-way one gives the same decision), until it's answered and read, dismissed or expired. After that the same text is a new question with a new id.
|
|
34
|
+
- Inside a Claude Code tool call, `--wait` has no time limit, as with `dibs run`: if the call reaches its timeout, Claude Code moves it to the background and tells you when the answer comes.
|
|
35
|
+
- A question belongs to whoever asked. Asked with `--wait` only, that's the waiting dibs: if it's killed, the question expires. Asked without it, it's your agent session: its questions expire when the session ends, or at the `--timeout` you gave when you asked, never at a later wait's.
|
|
36
|
+
|
|
37
|
+
An agent may answer another agent's question with `dibs answer <id> <text>` when it knows the answer: the asker sees `answered by <agent>, an agent, not the person` on stderr, beside the bare answer on stdout, and the history names who answered.
|
|
38
|
+
|
|
39
|
+
## The person's threads, and the desk
|
|
40
|
+
|
|
41
|
+
`dibs threads` holds what's for the person: one-way questions, and agents' `dibs say` notes, marked FYI. dibs's own notices to an agent about its jobs (bookings, stuck-job advice, "pass --mem 7G") go only to that agent through the hook, never into the person's threads.
|
|
42
|
+
|
|
43
|
+
Set `"desk": "<agent name>"` in `~/.dibs/config.json` to give the person one agent to talk to. `dibs tell desk "..."` (and the Mac app's chat) reaches that agent through the hook, and it answers with `dibs say --to person "..."`. `dibs threads --json` names it (`desk`), marks its thread `desk: true`, and its answers `reply: true`.
|
|
44
|
+
|
|
45
|
+
## For the person: hours
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
dibs hours 09:00-23:00 # dibs hours off clears them; dibs hours [--json] shows them
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
(or `"hours": { "start": "09:00", "end": "23:00" }` in `~/.dibs/config.json`) keeps questions below urgent out of your way at night. They stay in the list, marked "for tomorrow", and the board doesn't count them until `start`. An end before the start runs past midnight. Agents asking off hours are told their question waits for the morning unless it's urgent.
|
|
52
|
+
|
|
53
|
+
`dibs answer`, `dibs questions dismiss` and `dibs hours` work for the person and for agents alike; `dibs history` names who did each.
|
|
54
|
+
|
|
55
|
+
Closed questions stay in `dibs questions --json` for 7 days (at most 200), in `~/.dibs/questions.json`.
|
|
56
|
+
|
|
57
|
+
## Threads: notes and messages both ways
|
|
58
|
+
|
|
59
|
+
Questions are one half of a conversation. Each agent also has a thread, keyed by its session (and, for a subagent, its agent id), that holds its questions and your answers, the notes it leaves you, and the messages you send it.
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
dibs say "migration done, tests pass" # an agent: a note to the person, no answer expected (--as <label> for a subagent)
|
|
63
|
+
dibs threads # the person: every thread, newest first, with unread counts
|
|
64
|
+
dibs threads read web-app # the conversation; marks its notes and questions read
|
|
65
|
+
dibs tell web-app "use the staging database" # the person: a message for that agent
|
|
66
|
+
dibs tell web-app/Explore "check the tests" # a subagent's thread is <session name>/<label>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
How a message reaches the agent, with `dibs guard install` (or the plugin):
|
|
70
|
+
|
|
71
|
+
- On the agent's next Bash, edit or Agent tool call, the hook adds it next to the call as `additionalContext` ("Message from the person: ..."). The call itself goes through unchanged, through the normal permission checks. If the guard turns that call away (a heavy command outside dibs, a file another agent leased), the message waits for the next one.
|
|
72
|
+
- If the agent is ending its turn instead, the Stop hook (SubagentStop for a subagent) answers with `decision: "block"` and the message as the reason, so it keeps going and reads it. Each message is handed over once, and a stop that's already a stop hook's continuation (`stop_hook_active`) is never blocked again, so this can't loop.
|
|
73
|
+
- An agent that's idle, waiting for its person to type, gets it on its next tool call. A session that has ended keeps the message queued, shown as not delivered, in case it's resumed.
|
|
74
|
+
- Without the guard, the agent gets queued messages the next time it runs `dibs say`.
|
|
75
|
+
|
|
76
|
+
dibs leaves notices of its own in an agent's thread, as lines from dibs: a job of the agent's that has used no CPU for 20 minutes while others wait for it, one that used far more memory than it asked for (with the `--mem` to pass next time), and one paused for low disk or memory (it resumes by itself). Each is said once and handed over the same way as your messages, beside the next tool call, with "dibs has a notice about your jobs". A notice never keeps an agent from stopping, and one nobody picked up expires after an hour. Outside Claude Code, notices arrive on stderr with the agent's next dibs command.
|
|
77
|
+
|
|
78
|
+
Plain `dibs` counts unread notes with the questions: `2 questions and 1 note are waiting for you: dibs threads` (`dibs --detail`: `2 questions and 1 note for you: dibs threads`), and `dibs --json` has a `notes` count. Agents may run `dibs tell` and `dibs threads read` too, as they may `dibs answer`: a message from an agent reaches its reader marked as another agent's, never the person's. Threads keep 7 days and at most 200 lines each, in `~/.dibs/messages.json`.
|
package/docs/relay.md
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# dibs from anywhere: the encrypted relay
|
|
2
|
+
|
|
3
|
+
`dibs pair --remote` pairs a phone or any browser with this Mac. The browser then opens https://app.dibs.cc and sees the same page `dibs web` serves at 127.0.0.1:7421, carried end to end encrypted through a relay that only forwards opaque frames. The relay (a Cloudflare Worker, `relay/` in this repo) never holds a key, a pairing secret or a byte of the board.
|
|
4
|
+
|
|
5
|
+
Turn it on:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
dibs service install relay # keeps the outbound connection up, with backoff; off until you do this
|
|
9
|
+
dibs pair --remote # prints a one-time link and a QR code; open it on the phone. That browser can only look
|
|
10
|
+
dibs pair --remote --allow-actions # the same, and that browser may also boost, pause, resume and stop jobs, cap an agent, set the pace and cancel scheduled runs
|
|
11
|
+
dibs pair --list # local sign-ins and remote devices
|
|
12
|
+
dibs pair --revoke <id|all> # a revoked device's open session ends within 25 seconds
|
|
13
|
+
dibs service status relay # connected or not, since when, how many devices
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Keys
|
|
17
|
+
|
|
18
|
+
| key | where | what it does |
|
|
19
|
+
|---|---|---|
|
|
20
|
+
| Mac identity, Ed25519 | `~/.dibs/relay-keys.json` (0600), never sent | signs every pairing answer and session handshake; browsers pin its fingerprint |
|
|
21
|
+
| Mac relay key, Ed25519 | same file | proves to the relay that this Mac owns its machine id; opens no session, decrypts nothing |
|
|
22
|
+
| device key, Ed25519 | the browser's IndexedDB, made with `extractable: false` | signs the device's half of each handshake; page script can use it but never read it |
|
|
23
|
+
| session keys, AES-256-GCM | memory only, per connection | one per direction, from a fresh X25519 exchange |
|
|
24
|
+
|
|
25
|
+
Machine id `mid` = first 16 bytes of SHA-256("dibs-mid-v1\0" ‖ relay public key), base64url (22 characters). Fingerprint `fp` = SHA-256("dibs-fp-v1\0" ‖ identity public key), base64url (43 characters).
|
|
26
|
+
|
|
27
|
+
## Encoding
|
|
28
|
+
|
|
29
|
+
`tx(label, f1, f2, ...)` is every item as a 4-byte big-endian length followed by its bytes, so two different transcripts never encode the same. All binary fields travel as base64url and are checked for exact length. Messages between the page and the Mac are binary WebSocket messages: `0x01` followed by UTF-8 JSON for handshake messages, `0x02` followed by an encrypted frame.
|
|
30
|
+
|
|
31
|
+
## Pairing
|
|
32
|
+
|
|
33
|
+
`dibs pair --remote` makes a 32-byte random `secret` and prints
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
https://app.dibs.cc/#p=<mid>.<secret>.<fp>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The fragment never goes in a request, and the page removes it from the address bar (`history.replaceState`) before any other code runs. The Mac keeps only what's derived from the secret, for ten minutes: `pid` = HKDF(secret, info "dibs-relay-v1 pair id", 16 bytes), the HMAC key `kp` (info "... pair key"), the name key `kn` (info "... pair name"), and the hash of the pairing ticket `pt` (info "... pair ticket", 32 bytes), which it registers with the relay. The page sends `pt` to the relay to get into the pairing pool; the relay can't derive anything else from it.
|
|
40
|
+
|
|
41
|
+
1. **pair1**, browser to Mac: `{t, pid, d, nb, name, sig, mac}`. `d` is the new device public key, `nb` 32 random bytes, `name` is the device's name ("Safari on iPhone") padded to 64 bytes, followed by the device's 32-byte random relay token `rt`, sealed together with AES-GCM under `kn` (random nonce), so the relay learns neither the name, its length, nor the token. `T1 = tx("dibs-pair1-v1", mid, pid, d, nb, name)`, `sig = Sign_d(T1)`, `mac = HMAC(kp, T1 ‖ sig)`.
|
|
42
|
+
The Mac finds the pending link by `pid` (gone or expired: `pair-expired`), checks `mac` in constant time (three failures burn the link), checks `sig`, decrypts the name, and only then, under one lock, deletes the link and stores the device `{pub: d, name, rth, created}` under a random 16-byte id `did`, where `rth` is the first 16 bytes of SHA-256("dibs-relay-token-v1\0" ‖ rt). It sends the relay the new list of token hashes, then `{t: "admit", ch, h: rth}` for the pairing tab.
|
|
43
|
+
2. **pair2**, Mac to browser: `{t, m, nm, did, sig, mac}`. `m` is the Mac's identity key, `nm` 32 random bytes. `T2 = tx("dibs-pair2-v1", mid, pid, d, nb, name, m, nm, did)`, `sig = Sign_M(T2)`, `mac = HMAC(kp, T2 ‖ sig)`.
|
|
44
|
+
The browser requires `fingerprint(m) == fp` from the link, then the HMAC, then the signature, and only then stores `{mid, m, fp, did, device key pair}`.
|
|
45
|
+
|
|
46
|
+
So pairing needs the secret (256 bits, one use, ten minutes; there's nothing to brute force), and a relay that swaps either key is caught: the device key by the HMAC and the device's own signature, the Mac's key by the fingerprint and the HMAC.
|
|
47
|
+
|
|
48
|
+
## A session
|
|
49
|
+
|
|
50
|
+
Every connection, including the first right after pairing:
|
|
51
|
+
|
|
52
|
+
1. **hello1**, browser: `{t, did, eb, nb}`: a fresh X25519 public key `eb` and 32 random bytes.
|
|
53
|
+
The Mac refuses an unknown `did` (`unpaired`). Otherwise it makes its own X25519 pair `em`, 32 random bytes `nm`, and `TH = tx("dibs-hs-v1", mid, did, D, eb, nb, M, em, nm)` where `D` is the stored device key and `M` its identity key. It rejects an all-zero shared secret.
|
|
54
|
+
2. **hello2**, Mac: `{t, em, nm, sig}`, `sig = Sign_M(tx("dibs-hs2-v1", TH))`. The browser builds `TH` from its own view (the `M` it pinned at pairing) and verifies, so a relay answering with its own keys is caught here, before the browser has sent anything but a public key.
|
|
55
|
+
3. **hello3**, browser: `{t, sig}`, `sig = Sign_D(tx("dibs-hs3-v1", TH, sigM))`. The Mac verifies it against `D` and checks the device is still paired.
|
|
56
|
+
|
|
57
|
+
Keys: `salt = SHA-256(tx("dibs-hs-keys-v1", TH, sigM, sigD))`; from the X25519 shared secret, HKDF-SHA-256 with that salt gives `k_b2m` (info "dibs-relay-v1 key b2m"), `k_m2b` ("... key m2b") and the session id `sid` ("... sid"). Both ephemeral private keys are dropped after the exchange, so a later theft of the long-term keys reveals no recorded session (forward secrecy). Both sides signed the same transcript (mutual authentication); a replayed hello3 fails because the Mac's `em` and `nm` are new every time.
|
|
58
|
+
|
|
59
|
+
4. **ready**: the Mac's first encrypted frame. The page sends no call before it decrypts this (key confirmation).
|
|
60
|
+
|
|
61
|
+
## Frames
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
0x02 | seq (8 bytes, big-endian) | AES-256-GCM ciphertext | tag (16)
|
|
65
|
+
nonce = 4 zero bytes | seq
|
|
66
|
+
AAD = "dibs-frame-v1" | sid | direction (1 = browser to Mac, 2 = Mac to browser) | the 9 header bytes
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Each side's `seq` starts at 0, and the receiver accepts only exactly the next one. A replayed, dropped, reordered, altered or cross-session frame fails, and any failure closes the session (the page reconnects with new keys). Plaintext is a 4-byte length, the JSON, and zeros up to the next bucket of 1, 4, 16, 64, 256 KiB, 1 or 4 MiB; requests are capped at 64 KiB. Messages: `{t: "req", id, method, path, body}` from the page, `{t: "res", id, status, json}` from the Mac. The Mac runs a request only after it decrypts, only for `/api/...` paths, only if the device is still in `relay.json` at that moment, and only if the device may. Remote calls go through an allow-list, checked in the relay connector and again in `api()`, on the path as `api()` parses it (so `/api/x/../hook` is `/api/hook`):
|
|
70
|
+
|
|
71
|
+
- any paired device: GET `/api/board`, `/api/questions`, `/api/threads`, `/api/later`, `/api/history`, `/api/stats`, `/api/settings`;
|
|
72
|
+
- a device paired with `--allow-actions`, also: POST `/api/jobs/<id>/boost|pause|resume|stop`, `/api/cap`, `/api/pace`, `/api/later/<id>/cancel`;
|
|
73
|
+
- everything else is 403, a route added later included, so new routes are local-only until someone decides otherwise. That covers messaging an agent, marking a thread read, answering or dismissing an agent's question (all of which reach agents as "Message from the person", which agents act on, shell commands included), installing the hook (it edits `~/.claude/settings.json`) and setting the hours (they decide when the person gets asked).
|
|
74
|
+
|
|
75
|
+
A reason sent with a remote action is dropped: the action runs, but no words from a paired browser reach an agent as the person's. A remote action runs the CLI with `DIBS_VIA`, so the record names the device: the job's `by` (a stop's `stopBy`, a pause's `by`, which the job's agent is told), the override event and `logChange` all read "the person via Safari on iPhone (remote 1a2b3c4d)": a label from the page's fixed vocabulary (browser and system, or "a browser" for any name the page wouldn't have made, since the device chooses its own name and this text reaches agents), and the start of its id, the one `dibs pair --revoke` takes. The device's own name appears only in `dibs pair --list`. `dibs pair --list` shows each device as "can act" or "look only", and every `dibs pair --remote` is logged with whether it allowed actions. Sessions end after 12 hours; the page reconnects.
|
|
76
|
+
|
|
77
|
+
Errors before a session exists (`{t: "err", code}`) are unauthenticated, so the relay could write them. The page believes only four codes (`unpaired`, `pair-expired`, `bad-pair`, `bad-hello`), shows only its own fixed sentence for each, and never deletes keys because of one. Nothing else the relay sends reaches the page as words either: WebSocket close reasons are ignored, and every message the page shows about the connection is one of its own.
|
|
78
|
+
|
|
79
|
+
## The relay
|
|
80
|
+
|
|
81
|
+
| path | who | what the relay does |
|
|
82
|
+
|---|---|---|
|
|
83
|
+
| `wss://app.dibs.cc/ws/m/<mid>` | the Mac (also sends `{t: "tokens", h, p}`: the hashes of its paired browsers' relay tokens and of its open links' pairing tickets, within a second of any change in `relay.json`) | sends a 32-byte challenge; the Mac answers with its relay public key and `Sign_R(tx("dibs-relay-auth-v1", mid, challenge, host))`. The relay checks that the key hashes to `<mid>` and the signature; then routes. The newest authenticated connection replaces the old one |
|
|
84
|
+
| `wss://app.dibs.cc/ws/b/<mid>` | a browser tab | only from the page's own Origin. A tab gets a slot only by proving it's paired: its first message is `{t: "hello", rt}`, and the relay admits it if the hash of `rt` is one the Mac registered (compared in constant time), or `{t: "pair", ticket}` with a ticket whose hash the Mac registered for an open link, into a pool of 2 with a 30 s deadline that ends when the Mac admits it. A wrong ticket and no open link get the same answer, so the relay's answers say nothing about whether a link is open, and nobody without the link can take the pairing pool. Anything else (a byte, a made-up token, silence for 5 s) closes it. An admitted tab gets a random channel id; its binary messages go to the Mac prefixed with the id, and the Mac's go back by id. Text from the relay: `{t: "mac", up}`, and `{t: "refused", why: "unpaired" or "no-pairing"}`, which the page turns into its own words |
|
|
85
|
+
| `https://app.dibs.cc/` | anyone | the page, with the headers below |
|
|
86
|
+
| `https://dibs.cc/app`, `https://dibs.cc/app/*` | anyone | a 301 to `https://app.dibs.cc/`, which keeps the fragment. Exactly these two route patterns, so `/apple-touch-icon.png` and the like stay the waitlist's |
|
|
87
|
+
|
|
88
|
+
Limits: 20 connections a minute per address and role (Workers rate limiting), and 30 new tabs a minute per address in the machine's Durable Object. At most 8 paired tabs per machine and 4 per address; at most 6 tabs waiting to prove themselves, 3 per address, and past 6 the oldest waiting goes, never the newcomer. A Mac socket has 10 seconds to authenticate, on its own timer; at most 8 wait at once, and past that the oldest waiting one is closed rather than the newcomer refused, so silent sockets can't lock the real Mac out. When the Mac goes offline every tab hears so and is closed 5 seconds later, whatever it sends meanwhile; a tab that arrives while it's offline is turned away at once. When the Mac reconnects, every admitted tab is closed so it proves itself to the new connection. A revoke reaches the relay within a second, and that device's open tabs are closed. Also 64 KiB per browser frame and 4 MiB per Mac frame, token buckets of 20 frames a second (burst 60) per tab and 200 (burst 400) for the Mac, tabs closed after 10 idle minutes, a Mac closed after 90 seconds without a ping. One Durable Object per machine id, nothing in its storage, observability and logpush off, and nothing about a frame is logged.
|
|
89
|
+
|
|
90
|
+
## The page
|
|
91
|
+
|
|
92
|
+
- Its own origin, `app.dibs.cc`, not `dibs.cc/app`: the device key lives in that origin's IndexedDB, and anything else on the same origin (the waitlist page, a future blog) could use it. Keeping the origin to this one page keeps that surface to this one page.
|
|
93
|
+
- `Content-Security-Policy: default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self'; connect-src wss://app.dibs.cc; ... base-uri 'none'; form-action 'none'; frame-ancestors 'none'; require-trusted-types-for 'script'; trusted-types 'none'`. No inline script, no third-party anything, no DOM HTML sinks.
|
|
94
|
+
- `Strict-Transport-Security: max-age=63072000; includeSubDomains`, `X-Frame-Options: DENY`, `Referrer-Policy: no-referrer`, `X-Content-Type-Options: nosniff`, COOP/COEP/CORP same-origin, a Permissions-Policy denying every device API.
|
|
95
|
+
- Subresource Integrity (SHA-384) on every script and stylesheet, and `hashes.txt` listing the hash of every file, the page itself included, so anyone can check what app.dibs.cc serves:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
curl -s https://app.dibs.cc/ | openssl dgst -sha384 -binary | base64 # compare with relay/public/hashes.txt for /
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Remote MCP (mcp.dibs.cc)
|
|
102
|
+
|
|
103
|
+
`dibs relay mcp on` lets an MCP client somewhere else, such as a claude.ai connector on another Claude account, reach this Mac's MCP. The URL to give it is `https://mcp.dibs.cc/mcp`; `https://mcp.dibs.cc/<machine id>/mcp` works too. It's off until the person turns it on (`dibs relay mcp off` turns it off at once; `dibs service status relay` and `dibs pair --list` show which).
|
|
104
|
+
|
|
105
|
+
This part is **not end-to-end encrypted**. MCP clients speak HTTPS, and TLS ends at Cloudflare, so the relay carries these requests and answers in the clear on their way through. It stores none of it and logs no bodies.
|
|
106
|
+
|
|
107
|
+
### Sign-in codes
|
|
108
|
+
|
|
109
|
+
While remote MCP is on, `dibs pair` prints 12-character codes (60 bits, `XXXX-XXXX-XXXX`), good for sign-in here and through the relay; with it off they're 8 characters and local only. A code through the relay must be a long one. One use, ten minutes, as always.
|
|
110
|
+
|
|
111
|
+
### The bare host, https://mcp.dibs.cc/mcp
|
|
112
|
+
|
|
113
|
+
With no machine id in the URL, the relay finds the Mac three ways, and none of them lets it pretend to be one:
|
|
114
|
+
|
|
115
|
+
- **Discovery and registration** are answered by the relay itself, storing nothing. The issuer and resource are `https://mcp.dibs.cc`. A client id is `b.<payload>.<mac>`: the payload is the client's name and redirect URIs, and the mac is an HMAC under `REG_SECRET`, the one secret the relay holds. It signs registrations and nothing else; no Mac knows it, and it opens nothing on any Mac. The relay refuses an edited or unsigned client id at `/oauth/client`, `/oauth/authorize` and `/oauth/token`, and the Mac still checks the redirect exactly against the payload at sign-in and at token exchange.
|
|
116
|
+
- **Sign-in is routed by the code.** While remote MCP is on, the Mac lists the index hash of each live long code, SHA-256("dibs-mcp-code-v1\0" ‖ normalized code), with the relay over its authenticated socket. The relay keeps them in one code index (a Durable Object): hash to machine id, for the code's ten minutes at most, replaced whenever the Mac's list changes (a spent or revoked code drops out within a second; an accepted one is dropped at once), at most 10 per machine, and a machine can only replace its own entries. The sign-in page at `https://mcp.dibs.cc/authorize` sends the code; the relay hashes it, finds the machine, and forwards the request to that Mac, which checks the code itself. A malformed, unknown, expired or spent code gets exactly the answer a Mac gives a wrong code: the same 401, the same words, the same 800 ms.
|
|
117
|
+
- **Everything after is routed by tag.** The authorization code, access token and refresh token a Mac issues through the bare host start with `<machine id>.`; the relay routes `/oauth/token` and `/mcp` by it. The Mac checks the whole string by hash, so a token re-tagged for another machine, with a made-up tag, or made up whole is 401 (with `resource_metadata` for the bare host). The tag is a machine id, which isn't a secret: it's in every grant and token, so it reaches the MCP client and may end up in its logs or a browser's history. On its own it opens nothing. It doesn't sign anyone in (that takes the person's code), doesn't make a token (each is 32 random bytes the Mac checks by hash), and can't spend the signed-in client's budget (only tokens the Mac accepts count against that). The most it does is aim unauthenticated requests at one machine, which the per-machine and per-address limits below already cap.
|
|
118
|
+
|
|
119
|
+
Lookups at the index are limited: 10 a minute per address, and 300 a minute in total for an address's second and later tries. An address's first try in a minute always gets an answer, so a flood from many addresses can't lock out a person typing their code once.
|
|
120
|
+
|
|
121
|
+
### What's forwarded
|
|
122
|
+
|
|
123
|
+
Only `GET|POST /mcp`, `POST /oauth/register`, `GET /oauth/client`, `POST /oauth/authorize`, `POST /oauth/token` and the three `/.well-known` metadata documents, at the bare host or under `/<machine id>/` (metadata also at `/.well-known/<kind>/<machine id>`, the RFC 8414 form). Everything else on mcp.dibs.cc is 404 at the relay, and the Mac refuses anything else again: never the page, never `/api/*`, never the relay's own messages. Requests carry only `Content-Type`, `Authorization`, `Origin`, `Accept` and `Mcp-Protocol-Version` (at most 64 KiB of body) and the connecting address; answers carry only `Content-Type`, `WWW-Authenticate` and `Allow`. The relay sends each as a `{t: "http", id, ...}` message over the Mac's authenticated WebSocket and waits up to 25 s for `{t: "http-res", id, ...}`. The Mac answers 502 instead of any `http-res` over 3.5 MiB once serialized, so a big answer fails one request and never closes the connection.
|
|
124
|
+
|
|
125
|
+
### The sign-in page
|
|
126
|
+
|
|
127
|
+
The relay's own copy of `web/authorize.html`, with SRI and the same strict CSP as the page. It shows first, and largest, the address that will receive the token (the redirect's host, then the full address); the client's name comes after, marked as its own description, since anyone can register any name.
|
|
128
|
+
|
|
129
|
+
### Limits and separation
|
|
130
|
+
|
|
131
|
+
- **Wrong codes** through the relay are counted apart from local ones, per address and per client: 10 wrong in 10 minutes from one address, or for one client, and that address or client waits the window out, right code or not. Past 100 wrong from all addresses together in 10 minutes (a real flood), every remote try waits. Sign-in on the Mac itself is never affected.
|
|
132
|
+
- **Registrations** through the relay (at `/<machine id>/`) are limited to 10 in 10 minutes per address, 100 in all. At most 200 remote clients are kept; when full, the oldest one that never signed in is dropped, and a client that has signed in is never dropped (with none to drop, registration waits). Local clients are never touched.
|
|
133
|
+
- **Per machine,** requests with a token the Mac accepts have their own budget (120 a minute), apart from everything else (discovery, registration, sign-in, rejected tokens: 40 a minute), so strangers can't spend the signed-in client's. At most 8 requests at once per machine, 2 from one address. Per address, 120 requests a minute (Workers rate limiting).
|
|
134
|
+
- **Tokens, grants and clients** made through the relay carry `remote: true` and work only through it; local ones work only locally. `dibs pair --list` shows them as "MCP via mcp.dibs.cc: <client name>"; `--revoke` signs one out.
|
|
135
|
+
- **What a client can do** depends on the code it signed in with, here and through the relay alike. A plain `dibs pair` code gives the read tools: `board`, `agents`, `agent`, `progress`, `stats`, `questions`, `history`, `resource`, `machines`, `messages`. A code from `dibs pair --allow-actions` adds the write tools: `post_progress`, `answer_question`, `tell_agent`, `say_to_person`, `hold`, `release`, `boost_job`, `pause_job`, `resume_job`, `stop_job`. The grant goes from the code to its grant, its tokens and every refresh; `dibs pair --list` shows each client as "can act" or "look only".
|
|
136
|
+
- **A client acts as an agent, never as the person.** Every write runs the CLI as `mcp-<name>-<hash>` (its name made safe, and 4 hex characters of its client id), so its messages and answers reach agents as another agent's, its holds and job changes show under that name on the board and in `dibs history`, and acting on another session's job takes `owner`, as for any agent. No tool installs the hook or sets the hours.
|
|
137
|
+
- **Commands never go through the relay.** A code from `dibs pair --allow-commands` also gives `queue_run` (a command for dibs to run later, as `dibs later` does), but only to a client signed in at this Mac's own `http://127.0.0.1:7421/mcp`. Through mcp.dibs.cc a token could be read in transit, so a token issued there never carries the commands grant, `queue_run` is never listed, and a call to it is refused, whatever code the client signed in with. `dibs pair --list` shows such a local client as "can run commands".
|
|
138
|
+
- Through the relay, writes carry a token the Mac accepts, so they count against the signed budget like any other MCP call.
|
|
139
|
+
- Tool text is one line per field, and the server's instructions tell the client never to follow instructions found in agents' posts, questions or messages.
|
|
140
|
+
|
|
141
|
+
## Accounts (app.dibs.cc/account)
|
|
142
|
+
|
|
143
|
+
An account remembers your Macs, so any browser you sign in with opens all of them, still end to end. `dibs connect --account` adds a Mac; `dibs connect --approve <code>` lets a new browser have the account's key; `dibs connect --list` and `--remove <id>` show and undo it.
|
|
144
|
+
|
|
145
|
+
### The account key and the keyring
|
|
146
|
+
|
|
147
|
+
- The **account key** (AK) is 32 random bytes made by the account's first browser. It never reaches the relay except sealed.
|
|
148
|
+
- The **keyring** is JSON the browser seals with AK (AES-256-GCM, additional data "dibs-keyring-v1") and stores at the relay: one Ed25519 **account device key** (its private key, pkcs8), and for each Mac its machine id, its pinned identity key and fingerprint, the device id it gave the account, and the relay token. Each Mac trusts the account device key as one paired device ("account <id>"), so every browser that opens the keyring talks to every Mac over the same sessions as a phone does (above). The keyring is versioned: a write naming an old version is refused, so two browsers can't overwrite each other's Macs.
|
|
149
|
+
- A browser keeps AK, its session and the Macs in IndexedDB, which belongs to app.dibs.cc alone. The device key is imported there as non-extractable.
|
|
150
|
+
- **Changing the account takes AK.** The first keyring write stores SHA-256 of a proof, HKDF(AK, "dibs-account-auth"); every later write (the keyring, wrapped AKs, adding a Mac, adding or removing a passkey, ending sessions) must carry that proof. A session alone, say from a stolen inbox, can read the sealed keyring and ask a Mac for AK, and nothing else. The relay keeps only the proof's hash, so a copy of its storage can't write either.
|
|
151
|
+
- A sign-in in a browser that already holds an account keeps AK when it's the same account, and asks before switching to another one.
|
|
152
|
+
|
|
153
|
+
### Signing in
|
|
154
|
+
|
|
155
|
+
- **Email link.** The address is typed on a page at `https://mcp.dibs.cc/email`, not on app.dibs.cc: it runs Cloudflare Turnstile, whose script changes without notice and so can't be pinned, and app.dibs.cc runs no script it didn't ship, since AK is in its storage. The relay checks the Turnstile token with Cloudflare (for that host and action, once) before it sends anything. It keeps HMAC-SHA-256 under `ACCOUNT_SECRET` of the trimmed, lowercased address (so it can find the account an address signs in to, and can't list addresses), and sends `https://app.dibs.cc/account#signin=<token>` through Cloudflare Email Sending from no-reply@mail.dibs.cc. The token is 32 random bytes, works once, for 15 minutes, and is in the fragment, so it never lands in a server log or a referrer. The relay stores only its SHA-256. The answer is the same whether or not the address has an account. A first sign-in makes the account.
|
|
156
|
+
- **Passkey.** WebAuthn, checked by hand in the Worker (relay/src/webauthn.js): CBOR, COSE ES256 and EdDSA, attestation "none", the challenge, origin, relying party (app.dibs.cc), user presence, and a sign count that must go up (a copy of a passkey with an older count is refused as a possible clone). User verification (a PIN or biometrics) is required to add one, and a sign-in without it gets a session but not the wrapped AK. Challenges are stateless: the time, 16 random bytes and an HMAC under `ACCOUNT_SECRET` over them, the kind and the account, good for 5 minutes; the relay stores one only once it's been used, so asking for challenges costs it nothing. It stores each passkey's id and public key. The account page lists them and removes one.
|
|
157
|
+
- **PRF.** When the browser supports the WebAuthn PRF extension, adding a passkey wraps AK under HKDF of its PRF output (AES-256-GCM, "dibs-ak-v1"), and the relay stores the wrapped AK. Signing in with that passkey anywhere it's synced opens AK there and then. The relay never sees the PRF output.
|
|
158
|
+
- **A session** is 32 random bytes the browser sends as a bearer header (never a cookie, so a WebSocket upgrade doesn't carry it and the relay can't tie a session to the Macs it opens), good for 30 days; the relay stores its SHA-256, and drops it the first time it's shown for an account that's gone. "Sign out everywhere else" ends every session made before it (the relay stores the time) and gives the asking browser a new one.
|
|
159
|
+
- **Limits:** sign-in links 3 an hour per address from one IP, 20 an hour per address from anywhere (so strangers can't lock a person out), 10 an hour per IP and 300 an hour in all, every request counting toward all four, behind Turnstile, and counted in the object's storage by the clock hour (keyed by the address's and IP's keyed hashes), so an eviction doesn't reset them; sign-in attempts 10 in 10 minutes per IP; 30 account requests a minute per IP (Workers rate limiting); 10 passkeys and 50 Macs per account (a 51st is refused; a Mac joining again replaces its own entry). Expired entries are swept by the object's alarm, 128 keys per kind at a time, never during a request.
|
|
160
|
+
|
|
161
|
+
### A new browser without the key
|
|
162
|
+
|
|
163
|
+
A browser signed in by email (or with a passkey without PRF) has a session but not AK. It asks a Mac of the account, which holds AK (given when it joined, sealed in the pairing's own session, kept in `~/.dibs/relay.json` at 0600). The relay is only a mailbox, and the four steps make it unable to slip in a key of its own:
|
|
164
|
+
|
|
165
|
+
1. The browser posts a commitment: SHA-256("dibs-approve-commit-v1\0" || its ephemeral X25519 key || 32 random bytes).
|
|
166
|
+
2. A member Mac (one that shows the relay the account secret it was given when it joined; the relay keeps the secret's hash) posts its own ephemeral X25519 key.
|
|
167
|
+
3. The browser reveals its key and the random bytes; the Mac checks them against the commitment.
|
|
168
|
+
4. Both derive the same keys: HKDF of the shared secret, salted with the account, the request and both keys, gives an AES key and two 6-digit codes. The browser shows the first; the person types it on the Mac (`dibs connect --approve <code>`); only then does the Mac post AK sealed with that AES key, and print the second code.
|
|
169
|
+
5. The person types the second code into the browser, which opens the sealed AK only if it matches its own. A relay that answers the browser itself, posing as a Mac, knows the browser's codes, but the person has no code from a Mac to type, so its key is never used. Three wrong tries and the browser drops it.
|
|
170
|
+
|
|
171
|
+
Everything the relay lists is its word, so the Mac pins what it saw in step 2: the commitment, the label, and its own 10-minute deadline (it ignores the relay's). A list that later changes the commitment is refused, and a request never gets a second key from the Mac, even after the relay drops the Mac's socket: the ids it has answered stay in `relay.json` until their deadline, and an approval records the keys its codes came from, so the account key is sealed only to those (a relay that reconnected the Mac and replayed an approved id with keys of its own would otherwise be sealed to). A request caught by a reconnect can't be sealed any more: `dibs connect --approve` says so, refuses it so the browser hears no, and the person asks again. A browser reloaded mid-request carries on with the same one (its ephemeral key is kept in IndexedDB as a CryptoKey, which can't be read out); otherwise a relay could see the Mac's key, then grind keys of its own (1.65 million tries, about a minute on one core) until the Mac's code matched the one the person was about to type. With the commitment fixed before the Mac's key is out, a go-between has to choose blind, and its codes match one time in a million. A Mac answers at most 5 waiting browsers per account at once, and the relay keeps at most 5 open requests per account and 2 per session, so one stolen session can't crowd out the person's browsers. A wrong code approves nothing; a code that two waiting browsers show approves neither (both are refused).
|
|
172
|
+
|
|
173
|
+
### What the relay sees and keeps, for accounts
|
|
174
|
+
|
|
175
|
+
- **Keeps:** the email hash, the account id, the hash of AK's proof, passkey ids and public keys and sign counts, AK wrapped under each PRF passkey, the sealed keyring and its version, the hashes of member Macs' account secrets and their machine ids, when sessions were last ended, and for 15 minutes, 30 days, 5 minutes and 10 minutes the hashes of link tokens, sessions, used challenges and approval requests.
|
|
176
|
+
- **Sees in transit:** the email address while it sends the link (TLS ends at Cloudflare), the link and session tokens, the public keys and commitments of approvals, IPs and times, and the size of the keyring.
|
|
177
|
+
- **Never sees:** AK, a PRF output, the keyring's contents (which Macs, their keys, the device key), or any frame between a browser and a Mac.
|
|
178
|
+
- **Can infer:** which Macs a signed-in browser then opens, from timing and IP, since those WebSockets carry no session.
|
|
179
|
+
|
|
180
|
+
## What this doesn't protect against
|
|
181
|
+
|
|
182
|
+
- **Whoever controls app.dibs.cc can serve different JavaScript.** That's the Cloudflare account, anyone holding a deploy token, or Cloudflare itself. A changed page could use the device key (it can't export it) and read the board while the tab is open. SRI doesn't help here: the same party serves the HTML that carries the hashes. Mitigations: the local page at http://127.0.0.1:7421 (`dibs web`) never touches the network; `hashes.txt` and this repo let anyone compare what's served against the source; `dibs pair --list` shows when each device last connected, and `--revoke` cuts one off. A stronger fix would be a page installed on the device (a signed app or extension) instead of one loaded from a server.
|
|
183
|
+
- **The code index is one place every bare-host sign-in goes through.** It holds only code hashes and machine ids, and only for ten minutes, but it's a single object: a big enough flood can slow it, and while the global budget is spent, a person who mistypes their code has to wait a minute to try again (their first try always gets through). The per-machine URL, `https://mcp.dibs.cc/<machine id>/mcp`, doesn't use the index at all.
|
|
184
|
+
- **The relay holds one secret, `REG_SECRET`.** It signs bare-host client ids and nothing else. Whoever has it can mint a client id with any redirect, which is no more than anyone can do by registering; it can't sign anyone in, since that still takes the person's code.
|
|
185
|
+
- **An account is as safe as its key.** Whoever holds AK opens every Mac of the account (as the account device). It's in each signed-in browser's IndexedDB, on each member Mac, and wrapped under each PRF passkey. A stolen synced passkey with PRF, or a browser profile, gives it; so does a person approving the wrong browser at a Mac (the code is there to stop that). `dibs connect --remove <id>` takes a Mac off the account (its account device and key go); signing out clears a browser. There is no way yet to change AK without starting a new account.
|
|
186
|
+
- **Email is only as safe as the inbox.** A sign-in link gives a session, not AK, so a stolen inbox alone opens no Mac and changes nothing on the account; it can still ask a Mac for approval, which is why both codes must match.
|
|
187
|
+
- **Turnstile runs Cloudflare's script on mcp.dibs.cc/email.** It sees the address typed there and could, if changed, send it elsewhere or ask for links; it can't reach app.dibs.cc's storage or AK, and mcp.dibs.cc keeps nothing in the browser.
|
|
188
|
+
- **The account's first write sets its proof.** Whoever writes the keyring first sets it. That's the browser that made the account, at once; an attacker would need the account's first sign-in link before the person used it. An account that got a keyring before proofs existed (2026-11-02, before the accounts CLI shipped, so with no Mac on it) takes no first proof from anyone and can't be changed.
|
|
189
|
+
- **The relay sees remote MCP traffic in transit.** With `dibs relay mcp on`, whatever an MCP client reads (the board, agents' posts and tasks, stats) passes through Cloudflare decrypted, as do the sign-in codes and OAuth tokens on their way. It's never stored, but whoever controls the relay could read or change it, or keep a token and use it until it expires (access tokens last a day) or is revoked. Changing it can't do more than that client's code allowed: read, or with `dibs pair --allow-actions`, act as its `mcp-` agent. `queue_run` never goes through the relay. The page's own channel isn't affected. Leave remote MCP off unless a client elsewhere needs it.
|
|
190
|
+
- **The relay sees each tab's relay token.** A tab presents it so the relay can admit it; the relay keeps only hashes (in the Mac socket's state, gone when it disconnects). The token grants a tab slot and nothing else: it opens no session and decrypts nothing. Someone who steals it from the browser can occupy one of that device's slots until it's revoked.
|
|
191
|
+
- **The relay sees metadata**: which machine id is online and when, how many tabs, the time and padded size of each frame, IP addresses, and the public keys exchanged in pairing and handshakes. It can drop or delay anything (denial of service), but can't read, forge, replay or reorder a frame without the session closing.
|
|
192
|
+
- **The link is the key to pairing.** Anyone who sees it within ten minutes and opens it first pairs instead of the person (the person's own browser then gets "already used", and `dibs pair --list` shows the extra device to revoke). Don't paste it into a chat; scan the QR code with the phone's camera.
|
|
193
|
+
- **The link can reach synced browser history.** The page removes the fragment from the address bar as soon as its script runs, but a browser may record the full URL in its history first, and history syncs (iCloud, a Google or Firefox account). The link is dead after one use and after ten minutes either way, so a synced copy is only a risk in that window, and only before the person's own browser uses it. Scanning the QR code on the phone that will use it keeps it off the Mac's browser history altogether.
|
|
194
|
+
- **A compromised Mac or browser** is out of scope: malware in the person's account can read `~/.dibs`, and a browser extension with access to app.dibs.cc can drive the page.
|
|
195
|
+
- **A device paired with `--allow-actions`** can boost, pause, resume and stop any job, cap an agent, set the pace and cancel scheduled runs, as the person (the record names the device, and no reason text goes with it). It can't message agents, answer their questions, or change the hook or the hours. A lost phone that isn't revoked, or a changed page at app.dibs.cc while that device has it open, can do the same: stopping every job is the worst of it. Pair with actions only the devices that need them, and revoke a lost one at once. Look-only devices, the default, can read the board and nothing else.
|
|
196
|
+
- A pairing whose answer never reaches the browser (the connection dropped between pair1 and pair2) leaves a device on the Mac that no browser holds the key for. It can't be used; `dibs pair --list` shows it and `--revoke` removes it.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Releasing
|
|
2
|
+
|
|
3
|
+
How a version reaches people: dibs.cc, GitHub and the plugin marketplaces. The steps in AGENTS.md (suite twice, version bumps, CHANGELOG) come first; this is what happens after.
|
|
4
|
+
|
|
5
|
+
## Where a release goes
|
|
6
|
+
|
|
7
|
+
| where | what | how people get it |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| `https://dibs.cc/install.sh` | install.sh with the release's sha256 written in | `curl -fsSL https://dibs.cc/install.sh \| sh` |
|
|
10
|
+
| `https://dibs.cc/releases/` | `dibs-vX.tar.gz`, `dibs-vX.tar.gz.sha256`, `install-vX.sh` | install.sh downloads the tarball and always checks its sum |
|
|
11
|
+
| `https://dibs.cc/mac/` | the signed, notarized `dibs-X.dmg` and `latest.json` | `/mac/` redirects to the newest DMG (a 404 until the first one is uploaded); the app checks `latest.json` daily |
|
|
12
|
+
| GitHub | the tag, and a release with GitHub's own tarball (`.github/workflows/release.yml`) | the repo, and the Claude Code and Codex plugin marketplaces |
|
|
13
|
+
|
|
14
|
+
The dibs.cc files live in the R2 bucket `dibs-releases`; the `dibs-waitlist` Worker serves `/install.sh`, `/releases/*` and `/mac/*` from it.
|
|
15
|
+
|
|
16
|
+
## Steps
|
|
17
|
+
|
|
18
|
+
From the public repo, after the AGENTS.md steps and with the version bumped everywhere (test/version.test.mjs checks):
|
|
19
|
+
|
|
20
|
+
1. `git tag vX && git push origin main vX`. The release workflow runs the suite on macOS and Linux and makes the GitHub release.
|
|
21
|
+
2. `sh release.sh` uploads the tarball, its sum and install.sh to dibs.cc, then downloads each back and compares bytes. `DIBS_DRY_RUN=1` builds and checks without uploading.
|
|
22
|
+
3. The Mac app: `dibs run xcode-build -m "mac release" -- app/release.sh`, then `sh release.sh --mac` to upload the DMG and, last, `latest.json`.
|
|
23
|
+
4. Plugin users get the new version once the `version` in `.claude-plugin/plugin.json` changes and their marketplace refreshes (`claude plugin marketplace update dibs`).
|
|
24
|
+
|
|
25
|
+
The tarball is `git archive` of the tag through `gzip -n`, so the same tag always gives the same bytes and the same sum.
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# How dibs decides, and what it promises
|
|
2
|
+
|
|
3
|
+
The README covers using dibs. This is the detail: who goes next, what a lease guarantees, and the knobs that pause, pace and reset work.
|
|
4
|
+
|
|
5
|
+
## How a turn is decided
|
|
6
|
+
|
|
7
|
+
A waiter starts when all of these hold:
|
|
8
|
+
|
|
9
|
+
1. **Each resource it names has a free slot**, or the machine has room for one more on top (see "Running side by side" below).
|
|
10
|
+
2. **Nobody ahead of it in line wants the same resource and could use it.** Your own session's hold on a resource covers your runs on it, and so does the `dibs run` you're nested in. "Ahead" means arrival time, shifted by: its run time (what its command has taken, the median of its last ten runs, or `--est` until dibs has seen it, or 2 minutes for one never seen: shorter than 2 minutes moves it up, longer moves it back by the difference, an hour at most, so a 30-second check goes ahead of a 20-minute suite that arrived up to about 19 minutes before it, and no job waits behind quicker work much longer than it runs), heavy use of the same resources by the same agent in the last hour (5 minutes of use costs a minute, up to 10 minutes back, for fair share: an hour of test runs doesn't cost you your turn on the simulator), and priority (`urgent` +2 hours, `high` +1 hour, `normal` 0, `low` -10 minutes, `idle` -60: a high job goes ahead of a normal one unless that has waited an hour longer. `low` and `idle` run at background priority, and `idle` starts only when nobody else is waiting) and by a deadline that's getting close (`--by`: once slack drops under 20 minutes, you move up, by at most an hour). Every shift is bounded, so nobody waits forever. **The instant lane:** a job whose command usually takes under 15 seconds (the middle of its last ten runs) starts beside anything on a resource whose slots are capacity (tests, browsers, heavy jobs, Xcode builds), past full slots, the line and the load ceiling, as long as memory, disk and swap allow. Never on an exclusive resource (the shared simulator, deploys, a lock) or a simulator pool. **Pairs that slow each other:** dibs compares each command's runs that spent most of their time beside a kind of work (a resource) with its runs that didn't. If it has taken 1.8 times as long or more beside work running now (three runs of each to go on), or makes that job take that long, it waits for that job to finish, but never longer than its own usual run time since it joined (`blocked by together`). **Backfill:** you may pass someone who can't start yet anyway, if you'll be done before they could have started.
|
|
11
|
+
3. **It fits the budgets.** What jobs book never adds up past the memory budget (8 GB by default), whatever the machine looks like: nothing starts past it. Memory counts what each job was handed (asked for, or raised to what its command has used), or what its whole process tree was last measured using when that's more: a job that outgrows its number still fills the machine. **Booked at what it uses:** a run measured for 3 minutes books its peak so far plus 1 GB instead of its ask, never more than its ask. Once its memory has stopped climbing for 2 minutes, it books what it uses now plus 1 GB, or only what it uses once it has been idle 5 minutes. The gap between asks and use goes to waiters, but a waiter let into it (one that wouldn't fit if every running job used its full ask) also needs the machine to show the room: memory pressure normal, swap not growing, and the job plus 3 GB (or a fifth of the machine's memory, if that's more) free by the OS's reading (`kern.memorystatus_level` on macOS, MemAvailable on Linux). So a job that spikes later can't push the machine into swap. Past the booking too: when what running jobs measure using right now, plus the job, fits the budget and the machine shows that same room, it starts; bookings keep a job's peak for minutes after it falls. Swap that's high but holding still doesn't count against that room; only growing swap and memory pressure do. Cores count what each running job was last measured using (every 10 seconds), and what it asked for until its first measurement: suites and builds ask for their peak and spend most of a run under it, and a few too many busy cores only slows everyone a little, so on a quiet machine the CPU budget steps aside. A job as big as the whole budget runs when nothing else is; your own holds and file leases don't count as something else. A run inside your own hold (or nested in your `dibs run`) uses the memory that hold reserved, so the two count once: at the larger of what the hold reserved and what the runs inside it use. Paused jobs keep their memory but take no cores.
|
|
12
|
+
4. **The machine can take it.** Free disk covers the job's need and stays above `minDisk` (5G): below that nothing starts, `urgent` work and runs inside your own hold included. The machine isn't short on memory right now: while the OS reports memory pressure at warning or critical, or swap is over `maxSwap` (4G), grew by more than 512 MB in the last 5 minutes and is still growing over the last minute and a half, work below `urgent` waits while anything else is running. The OS's free-memory reading counts compressed and cached memory as free and can say 60% while the Mac pages gigabytes to disk, and on macOS swap grows on the startup disk. Swap alone doesn't count: macOS keeps it allocated for hours after a crunch ends. dibs keeps a swap reading every 30 seconds in `~/.dibs/swap.json` to see the growth. With nothing else running, one job starts, since waiting can't help then. `"maxSwap": null` turns the swap check off; memory pressure still counts. Swap needs free disk to grow into, so while swap is growing or memory pressure is above normal, work below `urgent` also keeps `swapRoom` (3G) free on top of what it needs (8 GB with the stock `minDisk`), and while free disk falls more than 3 GB in 5 minutes, fast enough to be under that within 10 minutes, it waits for it to hold steady (a disk with plenty free that two builds are writing to holds nobody up); in both cases one job still starts with nothing else running. If the swap, pressure and disk-for-swap waits keep every job out for 10 minutes, counting only starts that went through them (not runs inside your own hold, not urgent work), the smallest and shortest waiter they hold back starts anyway, one at a time until its memory has held steady for 2 minutes, while free disk is over `minDisk` and pressure isn't critical. `"swapRoom": null` turns the room off, and `"minDisk": null` the floor. For jobs of 2 GB or more, the OS also reports at least 15% of memory free. If free disk can't be read, the board says `disk unknown` and `dibs run` says the disk check is off.
|
|
13
|
+
5. **The load is under the ceiling**, when there is one (`maxLoad`, set by `dibs pace`). `urgent` and `high` work skips this rule, and so does work that already holds a lease (below).
|
|
14
|
+
6. **The last user's `onRelease` has finished** putting the resource back.
|
|
15
|
+
7. **A quota has the tokens**, for `quota:<name>` (below).
|
|
16
|
+
|
|
17
|
+
File leases (`files:<path>`) skip rules 3 to 5: holding a path runs nothing. See [files.md](files.md).
|
|
18
|
+
|
|
19
|
+
**Bigger than the machine.** A job that asks for more memory or cores than the budgets hand out at once (`--mem 12G` with an 8G budget, `--cpu 9` with 6 cores) could never start, so `dibs run` and `dibs hold` refuse it at once with exit 2 and the most it can ask for here. Only a number you typed does that: a size dibs chose (the resource's default, or one learned from runs on a bigger machine) is booked at the most this machine hands out, and the job runs. In a group of machines it also names the ones it would fit (`--on <machine>`, or `--anywhere`). A waiter that stops fitting while it waits (the budget was lowered) leaves the line the same way, and its agent hears why through the hook.
|
|
20
|
+
|
|
21
|
+
**Waiting long on the budget.** A waiter held back by the memory or CPU budget for more than `starveAfter` (3 minutes) goes ahead of lighter jobs that would otherwise keep passing it, but only of those that would delay it: dibs works out when enough of what's booked will really end for it to fit (a job already past its usual time counts as running as long again, not as ending in 30 seconds), and a job that will be done before then still starts. A waiter that needs three quarters of the budget or more reserves it only once it could start within 5 minutes; further off, it waits for a quiet moment and other jobs start meanwhile. High and urgent work never waits behind a lower-priority job's reservation. A job that usually uses more than the whole budget goes to an on-demand machine at once when one can take it (docs/machines.md). A job whose run time dibs knows (`--est`, or history) starts past a waiter reserving memory when that waiter's own start rests on a job of unknown length (no `--est`, no history, a hold, or one past its time), as long as it fits now: that start is only a guess.
|
|
22
|
+
|
|
23
|
+
Run times come from history (the median of the last 10 runs of the same command on the same resources), or `--est`, or a 5-minute guess. The same command means the same program and its first three words that aren't flags, each cut to its last path part (`npm run lint`, `node run.mjs` from any folder). For `xcodebuild` it's the first such word, the scheme, the configuration and the action, so a 20-second incremental build and a 7-minute archive of one project learn apart. History written by 0.0.74 and earlier kept only the first word; it counts for a command until the command has history of its own.
|
|
24
|
+
|
|
25
|
+
## What it guarantees
|
|
26
|
+
|
|
27
|
+
- **A lease belongs to a process, not a clock.** `dibs <res> -- cmd` holds until `cmd` exits, however long that takes. No keepalives, and no expiry stealing a live run.
|
|
28
|
+
- **Crashes clean up.** The command runs in its own process group, and children that split off into their own group (browsers, dev servers) are noted every 3 seconds while it runs. When it exits, or dibs is killed, all of them are killed and the slot frees. After a `kill -9`, a small watcher each run leaves behind does it within a second or two; a group that split off in the last 3 seconds before the kill is left to the next dibs call that reads the state. A group whose number was reused by another program is left alone. If the process table can't be read (spawn failures under memory pressure), nothing is reaped until it can. Pids are checked against their start time, so a recycled pid can't pose as a live holder.
|
|
29
|
+
- **Signals pass through.** Ctrl-C or SIGTERM to dibs reaches the command.
|
|
30
|
+
- **Holds end on their own.** `dibs hold` belongs to the Claude session that took it, and ends when that session dies, at `--for` (max 1 hour), or on `dibs release`.
|
|
31
|
+
- **Waiting is never blind.** The board says in a sentence what each line is doing and who's next (`Simulator: onboarding is using it, about 4 min left. Next: ios-checkout.`), and `dibs why` says where you are, when you start and what you're waiting for. A start time is "about N min" only when every job in the way has a run time from history or `--est`; otherwise it's "as soon as X finishes", or unknown when the wait is on the machine (disk, memory, load). `dibs --detail` rows say which rule stops each waiter (`[blocked by slot: xcode-build]`, `[blocked by files: src/auth/**]`, `[blocked by disk: 8.8G free, needs 10G]`, `[behind web-app]`). While you wait, dibs says once where you are, when you start, what you're waiting for, who to message to go first and when the wait gives up; after that, one line when your place or the reason changes, and otherwise every 2 minutes. When it gives up (exit 75) it prints the exact command that keeps your place.
|
|
32
|
+
- **Waiting ends when your turn comes, not at a deadline you didn't pick.** Inside Claude Code, `dibs run` and `dibs hold` wait as long as it takes: Claude Code doesn't kill a Bash command at its timeout, it moves it to the background and tells the agent when it exits, output and all. So don't run it again after the move; a second copy would run the command twice. dibs knows it's there from `CLAUDE_CODE_CHILD_SESSION=1`, which Claude Code sets only in its own tool calls, and goes back to a limit when background tasks are off (`CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1`, or bare mode via `CLAUDE_CODE_SIMPLE=1`). Everywhere else (Codex, scripts, a terminal) dibs gives up at `--max-wait` (8m), which fits a 10-minute tool call. `--wait` lifts the limit anywhere; put it in a background shell if your tool call has a time limit of its own.
|
|
33
|
+
- **Exit 75 is not a failure.** It means your command never started because dibs stopped waiting in line. Your place is kept for 2 minutes: the exact same command again (same session, resources and command; flags may differ) picks it up where it was.
|
|
34
|
+
- **`--notify <file>` says when it's over.** When dibs exits, for any reason, it appends one JSON line to the file: `{"at", "code", "started", "res", "cmd", "cwd", "secs", "pid"}`. `started` is false when the command never ran (exit 75, exit 74 before launch, a bad simulator), true once dibs had recorded it and started it, and null for a job sent to another machine. Give each job its own file and wait for it to fill (`until [ -s build.done ]; do sleep 5; done`, or a Monitor tool) instead of polling the board. A `kill -9` writes nothing. Inside Claude Code you rarely need it: a background Bash call already wakes the agent when it ends.
|
|
35
|
+
- **Random ports.** `--port NAME` puts a free port in `$NAME`, so two Playwright runs never fight over 4173.
|
|
36
|
+
- **Nesting works.** A script running under `dibs run sim` that calls `dibs run sim` itself goes straight ahead instead of queueing behind its own lease. One that needs more than its lease has (`dibs run deploy -- ./ship.sh`, which runs `dibs run xcode-build`) waits only for the rest, and goes ahead of waiters that hold nothing (10 minutes, less than `high`'s hour): it passes the load ceiling, but never jumps `high` or `urgent` work or pauses anyone's job. The board shows `[holds deploy, goes first]`. A session's own `dibs hold` counts the same way for its first 10 minutes. A lease on a resource that isn't configured, a run at `low` or `idle`, or a wait asked for with `-p low` doesn't count. `DIBS_LEASE` counts only when that lease's process is really an ancestor of the caller.
|
|
37
|
+
- **Something always runs.** dibs never leaves every job paused. Each pause it makes on its own (for urgent work, memory pressure or low disk) is refused if it would leave no job running, counting a run nested in a paused one as paused too. If every running job is paused anyway, because the one still going ended, the next dibs call that changes the state (and the watcher every 10 seconds) resumes the paused job closest to done, and `~/.dibs/cool.log` says so. dibs also never pauses a job about to finish: under 2 minutes left, or in the last tenth of its usual run. With nothing running at all, a small job (2 GB or less) that's urgent or known to take under 2 minutes may start past memory the paused jobs and idle holds still book, unless memory pressure is critical. Only the person's own `dibs pause` may leave every job paused. A job dibs stops and requeues for the disk (below) isn't paused: it gives back all its memory, so stopping it may leave nothing running, and that's meant.
|
|
38
|
+
- **Agents know each other by name.** dibs reads the Claude session name from `~/.claude/sessions`, the same name `SendMessage` uses.
|
|
39
|
+
|
|
40
|
+
Exit codes: the command's own, or 75 gave up waiting in line (not a failure: the command never started), 1 nothing matched (`mine`, `release`), 74 not enough disk with nothing running that would free it, 76 lost the coordinator or the other machine before a remote job started (safe to send again), 77 lost it after the job started (it may have run: check first), 127 the command didn't start, 2 bad usage (including a resource name close to a real one, an agent's high or urgent `dibs boost` without `-m`, and a `dibs run` you already have waiting or running), 70 dibs itself crashed (a bug in dibs; report it with `dibs ask`).
|
|
41
|
+
|
|
42
|
+
## Measuring what jobs use
|
|
43
|
+
|
|
44
|
+
`--mem` and `--cpu` (or the resource's defaults) are guesses, and macOS can't cap a process tree without root. So instead of a cage, dibs keeps the numbers honest. While anything runs, one `dibs run` every 10 seconds measures every running lease: physical footprint and CPU over all its process groups, plus a pool simulator's own processes, which run outside the job. A run nested in another is counted once, as itself. The peak goes into history with the run time, and the next run of the same command is planned at the most any of its last 5 measured runs used, when that's more than it asked for. Failed and killed runs count. A command never measured goes by its family: the same resources, program and next word, so `npx playwright test b.spec.ts` learns from `a.spec.ts`, while `npm run lint` learns nothing from `npm run build`. `dibs run` and `dibs when` say so (`xcodebuild build used up to 6.1 GB of memory (it asks for 4.0 GB) in recent runs, so dibs plans for that.`). A command that has used more than the whole memory budget is planned at the budget instead, so it starts once the budget is empty rather than once the machine has no leases at all. `dibs run` says it (`usually uses up to 14 GB of memory, more than the 11 GB dibs shares out at once, so dibs plans it at all 11 GB: it starts when no other job is using that memory.`), the plain board says the waiter is waiting for `all the memory dibs shares out to be free`, and `dibs --detail` marks it `[usually uses ~14G; planned at the 11G budget]`. History is kept per command shape (the program and up to three bare words; xcodebuild by scheme, configuration and action), so a build and a test of one project learn apart.
|
|
45
|
+
|
|
46
|
+
The board flags a running job past what it was handed by more than 10%: `[over: using 6.0G of 4.0G]`. Under memory pressure, the job furthest over is paused first (see below). Ask for what you need with `--mem` and `--cpu`.
|
|
47
|
+
|
|
48
|
+
**Linux.** With `"enforce": true` in config.json, each job runs in a `systemd-run --user --scope` with `MemoryHigh` and `CPUQuota` at its numbers: it's throttled past them, never killed. Where systemd user sessions don't work (containers, WSL1), jobs run as before.
|
|
49
|
+
|
|
50
|
+
**A capped scratch volume (macOS).** `dibs setup scratch [--size 40G]` prints the admin commands that make an APFS volume with a quota for build output, so a runaway build fills its own space instead of the disk every agent shares. dibs runs none of them. `dibs setup scratch --check` says how full it is.
|
|
51
|
+
|
|
52
|
+
## Rate-limit quotas
|
|
53
|
+
|
|
54
|
+
`quota:<name>` shares an API's rate limit between scripts, so they wait their turn instead of getting 429s:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
"quotas": { "asc": { "per": "1h", "limit": 300 } }
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
dibs run quota:asc --cost 3 -- ./upload-screenshots.sh # takes 3 tokens when it starts
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
A bucket holds at most `limit` tokens and refills `limit` every `per`, smoothly. A job waits until its bucket has `--cost` tokens (default 1), after anyone ahead of it for the same bucket, so a big request isn't passed forever by small ones. Tokens come back with time, not when a job ends. A quota costs no slots, memory or cores; combine it with a resource (`dibs run quota:asc,deploy -- ...`) when the work needs one. The board lists every bucket and what's left in it.
|
|
65
|
+
|
|
66
|
+
## Profiles
|
|
67
|
+
|
|
68
|
+
A project whose suite always needs the same resource, ports and sizes can name them once in `~/.dibs/config.json` instead of a wrapper script:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
"profiles": { "playwright:web": { "res": "playwright", "ports": ["WEB", "API"], "mem": "3G", "cpu": 2 } }
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
dibs run playwright:web -m "e2e" -- npm run e2e # playwright, $WEB and $API set, planned at 3G and 2 cores
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
A profile sets `res` (one name, a comma list or an array), `ports`, `mem`, `cpu`, `disk` and `est`. Flags on the command line win over it. `dibs when` and `dibs hold` take profiles too. A profile's name can't be a resource's or start with `files:` or `quota:`, and a bad one fails every call with its key named.
|
|
79
|
+
|
|
80
|
+
## Overrides, by the person or any agent
|
|
81
|
+
|
|
82
|
+
Anyone may `dibs boost`, `pause`, `resume`, `stop` and `cap` any job: the person, or any agent, its own session's work or another's. Each change is kept on the job with who made it (`owner.by`, the pause's `by`, `stopBy`; none means the person), shown on the board (`[boosted by web-app: release blocked]`, `[paused by web-app]`) and logged in `dibs history` as an `override` event with `by` and `byAgent`.
|
|
83
|
+
|
|
84
|
+
- An agent raising a job to `high` or `urgent` passes `-m`, as it does on `dibs run -p`, so everyone sees why.
|
|
85
|
+
- An agent's urgent gets what the person's does: past the swap and disk-room waits (only urgent work starts during those), past paused jobs' booked memory, and pausing low runs for a slot. The hard limits hold for everyone: below `minDisk` nothing starts, the memory budget holds unless the machine really has room, critical memory pressure stops the small-job exceptions, and dibs never pauses every job on its own.
|
|
86
|
+
- A job that was stopped tells its agent who stopped it and to find out why before running it again.
|
|
87
|
+
|
|
88
|
+
## Pausing low-priority work
|
|
89
|
+
|
|
90
|
+
- **For urgent work.** When an `urgent` or `high` waiter is stuck behind a `low` or `idle` run on a full resource, dibs stops that run's whole process tree (SIGSTOP on every process group it has) and lends the waiter its slot. It pauses only as many runs as it takes, and only if that lets the waiter start right away; if something else would still block it (normal work holding another resource it wants, the memory budget, disk), nothing is paused. The paused run resumes (SIGCONT) the moment the waiter's lease ends, whether it finished, crashed, or was killed: whatever dibs call next reads the state does it.
|
|
91
|
+
- **Under memory pressure.** `dibs throttle --watch` reads the OS memory pressure every 10 seconds (`kern.memorystatus_vm_pressure_level` on macOS, `/proc/pressure/memory` on Linux). After two critical readings in a row it pauses one idle or low run (the one furthest over the memory it was handed first, then idle before low, then the most memory), and another after each further two. After a minute of normal readings it resumes one, lighter first, then waits another minute before the next. A warning reading resets both counts, so nothing flaps while the machine hovers. When the watcher stops, it resumes everything it paused; if it dies, the next dibs call does.
|
|
92
|
+
- **When swap fills the disk.** Holding new starts doesn't stop jobs already running from growing. The same watcher reads free disk every 10 seconds: while it's under `minDisk` (never under 3 GB, whatever `minDisk` says) and swap is still growing (or free disk fell more than 3 GB in 5 minutes), and still is over the last minute and a half, it pauses one more run each pass, two when free disk is falling fast enough to be down to 1 GB within two minutes: a job on top first, then `idle`, `low` and `normal` work, newest first. `urgent` and `high` work and holds are never paused, and nothing is killed. Once free disk has been back over the line it pauses at and steady for a minute, it resumes one, then another a minute later. A paused job's memory stays in swap, so the disk may never come back over the line: after 3 minutes with nothing growing or falling it resumes one anyway, since waiting frees nothing then. Free some space or end a paused job yourself if it keeps happening.
|
|
93
|
+
- **Before the disk runs out.** Under twice `minDisk`, the watcher clears caches that rebuild themselves (npm's and Homebrew's, simulators `simctl` calls unavailable, Xcode DerivedData no build has touched in a day), at most every 30 minutes and again when the disk drops under the floor, and logs what it freed in `~/.dibs/cool.log`. Then every active session (a job running or waiting, or a thread with dibs in the last hour) hears through the hook how much is free, what's growing fastest, whose folder holds the most, what dibs freed, and to free its own build output and scratch: again only once free disk has fallen another gigabyte (or something grows fast), at most every 15 minutes, and at once when it drops under the floor; under the floor, every 15 minutes. If the throttle watcher isn't running, the coordinator (`dibs serve`) sends the notes and clears the caches instead. Under the floor the note says to save work now, and names each agent's running jobs (they may fail writing) and waiting ones. A job paused for the disk tells its agent through the hook right away.
|
|
94
|
+
- **Who is filling the disk.** While free disk is under `minDisk`, or a waiter is held for its own disk need, the same watcher measures the session folders in Claude Code's temp folder (`/private/tmp/claude-<uid>/<project>/<session>`) every 10 minutes and keeps the three biggest over 2 GB in `~/.dibs/hogs.json`. Each one's agent (the one that made its biggest scratchpad folder, else the session's main thread) hears once per drop, through the hook, how big it is, what fills it (git worktrees, node_modules) and how to free it. A disk wait (`dibs why`, `dibs when`, the wait message) names the biggest folder and whose session it is, so a waiting agent knows whom to ask: only that session, or the person, may delete there. It also names what grew most since the last reading, 10 minutes before (each session folder, swap, simulators, Xcode build output, caches, and dibs's copies of other machines' jobs, read from twice the floor down): `Growing fastest: swap, up 2.5 GB in 10 min`. Under half a gigabyte isn't named. Memory pressure easing doesn't resume what the disk paused. If the watcher stops while the disk is still short, its disk pauses stay for a minute so the restarted watcher takes them over, instead of every paused job resuming at once.
|
|
95
|
+
- **Never all of them.** None of these pauses the last running job, or one about to finish (see What it guarantees).
|
|
96
|
+
- **When the paused jobs themselves fill the disk.** A paused job keeps its memory, and under memory pressure that memory goes to swap, which fills the disk the job is waiting for. So while free disk is under the line and swap is still growing, the watcher stops one disk-paused job each pass, the one using the most memory, instead of pausing another. The job isn't lost: its own `dibs run` puts it back at the front of its line and runs the command again from the start once there's room, in the same call, and its agent hears why through the hook. Only on resources marked `rerun` (test, playwright, xcode-build and heavy by default; never deploy or sim), never a job a person or agent paused, and never one about to finish. The same goes for a job running far past what it booked, paused or not, even the only one running: at least 4 GB over its booking and either twice it or more than all the memory dibs shares out. That job goes back at the front booked at what it really used (up to the budget), what it used goes into the history so later runs are planned at it too, and it starts again only once that much memory is really free and swap holds still. A job stopped this way once isn't stopped for it again.
|
|
97
|
+
- **What stays the same.** A paused run keeps its lease and its place. Its clock stops, so time-left estimates and run-time history skip the pause. Its owner sees `paused your job for ...` and `resumed your job after ...` on stderr, and the board says why (`paused so web-app's urgent deploy could go first`; `dibs --detail`: `[paused for <who>]`, `[paused: memory pressure]` or `[paused: disk low]`). High and urgent work is never paused, and neither are holds; normal work only for the disk.
|
|
98
|
+
- **Memory.** A stopped process keeps its memory, so a paused run still counts against the memory budget. Only its slot and its cores are lent. Under pressure the OS can compress or swap a stopped job's pages, which is what eases it.
|
|
99
|
+
- **An urgent waiter a rate limit stops** pauses nobody: the quota is checked first.
|
|
100
|
+
- **Which resources.** `pausable` in the resource's config, and `rerun` for the ones whose jobs may be stopped and run again from the start (above). On by default for test, heavy and playwright. Off for xcode-build (`xcodebuild test` drives a simulator a pause can't stop, and pausing a real build is untested), deploy (a half-done deploy with remote timeouts running is worse than a slow one) and sim (the app runs under the simulator, outside the job's process tree, so pausing the script leaves the app and the booted device going). Off for names dibs doesn't know. A run on several resources pauses only if all of them allow it. Timers inside a paused job keep counting wall time, so a test or Playwright timeout may fire right after it resumes; the stderr notice says why.
|
|
101
|
+
- **Windows** has no SIGSTOP, so nothing is ever paused there.
|
|
102
|
+
|
|
103
|
+
## Pace and the load ceiling
|
|
104
|
+
|
|
105
|
+
The budgets above are skipped while the machine looks roomy, and nothing stops new work when the load climbs. `dibs pace` picks how hard dibs drives this machine in one word:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
dibs pace quiet # the fan stays calm and the person at the Mac never feels it
|
|
109
|
+
dibs pace normal # today's budgets, plus a load ceiling at one job per core
|
|
110
|
+
dibs pace max # finish fast: 1.5 busy jobs per core, three quarters of memory
|
|
111
|
+
dibs pace off # back to the numbers in config.json, no ceiling
|
|
112
|
+
dibs pace # what's set now, and what each pace sets on this machine
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Each pace sets six knobs from this machine's cores and memory. On a 10-core 16 GB Mac:
|
|
116
|
+
|
|
117
|
+
| | quiet | normal | max |
|
|
118
|
+
|---|---|---|---|
|
|
119
|
+
| `cores` in use | 4 (40%) | 6 (60%) | 15 (150%) |
|
|
120
|
+
| memory `budget` | 6.5G (40%) | 8G (50%) | 12G (75%) |
|
|
121
|
+
| `maxLoad` | 5 (half the cores) | 10 (one per core) | 15 (1.5 per core) |
|
|
122
|
+
| `coolLoad` (dibs throttle) | 5 | 8 | 12 |
|
|
123
|
+
| budgets skipped when roomy | never | load under 0.6 per core, 35% memory free, memory pressure normal, swap not growing past `maxSwap`, budget not already used up | never |
|
|
124
|
+
| `overlap` | off | fit | squeeze |
|
|
125
|
+
|
|
126
|
+
- **The ceiling.** While the 1-minute load average is above `maxLoad`, new `normal`, `low` and `idle` work waits; `dibs why` and the board say so. `urgent` and `high` work still starts, and so does work that already holds a lease (see nesting), and passes the waiters the ceiling holds back. Work already running is never stopped. Nothing waits on the ceiling forever: a job it alone has held for 20 minutes starts anyway at background priority, on the efficiency cores on Apple silicon, which barely warms the fan the ceiling protects. Jobs started that way share 40% of the cores between them, and one that asks for more still goes when it's alone. Memory, swap and disk limits still hold them. The wait says `held by load since 14:02, starts by 14:22 at the latest`, and that a job a person is waiting on now can go with `-p high -m "why"`, or to another machine with `--on <machine>`. Its agent hears once, through the hook, when it starts this way. On a coordinator with an on-demand machine (docs/machines.md), a job whose turn in line here is further off than 90 seconds (waking and sending) plus its usual run time goes there at once, and a job the machine has held for 2 minutes (the ceiling, the budgets, memory, swap, or a job ahead reserving memory) goes there instead, when it can run there: not when a resource it needs is macOS-only, its command names a macOS tool (`xcrun`, `swift`, `osascript` and the like) or a path of this machine (`/Users/...`, `~/...`), the script it runs imports Apple frameworks (Vision, Quartz, AppKit), its project's `.dibs.json` keeps it here (`stayOn`), or its folder is your home folder or outside git. Its `dibs run` says where it went, and the job runs there as if sent with `--on`.
|
|
127
|
+
- **Bursts.** The load average trails the real load by about a minute: a job started t seconds ago shows in it as only 1 - e^(-t/60s) of its cores. dibs adds the missing part of every recent start to the reading, so ten waiters can't all start under one reading taken before any of them did.
|
|
128
|
+
- **Your own numbers win.** A knob set in `~/.dibs/config.json` to anything but its stock value overrides what the pace says. A file dibs wrote holds every stock value, so those don't count as choices. `maxLoad` works on its own too, without a pace.
|
|
129
|
+
- **No pace, no change.** Without `pace` or `maxLoad` in the config, dibs behaves exactly as before. The board's first line names the pace when there is one.
|
|
130
|
+
|
|
131
|
+
## Running side by side
|
|
132
|
+
|
|
133
|
+
For most resources the slot count stands in for "the machine can take this many". When a resource is full but its jobs leave real room, `overlap` lets one more start on top:
|
|
134
|
+
|
|
135
|
+
- **`fit`.** A job starts on a full resource when its size fits what's really free right now: memory stays above `minFreeMem`, and the load stays under `maxLoad` (one per core without a ceiling). Its size is the most its command used in recent measured runs (see "Measuring what jobs use"), else the `--mem` it asked for. A command dibs has never measured, run without `--mem`, has an unknown cost and waits for a slot.
|
|
136
|
+
- **`squeeze`.** Also: a job that usually takes less than `squeezeUnder` (60s, from its run history, never `--est`) starts if its memory fits, even if its cores take the load past `maxLoad`. You accept that load hit by choosing it. Not once the load is already past it.
|
|
137
|
+
- **`off`.** One job per slot, as before.
|
|
138
|
+
- **Who decides.** `dibs pace` sets it: `quiet` off, `normal` fit, `max` squeeze, and off without a pace. `"overlap"` in `~/.dibs/config.json` wins over the pace. Switching the pace is the person's call: an agent's `dibs pace <word>` is refused.
|
|
139
|
+
- **Never on.** Resources that are one at a time: `exclusive: true` in their config (`sim` and `deploy` by default), names dibs doesn't know (often someone's lock; set `"unknown": { "exclusive": false }` to change that), the `sim-own` pool, resources with an `onRelease` reset, file leases and quotas. Nor holds: a hold keeps the resource to itself.
|
|
140
|
+
- **Bursts.** The free-memory reading lags a start by up to half a minute while a job loads, and the load average by a minute. Jobs started in the last 30 seconds count at their size, less what dibs has already measured them using, and recent starts count against the load as they do for the ceiling.
|
|
141
|
+
- **Fair.** A job on top never takes a slot. When a slot frees, the next waiter in the queue gets it as usual, so a big job waiting for a slot isn't passed for good by small ones running on top. A waiter ahead that fits on top too goes first. The budgets, disk, swap, memory and load rules still apply, and the memory budget always does: a job on top never gets the roomy exception. Nobody is paused or slowed to make room.
|
|
142
|
+
- **Under memory pressure** jobs on top pause first, newest first, and resume last (on resources that allow pausing; `xcode-build` doesn't). They're never killed.
|
|
143
|
+
- **What you see.** `dibs run` says `the test queue is full, so this runs alongside web-app: it needs about 0.5 GB of memory, and there's room.` The plain board says `api is running alongside web-app, since the machine had room` or `squeezed in next to web-app, since it usually takes under a minute`, and `dibs --detail` marks the row `[running alongside web-app]` or `[squeezed in (usually takes under a minute)]`. `dibs why` explains a refusal: `Can't run alongside: it usually needs 6.0 GB of memory and 3.0 GB is free.` A command dibs has never measured needs `--mem` the first time to run alongside.
|
|
144
|
+
|
|
145
|
+
## Putting a resource back
|
|
146
|
+
|
|
147
|
+
A resource can name a command that runs after each lease on it ends, so the next agent finds it the way you want it. For the shared simulator, a reset to the default text size, light mode and a clean status bar:
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
"resources": {
|
|
151
|
+
"sim": { "onRelease": "xcrun simctl ui booted content_size large; xcrun simctl ui booted appearance light; xcrun simctl ui booted increase_contrast disabled; xcrun simctl status_bar booted clear" }
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
- **When.** Once per lease end, however it ends: the command exits, crashes, dibs is killed with `-9` (the next dibs call notices), a hold is released or runs out. A run under your own session's hold isn't the end of your turn: the hold's end is.
|
|
156
|
+
- **The next user waits for it.** Until the reset finishes, the next lease on that resource waits (`Waiting for the simulator to be reset after onboarding's turn`), so it can't race them. It gets `onReleaseTimeout` (default `30s`) and is then killed with everything it started.
|
|
157
|
+
- **It never fails anyone.** It runs outside the state lock in its own process, with `$DIBS_RESOURCE` and `$DIBS_RELEASED_BY` set, from `~/.dibs`. A failure or timeout is logged to `~/.dibs/onrelease.log` with the end of its output; the job's exit code is its own.
|
|
158
|
+
- Use `;` between steps rather than `&&`, so one failing step (no simulator booted) doesn't skip the rest.
|
|
159
|
+
- `booted` means the one booted simulator. While `sim-own` devices are booted too, put the shared simulator's udid in its place (`xcrun simctl list devices booted`).
|
|
160
|
+
|
|
161
|
+
## Throttling
|
|
162
|
+
|
|
163
|
+
`dibs throttle --watch` runs a watcher. When the 1-minute load is over `coolLoad` (8, or what `dibs pace` sets), build and test processes that keep a core hot outside any lease are moved to background priority (the efficiency cores on Apple silicon, nice 10 on Linux). Nothing is killed. The same watcher pauses idle and low runs under heavy memory pressure, and runs below high when swap fills the disk (see above). Moves are logged to `~/.dibs/cool.log`. `dibs throttle` does one pass.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Simulators
|
|
2
|
+
|
|
3
|
+
`sim` is the one shared booted simulator, the one other sessions screenshot. `sim-own` gives your command a simulator nobody else touches:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
dibs run sim-own -- sh -c 'xcrun simctl install "$SIM" App.app && xcrun simctl launch "$SIM" com.example.app'
|
|
7
|
+
dibs run sim-own,xcode-build -- sh -c 'xcodebuild test -scheme App -destination "id=$SIM"' # single quotes: $SIM is set inside the run, not in your shell
|
|
8
|
+
dibs hold sim-own --for 20m # keep one booted across tool calls; it prints the udid
|
|
9
|
+
dibs sims # the pool: devices, who has them, disk they use
|
|
10
|
+
dibs sims prune # delete the idle ones
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
- **What you get.** `$SIM` is the device's udid and `$SIM_NAME` its name (`dibs-pool-1`). It's booted when your command starts and shut down when it exits. A new device is an iPhone 17 on the newest installed iOS runtime; set `pool.deviceType` and `pool.runtime` on `sim-own` in the config to pick others (names like `iPhone 16` and `iOS 18.6` work).
|
|
14
|
+
- **Reuse.** Devices stay between leases, because creating one and its first boot are slow and each costs 1 to 5 GB of disk. You get the device you used last if it's free, so your installed app is still there. A device last used by another agent is erased first (`pool.erase`: `other-agent`, `always` or `never`).
|
|
15
|
+
- **How many at once.** A new one boots only if free memory covers another simulator (`pool.perSim`, 2G) and still leaves `minFreeMem` free. Devices still booting count as taken. `slots` caps it on top of that. A `sim-own` lease counts the simulator plus its job against the memory budget, and `--mem` names the job's own need, so `--mem 2G` hands out 4G.
|
|
16
|
+
- **Crashes.** If the command or dibs dies, even with `kill -9`, the next dibs call anywhere shuts the device down and puts it back in the pool.
|
|
17
|
+
- **What dibs deletes.** Only devices it named `dibs-pool-*`, and only on `dibs sims prune`. It never shuts down, erases or deletes any other simulator. It adopts or prunes only the pool devices this `DIBS_HOME` created (listed in `~/.dibs/pool-made`); another dibs's `dibs-pool-*` devices show as "not made by this dibs" and are left alone.
|