oliver-zehentleitner / maity

runner: a harness's isolated git worktree in a placement's clone must not block maity

Sign in to report

tsk-d5e4d9s95ytj Done Maity Coder Claude 003

Twice on 2026-11-20 a Claude Code subagent in a placed session created an isolated git worktree in the placement's clone (under .claude/worktrees/). While a worktree exists, maity refuses git in that clone ("Worktrees are not supported under the runner yet"), so maity report and maity gh pr create fail, and the placed session cannot remove the worktree itself (git worktree remove is refused by its sandbox). Both times the owner had to remove it by hand on the host.

Done when one of these holds, decided in the PR with a Keep the Why entry:

  • the runner's harness settings for a placement keep the harness from creating worktrees in the clone (for Claude Code: the worktree isolation of subagents and EnterWorktree switched off or denied), and maity runner check reports it; or
  • the runner removes a clean, harness-made worktree under .claude/worktrees/ at the session's next start or close (never one with uncommitted changes, which is reported instead), and maity's refusal names that way out.

Also: docs/runners.md and the agents' help say that worktree isolation is not available under the runner. Tests for the chosen path. Security leg on the PR (the clone boundary).

Notes

  1. Maity Test Team · Nov 21, 2026, 11:57 UTC

    Tester result (maity-test-team) for #2075, no git worktree in a placed Claude Code session. Run headless on origin/main 35b330c73. There's no Claude Code binary on my box, so this is not a live test of Claude Code's handling. PASS, nothing filed.

    Suite: pytest cli/tests -k worktree: 82 passed.

    Generated settings (adapters.claude_settings, the test_adapters context):

    • Claude Code 2.1.325, unsandboxed and sandboxed: EnterWorktree is in deny. So are Bash(git worktree) and Bash(git worktree *). A WorktreeCreate hook is set and disableAllHooks: false is written.
    • No allow rule names worktree. GIT_SUBCOMMANDS has no global option such as -C, so under dontAsk git -C . worktree … isn't allowed either.
    • Version 2.1.49 or unknown: the two denies stay, and there's no hook and no disableAllHooks, as the floor (2.1.50) says. The worktree_hook_version_ok check gives 2.1.49 → False, 2.1.50 → True, 2.1.326 → True, None → False.

    Hook line run in sh: CLAUDE_WORKTREE_HOOK exits 2 with nothing on stdout and the reason on stderr ("git worktrees are off in a placement clone; work in the clone itself").

    Leftover detection (worktree.registrations, on scratch git repos; result is (cleared, left)):

    • Plain clone → (0, 0).
    • Worktree under .claude/worktrees/agent-1 → (1, 0). After deleting its directory (dangling) → (1, 0).
    • Worktree outside .claude → (0, 1), left for a person.
    • A bare directory under .claude/worktrees/ → (0, 0) registrations, as it should be.
    • .claude/worktrees as a symlink → (0, 0), so it counts as nothing.

    Not covered:

    • That Claude Code really hides EnterWorktree and honours the WorktreeCreate hook. That needs a live binary ≥ 2.1.50 on a runner.
    • maity runner check against a real runner or ssh host.