Repository navigation
feat(permission-manager): layered user rule files with validation and cached merge - #256
Merged
st0nefish-ci[bot] merged 1 commit intoNov 24, 2026
Conversation
… cached merge Rules could only be changed by forking: gate.sh hard-coded scripts/rules and edits to the installed copy are lost on update. Add system, user and project rule layers so local policy survives updates. - layers: shipped < system (/etc/claude-code/permission-manager.d) < user (XDG config rules.d) < project (.claude/permission-manager, opt-in via PERMISSION_MANAGER_PROJECT_RULES=1, ask/deny only); PERMISSION_MANAGER_RULES_PATH replaces system+user; layer dirs inside the working repo are ignored - validate.jq checks keys, sections per layer, id format, regexes, clause keys and the field shapes engine.jq dereferences, so a bad file is skipped alone - merge.jq applies adds, id overrides (position kept) and disables - gate.sh merges once, caches under XDG_CACHE_HOME keyed on file content, falls back to shipped rules on any failure, notes once per session and writes a RULES_ERROR audit line; no layer files means no extra work - engine.jq: new push_target_re and flag_with_pos clauses - test-gate.sh: --rules-dir and --cases options and layer, project, malformed file and cache checks, with fixtures and release cases - README documents the layers; plugin bumped to 3.2.0 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018KC1pVN4bq5bqbeVZwNVDQ
st0nefish-ci
Bot
deleted the
worktree-feature-permission-manager-layered-rules
branch
November 24, 2026 16:45
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
Adds layered rule files to permission-manager so local policy survives plugin updates (#255). With no layer files, behaviour and cost are unchanged.
/etc/claude-code/permission-manager.d) < user ($XDG_CONFIG_HOME/permission-manager/rules.d) < project (.claude/permission-manager, opt-in viaPERMISSION_MANAGER_PROJECT_RULES=1, ask/deny only, no override/disable).PERMISSION_MANAGER_RULES_PATHreplaces system+user. A system/user layer directory inside the repository being worked in is ignored, since a repo can set hook env vars.validate.jq: known keys, sections per layer,owner.nameids, compiling regexes, known clause keys, and the field shapesengine.jqdereferences. An invalid file is skipped by itself.merge.jq+gate.sh: one merge, cached underXDG_CACHE_HOME(dir 700, files 600) keyed on file content; any failure falls back to the shipped rules; one stderr note and aRULES_ERRORaudit line per session.engine.jq: newpush_target_reandflag_with_posclauses.test-gate.shgains--rules-dirand--cases, plus layer precedence, project restrictions, malformed-file, wrong-typed-field, cache and push-target checks, with fixtures andlayer-cases/release.tsv.Review
Three review passes. Fixes include: wrong-typed fields no longer silence the gate; a bad regex name no longer drops every layer;
push_target_reis barred from allow entries andnot; overrides are validated like added entries; the cache key hashes content (symlinked rule files tracked); the push target is trusted only for a plaingit push, socd,-Candgit checkout master && git pushask.Decision D1 (accepted): the push target is resolved before the engine run and only when a loaded rule uses
push_target_re, instead of after the run as the issue describes. Same behaviour, no second engine pass.Left open as nits: regex backtracking in layer files, cache prune by build age (30 days), the example
gh apirule also asks on-X GET.Test plan
bash tests/permission-manager/test-gate.sh: 1692 pass, 2 fail. The twooversize: 250 harmless commands/150-stage read-only pipelinechecks also fail on unmodified master in this environment.bash .github/scripts/lint-shell.shpasses; rumdl is clean for the plugin.validate-all.shmarkdown failures are all in session spine files this PR does not touch.Closes #255
🤖 Generated with Claude Code
https://claude.ai/code/session_018KC1pVN4bq5bqbeVZwNVDQ