Repository navigation
fix(guard): resolve git branch per command target, not process cwd - #154
Merged
Merged
Conversation
currentBranch() ran git rev-parse --abbrev-ref HEAD without a cwd option, so the tool_call guard judged every commit and push against the agent process working directory (the session root) instead of the repository the bash command actually targets. Consequence: with a session rooted in a parent repository that sits on a protected branch, commits are blocked in every other repository — even on a feature branch (entering another repo before committing misfires as a direct commit to the protected branch). Monorepo and submodule layouts hit this constantly. Fix: - commandGitCwd(command, upTo, fallback): resolve the directory a commit or push occurrence will run in — the last directory-change before it within the command prefix, overridden by the last git -C path in the command; quoted paths supported; command substitution declined. - currentBranch(cwd): rev-parse with an explicit cwd. - commit guard: evaluate EVERY commit occurrence in a chained command against its own target repo (per-occurrence protection). - push guard: the bare-push branch rule now uses the resolved target branch. Safety posture: fail-closed — unresolvable paths fall back to the process cwd (previous behavior: over-blocks, never under-blocks). The explicit-ref push rule and Conventional Commits checks are unchanged. Verified with 10 scenarios (throwaway fixtures with real git repositories): a parent session on a protected branch plus a subproject feature-branch commit is now allowed; a subproject that is itself on its protected branch is still blocked; a commit without a directory change on the session root is still blocked; the -C flag is respected; multi-repo chains are checked per occurrence; quoted paths with spaces work; an unresolvable path falls back (fail-closed); a bare push from a feature branch is allowed; an explicit push to the protected branch is still blocked; the conventional-commit rule is intact.
Owner
|
The |
github-actions Bot
pushed a commit
that referenced
this pull request
Oct 25, 2026
## [2.88.11](v2.88.10...v2.88.11) (2026-10-25) ### Bug Fixes * **guard:** resolve git branch per command target, not process cwd ([#154](#154)) ([07c7498](07c7498)) * **lockfile:** add missing slash in skill path + self-contained resolve_repo_root ([#156](#156)) ([04bda15](04bda15)) * **omp-hooks:** inGitRepo bail-early, accept type!(scope) form, echo subject ([#157](#157)) ([9e1b11a](9e1b11a)), closes [#147](#147) [#151](#151) [#151](#151) ### Performance Improvements * **sync:** render all skills in one bash process per adapter ([#155](#155)) ([1b56463](1b56463)), closes [#137](#137)
|
🎉 This PR is included in version 2.88.11 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
tool_callsafety guard inextensions/omp-hooks.tsresolves the current git branch like this:Without a
cwdoption, this reads the branch of the agent process working directory — the session root — rather than the repository the guarded bash command actually targets (cd <repo> && git commit …orgit -C <repo> …).Consequence: when a session is rooted in a parent repository that sits on a protected branch (
main/master), every commit in every other repository is blocked, even on a feature branch:This makes bigpowers unusable for the common monorepo / git-submodule layout where the agent session is rooted at a parent repo and works inside nested repositories. (It also silently under-protects the inverse case: a session rooted on a feature branch could commit directly to a nested repo's protected branch.)
Fix
commandGitCwd(command, upTo, fallback)— resolve the directory agit commit/git pushoccurrence will actually run in: the lastcd <path>before it within the command prefix, overridden by the lastgit -C <path>anywhere in the command. Quoted paths (with spaces) supported; tokens containing command substitution ($, backticks) are declined.currentBranch(cwd)—rev-parsewith an explicitcwd.git commitoccurrence in a chained command is evaluated against its own target repository (a chain touching two repos is judged per repo).Safety posture: fail-closed. If a path cannot be resolved (quoting/substitution edge cases, missing directory), the fallback is the process cwd — i.e. exactly the previous behavior. The patch can therefore only relax over-blocking; it cannot introduce an under-blocking path that did not already exist.
Verification
10 scenarios replayed against the patched functions (extracted verbatim from the installed file, executed through jiti) on throwaway fixtures with real git repositories:
cd+ commitcd, session root on protected branch, commitgit -C <feature-branch-repo> commitAll 10 pass. Also verified live: after
/reload, a subproject commit landed from a parent-rooted agent session (the exact scenario that used to misfire).This change was generated by an AI coding agent (pi + bigpowers skills) and has been reviewed only by a hobbyist owner, not by a professional programmer. The verification above is machine-run and machine-reported. Please review with extra scrutiny — especially the regex path-parsing in
commandGitCwd(known limits: no tilde expansion, no command-substitution parsing,git -Cfoowithout a space is not recognized — all fall back fail-closed).