Enforce central authorization with group ancestry and bounded revocation (#10) #44

Merged
amiryahaya merged 13 commits from feat/10-central-authorization into main 2026-10-22 18:27:56 +02:00
Owner

Implements issue #10 (F05): one deny-by-default authorization path, including group ancestry, at the request boundary, with freshness read on every call so revocation takes effect on the next call. Follows the plan and the identity design.

This does not authorize operational or classified data. The revocation ceiling (OD-14), behavior after revocation (OD-12) and the other open decisions in the decision register are still proposals. Synthetic labels and test routes only.

What it adds

  • GroupGraph in rag-domain: validated, bounded, cycle-free, same-organization. A document is readable only via the subject's direct groups and their ancestors, never descendants, siblings or other organizations. Documents carry an optional group in the marking.
  • Decider and search scope (rag-authorization, still pure, no I/O): the group rule, permitted_groups for SQL and Qdrant prefilters, and UnexpectedGroup (a conversation marking that carries a group is denied).
  • PolicySource, StaticPolicySource, GroupSource and a PostgreSQL group source read in one REPEATABLE READ, READ ONLY snapshot. Errors, timeouts and inconsistent graphs never yield a permit.
  • Enforcer in rag-api: re-reads session, policy and groups on every call (no cache) and answers permit, hidden or unavailable. Absent, forbidden, cross-organization and unauthenticated requests get byte-identical 404s; dependency failures get a uniform 503. SearchGrant carries a scope plus matching contexts for adapters. ResourceLoader receives the verified subject so a conversation loader can enforce ownership.
  • The conversation codec now refuses group-tagged markings on write.
  • Revocation tests for nine causes (each proves a permit first), a read-counter test pinning "no cache" on the group source, and a propagation measurement.
  • Operations guide docs/operations/authorization.md; OD-14 evidence line in the register (status unchanged).

Verification (this branch, local PostgreSQL 17)

  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
  • cargo test --workspace --locked: 68 passed, 0 failed, 75 ignored (the PostgreSQL suites).
  • bash scripts/test-postgres.sh --local: admin 4, authz 10, identity 30, policy 1, foundation 15, recovery 9, revocation 6, all passing.
  • Rust line coverage 90.18% at the task-5 measurement (gate 80%); not re-measured after the final fix wave. Frontend unchanged on this branch.
  • Test-first throughout; each task had an independent spec-and-quality review and a final whole-branch review. The final review found no Critical issues; its three Important findings were fixed and re-reviewed.
  • Propagation (local, synthetic, 20 runs x 3): p50 2.7 to 4.7 ms, worst case 5.8 to 20.4 ms, dominated by the write latency of the suspension commit. A regression guard, not an SLA.

Known gaps and open decisions

  • No document or conversation routes exist yet (#17, #13); the boundary is proven through test routes.
  • An already-issued search grant stays valid until its own short expiry (bounded by the enforcer limit); documented.
  • Each enforcement call reads the whole identity_groups table and the 10,000-node cap is global (fail-closed); scoping per organization is a follow-up.
  • Open decisions recorded, not changed: a lapsed policy snapshot gives 404 not 503; a missing session gives 404 here but 401 through ActiveSubject.
  • The ResourceLoader contract must forbid id-dependent errors before the first real loader (#17).
  • SearchGrant cannot carry cancellation yet (#19/#20); decision audit and metrics belong to #11 and O02.
  • A pre-existing readiness test in postgres.rs can flake under --test-threads=4.
  • Needs independent human review before merge.

Refs #10, #2, #9.

🤖 Generated with Claude Code

Implements issue #10 (F05): one deny-by-default authorization path, including group ancestry, at the request boundary, with freshness read on every call so revocation takes effect on the next call. Follows the [plan](docs/superpowers/plans/2026-10-23-central-authorization.md) and the [identity design](docs/superpowers/specs/2026-10-22-identity-groups-and-recovery-design.md). **This does not authorize operational or classified data.** The revocation ceiling (OD-14), behavior after revocation (OD-12) and the other open decisions in the [decision register](docs/decisions.md) are still proposals. Synthetic labels and test routes only. ## What it adds - `GroupGraph` in `rag-domain`: validated, bounded, cycle-free, same-organization. A document is readable only via the subject's direct groups and their ancestors, never descendants, siblings or other organizations. Documents carry an optional group in the marking. - Decider and search scope (`rag-authorization`, still pure, no I/O): the group rule, `permitted_groups` for SQL and Qdrant prefilters, and `UnexpectedGroup` (a conversation marking that carries a group is denied). - `PolicySource`, `StaticPolicySource`, `GroupSource` and a PostgreSQL group source read in one `REPEATABLE READ, READ ONLY` snapshot. Errors, timeouts and inconsistent graphs never yield a permit. - `Enforcer` in `rag-api`: re-reads session, policy and groups on every call (no cache) and answers permit, hidden or unavailable. Absent, forbidden, cross-organization and unauthenticated requests get byte-identical 404s; dependency failures get a uniform 503. `SearchGrant` carries a scope plus matching contexts for adapters. `ResourceLoader` receives the verified subject so a conversation loader can enforce ownership. - The conversation codec now refuses group-tagged markings on write. - Revocation tests for nine causes (each proves a permit first), a read-counter test pinning "no cache" on the group source, and a propagation measurement. - Operations guide `docs/operations/authorization.md`; OD-14 evidence line in the register (status unchanged). ## Verification (this branch, local PostgreSQL 17) - `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean. - `cargo test --workspace --locked`: 68 passed, 0 failed, 75 ignored (the PostgreSQL suites). - `bash scripts/test-postgres.sh --local`: admin 4, authz 10, identity 30, policy 1, foundation 15, recovery 9, revocation 6, all passing. - Rust line coverage 90.18% at the task-5 measurement (gate 80%); not re-measured after the final fix wave. Frontend unchanged on this branch. - Test-first throughout; each task had an independent spec-and-quality review and a final whole-branch review. The final review found no Critical issues; its three Important findings were fixed and re-reviewed. - Propagation (local, synthetic, 20 runs x 3): p50 2.7 to 4.7 ms, worst case 5.8 to 20.4 ms, dominated by the write latency of the suspension commit. A regression guard, not an SLA. ## Known gaps and open decisions - No document or conversation routes exist yet (#17, #13); the boundary is proven through test routes. - An already-issued search grant stays valid until its own short expiry (bounded by the enforcer limit); documented. - Each enforcement call reads the whole `identity_groups` table and the 10,000-node cap is global (fail-closed); scoping per organization is a follow-up. - Open decisions recorded, not changed: a lapsed policy snapshot gives 404 not 503; a missing session gives 404 here but 401 through `ActiveSubject`. - The `ResourceLoader` contract must forbid id-dependent errors before the first real loader (#17). - `SearchGrant` cannot carry cancellation yet (#19/#20); decision audit and metrics belong to #11 and O02. - A pre-existing readiness test in `postgres.rs` can flake under `--test-threads=4`. - Needs independent human review before merge. Refs #10, #2, #9. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Five test-first tasks for issue 10: validated group graph and document
group marking, the group rule in the decider and search scope, a
fail-closed policy source, request-boundary enforcement with hidden-or-
unavailable outcomes, and revocation propagation with measurement.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner-scoped loaders can now hide conversations the subject does not own.
Also corrects the absent-fixture reasoning, de-flakes the grant context test
and records known limits and open decisions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs: record revocation propagation evidence against OD-14
All checks were successful
CI / Web checks (push) Successful in 1m1s
CI / Web checks (pull_request) Successful in 1m13s
CI / Rust checks (pull_request) Successful in 11m45s
CI / Rust checks (push) Successful in 12m26s
b2ef1cb3d2
Add the local, synthetic measurement from issue 10 to the OD-14 row of
the decision register and link the register from the authorization
operations guide. The status stays proposed; nothing is approved.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No description provided.