Repository navigation
fix(core): inherit parent agent denies on child sessions - #475
Merged
Merged
Conversation
Plan mode's edit deny lives on the agent, so a child that only copied the parent session rules could still edit. Append parent-agent denies after the inherited session rules without copying allows or asks.
A parent session that names an agent still fails closed when that agent is missing from the registry or the location has no agent service. Parents with no agent id keep inheriting only their session rules.
This was referenced Nov 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
None. Ports upstream
b8ca71d309(anomalyco#26597) onto V2. Do not merge until review.Type of change
What does this PR do?
Plan mode denies
editon the plan agent. A child session only copied the parent session rules, which are empty in plan mode, so a general or custom child could still edit, write, and patch.Child creation now appends the parent agent's deny rules after the inherited session rules. Allows and asks stay on the parent agent. Session rules are evaluated after the child agent's rules, and the last match wins, so a copied parent allow would grant something the child had refused. An explicit
permissionsarray onSession.createstill replaces inheritance.When the parent names an agent that is missing after activation, either because the location has no agent service or the registry has no record, the child gets the same deny-all fallback permission checks use for a missing agent (
* * deny). A parent with no agent id still inherits only its session rules.The subagent tool, command subagents, and restart recovery all create children through
Session.createwithout a ruleset, so they pick this up. Restart waits for plugin activation before reading the parent agent, because a cold location may still be starting.How did you verify your code works?
packages/core/test/plan-subagent-permission.test.tsfails on the previous inheritance and passes with this change. It creates real child sessions and evaluates permissions throughPermission.Service,Permission.evaluate, and the tool snapshot:editoutside the workspace and inside the plan directory.edit,write, andpatchdrop out of the tool snapshot.readstays.permissions: [], keeps the deny. Switching the child to a permissive agent still deniesedit.shell) is forwarded. Sessionreadandexternal_directorydenies stay. A parenteditallow does not let a read-only child edit.editandread. A parent with no agent id still allowseditand keeps its sessionreaddeny.edit.bun typecheckinpackages/corepassed.plan-subagent-permission.test.tsandsession-create.test.ts: 50 pass, 0 fail. Pre-push typecheck: 40 tasks successful.Head:
4949a81429db3f334f672d9c0345468318dd3681Differences from upstream: V2 keeps the full parent session ruleset, then appends denies, so a parent-agent deny wins over an earlier session allow. The plan-directory allow is not copied, so children cannot edit plan files even though the plan agent can. Asks are not forwarded. Children that already exist are not rewritten when a follow-up reuses them or when the parent later switches into plan mode.
Visual
Screenshots / recordings
Permission behavior only. No UI change.
Checklist