Resource gate
Every Marvin project on this machine shares one queue for heavy runs. Parallel sessions never start several test suites or Docker stacks at once and take the machine down.
How it holds
On a narrow screen, scroll the diagram sideways.
- It protects every mode: a solo session, sub-sessions and a fleet.
- It holds, queues and reports. It never kills, stops, takes down or removes anything.
What counts as heavy
- Docker:
docker compose … up|run|build,docker run,docker build. - Test runners:
npm|pnpm|yarn|bun test,pytest,phpunit,pest,go test,cargo test,mvn|gradle test,php artisan test. - Your own additions in
resource_heavy_cmds, minusresource_light_cmds. - Each
&&,;or|segment is judged on its leading command, never as a substring.
Running one
bash '<gate path>' run -- npm test
- The gate path is the plugin's own script. Each session start prints it:
Resource gate: bash '…'. The hook's hold message names it too. - Every heavy segment gets its own
run. A second heavy segment after a gated one is held too. - Waiting prints one line each time the place in line moves.
- Past
--wait(default 540 s) it exits 75:QUEUED: position <n>, holder …orHELD: free memory … below the floor. Another project sees only the holder's leading command words. - Give that Bash call a 10-minute timeout (
timeout: 600000) or run it in the background. The 2-minute default would kill a queued run. - Exit 75 is a wait, never a failed round and never a reason to change code. Re-run, or start a long run in the background.
checkandstatusstart nothing.statuslists the queue, free memory, the stack slots and each worktree's Docker memory.
Memory: the floor decides
- The floor is the hard gate: free memory at least 15 % of the total, on the host and, with Docker Desktop, inside its VM.
- The 10 % flag: a worktree whose containers use more is marked
OVER. Only its creator or you stop it. - Before a new worktree,
check --new-worktreereserves that worktree's last measured stack size first. - No Docker, or a Docker that does not answer in time: host only. The host floor still holds.
- Where memory cannot be read (no
vm_stat, no/proc/meminfo) or the state is not writable, eachrunandcheckprintsADVISE:and does not hold. - A stack without the
marvin.*labels frees its slot after 120 s. Only the floor protects it then.
Settings
| Key | Default | Sets |
|---|---|---|
resource_gate | block | The hook: block, advise or off. |
resource_free_min_pct | 15 | The floor, % free. |
resource_run_max_pct | 10 | The flag, % per worktree. |
resource_stack_slots | 1 | Detached stacks at once. |
resource_hold_max_min | 120 | Minutes until a holder is stale. |
All optional, in .marvin/PROJECT-INFO.md. Details: resource-gate.md, the hook.