Skip to content

refactor(permissions): split permissions module by responsibility (#47) - #176

Open
ConardLi wants to merge 1 commit into
mainfrom
refactor/issue-47-permissions-split
Open

ConardLi wants to merge 1 commit into
mainfrom
refactor/issue-47-permissions-split

Conversation

@ConardLi

@ConardLi ConardLi commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Part of #47
Unblocks #152
Related: #99

Summary

Pure structural refactor of src/permissions/permissions.ts (671 lines → 121 lines) into cohesive modules ahead of migrating permission checks to named capability-driven steps (#152). No permission behavior, decision ordering, rule matching, or public exports are changed.

  • src/permissions/types.ts — shared permission types (PermissionBehavior, PermissionMode, PermissionDecision, PermissionRuleSet, PermissionSettings, PermissionRequest, PermissionResponse, PermissionCheckParams).
  • src/permissions/rules.ts — rule matching (matchesPermissionRule, matchesAnyRule, findFirstMatchingRule), settings loading (loadPermissionSettings), target extractors, and policy sets (PLAN_ALLOWED_TOOLS, COORDINATION_TOOLS, Bash hard-deny / dangerous prefix checks).
  • src/permissions/requestSummary.ts — summarizePermissionRequest, buildPermissionRuleHint, getRiskLabel, buildPermissionRequest.
  • src/permissions/sandboxPolicy.ts — checkSandboxAutoAllow and resolveSandboxAutoAllow.
  • src/permissions/autoMode.ts — resolveAutoModeDecision.
  • src/permissions/webFetchPolicy.ts — resolveWebFetchDecision.
  • src/permissions/planMode.ts — resolvePlanModeDecision.
  • src/permissions/permissions.ts — orchestrates checkPermission and re-exports all existing public symbols so all existing callers remain compatible.
  • scripts/check-frontend-boundaries.ts — widens the permissions/permissions boundary entry to permissions/ so frontends cannot bypass the boundary via the newly extracted modules.

Compatibility & Scope

  • Pure structural change: zero behavior changes across CLI, Headless, SDK, RPC, ACP, permissions, Auto Mode, Plan Mode, or sandboxing.
  • All existing golden characterization suites (including all 402 permission decision golden rows and all 4 model replay cassettes) remain byte-identical.

Verification

  • npm run typecheck — passed
  • npm run lint — passed (0 warnings)
  • npm run format:check — passed
  • npm run check:source-hygiene — passed (349 files, 0 violations)
  • npm run check:frontend-boundaries — passed (75 files, 0 violations)
  • npm run check:config-inventory — passed
  • npm run build — passed
  • npm run verify:production:tests — 93/93 passed (0 skipped, 0 failed)
  • npm run verify:production:platform — 2/2 passed (sandbox-host, bash-sandbox-host)
  • npm run perf:trace — 2/2 passed (p95 0.24 ms, 0.77× transcript)
  • node --import tsx src/scripts/test-stage36.ts (npm run verify:release) — 73/73 passed (includes isolated install, Headless, and interactive PTY startup)

Generated with Devin

Break src/permissions/permissions.ts into focused modules (types, rules,
requestSummary, sandboxPolicy, autoMode, webFetchPolicy, planMode) while
keeping all existing exports, decision ordering, and permission behavior
unchanged. Also widen the frontend boundary guard to cover all of
src/permissions/.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant