fix(review): reject repository-local grafts - #2113
Conversation
📝 WalkthroughWalkthroughExact-revision snapshot resolution now rejects repository-local Git grafts and reads native commit ancestry. Tests cover primary and linked worktrees. Guard-population metadata includes the new fail-closed guard. ChangesExact-revision snapshot integrity
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/reviewtransaction/snapshot.go`:
- Around line 1042-1045: The parent commit lookup in the snapshot-building flow
must be atomic with the graft validation: replace the post-check runGit rev-list
call with raw commit-object parsing from the repository used by
rejectRepositoryLocalGrafts, or query the raw object with grafts disabled, then
use that parent when selecting the base tree.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 0f870111-3e5d-49f0-a465-43eea98ed275
📒 Files selected for processing (4)
.guard-population-baseline.txtinternal/cli/guard_population_test.gointernal/reviewtransaction/snapshot.gointernal/reviewtransaction/snapshot_test.go
Linked Issue
Closes #1719
PR Type
type:bug- Bug fix (non-breaking change that fixes an issue)type:feature- New featuretype:docs- Documentation onlytype:refactor- Code refactoringtype:chore- Build, CI, or tooling changestype:breaking-change- Breaking changeSummary
Changes
.guard-population-baseline.txtinternal/cli/guard_population_test.gointernal/reviewtransaction/snapshot.goinfo/grafts, derives parents from raw commit headers with replacement objects disabled, and declares external graft cleanup by design.internal/reviewtransaction/snapshot_test.goTest Plan
Passed
git diff --checkgo run ./internal/gofmtcheckgo test ./internal/reviewtransaction -run TestSnapshotBuilderExactRevision -count=1go test ./internal/cli -run TestEveryProductionRefusalNamesResolutionOrDeclaresByDesign -count=1go build ./...go vet ./...bench:go build ./...andgo vet ./...Incomplete / unrelated local-suite failures
go test ./... -count=1did not complete cleanly in the Windows worktree. Unrelated update/release tests require unavailable WSL/POSIX tooling, and three review/SDD tests timed out outside the exact-revision path. Focused affected tests pass.bench/go test ./... -count=1still failsTestProbeCapabilityRejectsAMissingFlag,TestProbeAndHelpProbeDoNotShareACacheEntry, andTestReadBackBlanksGitTrace. The benchmark module is untouched, and these are the same runner failures previously reproduced on the exact base.Automated Checks
All automated checks passed on commit
44a0aa45, including Unit Tests, Go Format, runtime checks, the complete E2E matrix, PR validation, and CodeRabbit. The authored diff is 124 changed lines (119 additions and 5 deletions), within the 400-line review budget.Contributor Checklist
status:approvedtype:buglabel is appliedgo run ./internal/gofmtcheck)Co-Authored-BytrailersNotes for Reviewers
Please focus on the common-directory boundary for primary and linked worktrees, and on raw first-parent derivation remaining immune to repository-local grafts.