Skip to content

fix(permission): disabled() hides tools with per-subagent allow rules (#401)#402

Merged
randomm merged 2 commits intodevfrom
fix/issue-401-permission-disabled-hides-tools
Apr 8, 2026
Merged

fix(permission): disabled() hides tools with per-subagent allow rules (#401)#402
randomm merged 2 commits intodevfrom
fix/issue-401-permission-disabled-hides-tools

Conversation

@randomm
Copy link
Copy Markdown
Owner

@randomm randomm commented Apr 8, 2026

Fixes #401

Root Cause

PR #389 rewrote disabled() to use evaluate(permission, "*", ruleset) for consistency with evaluate(). However, "*" as the query pattern only matches wildcard rule patterns — specific patterns like "ops" or "developer" are invisible because Wildcard.match("*", "ops") returns false. This caused tools with per-subagent configs like { "task": { "*": "deny", "ops": "allow" } } to be incorrectly hidden.

Fix

disabled() now checks if ANY allow rule exists for the permission (regardless of pattern) before hiding. A tool is only disabled if no allow rule exists AND the default evaluates to deny.

Changes

  • packages/opencode/src/permission/next.ts: Added hasAllow check before disabling tools; added JSDoc documentation
  • packages/opencode/test/permission/next.test.ts: Flipped incorrect test expectation; added 7 new tests covering per-subagent configs, deny-only, glob allows, and wildcard collision

Quality Gates

  • Typecheck passes
  • 75 tests pass (0 failures)
  • Adversarial review: APPROVED (MEDIUM and LOW findings addressed with docs + edge case test)

randomm added 2 commits April 8, 2026 13:37
…#401)

- Simplified duplicate condition check in disabled() - single if block
- Updated 4 tests in permission-task.test.ts for new visibility semantic
- Updated comments from findLast() to last-match-wins
@randomm randomm merged commit 1250207 into dev Apr 8, 2026
1 check passed
@randomm randomm deleted the fix/issue-401-permission-disabled-hides-tools branch April 8, 2026 10:49
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.

fix(permission): disabled() hides tools with per-subagent allow rules

1 participant