Repository navigation
Run the reviewer with a read-only git and a worktree tripwire - #14
Conversation
catalan-adobe
left a comment
There was a problem hiding this comment.
Approach
What it does: Gives pi a Git wrapper that refuses write commands and compares checkout snapshots before and after each pass. A change to HEAD or Git status stops the run before posting, with exit 4 and the session preserved.
Fit with the repo: Task 4 of docs/superpowers/plans/2026-11-26-review-tracking-pr3-local-worktrees.md names lib/git-ro, lib/guard.sh, and the shared run_pi function. Both passes already call that function, so neither prompt nor the posting code needs its own guard.
Strongest case for the approach as built: It protects today’s throwaway checkout without coupling the guard to clone setup. PR #16 can pass separate clone and worktree paths to the same snapshot helper, so a developer’s commit in their own checkout warns rather than stopping the review.
Alternatives: Keep as-is and maintain one Git allowlist. Waiting for #16 would save a small argument change but leave both passes relying on prompts in the meantime.
Questions for the author: None. I’d revisit the design if it had to contain hostile execution; the stated goal is “a guard rail, not a security boundary.”
Missing context: None material.
Approach: Sound
Strengths
- [gh-pr-review:245–262] — Both passes use the same guard, and the after-snapshot runs even when pi fails. A checkout change therefore takes precedence over a generic model error and stops the run before posting.
- [tests/flow.sh:1431–1445] — The local bare-repository test checks the user-visible outcomes: a changed checkout exits 4 and posts nothing, while a clone-only branch change warns and still posts.
tests/guard.sh,tests/passes.sh, andtests/flow.shpassed locally.
Issues
🚨 Critical (Must Fix Before Merge)
(none found)
⚠️ Important (Should Fix)
-
[lib/guard.sh:37] — The tripwire inherits
status.showUntrackedFiles. With that preference set tono, I created a non-ignored file between snapshots andtripwire_checkreturned 0. The review can therefore post after pi writes a new file, without anyone bypassing the wrapper. Pass--untracked-files=allexplicitly and cover this configuration in the new-file test. -
[lib/guard.sh:35–38] — Two failed snapshots can compare equal. With an invalid status configuration, both snapshots recorded
status failed: 128; editing a tracked file between them still produced exit 0 and no warning. Require a successful HEAD and status read before accepting a worktree snapshot, while treatingsymbolic-ref -qreturning 1 as the expected detached-HEAD case. If the checkout cannot be verified, keep the diagnostic and do not post. -
[lib/guard.sh:26] —
GIT_OPTIONAL_LOCKS=0protectsgit status, but not a plaingit diffagainst the working tree. On Git 2.55, the wrappedgit diffchanged the checksum of a stale index even though file contents were unchanged; the tripwire did not see that write. Setdiff.autoRefreshIndex=falseinpi_envand extend the existing stale-index checksum test to coverdiff. That setting preserved the checksum in the same test. -
[lib/guard.sh:24] —
core.hooksPath=/dev/nulldoes not disable a hook named directly bycore.fsmonitor. I confirmed that wrappedgit statusinvoked the configured monitor. The snapshots already disable it at line 32; apply the same override to pi and test the hook inside and outsidepi_env. -
[lib/guard.sh:23] — Git versions before 2.31 ignore
GIT_CONFIG_COUNT, but preflight only checks thatgitexists (gh-pr-review:308). On Git 2.30 the review starts with the operator’s credential helper and hooks still configured. Probe support for environment-supplied Git configuration before launching pi, and report the minimum requirement in--doctorand the README.
💡 Minor (Nice to Have)
-
[README.md:325] — “No credentials” is broader than the implementation. Git credential helpers are disabled, but pi intentionally retains authenticated
ghaccess;--userexplicitly exports its token. Say “Git credential helpers and prompts are disabled” and describe the wrapper as a guard rail rather than credential isolation. -
[lib/guard.sh:62] — A clone-only warning goes only to stderr. Task 4 also calls for adding it to the run’s warnings; someone inspecting a completed session currently has to compare the raw snapshots. Save the warning in the session while preserving exit 0.
-
[tests/flow.sh:1424] — The new fixture creates real commits before
runswitches to the stub home. A developer’s global signing policy or hooks can therefore prompt, fail, or run during test setup. Isolate Git configuration before initializing the fixture, followingtests/delta.sh:17–21.
Recommendations
Keep the shared run_pi integration. Extend the real-Git tests with operator configurations as inputs, and assert both the exit decision and the state that must remain unchanged. The existing checksum and inside/outside control tests are good patterns for this.
Assessment
Ready to merge? No
Reasoning: The orchestration and posting behavior are sound, but the tripwire can currently report an unchanged checkout when a file was added or when inspection failed entirely. These are ordinary Git configuration cases, not attempts to defeat the guard.
Review generated by gh pr-review · model: azure-openai-direct/gpt-6.2-astra
|
Thanks for the review. All items are addressed; each reproduced on git 2.55 first, and each fix has a test that failed before it (except the docs item and the test-setup item, see below). Important
Minor
|
catalan-adobe
left a comment
There was a problem hiding this comment.
Round 2 · since round 1
6 fixed · 2 still open · 4 new (4 in the new commits) · open blocking: 3 (was 5) · loop: early
Approach
Unchanged since round 1: Both passes still use run_pi, so the stricter Git checks and the decision to stop before posting when a snapshot is unreadable need no pass-specific logic.
Approach: Sound
Strengths
- [gh-pr-review:249–252] — Both passes now stop on a failed Git read, and the after-snapshot still runs when pi fails. The flow tests distinguish the two cases that matter: an unreadable baseline means zero model calls; an unreadable checkout afterward means nothing is posted.
- [tests/guard.sh:117–135] — The stale-index tests check the index checksum, not just
git status. Their controls establish that the same operations outsidepi_envreally do rewrite the index.
Issues
🚨 Critical (Must Fix Before Merge)
(none found)
⚠️ Important (Should Fix)
-
F4 · [lib/guard.sh:36–40] — A filesystem monitor inherited from a parent Git process still takes precedence. The new override works for
.gitconfig, but whengh pr-reviewis launched through a Git alias, the parent's-csettings can arrive inGIT_CONFIG_PARAMETERS. I confirmed that the real Git insidepi_envthen reported the parent's monitor, notfalse. Wrappedgit statuscan therefore invoke it without pi requesting any override. ClearGIT_CONFIG_PARAMETERSat thepi_envboundary and test this inheritance path; the same precedence applies to the other three settings. -
[lib/git-ro:33] — The new
describecheck rejects only the full option names. Git 2.55 also recognizes unique prefixes of--dirtyand--broken, so those spellings reach the same index-refreshing code. The tripwire does not see an index stat-cache rewrite. Reject the accepted abbreviations as well, or allow only known read-onlydescribeoptions; cover abbreviated forms in the checksum test. -
[lib/guard.sh:63–70] — A snapshot can return success without creating
worktree.txt.run_pinow calls the function on the left of||, soerrexitdoes not stop it on a failedmkdiror output redirection. With a regular file blocking the snapshot directory, I got a successful return with no artifact;run_piwould start pi without a baseline. Check snapshot creation and writes explicitly. Make the diagnostic ingh-pr-review:273tolerate a missing snapshot file so this path still names the session and exits 4.
💡 Minor (Nice to Have)
-
F8 · [tests/flow.sh:1437–1445] — The fixture now ignores the developer's config files, but still inherits
GIT_CONFIG_COUNTuntil after its first commits. An inherited signing policy made the fixture fail before it reached an assertion. The newly added commit attests/passes.sh:26has the same problem and still reads the developer's global files. Use the same isolated Git environment in both fixtures, clearing inherited config pairs before the first Git command. -
[lib/guard.sh:16–17] — The capability probe can reject a supported Git. On Git 2.55,
GIT_CONFIG=/dev/nullmakesgit_env_configfail:git config --getreads only that file, although other Git commands still honorGIT_CONFIG_COUNT. The resulting advice to upgrade Git will not fix the run. UnsetGIT_CONFIGfor the probe and add this as a supported-Git control. -
[gh-pr-review:25–27] —
--helpstill attributes exit 4 only to a reviewer modification. A failed before-snapshot now produces that code without ever calling the reviewer. Match the two causes already documented in the README.
Fixed since the last round (6)
- F1 — The snapshot explicitly includes all untracked paths and overrides submodule-ignore settings.
- F2 — Failed HEAD or status reads now stop the run rather than comparing equal; detached HEAD remains valid.
- F3 —
diff.autoRefreshIndex=falseprevents a plaingit difffrom refreshing the stale index in the original case. - F5 — Preflight,
--doctor, andpi_envnow check for environment-config support rather than assuming every installed Git has it. - F6 — The README distinguishes disabled Git credential helpers from pi's retained authenticated
ghaccess. - F7 — Clone-only warnings are now appended to the session's
warnings.txtas well as printed.
Recommendations
Keep the real-Git controls. For the remaining guard tests, assert both the decision and the side effect: zero pi calls when the baseline cannot be saved, and an unchanged index for every refused describe spelling. tests/guard.sh, tests/passes.sh with isolated config, and the targeted flow cases passed locally; the full flow suite did not finish within the 240-second review timeout.
Assessment
Ready to merge? No
Reasoning: The original Git-read failure cases are fixed. The reviewer can still start without a saved baseline, inherit an active monitor, or rewrite the index through a spelling the new option check misses.
Review generated by gh pr-review · model: azure-openai-direct/gpt-6.2-astra
|
Thanks for round 2. All six items are fixed; each reproduced on git 2.55 and each new test failed on the code before its fix, controls included. This branch also merges Important
Minor
All test files pass on macOS (bash 5) and ubuntu:24.04; |
catalan-adobe
left a comment
There was a problem hiding this comment.
Round 3 · since round 2
5 fixed · 1 still open · 2 new (2 in the new commits) · open blocking: 0 (was 3) · loop: ready
Approach
Unchanged since round 2: The stricter Git checks stay in lib/git-ro and lib/guard.sh, and both review passes still rely on run_pi to stop before posting if a checkout snapshot cannot be saved.
Approach: Sound
Strengths
- [lib/guard.sh:38–44] —
pi_envremoves the parent Git process’s configuration before applying its own. The controls intests/guard.sh:168–204check actual side effects: whether hooks run, credentials are returned, and the index changes. - [gh-pr-review:250–253] — Both passes require a saved baseline before calling pi and take the after-snapshot even if pi fails. The flow test at
tests/flow.sh:1456–1458verifies the important user-visible result: zero model calls, nothing posted, and a diagnostic naming the session.
Issues
🚨 Critical (Must Fix Before Merge)
(none found)
⚠️ Important (Should Fix)
(none found)
💡 Minor (Nice to Have)
-
F8 · [tests/flow.sh:1470–1474] — Clearing
GIT_CONFIG_COUNTfixes the inherited signing-policy case, but the fixture can still run a developer’s hook. The same setup attests/passes.sh:26–34leavesGIT_TEMPLATE_DIRintact. With that variable pointing to a template containing a failingpre-commithook, the fixture executed the hook and exited 1 before its first assertion. UnsetGIT_TEMPLATE_DIRalongside the config variables in all three real-Git fixtures. -
[gh-pr-review:272–275] — The existence of both snapshot files does not prove both writes succeeded. With a file-size limit that let
worktree.txtfinish but truncatedclone.txt, the writer correctly reported a save failure;unreadable_checkoutthen reported the opposite cause, that the checkout could not be read. Exit 4 is correct. Pass the failure cause to the diagnostic instead of inferring it from-f. -
[lib/git-ro:31–35] — The
describecheck treats option values as options. On Git 2.55,git describe --always --match --br HEADsucceeds:--bris the tag pattern consumed by--match. The wrapper now refuses this read-only invocation as--broken. Skip values consumed by--matchand--exclude, and add a passing case alongside the refusal tests.
Fixed since the last round (5)
- F4 —
pi_envdropsGIT_CONFIG_PARAMETERS, so a parent Git alias no longer overrides the monitor, hook, helper, or index-refresh settings. - F9 — Abbreviations of
--dirtyand--brokenare refused; the tests check both the refusal and the unchanged index checksum. - F10 — Directory creation and both snapshot writes are checked explicitly. A failed baseline save stops the run before pi, even when no snapshot file exists.
- F11 — The capability probe ignores
GIT_CONFIGand inherited-csettings, with controls for both on a supported Git. - F12 —
--helpnow describes exit 4 for a changed checkout, an unreadable checkout, and a snapshot that could not be saved.
Recommendations
Keep the paired controls in the guard tests. Add a partial-write case to complement the existing directory-creation failure: it distinguishes “the file exists” from “the snapshot was saved.”
Assessment
Ready to merge? Yes
Reasoning: The blocking findings from round 2 are fixed. tests/guard.sh, tests/passes.sh, and the targeted flow cases passed with an inherited signing policy; the remaining issues affect fixture isolation, diagnostic accuracy, and one read-only describe invocation, not the decision to stop before posting.
Review generated by gh pr-review · model: azure-openai-direct/gpt-6.2-astra
|
Thanks for round 3. The three Minor items are fixed, each with a test that failed before its fix.
All test files pass on macOS (bash 5) and ubuntu:24.04; |
…ers in the PR's state folder in the tests
|
Merged
All test files pass on macOS (bash 5), and |
Conflicts: - README.md: #13's lock description and #14's tripwire/ entry, with this branch's review-worktree paragraph, pr.json facts, repo/ (--fresh only) and warnings.txt (a reset dirty worktree, or a change in the clone only). - tests/flow.sh: the stub pi keeps both pi.pwd and #14's pi.evil; run, run_no_y and run_tty run $ext_bash (#15) with --fresh; run_local runs $ext_bash too; the local-clone cases come before #14's real-git --fresh cases.
PR 3b of review tracking: the reviewer (pi) runs with a read-only git and a tripwire. Task 4 of
docs/superpowers/plans/2026-11-26-review-tracking-pr3-local-worktrees.md(see #13 for the plan's split into four PRs), applied to today's throwaway clone. 3c will pass a real clone and a review worktree.What changes
lib/git-ro: pi finds it asgit, first on itsPATH.-C,-c,--no-pager,-P,--git-dir=,--work-tree=) to find the subcommand.show diff log blame grep ls-files ls-tree cat-file rev-parse rev-list merge-base range-diff for-each-ref describe shortlog status help version.pi_env: both pi passes (approach and code review) run with no credential helper, hooks off, no terminal or askpass prompts, andGIT_SSH_COMMAND=false.HEAD,symbolic-ref HEADandstatus --porcelain, plus the clone's refs (minusrefs/pr-review/),HEADand stash, before and after.lib/git-ro.git-rois a guard rail, not a security boundary:-cis allowed, so a config key could still run a command. The tripwire is what catches a change that gets past the wrapper. In six recent real review sessions, pi left the checkout clean, so normal runs don't trip it.GIT_OPTIONAL_LOCKS=0and the tripwire's snapshots with--no-optional-locks, sogit statusnever rewrites the index.git-roalso skips-p/--paginate,--no-optional-locks,--literal-pathspecs,--no-replace-objects, and the space forms of--git-dir/--work-tree.Tests
tests/guard.sh(33 checks, real git):commit,checkout,branch -D,push,stash,worktree add,fetchandreset --hardare refused, and the repo is unchanged afterwards.pi_env:credential fillreturns nothing and hooks don't run.tests/flow.sh, a real-git case through a local bare repo (insteadOf, no network): the stub pi'sgit stashandcheckout -b evilare refused in both passes, then a real-git commit gets through. The run exits 4 and posts nothing. A pi that only creates a branch gets a warning and is posted.tests/passes.sh: a pi that writes into the checkout makesrun_piexit 4.All tests pass on macOS (bash 5 and 3.2) and Ubuntu 24.04, and shellcheck and shfmt are clean. Diff: 8 files, +312 −9. It merges cleanly with #13 in either order.