Skip to content

Read Commit and Clean Short-Option Clusters Only Up to a Value-Taking Letter in the Write Guard #3783

Closed

Description

@ptr727

Found by the local strict review of the fix for #3720, on code that change did not touch. Both are in host-setup/agent-safety/claude/gh-write-guard.py, and both are the class #3720 fixed in _push_targets: a short-option cluster read past its first value-taking letter.

  • _skips_hooks, commit (requirement 4). i += a[-1] in "mFcCt" consumes the next word whenever the cluster's last letter takes a value, even when the value is attached. So git commit -mtest --no-verify skips --no-verify as the message's value, and _skips_hooks("commit", ["-mtest", "--no-verify"]) returns False. -mwip --no-verify returns True. Any attached message ending in m, F, c, C, or t bypasses the explicit-bypass check, -n as well as --no-verify. The next word should be consumed only when the value-taking letter is the last character of the word.
  • _primary_checkout_verdict, clean (requirement 6). git clean takes a value through -e <pattern>, but the reader looks for n or f anywhere in an all-letter cluster. So git clean -fen reads n as a dry run although git reads it as force with exclude n. git clean -fe.env is not all letters, so its f is missed. Each is allowed in a primary checkout, and each deletes untracked files. The attached -e form is rare.

The review also raised the design point that the guard now reads short clusters three different ways. One helper returning the flags before the first value-taking letter, and whether the next word is consumed, would serve _push_targets, _skips_hooks, and the clean reader. #3720 fixed only _push_targets, since that was the approved scope.

Self-test rows for -mtest --no-verify, -mtest -n, clean -fen, and clean -fe.env would pin it.

Activity

  1. added
    pre-existing
    on Nov 1, 2026
  2. ptr727 commented on Nov 1, 2026

    @ptr727
    OwnerAuthor

    A further site of the same class, raised by the next local pass on #3720: the git branch rename check (re.fullmatch(r"-[A-Za-z]*[mM][A-Za-z]*|--mo.*", a), in the branch-switch reader) reads an m inside an attached -u value as -m. So git branch -umain && git push is read as a command that may switch the branch. That only denies more, so it is no bypass, but the shared helper should cover this site too.

  3. ptr727 commented on Nov 2, 2026

    @ptr727
    OwnerAuthor

    Decision triage: researched question

    This fix edits host-setup/agent-safety/, so the design needs the maintainer's approval before an attended run implements it. What design should replace the guard's three or four short-option-cluster readers, so a commit, clean, and branch cluster is read only up to its first value-taking letter?

    Options, recommended first:

    1. (Recommended) One shared helper, extended to separated values. A helper taking a word, its value-taking letters, and its optional-value letters returns the flags before the first value letter, and whether the next word is consumed (only when that letter ends the word). _push_targets, _skips_hooks, the clean reader, and the git branch rename check all call it. The clean reader also skips the word after -e and --exclude, because the separated forms clean -f -e -n and clean -f --exclude -n are read as dry runs while git takes -n as the exclude pattern, a gap the issue does not list. It replaces inline readers rather than adding one, against a 2208-line guard and a 2500-line ceiling.
    2. Per-site minimal patches. In _skips_hooks consume the next word only when the breaking letter ends the word, and make the clean reader stop at e and skip the value after -e and --exclude. Leave the branch site, since it only over-denies. Smallest diff, but it keeps four readers, which is how Read a Push Option Attached to -o as Its Value in the Write Guard #3720 and then Read Commit and Clean Short-Option Clusters Only Up to a Value-Taking Letter in the Write Guard #3783 were each found by successive review passes.
    3. Fail closed on clean plus the commit patch. In a primary checkout, deny any clean carrying -e, --exclude, or an e in a short cluster, and give _skips_hooks the one-line fix. Nothing to parse for the rare exclude form, and the remedy is a worktree. It over-denies a dry run with an exclude pattern and leaves the readers divergent.

    Evidence: #3783 (comment); host-setup/agent-safety/claude/gh-write-guard.py on develop 23c7d78: :854-856 (_push_targets, fixed by #3784), :976-991 (_skips_hooks), :1022-1023 (branch rename), :1143-1147 (clean reader); #3784 body (2208 lines against tests/test_guard_size.py MAX_LINES = 2500); host-setup/agent-safety/README.md:39,43. Constructed cases against the develop guard functions: _skips_hooks("commit", ["-mtest", "--no-verify"]) returns False, and the primary-checkout verdict allows clean -fen, -fe.env, -f -e -n, and -f --exclude -n, each of which deletes untracked files in a fresh repository.

    Blocks: none. Merging the resulting PR still waits on the maintainer's go-ahead after reading its diff.

  4. added
    decision
    on Nov 2, 2026
  5. ptr727 commented on Nov 2, 2026

    @ptr727
    OwnerAuthor

    Maintainer answer (2026-11-02, via decision triage): approves the design "one shared helper, extended to separated values".

    One helper taking a word, its value-taking letters, and its optional-value letters returns the flags before the first value letter and whether the next word is consumed. _push_targets, _skips_hooks, the clean reader, and the git branch rename check all call it, and the clean reader also skips the word after -e and --exclude. This approval covers the design, so an attended run may implement it and drive its pull request. Merging that pull request still waits on the maintainer's go-ahead after reading its diff, and an away-mode run holds it.

  6. removed
    decision
    on Nov 2, 2026
  7. ptr727 commented on Nov 10, 2026

    @ptr727
    OwnerAuthor

    Released (2026-11-10): PR #4032 merged into develop at 4673434 on the maintainer's go-ahead, and its branch and worktree are removed, so this claim holds no files.

    Backlog burndown claim (attended run 2026-11-10, round 1, group G2). Branch: burndown/1172-agent-safety-launcher-and-clusters. Issues: #1172, #3783.

    Predicted file set:

    • host-setup/agent-safety/claude/install.py
    • host-setup/agent-safety/claude/install.sh
    • host-setup/agent-safety/claude/test_install.py
    • host-setup/agent-safety/claude/README.md
    • host-setup/agent-safety/README.md
    • host-setup/agent-safety/ guard files including gh-write-guard.py
    • tests/test_guard_size.py

    No other group may edit these files while this claim stands. The orchestrator releases it at cleanup.

  8. ptr727 commented on Nov 10, 2026

    @ptr727
    OwnerAuthor

    Stopped for the maintainer (burndown round 1, 2026-11-10). PR #4032 carries this fix, at head 6818c267.

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-existing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions