Skip to content

Share One Command-Position Walker Across the Write Guard's Readers #3308

Closed

Description

@ptr727

Context

Raised by the Copilot review and the local review passes on #3306. It is a design consolidation, not a defect in any one verdict.

The Write Guard Carries Several Copies of the Same Command-Position Walk

host-setup/agent-safety/claude/gh-write-guard.py now decides "may this word run as a command before the push" in several places, each with its own exclusions:

  • _head_may_move and _config_may_change each walk the tokens before a push with the same skeleton (range(end), skip, a gh arm, a git arm), with different predicates. They have drifted on wrapper shells and substitutions.
  • _word_runs, _is_run_time_command, and the gh-merge reader each re-derive "right after an unquoted (, or where _runs_as_command says". They differ on array assignments, case/for ... in lists, and a gh word before the run-time word.
  • _hooks_path_reason's commit/push clause overlaps the bypass block's _overrides_hooks_path check for the -c and --config-env spellings.

Each copy is a place a later fix lands in one reader and not its siblings, which is how the #3306 review rounds kept finding the same class.

Possible Direction

One ordered walker taking a predicate, used by _head_may_move and _config_may_change. One command-position helper carrying the union of exclusions, used at every site that asks. One hooks-path predicate both sites call.

Activity

  1. added
    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

    script

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions