Skip to content

Scope a Wrapper's GIT_DIR to Its Own Body in the Write Guard #3309

Closed

Description

@ptr727

Context

Raised by the Copilot review on #3306, which closed #3078's wrapper half.

A Wrapper's GIT_DIR Is Applied to Every Wrapper Body in the Command

host-setup/agent-safety/claude/gh-write-guard.py carries a GIT_DIR or GIT_WORK_TREE that reaches a wrapper shell into the git commands in its body (_wrapper_dir_prefixes, _all_git_invocations). It collects those pairs from every wrapper in the command, then reads each inner invocation again under each pair, since it does not pair a body with the wrapper that runs it.

This only adds readings, so it fails closed, but it over-denies. Constructed case: GIT_WORK_TREE=/example/primary bash -c 'git status'; bash -c 'git reset --hard', run from a linked worktree. The second wrapper's reset --hard is read against /example/primary too, and rule 6 denies it, though nothing points that wrapper there.

Possible Direction

Have _wrapper_env_groups return each shell's bodies beside its assignments, and carry each pair only into the invocations read from those bodies and the bodies nested in them.

Activity

  1. added
    bug
    script
    on Oct 21, 2026
  2. ptr727 commented on Oct 23, 2026

    @ptr727
    OwnerAuthor

    Closed as out of the write guard's scope under the maintainer's decision (ptr727, 2026-10-23) on #3391, item 1. The guard bounds a good-faith agent's mistake rather than an adversary, so a parse gap reached only by a command shape no agent plausibly types in a coding session is closed rather than fixed, and the guard's own growth is a cost each later review pays again. The scope statement lands in the guard's docstring and README under #3391. Reopen only with a command a session actually produced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugscript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions