Skip to content

Issue #736: adopt PermissionRequest hook to replace --dangerously-skip-permissions#752

Merged
hubertciebiada merged 3 commits into
mainfrom
feat/736-permission-policy-hook
May 27, 2026
Merged

Issue #736: adopt PermissionRequest hook to replace --dangerously-skip-permissions#752
hubertciebiada merged 3 commits into
mainfrom
feat/736-permission-policy-hook

Conversation

@hubertciebiada
Copy link
Copy Markdown
Owner

Closes #736

Summary

  • Adds opt-in per-project permission_policy='hook' mode that drops --dangerously-skip-permissions and registers a synchronous PermissionRequest hook (CC 2.1.45+).
  • New pure-function PermissionPolicyService evaluates each tool call: read-only allow, write-inside-worktree allow, write-outside-worktree deny, WebFetch against project allowlist, Bash audit-only allow.
  • Permission decisions are recorded as permission_request events (visible in TeamDetail via existing team_event SSE broadcast).
  • Default behavior (--dangerously-skip-permissions) is preserved for backward compatibility.

Test plan

  • 31 unit tests in permission-policy.test.ts (all 5 policy rules + Windows path edge cases + sibling-dir prevention)
  • 8 integration tests in hooks-routes.test.ts for POST /api/hooks/PermissionRequest
  • 8 cc-spawn tests for the conditional --dangerously-skip-permissions arg
  • 2262 existing server tests still pass; 3 pre-existing environment-only failures unchanged
  • npx tsc --noEmit clean
  • v27 idempotent migration adds permission_policy + allowed_domains_json columns to projects

🤖 Generated with Claude Code

hubertciebiada and others added 2 commits May 27, 2026 01:50
…sion policy

- Add permission_policy ('skip'|'hook'|null) and allowed_domains_json columns to projects table (DB migration v26)
- Create pure-function permission-policy.ts service with evaluatePermission() covering read-only, network, write, bash, and default rules
- Handle POST /api/hooks/PermissionRequest synchronously (CC blocks waiting for response)
- When permissionPolicy='hook', omit --dangerously-skip-permissions from spawned CC processes
- Add PermissionRequest hook to settings.json.http.example
- Update ProjectService, cc-spawn, team-manager to thread permissionPolicy through
- Add 31 unit tests, 8 integration tests, 8 cc-spawn tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… to ProjectsPage

- Add Permission Policy selector (skip/hook) to project settings inline controls
- Add AllowedDomainsEditor textarea shown only when policy='hook'
- Add handleSavePermissionPolicy and handleSaveAllowedDomains callbacks
- Update CLAUDE.md: per-project permission policy section, FLEET_SKIP_PERMISSIONS note, projects table description

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hubertciebiada hubertciebiada enabled auto-merge (squash) May 27, 2026 00:02
Append a random suffix to repoPath and name so multiple seedProject() calls
within the same millisecond don't collide on the UNIQUE constraints. The file
has no beforeEach that wipes projects, so on fast CI two calls in different
tests could land in the same ms and trigger SqliteError: UNIQUE constraint
failed: projects.repo_path. Exposed by timing shifts from the new permission
policy tests added in this PR.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hubertciebiada hubertciebiada merged commit fdd74c9 into main May 27, 2026
1 check passed
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.

permissions: adopt PermissionRequest hook to replace --dangerously-skip-permissions

1 participant