feat: worktree sessions inherit parent always-allow permissions (#101) #282
No reviewers
Labels
No labels
backend
bug
chore
duplication
effort:complex
effort:medium
effort:trivial
enhancement
frontend
fullstack
priority:high
ready-for-agent
refactor
security
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dries/ocman!282
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/101-worktree-inherit-permissions"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #101.
Worktree/child sessions launched from a parent now inherit the parent's accumulated always-allow approvals, so the user isn't re-prompted for patterns the parent already accepted. Default-on, soft-fails, snapshot at split time.
What changed
internal/autoapprove/inherit_capture.go): a bounded asked-cache bridgespermission.asked->permission.replied; onreply == "always"we persist anauto_approved_permissionrow (once/rejectpersist nothing). Threadedreplythrough the wholeOnPermissionRepliedchain (tee/watcher/session-events).internal/permissions/inherit.go): maps storedPermissionText+PatternsfromListApprovedPermissions(parent)into theLaunchRequest.PermissionRulesshape. Allowlist-gated keys, flat vs patternable handling, dedup, unknown-key drop, 500-pattern cap, empty-parent -> nil.mcp/tools_split.go(same-dir + worktree paths) andserver/handlers_worktree.go(parentSessionIdin body) build the ruleset when the setting is on and pass it via the existingPermissionRulesplumbing. AddspermissionsInherited/permissionsInheritedCount/permissionsInheritErrorto results; never blocks launch.settingKV table, no migration):worktree.inherit_permissions, default on;GET/POST /api/settings/worktree-inherit-permissions.WorktreeFormModalpassesparentSessionIdand shows a grey "Will inherit N approved permissions" hint; Settings toggle.Notes / deviations from the issue
LaunchRequest.PermissionRulespath added in a prior commit. Built on that instead.internal/permissionspackage rather than inline, for testability.internal/platforms/opencodeshows in a raw diff-vs-main only because main advanced; the branch itself does not touch it.Verification
make test— greenmake lint— 0 errors (platform-branching / host-helper / settings-row checks pass)Wire the inherited-ruleset builder into both new_session paths (MCP same-dir + worktree) and the /wt HTTP flow. When the worktree.inherit_permissions setting is on and a parent is known, the child session is seeded with the parent's always-allow rules. Adds permissionsInherited{,Count} result fields and soft-fails (never blocks the launch) with permissionsInheritError on any build/apply error (#101).Thread the current session into the /wt flow as parentSessionId (command-palette and composer target-selector call sites), show a grey hint with the count of approvals the new session will inherit, and add a Settings toggle for the worktree.inherit_permissions setting. Types gain parentSessionId on the request and permissionsInherited{,Count, Error} on the response (#101).Document the parent->child always-allow inheritance under the Worktrees and MCP server sections of AGENTS.md, and tell the splitting skill to surface permissionsInherited{,Count} in its summary.Coverage ratchet: ✅ pass
Tolerance: -0.1%. Baseline stored on
gh-pages.