Skip to content

Read Short-Option Clusters Through One Primitive in the Write Guard #3071

Closed

Description

@ptr727

Problem

host-setup/agent-safety/claude/gh-write-guard.py reads a short-option cluster, such as -iu or -mF, in three places, each with its own copy of the rule:

  • _option_takes_next, for a precommand such as sudo -iu root.
  • _short_push_cluster and takes_next in _push_readings, for a push's -o.
  • The cluster branch of _is_commit_value_option, for a commit.

The rule is that the first letter taking a value consumes the rest of the word, and takes the next word only where it ends the word. The commit site checks only the last letter instead. So git commit -mF x is read as -F taking x, while git reads -m taking F as the message and x as a pathspec.

Fix

One primitive, given the letters that take a value, answering whether a cluster takes the next word, and each of the three sites moved onto it. The commit site's verdict changes are to be checked against develop's with a differential over constructed commit commands.

Found by a local review pass on the promotion fix for #3064. The precommand site is new there, and the two older sites are pre-existing.

Activity

  1. added
    pre-existing
    script
    on Oct 15, 2026
  2. ptr727 commented on Oct 16, 2026

    @ptr727
    OwnerAuthor

    A fourth site joins this class in the lane closing #3093, #3080, #3067, #3089, #3079, and #3069: _cluster_repo_value reads a gh short-option cluster for its R, as pflag does, so -dR x is -d -R x. It walks the letters until one takes a value, which takes the rest of the word or the next word, the same rule as the three sites above. The one primitive this issue asks for should take that site too, and the lane leaves it on its own helper so its differential stays scoped to the gh write class.

  3. 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

    pre-existingscript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions