feat(stop-review-gate): add monorepo mode for sibling git repos#353
Open
PAzter1101 wants to merge 1 commit into
Open
feat(stop-review-gate): add monorepo mode for sibling git repos#353PAzter1101 wants to merge 1 commit into
PAzter1101 wants to merge 1 commit into
Conversation
The stop-time review gate resolves the workspace via `git rev-parse --show-toplevel` from the session cwd. In layouts where several independent git repositories live under one parent directory (a common monorepo pattern with submodules-like checkouts or just by convention) this means changes Claude makes in sibling repos are silently skipped by the hook — the gate runs in the primary repo, sees no diff there, returns ALLOW, and the session ends without any review of the actual work. This change adds an opt-in `monorepoMode` config flag (default `false`, fully backwards-compatible). When enabled on the primary repo, the `Stop` hook also scans the parent directory for sibling git repos, and for each one that - has its own `stopReviewGate` enabled, and - has uncommitted changes, runs an independent stop-time review. Empty-diff siblings are skipped (Codex would just reply ALLOW and waste tokens). If any review blocks, the combined reason is returned and the gate blocks the Stop. Single-repo behavior is unchanged: when `monorepoMode` is off (the default), only the primary workspace is reviewed exactly as before. Configurable via: /codex:setup --enable-monorepo /codex:setup --disable-monorepo Tests cover the config defaults and persistence. The hook behavior is exercised end-to-end by the existing `tests/runtime.test.mjs` stop hook tests, which still pass.
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.
Summary
The stop-time review gate currently resolves a single workspace via
git rev-parse --show-toplevelfrom the session cwd. In layouts where several independent git repos sit under one parent directory (a common monorepo pattern — sibling clones managed by convention rather than git submodules), changes Claude makes in a sibling repo are silently skipped: the hook runs review only in the primary repo, sees no diff there, returnsALLOW, the session ends without the review actually covering the work.This PR adds an opt-in
monorepoModeconfig flag (defaultfalse, fully backwards-compatible). When enabled on the primary repo, theStophook scans the parent directory for sibling git repos and runs an independent stop-time review for each one thatstopReviewGateenabled, andEmpty-diff siblings are skipped (Codex would just reply
ALLOWand waste tokens). If any review blocks, the combined reason is returned and the gate blocks the Stop.When
monorepoModeis off (the default), behavior is identical to today: only the primary workspace is reviewed.Configuration
Setup must still be run separately in each sibling repo to enable the gate for it (
/codex:setup --enable-review-gate). The hook respects each sibling's own state — a repo whose gate is off is skipped.Why opt-in
~/code/with dozens of unrelated clones).Test plan
npm test— 86 → 88 tests (two new state tests for the flag); only pre-existing failures remain (test: isolate saveState pruning test from shared git-repo state dir #133-style flake onresolveStateDirand thestatus/resultformatter tests). No regressions from this change.tests/runtime.test.mjs(which set up a git repo + a committed change) continue to pass — primary workspace review path is unchanged.Out of scope
fs.realpathresolution already instate.mjs.