┌─────────────────────────────────────────────────────────────────┐
│ EVALUATION INPUT │
│ { actor, scopeId, action, resource, context } │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ 1. RESOURCE POLICIES │
│ • Find policies targeting this resource │
│ • Find collections matching this resource │
│ • Evaluate subject/context conditions │
│ • If match → return allow/deny │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ 2. RESOURCE HIERARCHY │
│ • Check parent resources (if cascade: inherit) │
│ • Traverse ancestors until permission found │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ 3. ROLE-BASED PERMISSIONS │
│ • Resolve subject memberships in scope hierarchy │
│ • Collect role assignments │
│ • Gather permissions from roles │
│ • Apply scope overrides │
│ • Match action/resource pattern │
│ • Evaluate conditional permissions │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ EVALUATION OUTPUT │
│ { allowed, matches, explanation, evaluatedPolicy, ... } │
└─────────────────────────────────────────────────────────────────┘