Repository navigation
fix(agents): keep named task allows winning over the ambient wildcard deny - #787
Merged
ualtinok merged 1 commit intoOct 26, 2026
Conversation
… deny
denyTaskRoutingToAgents() moved a literal '*': 'deny' entry from the
agent's own permission.task map to the end of the merged map whenever
one was present. OpenCode resolves task permissions with the last
matching rule, so with a deny-by-default-with-exceptions map like
task: { "*": "deny", "my-scout": "allow" }
the re-appended wildcard overrode every named allow and the Task tool
disappeared from the agent entirely - it could not dispatch the very
subagent it named.
Only move the wildcard when its sole companions are our own appended
agent-id denies, so a lone catch-all still hides the tool while a mixed
map keeps the agent's own ordering. Exempting our internal ids from
that check keeps re-merging our own output idempotent. Add regression
tests covering the mixed map's evaluated outcome via
permissionDisabled() and the re-merge idempotence of the mixed shape.
Fixes cortexkit#777
Co-authored-by: ZCode Scout <noreply@zcode.local>
Signed-off-by: NefelibateLG <3453510037@qq.com>
|
#777 has the |
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.
Approved issue: #777 — confirmed by the maintainer in the issue thread; this implements exactly the direction from that reply so the queued fix can land sooner.
Summary
denyTaskRoutingToAgents()moved a literal"*": "deny"entry from the agent's ownpermission.taskmap to the end of the merged map whenever one was present. OpenCode resolves task permissions with the last matching rule, so for the deny-by-default-with-exceptions shapethe re-appended wildcard overrode every named allow and the Task tool disappeared from the agent entirely — it could no longer dispatch the very subagent it named (#777).
The wildcard is now moved only when its sole companions are our own appended agent-id denies, so:
task: { "*": "deny" }alone — unchanged: the wildcard is re-emitted last and the Task tool stays hidden.task: { "*": "deny", "x": "allow" }— the agent's own ordering is kept; the named allow still wins, the tool remains visible, and every other target is still denied by the user's own wildcard.One deliberate refinement over the predicate sketched in the issue (
Object.keys(configuredTask).every(id => id === "*")): internal agent ids are exempted from the "sole companion" check. Our own merged output is exactlyinternal denies + wildcard, so the strict predicate breaks the existing re-registration idempotence contract (Task wildcard re-emission is idempotent across repeated registration); exempting our own ids keeps that test green while still never overriding a user-authored rule.Harness coverage (required)
For each entry select: covered / not applicable — surface does not exist there / NOT covered.
denyTaskRoutingToAgents()runs in the plugin'sconfighook (packages/plugin/src/index.ts); the new unit tests assert both the merged map and the evaluator-visible outcome viapermissionDisabled().hiddenChildPermissions(packages/plugin/src/v2/hooks/hidden-child.ts) and never calls the merged task map.How verified
bun install --frozen-lockfile— 1108 packages, clean install.bun test src/agents/permissions.test.ts src/agent-registration-drift.test.ts→ 52 pass / 0 fail (includes the 2 new regression tests).bun test src/agents/permissions.test.ts src/agent-registration-drift.test.ts src/index-hook-delegation.test.ts src/index-refresh.test.ts src/standalone-plugin-marker.test.ts src/standalone-plugin-marker-entry.test.ts→ 63 pass / 0 fail.permissions.tschange reverted (git stash push -- packages/plugin/src/agents/permissions.ts), the new testnamed task allows survive an ambient wildcard deny (#777)fails on the pre-fix code — the regression test pins the bug.biome check src/agents/permissions.ts src/agent-registration-drift.test.ts→ clean.tsc -p ../retina-local-fs/tsconfig.build.json && tsc --noEmit(the repo's typecheck order) → clean.packages/pi-plugintests crash under the locally available bun 1.2.23 (bun runtime crash, bun.report link emitted). Reproduced identically on a clean checkout with no local changes, so it is a local toolchain floor (the repo pinsbun@1.4.2), not an effect of this change; thepackages/pluginsuite used above does not hit it.