Resolved current policy after all updates:
- deny_wins: false
- expiry_inclusive: false
- inherit_roles: false
- owner_bypass: false
- action_casefold: false
- group_union: false
- resource_scope: prefix
- suspended_denies: false
- token_ttl: 200
- wildcard_action: false
- audit_denials: false
- default_allow: false

Implementation notes: the policy still handles the disabled options generically, but only the first-deny order matters here. A grant has role, action, scope and expires fields. Prefix scope means resource.id starts with grant.scope. Without deny_wins, any allow suffices. A grant's effect is read from `effect`, treating "deny" as deny and anything else as allow.

```json
{"files":{"main.ts":"import {run} from './core.ts';\nimport {POLICY} from './policy.ts';\nexport function evaluate(payload: any): any { return run(payload, POLICY); }\n","policy.ts":"export const POLICY: any = {\n  deny_wins: false,\n  expiry_inclusive: false,\n  inherit_roles: false,\n  owner_bypass: false,\n  action_casefold: false,\n  group_union: false,\n  resource_scope: 'prefix',\n  suspended_denies: false,\n  token_ttl: 200,\n  wildcard_action: false,\n  audit_denials: false,\n  default_allow: false\n};\n","helpers.ts":"export function lower(s: any): string { return String(s).replace(/[A-Z]/g, (c) => String.fromCharCode(c.charCodeAt(0) + 32)); }\nexport function expandRoles(initial: string[], parents: any): Set<string> {\n  const seen = new Set<string>(initial);\n  const stack = [...initial];\n  while (stack.length) {\n    const r = stack.pop() as string;\n    const ps = parents && Object.prototype.hasOwnProperty.call(parents, r) ? parents[r] : [];\n    for (const p of (Array.isArray(ps) ? ps : [])) {\n      if (!seen.has(p)) { seen.add(p); stack.push(p); }\n    }\n  }\n  return seen;\n}\n","core.ts":"import {lower, expandRoles} from './helpers.ts';\n\nexport function run(payload: any, policy: any): any {\n  const subject = payload.subject || {};\n  const resource = payload.resource || {};\n  const fin = (allowed: boolean, reason: string, matched: number[]) => ({\n    allowed,\n    reason,\n    matched,\n    audit: !allowed && policy.audit_denials ? [reason] : []\n  });\n  if (subject.tenant !== resource.tenant) return fin(false, 'tenant', []);\n  if (payload.now - payload.issued_at > policy.token_ttl) return fin(false, 'token', []);\n  if (policy.suspended_denies && subject.suspended) return fin(false, 'suspended', []);\n  if (policy.owner_bypass && subject.owner) return { allowed: true, reason: 'owner', matched: [], audit: [] };\n\n  let initial: string[] = [...(subject.roles || [])];\n  if (policy.group_union) initial = initial.concat(subject.groups || []);\n  const roles = policy.inherit_roles ? expandRoles(initial, payload.role_parents || {}) : new Set<string>(initial);\n\n  const grants: any[] = payload.grants || [];\n  const matched: number[] = [];\n  let anyAllow = false;\n  let anyDeny = false;\n  const act = policy.action_casefold ? lower(payload.action) : payload.action;\n  grants.forEach((g, i) => {\n    if (!roles.has(g.role)) return;\n    const ga = policy.action_casefold ? lower(g.action) : g.action;\n    const actionOk = ga === act || (policy.wildcard_action && g.action === '*');\n    if (!actionOk) return;\n    const scope = g.scope === undefined || g.scope === null ? '' : String(g.scope);\n    const id = String(resource.id);\n    const scopeOk = policy.resource_scope === 'exact' ? scope === id : id.startsWith(scope);\n    if (!scopeOk) return;\n    const e = g.expires;\n    const expOk = e === null || e === undefined || (policy.expiry_inclusive ? payload.now <= e : payload.now < e);\n    if (!expOk) return;\n    matched.push(i);\n    if (g.effect === 'deny') anyDeny = true; else anyAllow = true;\n  });\n\n  if (matched.length === 0) {\n    return fin(!!policy.default_allow, 'default', []);\n  }\n  const allowed = policy.deny_wins ? (anyAllow && !anyDeny) : anyAllow;\n  return fin(allowed, 'grants', matched);\n}\n"}}
```