fix(server): start Claude full access without forbidden permission modes (#4927) - #7246
fix(server): start Claude full access without forbidden permission modes (#4927)#7246imMxts wants to merge 3 commits into
Conversation
Claude full access mapped straight to bypassPermissions even when resolved settings set disableBypassPermissionsMode to disable. Resolve the same filesystem sources as the session and omit the forbidden request so the session can start. Co-authored-by: Mats Varnskühler <imMxts@users.noreply.github.com>
Honor disableAutoMode as well as disableBypassPermissionsMode so a locked Auto fallback does not send another forbidden mode. Swap CLAUDE_CONFIG_DIR only around settings resolve and restore it if resolve throws. Co-authored-by: Mats Varnskühler <imMxts@users.noreply.github.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
There was a problem hiding this comment.
One finding on error modeling for the new ClaudeSettingsResolveError. Everything else (namespace imports, Semaphore usage, option-based test seams, warning-log payloads) matches the service conventions.
Posted via Macroscope — Effect Service Conventions
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4fbcb8e. Configure here.
ApprovabilityVerdict: Needs human review This PR changes runtime behavior for permission mode selection when Claude policy forbids certain modes. It affects security-related functionality (bypass permissions, auto-approval behavior) and introduces new policy resolution logic. These substantive changes to permission handling warrant human review. You can customize Macroscope's approvability policy. Learn more. |
Keep CLAUDE_CONFIG_DIR swaps behind a process-wide semaphore, capture settings-resolve cwd and sources on the tagged error, and auto-allow tools only when the effective permission mode is still bypass. Co-authored-by: Mats Varnskühler <imMxts@users.noreply.github.com>

Fixes #4927
What Changed
Claude
startSessionnow resolves the same filesystem settings cascade as the SDK session (user,project,local; managed policy still loads regardless) before requestingbypassPermissionsorauto.If resolved policy forbids the requested mode, the adapter:
allowDangerouslySkipPermissionsunless effective mode is still bypassExisting Full access behavior is unchanged when policy allows bypass. Auto-accept-edits and supervised keep their current mappings.
Settings resolve for isolated Claude homes temporarily sets
CLAUDE_CONFIG_DIRunder a process-wide mutex and always restores it, including when resolve throws. Tool auto-allow follows the effective Claude permission mode, not the requested Full access label.Why
Verified root cause
On
origin/main(bab4b6f02),ClaudeAdapter.startSessionmapped"full-access"straight topermissionMode: "bypassPermissions"plusallowDangerouslySkipPermissions: true. It never read Claude's resolved policy. Current Claude docs saypermissions.disableBypassPermissionsMode: "disable"(user settings or managed policy) forbids that mode. The adapter still sent it, so the Claude CLI/SDK rejected the session.The first draft only remapped Full access to Auto. Claude also accepts
disableAutoMode: "disable"(top-level orpermissions.disableAutoMode). Sending Auto in that case is the same class of bug. Claude docs say a session that would start in Auto then starts in default / Manual instead.Why this seam
startSessionpublic interface, strongest policy guarantee, UI can still be added later.Requested vs effective mode
session.runtimeModestays what the client asked for (full-accessorauto).claude.query.permission_modeis the allowed mode (bypassPermissions,auto, or omitted for Supervised);claude.query.requested_permission_modekeeps the original mapping.auto, ordefaultwhen Supervised).canUseToolauto-allows only when the effective mode is stillbypassPermissions.Tests and commands
vp test run apps/server/src/provider/Layers/ClaudeAdapter.test.ts vp run --filter t3 typecheck vp lint apps/server/src/provider/Layers/ClaudeAdapter.ts apps/server/src/provider/Layers/ClaudeAdapter.test.ts88 tests passed. Typecheck passed. No new lint on the changed logic. No real Claude account, credentials, or managed policy required. Policy tests inject settings fixtures.
CLAUDE_CONFIG_DIRtests inject the inner SDK resolve so they observe the env swap without hitting disk or MDM.Covered matrix: permissive + full access; bypass locked + full access → Auto; bypass and Auto locked + full access → Supervised; Auto locked + Auto runtime → Supervised; Auto locked + full access still bypass; top-level and
permissions.disableAutoMode; non-"disable"policy values; settings resolution failure (fail closed to Auto); plan restore after Auto or Supervised downgrade; resolve call uses cwd +["user","project","local"]; instanceCLAUDE_CONFIG_DIRis visible during resolve and restored after success or throw; process-wide config-dir lock; tools are not auto-allowed after a Supervised downgrade.Risk, compatibility, and rollout
resolveSettings()is an alpha Claude Agent SDK API. We call it with the same sources asquery().CLAUDE_CONFIG_DIRis applied around the in-process resolve call under a process-wide mutex so user settings from isolated Claude homes are visible. The SDK call itself stays interruptible; acquire/release restore the previous env.UI Changes
None. Composer, compact menu, and mobile still show Full access. A later change can grey it out once provider state surfaces "bypass locked".
Remaining uncertainty
Checklist
Model: Cursor Grok 4.6. Harness: Cursor cloud agent.
Note
Fix Claude full-access sessions to start without forbidden permission modes
bypassPermissionsbut policy has disabled it, the adapter now downgrades toauto; ifautois also disabled, it falls back to supervised (undefined) mode.CLAUDE_CONFIG_DIRswap to safely serialize concurrent environment mutations.CLAUDE_BYPASS_DISABLED_SETTINGS.permissionModeisbypassPermissions; otherwise they require approval.startSessionnow resolves Claude policy settings and may silently downgrade the requested permission mode, logging a warning and annotating the span with both requested and effective modes.Macroscope summarized 7278ed4.