Skip to content

refactor(permission): express protected paths as shipped rules - #793

Merged
hakula139 merged 9 commits into
mainfrom
refactor/permission-shipped-rules
Nov 1, 2026
Merged

hakula139 merged 9 commits into
mainfrom
refactor/permission-shipped-rules

Conversation

@hakula139

@hakula139 hakula139 commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

Protected edits used a separate name matcher and cached protected-root list alongside ordinary permission rules. Shipped ask-tier edit rules now share the configured-rule parser, folded-name matching, and symlink-prefix handling.

  • Shipped rules: protected names generate any-root and anchored patterns that also protect symlink targets. Home and application locations use absolute patterns. Group identity, secret-guarding config-fix restrictions, and the forced recursive rm check remain intact.
  • Portable patterns: /**/ matches beneath POSIX roots, drives, and UNC shares without a literal anchor. Recursive readers account for possible matches beneath any root. Other drive-less rooted patterns still fail on Windows.
  • Subtrees: protected names cover descendants, including directories named .bashrc or .claude/settings.json.
  • Approval guidance: configured ask rules remain active in yolo and match once before other ask conditions. Unrecognized syntax supplies rewrite guidance before shipped ask groups. An unrecognized device write names that syntax while retaining its Ask decision.

Test plan

  • cargo fmt --check, cargo build, both Clippy runs, cargo doc --no-deps, and cargo llvm-cov --show-missing-lines: pass. 3,495 tests pass, five existing paid live tests remain ignored, and overall line coverage is 99.24%.
  • Existing configured-ask priority and yolo regressions pass. A viable mutation that skips configured asks in yolo fails at runtime, then passes after restoring the source.
  • pnpm format, pnpm lint, pnpm spellcheck, and all applicable commit and push hooks: pass.
  • POSIX, drive, and UNC matcher cases run locally with synthetic paths. Two non-Unix device-default branches are not covered locally. Cross-platform CI is reported in the PR checks.
  • cargo deny check was omitted because dependencies are unchanged.

Protected paths duplicated the ask-tier `edit` rule: their own name tables and matcher, home
locations, resolved roots with their own alias respelling, a `protected` field on every path
target, `Policy::protected_group` at two call sites, and a `Policy.enabled` list that repeated the
`builtin` tags of the shipped entries.

Each shipped group now returns its rules with their tiers. A protected name becomes a built-in
`edit` rule that matches it at any depth on disk, a directory with everything below it and a file
only where a path ends in it, plus a copy anchored under each workspace root whose prefix the
policy resolves, so a symlinked `.vscode` still protects its target. Home locations become
absolute patterns, and `ssh` holds both its read deny and its edit ask. `rm` stays the one custom
check, kept as a `bool` on the policy, and `config_fix` turns a group off by dropping its entries.
The design doc drops the Protected zone, which the code never had.
Compile protected names through the same parser and matcher as configured rules. The portable /**/ form spans POSIX, drive, and UNC roots and retains recursive-reader coverage without projecting an arbitrary root.

Protect descendants of directories named like config files too. Keep configured asks first and unrecognized-command rewrite guidance ahead of shipped asks.
@hakula139 hakula139 added refactor Restructured code that preserves behavior (refactor) area: permission Touches permission rules, modes, or the approval gate labels Oct 30, 2026
@hakula139 hakula139 self-assigned this Oct 30, 2026
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@hakula139
hakula139 merged commit caa8f0a into main Nov 1, 2026
10 checks passed
@hakula139
hakula139 deleted the refactor/permission-shipped-rules branch November 1, 2026 09:15
@hakula139 hakula139 added this to the v0.1.0-alpha.10 milestone Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: permission Touches permission rules, modes, or the approval gate refactor Restructured code that preserves behavior (refactor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant