Skip to content

gh-write-guard installer: four small pre-existing correctness gaps found via PR #1086's review #1087

Closed as not planned

Description

@ptr727

Surfaced by CodeRabbit's outside-diff review on PR #1086 (the agent-safety/ restructure), against
host-setup/agent-safety/claude/install.py and test_install.py. All four are pre-existing
behavior, unrelated to that PR's pure file move (confirmed: the move is a byte-identical rename,
git diff -M shows zero changed content lines in these files), so filing here rather than folding
into that PR's now-larger diff.

1. registration_problems doesn't check the hook's matcher

Around install.py:332-337, the function counts any PreToolUse group whose hooks list names
gh-write-guard, regardless of that group's own matcher value. The installer always registers
under matcher == "Bash". If a hand-edited settings.json moves the registration to a different
matcher, the hook no longer runs on Bash commands at all, but this function still reports it as
registered -- the "complete and entirely inert kit" case the function's own docstring names as the
thing to catch.

Fix: skip a group whose matcher != "Bash" before counting.

2. Truncating a missing commit prints hub unknow

install.py:393: source_ref().get('commit', 'unknown')[:7] applies the [:7] slice after the
default has already been substituted, so a host with no git checkout (source_ref() returning
{"vcs": "none"}) prints hub unknow instead of hub unknown.

Fix: slice only when a commit value actually exists.

3. A malformed settings.json can traceback on install, not just on --report

install.py:516-524: the install path's read of settings.json sits outside its own try/except
and the surrounding catch is scoped to json.JSONDecodeError alone. A non-UTF-8 or otherwise
unreadable file raises UnicodeDecodeError/OSError here, which is uncaught, so install ends in a
traceback after the hook has already been copied. registration_problems was already widened to
(ValueError, OSError) for the equivalent --report case; the install path should match.

4. Cosmetic: launcher quoting, and a misleading test name

  • install.py:678's printed re-check command doesn't quote launcher the way line 512 does, so a
    sys.executable containing a space isn't safely pasteable.
  • test_install.py:363's
    test_installing_onto_a_duplicated_block_does_not_report_current actually asserts the CURRENT
    (returncode == 0) verdict, the intended behavior once the second install collapses the
    duplicate -- the name reads as the opposite of what it checks. Suggested rename:
    test_installing_onto_a_duplicated_block_collapses_it_and_reports_current.

Also flagged, lower priority (a design tradeoff, not obviously a bug)

test_install.py's payload-digest test cases (449-460, and similarly 468-475/482-491/
502-514) write directly to tracked files under HERE (claude-md-safety.md and others),
restoring them via try/finally/addCleanup. An interrupted run (killed, timed out) skips that
restore, leaving the checkout looking dirty to source_ref()'s own git status --porcelain
check, which then makes a later --report misreport a clean host as stale, and blocks running these
cases in parallel with each other since they share one mutable path. Worth fixing by pointing the
digest helpers at a temporary copy instead of the tracked files, but lower priority than 1-4 since it
only bites on an interrupted run.

None of these were introduced by PR #1086; they were found only because that PR's review happened
to read this file's outside-diff context.

🤖 Filed by Claude Code while driving PR #1086's review loop.

Activity

  1. added
    script
    on Sep 5, 2026
  2. ptr727 commented on Oct 8, 2026

    @ptr727
    OwnerAuthor

    Declined per #2517, approved by the maintainer, under GOVERNANCE.md "Trust Boundaries and Hardening Effort": Its matcher item is already fixed on develop (install.py checks matcher_sees_bash), and the rest is installer cosmetics or a non-UTF-8 settings.json no real host produces.

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