Repository navigation
Conversation
…ath Override (#2178) ## Summary Refs #1816. - **`repo-worktree` "Preparing Git Hooks".** A linked worktree shares the base clone's git config, and with no `core.hooksPath` set it also shares the base clone's hooks directory. Running `pre-commit install` there rewrote the hook for every checkout. The section now: - checks for an existing hook with `git rev-parse --git-path hooks` before installing; - identifies a linked worktree by `--git-dir` differing from `--git-common-dir`, both run from the root; - forbids changing a shared hook or setting from a linked worktree, and binds a repository override to the same limit; - lets a standalone clone install into its own hooks; - runs the Husky.Net install in a linked worktree only where `core.hooksPath` already reads `.husky`; - names a commit-time `core.hooksPath` override as a hook bypass. - **`gh-write-guard`** denies `git -c core.hooksPath=... commit|push` and the `--config-env` forms beside `--no-verify`, with self-test rows. It refactors `_git_subcommand_arglists` onto a new `_git_subcommand_invocations` that keeps the global options. - **Guard READMEs** name the new denial. The remaining bypass routes, all older than this change, are filed as #2177: a persistent `git config core.hooksPath`, the `GIT_CONFIG_*` environment forms, wrapped or aliased git, and a heredoc false positive. ## Verification - `gh-write-guard.py --selftest` passes. With the new check disabled, the four new deny rows fail. - Hook-path resolution was probed in a scratch base clone and linked worktree, with and without a relative `core.hooksPath`. - Four local strict-review passes ran, raising 7, 2, 1, and 0 findings. The last pass is clean at the pushed head. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Repository: ptr727/ProjectTemplate/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2179 +/- ##
=======================================
Coverage 56.47% 56.47%
=======================================
Files 16 16
Lines 7455 7455
=======================================
Hits 4210 4210
Misses 3245 3245
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
It promotes to main and modifies security-relevant agent-safety hook-bypass enforcement, which warrants final human sign-off despite no issues being found.
Review effort: Balanced
Findings: None
What changed in this PR
This pull request promotes develop to main, carrying the change that hardens the fleet's local-hook protections. It closes a gap where repo-worktree's hook-installation step could rewrite a shared hook for every checkout of a base clone, and it extends gh-write-guard to deny a per-invocation core.hooksPath override on a commit or push, alongside the existing --no-verify denial. The change fits into the repository's agent-safety layer (host-installed Claude Code hooks) and the repo-worktree skill that governs worktree setup.
Changes:
gh-write-guard.py: adds_git_subcommand_invocations(preserving global-option tokens) and_overrides_hooks_path, and deniesgit -c core.hooksPath=/--config-envoverrides ofcore.hooksPathoncommit/push, with new self-test rows.repo-worktreeskill: install hooks only after checking for an existing shared hook, distinguish a linked worktree from a standalone clone via--git-dirvs--git-common-dir, and never change a shared hook or its setting from a linked worktree.- Documentation: guard READMEs and the regenerated skill copies/digest reflect the new denial.
| File | Description |
|---|---|
host-setup/agent-safety/claude/gh-write-guard.py |
Core logic: new invocation/override helpers, bypass-flag denial, and self-test coverage. |
.agents/skills/repo-worktree/SKILL.md |
Source skill prose for shared-hook-safe installation and linked-worktree rules. |
.github/skills/repo-worktree/SKILL.md |
Generated copy of the skill (matches source). |
.claude-plugin/fleet-skills/skills/repo-worktree/SKILL.md |
Generated plugin copy of the skill (matches source). |
.claude-plugin/fleet-skills/.source-digests/repo-worktree |
Regenerated source digest (verified: matches computed sha256[:16]). |
host-setup/agent-safety/README.md |
Root spec requirement 4 now names the core.hooksPath override. |
host-setup/agent-safety/claude/README.md |
Per-agent guard summary names the core.hooksPath override. |
I verified the new guard logic against its edge cases (per-invocation -c, both --config-env forms, negative keys, and quoted-message false positives all behave as the self-test asserts), confirmed the generated skill copies are byte-identical to the source and the committed digest matches the recomputed value, and confirmed the changed prose is ASCII-clean and consistent. I found no issues to comment on.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Summary
Promotes develop to main, carrying #2178.
That PR stops
repo-worktree's hook step from installing into the git config or hooks directory a linked worktree shares with its base clone. Such an install rewrote the hook for every checkout. The skill now checks for an existing hook first, tells a linked worktree from a standalone clone, and lets only the standalone clone install locally.gh-write-guardnow denies a commit-time-c core.hooksPath=or--config-envoverride on a commit or push, beside--no-verify. The remaining older bypass routes are filed as #2177.Fixes #1816
🤖 Generated with Claude Code