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.

Decisions and deviations, flagged for the architect.

Acceptance.

Follow-ups.

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.md and sub-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: block by default). To soften it, set resource_gate: advise or off in .marvin/PROJECT-INFO.md.
  • Run heavy commands through the gate: the session-start message prints Resource gate: bash '<path>/marvin-resource-gate.sh'; use bash '<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 (or run -- bash -c 'source .venv/bin/activate && pytest'). The persona scope denies source … && bash '<path>' run … to Marvin's sub-agents.
  • Optional new keys: subsession_max (1–3, default 3) and the resource_* tuning keys documented in resource-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) and sub-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, default block).
  • 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_frontmatter reads the whole frontmatter block (up to 200 lines / 16 KiB), so keys past line 40 are read.
  • /marvin:fleet stop refuses 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) through bash +c '…', or through -c text 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; set resource_gate: advise or off to soften that. Update marvin-progress to 0.4.0 for the sub-session view.