bunqueue-running-machine-gates
Skill601 starsChanged 18 days agoMITView on GitHub
Runs the bunqueue OrbStack Machine gate with scripts/machine-gate.sh. Use when a candidate or release needs its Linux validation on Ubuntu 24.04 or Debian 13 Machines, when asked to validate on OrbStack, orb create or a clean Linux host rather than Docker, when machine-gate.sh exits non-zero or an older manifest shows the retired exit 3, when copying a snapshot of the tree into an isolated Machine, or when reading or rerunning a manifest under artifacts/machines. Not a replacement for bun run test:sandbox, and not for Docker sandbox failures (bunqueue-running-gates).
- Reads credentials
In this repository11 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/bunqueue/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- sdk/CLAUDE.mdCLAUDE.md
- bunqueue-devSkill
- bunqueue-fixing-bugsSkill
- bunqueue-releasingSkill
- bunqueue-running-gatesSkill
- bunqueue-working-autonomouslySkill
- bunqueue-working-sessionsSkill
- bunqueueSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 50
Run it in the background (about 30 minutes.
- Distinctive: line 65
Read the manifest, then copy its verdict, totals and path into the evidence.
- Very specific: line 149
If node: command not found ever appears in a Machine's unit log again, a test started depending on Node: fix that test the same way, never …
- Very specific: line 178
After an interrupt, let the gate finish (up to the 60 s settle window plus the log copies).
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Running the OrbStack Machine gate
The rules are in CLAUDE.md and
docs/testing.md: repository
tests run in isolated OrbStack Machines by default (a macOS-host run is diagnostic
only); the final Linux gate is a fresh Ubuntu 24.04 Machine on the native architecture,
plus Debian 13 for every release; --isolated --isolate-network, never a mount, a
forwarded SSH agent or a secret; CI's Bun and the frozen lockfile; and the Machines
supplement the sandboxes, never replace them. The scripts do all of it on the macOS
host; run the first one rather than typing the steps:
- scripts/machine-gate.sh: the entry point (snapshot, workers, cleanup, verdict);
- scripts/machine-worker.sh: one Machine, from
orb createto a finished run inside it; - scripts/machine-steps.sh: the steps inside a Machine;
- scripts/machine-cleanup.sh: stops the workers, copies the logs back and deletes the Machines, on every exit path;
- scripts/machine-verdict.sh: the manifest and the exit code.
- scripts/machine-process.sh: shared bounded process-tree termination; scripts/machine-claims.sh: atomic host-wide Machine-name claims held through cleanup.
- Bounded calls reuse the shared command runner and its owned process-group lifetime, retaining the deadline until output pipes close and stopping silent descendants even when the command launcher already exited.
- scripts/machine-evidence.sh: validates the final result summaries independently of step exit receipts.
Run it
- Freeze the candidate: stage it, then
git diff --checkandgit diff --cached --checkmust be clean (the Machine gets no.git, so whitespace is checked on the host). Record the tree withgit write-tree. Preview, which creates nothing:
bash .agents/skills/bunqueue-running-machine-gates/scripts/machine-gate.sh --dry-run --tree <hash>Run it in the background (about 30 minutes; the Machines run in parallel). The default is Ubuntu 24.04 and Debian 13, the release scope; outside a release
--distros ubuntu:24.04is the gate:bash .agents/skills/bunqueue-running-machine-gates/scripts/machine-gate.sh --tree <hash>It prints every step that starts or finishes, with its exit code, on stderr (one poll every 30 s) and, at the end, the exit code and
artifacts/machines/<run-id>/manifest.md.orb create, the package install, the Bun download and each copy are stopped after 15 minutes each (exit 4). OrbStack list/info/version and established SSH control queries are bounded to 30 seconds (BUNQUEUE_MACHINE_CONTROL_SECONDSshortens this for tests); a timeout stops the owned command tree before returning infrastructure failure.- Read the manifest, then copy its verdict, totals and path into the evidence.
--steps takes a subset for diagnosis; the verdict is then DIAGNOSTIC (exit 5).
--keep leaves the Machines running for debugging, also with a DIAGNOSTIC verdict;
delete them yourself with orb delete -f <name>.
Each name is claimed atomically before its list/create checks across cooperating
worktrees, under /tmp/bunqueue-machine-claims-$UID (tests override
BUNQUEUE_MACHINE_CLAIM_ROOT). Cleanup releases only its own token after confirmed
deletion, or if creation was never attempted. Uncertain and kept Machines retain
their claim: inspect the name with orb list and reconcile it before removing that
claim directory. A failed create retains its settling marker even for non-timeout
errors, since the daemon may still complete the request.
Any failed copy of gate-out/ or gate-runner.log leaves COPY_INFRA in the
Machine's artifact directory. A passing receipt also needs every requested step
log and the runner log; a partial transfer cannot establish PASS. An interrupted
--keep run exits 4 because its Machines remain present.
Step exit zero also needs complete, nonempty final result summaries: Bun test
counts for unit/tinyfs, suites and assertions for TCP/embedded, both typecheck
project completion markers, and format completion. Reported test/error counters
produce FAIL (1); absent or inconsistent summaries produce infrastructure failure
(4), even when steps.tsv claims success.
Exit codes
| Exit | Verdict | What it means |
| 0 | PASS | evidence: every step passed in every Machine. Release evidence only with both Ubuntu 24.04 and Debian 13; with Ubuntu 24.04 alone, evidence for a candidate (the manifest's Scope line says which) |
| 5 | DIAGNOSTIC | passed, but not evidence: a step subset, no Ubuntu 24.04 Machine, or --keep |
| 1 | FAIL | a real failure: read the step log the manifest names; classify as in bunqueue-running-gates |
| 4 | INFRASTRUCTURE FAILURE | no evidence (OrbStack, whitespace, secret scan, an existing Machine name, creation, isolation, SSH, copy, hash mismatch, timeout), or a Machine not deleted, an interrupted create that never appeared, or no recorded cleanup: that outranks an interrupt |
| 130 | INTERRUPTED | SIGTERM or SIGINT, and every Machine was deleted: nothing is claimed. If cleanup could not delete everything the exit is 4 |
| 2 | usage error | fix the options |
| 3 | retired | never returned since 2026-11-13: it was the known node gap (below); an older manifest that says 3 stays valid for its tree, and --classify now reads that run as 1 |
--classify <run-dir> (the same as machine-verdict.sh <run-dir>) re-reads a run
directory, prints its manifest and exits with the code the run ended with, without
starting a Machine.
Interrupts and cleanup
machine-cleanup.sh runs on every exit path: success, failure, die, SIGTERM and
SIGINT. It signals each live worker so its command supervisor terminates its owned
group without racing a second tree controller. A control query can defer the worker
trap until its 30 s deadline; after that bound plus 5 s, an unresponsive worker tree
is frozen top-down before termination. It signals only children of the gate: a worker that
already exited is dropped from the list, because its pid may belong to another process
by then. It waits up to 60 s for a create the OrbStack daemon may still finish after its
CLI is gone, copies back gate-out/ and gate-runner.log from every Machine the run
created, and deletes them: orb delete -f is repeated, up to five times, until
orb list no longer shows the name, because the CLI can fail (it has panicked) after
the daemon deleted the Machine, and can be stopped before it did. run.env records
cleanup=, a cleanup_note= that says which Machines' logs were copied and which were
not, and delete_exit= with every attempt's exit code; cleanup.log and delete.log
stay in the run directory. If an interrupted create has still not appeared
after that wait, it may appear later: the run is recorded as not-deleted with the
names, exits 4, and you check orb list and delete them by hand. A Machine whose name
already exists is never created, touched or deleted, and a failing orb list is an
infrastructure failure, never "the name is free". Cleanup ignores further signals, and
runs every rsync and orb call in a session of its own: a repeated Ctrl-C signals
the terminal's whole process group, and on real OrbStack it killed the copy and the
delete although the cleanup shell ignored it. It is bounded (a 60 s settle window
plus, per Machine, two 120 s copies, five 120 s deletes, 30 s list queries and
termination grace).
test/agent-skills-machine-lifecycle.test.ts proves all of this with a fake OrbStack.
So an interrupt during orb create does not return at once: the gate waits the settle
window, then exits 130 only when every Machine the run started creating is confirmed
deleted. In every other case the exit is 4, with the names to check.
Node in the Machines
The Machines carry Bun and no Node, and the gate installs no node->bun shim.
test/repro-docker-version-gate-errors.test.ts and
test/repro-release-source-commit.test.ts run CI's version-gate bash, which calls
node -p; until 2026-11-13 six of their tests failed there with
node: command not found, and the gate reported that known gap as exit 3 after
rerunning them with a shim. Each file now links a node to the running Bun
(process.execPath) first on the PATH of the bash it spawns, so they pass in a
Bun-only Machine as they do in the sandbox and in CI, and
test/repro-ci-script-tests-without-node.test.ts runs both with node absent.
The gate therefore has no exception: any unit failure is a real failure (exit 1).
If node: command not found ever appears in a Machine's unit log again, a test
started depending on Node: fix that test the same way, never the gate.
Evidence
OrbStack Machines (machine-gate.sh exit 0, artifacts/machines/<run-id>/manifest.md) on
staged tree <hash>: Ubuntu 24.04 and Debian 13, arm64, Bun <version>: unit
<n> pass / 0 fail / <n> skip, tcp <n>/<n>, embedded <n>/<n>, typecheck and format
clean, tinyfs <n> / 0; Machines deleted.Doing it by hand, and what each manifest field means: references/manual-procedure.md.
What stands behind the scripts, as of 2026-11-13 (OrbStack 2.2.5, macOS 27.2.1, arm64,
on 3e08f75b, before the changes of that day's review):
| Proven on real OrbStack | Proven with fakes only |
| The canonical run: exit 3 (the node gap, since retired) in 24 min 41 s; in both Machines unit 11871 pass / 6 fail / 399 skip, tcp 69/69 suites and 553/553, embedded 43/43 and 349/349, tinyfs 9 / 0 | A create that appears after the settle window (exit 4, not deleted) |
SIGTERM and SIGINT during orb create, during provisioning and during the steps: exit 130, no Machine and no process left | A failing or slow orb list |
A step subset and --keep: exit 5; an existing Machine name: exit 4, the Machine untouched | The rule that only children of the gate are signalled |
The gap: six node-dependent tests failed, 22 / 0 with the shim; the fix in the tests is proven on the host with node absent, not yet on OrbStack | Exit 0 and exit 1 (no real log ended that way), and the other infrastructure failures |
| The 15-minute bounds, the repeated delete and the detached cleanup: written after the real run, which showed the need; not yet rerun on OrbStack | |
An amd64 host |
Gotchas
- After an interrupt, let the gate finish (up to the 60 s settle window plus the log
copies). A second, harder kill (
kill -9) skips the cleanup and can leave a Machine that the daemon creates later; read the exit code, and after a 4 runorb list. - Started with
&from a non-interactive shell (an agent's background command), the gate ignores SIGINT: that is the shell's rule for background jobs. Stop it with SIGTERM (kill <pid>), which runs the same cleanup. - The snapshot is
git archive <tree>: untracked files are not in it, even intended ones. Stage them, or build a tree from a temporary index (manual procedure, step 1). orb pushcannot write an isolated Machine; the copy isrsyncover OrbStack's SSH endpoint (MACHINE@orb), sorsyncis installed in the Machine first. The SSH key stays on macOS, withForwardAgent=noandClearAllForwardings=yes.- Debian 13 has no
curlby default and the Bun installer needsunzip; the worker installsca-certificates curl jq openssl procps rsync unzip. - The unit suite needs
bun run build:clientfirst, as in CI andDockerfile.test;machine-steps.shruns it as its own step. - The Machines keep the macOS host's local time zone with
TZunset, unlike the sandbox (TZ=UTC). The manifest records it; a date-dependent failure that only a Machine shows is an environment finding to investigate, not noise. - Requested resources are not effective resources: OrbStack clamps a Machine to its
global limits, so the manifest records the cgroup
cpu.maxandmemory.max. - A translated
amd64Machine on Apple Silicon is diagnostic only; the gate always creates Machines of the host's native architecture. - Running the Machines while a sandbox runs on the same host shares the OrbStack VM's CPUs. Results stay valid, but compare durations only between quiet runs.
- The Machines and containers share OrbStack's kernel: strong process and filesystem isolation, not a separate-kernel boundary.
--isolate-networkis not a network sandbox. Measured on OrbStack 2.2.5: a Machine created with it cannot reachhost.orb.internalor the gateway, but it reached a listener in the sibling Machine and the Mac's LAN address, and it has the internet (the gate installs packages and Bun through it). Only the Docker sandbox runs tests without a network; never treat a Machine as offline.create.log,rsync.loganddelete.loghold little more than(exit N)lines:orbandrsyncprint nothing when they are not on a terminal. The exit codes are the record.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

