Skip to content

Permission rules use first-match-wins instead of documented last-matching-rule-wins #31854

Closed as not planned

Description

@CresentMoon

Description

The Permissions documentation states:

Rules are evaluated by pattern match, with the last matching rule winning. A common pattern is to put the catch-all "*" rule first, and more specific rules after it.

However, the actual implementation uses first-matching-rule-wins. This means the documented "common pattern" of putting "*": "deny" first with specific "allow" overrides after it never works — the catch-all always takes priority.

Example

{
  "edit": {
    "*": "deny",
    "Docs/*": "allow"
  }
}
  • Expected per docs: editing Docs/foo.md is allowed (last match Docs/* → allow)
  • Actual: editing Docs/foo.md is denied (first match * → deny)

Workaround

List allow rules before deny rules, and avoid using a catch-all "*" entirely:

{
  "edit": {
    "Docs/*": "allow",
    "*.cs": "deny"
  }
}

This happens to work because the first match (allow) wins, but it contradicts the documented behavior.

Plugins

Jetbrains - OpenCode UI

OpenCode version

1.17.3

Steps to reproduce

  1. Create opencode.json with:
{
  "agent": {
    "Design": {
      "permission": {
        "edit": {
          "*": "deny",
          "Docs/*": "allow"
        }
      }
    }
  }
}
  1. Start opencode with opencode --agent test
  2. Ask the agent to edit a file under Docs/ (e.g. Docs/readme.md)
  3. Observe that the edit is denied even though the specific Docs/*: allow rule should take precedence per documentation

Screenshot and/or share link

Image

Operating System

Windows 10 Pro 24H2 (build 26100)

Terminal

Windows Terminal, PowerShell 5.1

Activity

  1. github-actions commented on Jun 11, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your issue is distinct or adds new information, feel free to clarify.

  2. ro-mak commented on Jun 11, 2026

    @ro-mak

    I have the same issue in OpenCode CLI 1.17.3 macos version

  3. github-actions commented on Aug 11, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions