fix(rules): avoid duplicate home rule scope#62
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesHome directory config deduplication
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #62 +/- ##
==========================================
- Coverage 97.42% 97.40% -0.02%
==========================================
Files 94 94
Lines 10327 10341 +14
==========================================
+ Hits 10061 10073 +12
- Misses 266 268 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Greptile SummaryThis PR fixes a fail-closed regression that triggered whenever
Confidence Score: 5/5The change is safe to merge — it adds a targeted deduplication guard with no impact on the normal distinct-scope code path. The fix is narrow: a new helper that short-circuits one readRulesConfig call when both config paths resolve to the same file. The existing duplicate-detection logic, override handling, and lock-file validation are all untouched for the normal case. Regression tests cover both the unit and CLI surfaces of the bug. No files require special attention; the three dist/ bundles are mechanical rebuilds of the single source change in scope-policy.ts. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[loadRulesPolicy] --> B[getPolicyPaths]
B --> C{isSameConfigPath?}
C -- resolve paths equal --> D[true]
C -- paths differ, check existence --> E{Both files exist?}
E -- no --> F[false]
E -- yes --> G[realpathSync comparison]
G --> H{Same real path?}
H -- yes --> D
H -- no --> F
D --> I[project = null config]
F --> J[readRulesConfig project path]
I --> K[userPolicy only]
J --> L[userPolicy + projectPolicy]
K --> M[Return policy - single user scope]
L --> N[getDuplicateRulebookNames check]
N --> O[Return merged policy]
Reviews (1): Last reviewed commit: "fix(rules): avoid duplicate home rule sc..." | Re-trigger Greptile |
PR Summary
Fixes #61.
This PR prevents user-scope rulebooks from being loaded twice when
cc-safety-netruns withcwd === $HOME.When the current working directory is the user’s home directory, the computed user config path and project config path can both point to:
Previously, the policy loader treated those as separate scopes, which duplicated the same active rulebook and caused runtime fail-closed behavior:
That blocked every tool call, including harmless commands.
Changes
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests