v0.42.0 — Session clean-up fix (session worktrees and run state survive clean-up)

Consumers act once.

  1. Pre-set ticket_lint, worktree_sweep and docker_lint if you want other than the defaults.
  2. Run claude plugin update marvin, then /marvin:upgrade-agent-os in one session.
  3. Restart the other open sessions.
  4. Run the upgrade again once the sessions it deferred have finished (upgrades/v0.42.0.md).

Why. Two architects lost live state. The v0.37 sweep treated every worktree under .claude/worktrees/ as disposable. A desktop session that had made no commit of its own and had been quiet for 15 minutes passed every guard, and another session's sweep removed it. The orchestrator's git-ignored ledger, briefs and run reports lived inside that worktree and went with it (CAL-184; Erik's questions).

Host facts (verified on CLI 2.1.289 and the desktop app).

What changed.

Acceptance.

This note's scope: was derived over v0.41.0..HEAD, non-merge commits only; the container epic AOS-222 is excluded.

Upgrade

Consumer-facing: the automatic worktree sweep now removes only worktrees Marvin marked as its own, and run state (ledger, briefs, run reports) lives in the project's .marvin/runs/<session>/<KEY>/, carried there by hooks from any worktree. Rules: .marvin/agents/worktrees.md and .marvin/agents/briefing.md item 11.

  • Before updating the plugin, decide enforcement in .marvin/PROJECT-INFO.md frontmatter. An absent key never enforces: ticket_lint → advise, worktree_sweep → check (report only), docker_lint → advise. The upgrade writes ticket_lint: block, worktree_sweep: on and docker_lint: advise only where a key is missing, directly after ticket_lint.
  • Update with the procedure the SessionStart notice prints. Then run /marvin:upgrade-agent-os in ONE session. It refreshes the cascade (new session-recovery.md; briefing.md, worktrees.md, tidying.md, git-strategy.md, ticket-filing.md, escalation-ladder.md, validation-agent.md, session-budget.md, the kit core). Its new step 6b moves existing run state into the per-session layout with marvin-runs-migrate.sh. It asks which sessions are still open mid-task and defers those.
  • Restart every other open session, because sessions started earlier run the old, unscoped sweep until restarted. /clear or restart the upgrading session before its next task.
  • Once the deferred sessions have finished or been cleared, run /marvin:upgrade-agent-os again. It moves the run state it deferred.
  • Agent worktrees made before this release are never swept by the kit; remove them by hand or leave them. Desktop session worktrees are left to the app's own clean-up.

Changes

Added

  • worktree_sweep: on | check | off in PROJECT-INFO (absent = check, report only); the upgrade writes on when missing.
  • docker_lint: advise | off in PROJECT-INFO (absent = advise).
  • Run-state hooks carry the ledger, build briefs and run reports to the project's .marvin/runs/<UTC>-<session_id>/<KEY|adhoc>/ from any worktree (SessionStart, PostToolUse, SubagentStop, and a Stop catch-up for Bash-written ledgers); a clash keeps both copies and saves a .clash-* sidecar.
  • /marvin:clean-worktrees --mark <path> and the sweep's report-only --at-risk mode.
  • .marvin/agents/session-recovery.md: the procedure when a session's worktree vanishes mid-task.
  • Upgrade step 6b (session readiness) and scripts/marvin-runs-migrate.sh: run state moved into the per-session layout, open sessions deferred, at-risk files and both sweeps' --check lines reported.
  • A Windows CI job (Git Bash), a README Windows section and LF .gitattributes; the job is non-blocking until its first green run.

Changed

  • The worktree sweep removes only worktrees Marvin marked as its own (agent worktrees at stop, hand-made ones via --mark); session and older worktrees are never touched. G8/G9 keep a worktree whose ignored .env* or carried run file is not safely in the main checkout.
  • Ledgers chain across sessions (the newest earlier ledger for a key is authoritative), and the milestone prune follows the per-session layout.
  • An absent ticket_lint now means advise; an unknown explicit value still blocks.
  • The update gate checks the structure of callouts and tails, not their English labels, so a project may write them in its own language.
  • The precedence clause gates only selective staging and the tagging authority; the branch model, merge style and push cadence are project-refinable.
  • Hook stdin paths are decoded and compared in one form (mh_path), so Windows C:\ paths work.
  • The task key rule admits single-letter prefixes and bare GitHub issue numbers.
  • Codex: the forwarder's prompt file is <base>.prompt.txt, and its DATA files are passed as absolute paths under the orchestrator's checkout.

Action needed

  • Pre-set ticket_lint, worktree_sweep and docker_lint before updating the plugin if you want other than the defaults. Restart other open sessions after /marvin:upgrade-agent-os, and run the upgrade again once deferred sessions have finished.