v0.50.0 — Sub-sessions and the resource gate
Consumers: run /marvin:upgrade-agent-os. Heavy commands are now held unless they run through the gate; set resource_gate: advise or off to soften that. Update marvin-progress to 0.4.0. See upgrades/v0.50.0.md.
Why. The architect wanted a solo orchestrator to stop filling its own context with every epic and to hand work units to fresh sessions itself (epic AOS-386). The hard limit is RAM: each worktree can start a full copy of the project, Docker stack included, and parallel stacks have crashed the machine. So sessions may run in parallel only for light work, and heavy runs queue one at a time across the whole machine.
What changed.
- The gate (AOS-387).
scripts/marvin-resource-gate.sh run|check|statuskeeps one FIFO queue for heavy runs across every Marvin project on the machine, under~/.marvin/resource-gate/. A run starts only while free memory is at least 15 % on the host and, under Docker Desktop, in its VM. Exit 75 means still queued or held, never a failure. Detached stacks take a stack slot until theirdown. A meter flags a worktree over 10 % of memory but never holds or stops it. Every reading is written as a snapshot for the progress panel. The gate holds, queues and reports; it never stops anything. - The hook and the persona scope (AOS-388). A PreToolUse hook holds tests, Docker builds and stacks run outside the gate (
resource_gate: block | advise | off), without echoing the command. The persona scope lets Marvin's sub-agents run the plugin's own gate and still checks what the gate runs.scripts/lib/marvin-shell-split.awkis the Docker lint's splitter, shared. - Settings (AOS-389).
subsession_maxand theresource_*keys inPROJECT-INFO.md, checked by the project-info skill and documented inresource-gate.md. - Guides (AOS-390).
resource-gate.md,sub-sessions.md(the orchestrator) andsub-session.md(the unit's session), with their cascade lines in the kit core. - Context hook (AOS-391) and progress contract (AOS-393).
mode=subin the worktree marker gives the child and the orchestrator their own texts, the marker mode and the sub-session pane title. - Questions (AOS-392). A sub-session's question can be answered from the orchestrator's sidebar too; the sub-session's own mod picks the answer up, only in the worktree it was answered in.
- marvin-progress 0.4.0 (AOS-394). The sub-session pane, a RAM column, agents grouped by unit, and units in the band.
- Docs (AOS-395). Sub-sessions and Resource gate concept pages; sub-session sections on the fleet, marvin-progress and questions-sidebar pages; README rows and rule 8.
- Final fix wave (AOS-386). SessionStart prints the gate's path; the guides tell callers to give the Bash call
timeout: 600000or run it in the background;mh_frontmatterreads the whole frontmatter block; every Docker call is time-bounded; records that cross projects keep only the leading command words;/marvin:fleet stoprefuses a sub-session marker.
Decisions and deviations, flagged for the architect.
- Recognising the gate only adds checks. Three review rounds each closed a shell-parse route around the persona-scope exemption and each re-review found another. A read-only rethink replaced the exemption with one rule: every
marvin-resource-gate.sh runword adds a check of its tail, and the gate path is masked only for confirmed command positions whose count matches its whole-word occurrences. Rare forms are now denied:source … && bash <gate> run …, nesting past depth 3,su -c,flock -c,script -c. - Two older holes closed (Security). v0.49.0 and earlier let a sub-agent write a protected path through
bash +c '…', or through-ctext running a shell that reads the command's stdin (bash -c bash <<< '…'). Both are now denied; consumers on v0.49.0 or earlier should upgrade. - The hold message never echoes the command. It names the gate prefix and says "the same command" (spec note 4).
- No questions nudge. The sub-session's own mod polls while a question waits, so no cross-session text is sent (spec note 5).
- Open: the sandbox write allow-list. Whether install should add
~/.marvin/resource-gate/to a project sandbox's allow-list (spec call 3) is left to the architect; without it, a sandboxed session's gate only advises.
Acceptance.
- Documentation (repo rule 10): README inventory rows for the gate script, its suite, the shared splitter and the three guides; the suite count (25) and list; rule 8 lists "resource gate" in
CLAUDE.mdandAGENTS.md, byte-identical; the PROJECT-INFO template carries the new keys; the install, upgrade, project-info and fleet skills are updated; the fleet, hooks, home, marvin-progress and questions-sidebar pages are updated and regenerated. - Site (repo rule 11): (a) the sub-session flow and the gate each have a concept page with an inline diagram; (b) three screenshots from a real session on the release builds (kit
release/0.50.0, marvin-progressrelease/0.4.0, Claude Code 2.1.332, a scratch install with two sub-sessions): the Sub-sessions pane (subsessions.png), its RAM column with a stack started through the gate (ram-column.png), and a sub-session's question answered by the architect from the orchestrator's Questions pane (subsession-answer.png). Each is cropped to the pane, with no path, account or private content. The layout sketches stay, labelled as sketches. - Gates on
release/0.50.0(Claude Code 2.1.332): all 25scripts/test-*.shsuites pass twice, normally and with SIGPIPE ignored (trap '' PIPE): persona-scope 2159, resource-gate 472, hook-lib 301, session-hook 228, build-docs 731 checks (733 after the screenshots, re-run in both modes withvalidate-kit.sh).validate-kit.sh,claude plugin validate .(passed with the pre-existing warning) andclaude plugin test .(232 tests) pass. In marvin-progress,claude plugin validate .andclaude plugin test .pass (191 tests). No migration script, somutate-migrations.shdoes not apply. - Scratch install (repo rule 5): a fresh
git initrepo with the Local tracker: the placeholder check exits 0; the three guides and both cascade lines are present (kit core 62 lines);npm testin Claude's Bash is denied without echoing it, and passes throughrun(exit 0);resource_gate: adviseturns the denial into context; SessionStart prints the gate line; the persona scope allows a gatednpm testand denies a gatedtee .claude/settings.json. - Reviews: every story had a task review with spec and quality verdicts. AOS-388 took five fix rounds and a rethink (above). The whole-branch review and a separate security review found four important items (frontmatter cut at 40 lines, no gate path for callers, the Bash 2-minute default, unbounded Docker calls) and security items F1–F3 and F6; one fix wave closed them, and a scoped re-review's residuals were fixed and re-checked.
Follow-ups.
- Filed: AOS-405 (a visual pass of the new pages; the remaining questions-sidebar shots), AOS-406 (the Docker lint onto the shared splitter), AOS-407 (heavy defaults for make, npx jest, vitest, playwright), AOS-408 (forms the persona scope does not parse:
su -c,trap,flock -c,script -c, depth past 3, a copied gate, zsh and dash), AOS-409 (security F4, F5, F7), AOS-410 (marvin-progress: RAM staleness, snapshot read race, pane title, marker spaces), AOS-411 (GitHub bare-number keys in the marker), AOS-412 (a stale SessionStart path after auto-update,registry.tsfrontmatter bound, a newline in a holder record), AOS-413 (test hardening); Windows advise-only stays with AOS-227. - Filed: AOS-414, seen in the live shoot: the HELD line calls free memory after the stack reservation "free memory";
/marvin-fleetsays "not a fleet master" while the Sub-sessions pane opens; an orchestrator's band can keep counting a question answered from another window's pane until it refreshes.
Upgrade
Consumer-facing: sub-sessions and a machine-wide resource gate. A solo orchestrator can run up to three work units as sub-sessions, and heavy runs (tests, Docker builds and stacks) queue one at a time across the machine with a free-RAM floor. Map: docs site pages Sub-sessions and Resource gate.
- Update the plugin, then run
/marvin:upgrade-agent-os. The refresh brings three new guides:.marvin/agents/resource-gate.md,sub-sessions.mdandsub-session.md, and adds their lines to.marvin/CLAUDE.marvin.md. - The gate now holds heavy commands that Claude runs outside the queue (
resource_gate: blockby default). To soften it, setresource_gate: adviseoroffin.marvin/PROJECT-INFO.md. - Run heavy commands through the gate: the session-start message prints
Resource gate: bash '<path>/marvin-resource-gate.sh'; usebash '<path>' run -- <command>with a Bash timeout of 600000 ms, or in the background. Exit 75 means still queued: run it again. - With a virtualenv, run
bash '<path>' run -- .venv/bin/pytest(orrun -- bash -c 'source .venv/bin/activate && pytest'). The persona scope deniessource … && bash '<path>' run …to Marvin's sub-agents. - Optional new keys:
subsession_max(1–3, default 3) and theresource_*tuning keys documented inresource-gate.md. Absent keys take their defaults. - Gate state lives in
~/.marvin/resource-gate/. Under a sandbox that blocks writes there, the gate only advises. - Update marvin-progress to 0.4.0 for the sub-session pane, the RAM column and units in the band.
- No migration script.
Changes
Added
- Sub-sessions: a solo orchestrator runs up to three work units (
subsession_max, 1–3) as sessions in their own worktrees. It reads their doorbell lines (SUB <KEY> <event>: <line>), merges each finished unit and cleans up after it. Guides:sub-sessions.md(orchestrator) andsub-session.md(the unit's session). - Resource gate,
scripts/marvin-resource-gate.sh run|check|status|hook: one machine-wide FIFO queue for heavy runs, a free-memory floor on the host and the Docker VM, stack slots, a per-worktree memory meter and a snapshot for the progress panel. Exit 75 means still queued. It never stops anything. Guide:resource-gate.md. - A PreToolUse hook holds heavy commands (tests, Docker builds and stacks) that Claude runs outside the gate (
resource_gate: block | advise | off, defaultblock). - Settings:
subsession_max,resource_gate,resource_run_max_pct,resource_free_min_pct,resource_hold_max_min,resource_stack_slots,resource_heavy_cmds,resource_light_cmds. - SessionStart prints the gate's path (
Resource gate: bash '<path>') in Marvin projects. scripts/test-resource-gate.sh, the 25th suite, run by CI;scripts/lib/marvin-shell-split.awk, the shared word splitter.- Docs site: Sub-sessions and Resource gate concept pages, with sub-session sections on the fleet, marvin-progress and questions-sidebar pages.
Changed
- Questions: a sub-session's question can be answered from the orchestrator's sidebar too; the sub-session's own mod picks the answer up.
- The context hook and the progress contract know
mode=sub(child and orchestrator texts, the marker mode, the sub-session pane title). - The persona scope lets Marvin's sub-agents run the plugin's own gate, and still checks the command the gate runs.
- The Docker lint also reads a command run through the gate.
mh_frontmatterreads the whole frontmatter block (up to 200 lines / 16 KiB), so keys past line 40 are read./marvin:fleet stoprefuses a sub-session marker and names the mode.
Security
- The gate takes its command as argv, never through
eval. Its numbers are checked as whole digit words before any arithmetic. - Records that cross projects keep only the program and its first plain subcommand word, with secret patterns redacted. Names are cut to 64 bytes of
[A-Za-z0-9._-]. Every Docker call is time-bounded. - Recognising the gate only adds checks in the persona scope: the gated command, its here-strings and heredocs, and the gate's stdin are all checked.
- Closes two persona-scope holes present in v0.49.0 and earlier: a sub-agent could write a protected path (e.g.
.claude/settings.json) throughbash +c '…', or through-ctext that runs a shell reading the command's stdin (bash -c bash <<< '…'). Both are now denied; upgrade to close them.
Action needed
- Run
/marvin:upgrade-agent-os. Heavy commands are now held unless run through the gate; setresource_gate: adviseoroffto soften that. Update marvin-progress to 0.4.0 for the sub-session view.