fix(hooks): propagate customPoliciesEnabled in readMergedHooksConfig … - #617
fix(hooks): propagate customPoliciesEnabled in readMergedHooksConfig …#617AVPthegreat wants to merge 1 commit into
Conversation
|
Warning Review limit reached
Next review available in: 57 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
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 |
|
Your PR is awaiting review by a reviewer. Till then you can join the Discord for conversation: https://discord.befailproof.ai |
There was a problem hiding this comment.
Pull request overview
This PR fixes a config-merging gap in the hooks subsystem by ensuring the customPoliciesEnabled flag is propagated through readMergedHooksConfig, so users can reliably disable convention-discovered custom policies via config.
Changes:
- Merge
customPoliciesEnabledacross project/local/global scopes using “first defined scope wins”. - Include
customPoliciesEnabledin thereadMergedHooksConfigreturn value only when explicitly set. - Add unit tests covering scope precedence for
customPoliciesEnabled.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/hooks/hooks-config.ts |
Adds merged customPoliciesEnabled handling to ensure enforcement respects the config toggle. |
__tests__/hooks/hooks-config.test.ts |
Adds regression tests verifying the correct precedence rules for customPoliciesEnabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return { | ||
| enabledPolicies: [...enabledSet], | ||
| ...(Object.keys(mergedParams).length > 0 ? { policyParams: mergedParams } : {}), | ||
| ...(customPoliciesPath !== undefined ? { customPoliciesPath } : {}), | ||
| ...(customPoliciesEnabled !== undefined ? { customPoliciesEnabled } : {}), | ||
| ...(llm !== undefined ? { llm } : {}), |
Summary
Fixes #590 by ensuring
customPoliciesEnabledis read across project, local, and global configuration scopes and returned byreadMergedHooksConfig.❌ Root Cause Analysis
In
src/hooks/hooks-config.ts, thereadMergedHooksConfig(cwd)function merges policy configurations across 3 scopes:.failproofai/policies-config.json).failproofai/policies-config.local.json)~/.failproofai/policies-config.json)Why it failed:
HooksConfigtype definescustomPoliciesEnabled?: boolean;.customPoliciesEnabled: falsetopolicies-config.jsonwhen unticking custom policies.readMergedHooksConfig, the function mergedenabledPolicies,policyParams,customPoliciesPath, andllm, but forgot to read or includecustomPoliciesEnabled!src/hooks/handler.tscalled:config.customPoliciesEnabledwas alwaysundefined, so setting"customPoliciesEnabled": falsein config had no effect and custom convention policies continued to load.✅ Fix Details
Updated
readMergedHooksConfiginsrc/hooks/hooks-config.tsto mergecustomPoliciesEnabledusing first-scope-wins priority (project > local > global):🧪 Unit Tests & Verification
Added unit test coverage in
__tests__/hooks/hooks-config.test.ts:Test Results:
vitest run __tests__/hooks/hooks-config.test.ts✓ 36 passed (36)