Skip to content

Promote develop to main: Check the Shared Hook Before Installing and Deny a Commit-Time hooksPath Override - #2179

Merged
ptr727 merged 1 commit into
mainfrom
develop
Sep 30, 2026
Merged

ptr727 merged 1 commit into
mainfrom
develop

Conversation

@ptr727

@ptr727 ptr727 commented Sep 30, 2026

Copy link
Copy Markdown
Owner

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-guard now denies a commit-time -c core.hooksPath= or --config-env override on a commit or push, beside --no-verify. The remaining older bypass routes are filed as #2177.

Fixes #1816

🤖 Generated with Claude Code

…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]>
Copilot AI balanced review requested due to automatic review settings September 30, 2026 19:16
@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: ptr727/ProjectTemplate/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 68318d0b-e5e3-4b24-8e9e-801c647265c5

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.47%. Comparing base (3196954) to head (4b4a92b).
⚠️ Report is 298 commits behind head on main.

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           
Flag Coverage Δ
python-3.13 56.47% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 denies git -c core.hooksPath= / --config-env overrides of core.hooksPath on commit/push, with new self-test rows.
  • repo-worktree skill: install hooks only after checking for an existing shared hook, distinguish a linked worktree from a standalone clone via --git-dir vs --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.

@ptr727
ptr727 merged commit fe7cfa1 into main Sep 30, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

repo-worktree's hook step installs into the git hooks dir every worktree shares

2 participants