Skip to content

Provider permissions: tier resolution engine #165

Description

@jeonghun-jj-lee

Important

Decision Surface

Problem: No runtime logic exists to resolve a model's effective permissions from its trust tier assignment.

Approach: Implement resolveProviderPermission(modelId, action, resource) — looks up model → tier → directory rules → effect. Most-specific glob wins. O(1) tier lookup via pre-built map.

Scope: Resolution engine only. Does not wire into the permission system (that is slice #4).


Acceptance Criteria

  • resolveProviderPermission(modelId, action, resource) returns the correct Effect for any model/action/resource combination
  • Unassigned models (not in assignments) resolve against the defaultTier
  • Most-specific glob wins: ~/secrets/** takes priority over ** for paths under ~/secrets/
  • Action mapping is correct: read action resolves against the read group, glob/grep also resolve against read; write/edit against write; bash against execute; webfetch/websearch against network
  • Tier lookup is O(1) — uses a pre-built Map<tierId, TrustTier> not a list scan
  • Returns undefined when no rule matches (signals fallthrough to existing permission system)

Key Decisions

# Decision Rationale
1 Pre-build a Map<tierId, TrustTier> at config parse time O(1) lookup per tool call
2 Return undefined for no-match (not "ask") Lets the enforcement hook distinguish "no opinion" from "explicitly ask"
3 Glob specificity by pattern length (longest match wins) Simple, predictable, matches user mental model

Testing Decisions

  • Test model in "trusted" tier gets "allow" for all actions
  • Test model in "limited" tier gets "allow" for read, "deny" for write/execute/network
  • Test unassigned model falls through to default tier
  • Test most-specific-glob precedence (specific dir rule overrides wildcard)
  • Test action-to-group mapping (grep → read, edit → write, bash → execute, webfetch → network)
  • Test returns undefined when tier has no matching directory rule

Constraints & Invariants

  • Pure function with no side effects — stateless resolution from config
  • Must handle the case where a model's assigned tier ID no longer exists in config (treat as unassigned)

Source

Part of #163
Blocked by #164

Metadata

Metadata

Assignees

Labels

afkImplement + merge unattended

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions