[P0] F02: Complete typed security values and policy-owned authorization contracts #7

Closed
opened 2026-10-21 20:29:22 +02:00 by amiryahaya · 1 comment
Owner

Backlog ID: F02 | Priority: P0 | Phase: M1 — Secure build and persistence foundation

Outcome and scope

Extend the existing policy skeleton with domain-owned identifiers, security markings, request context, freshness/version metadata, explicit actions and policy-owned AuthorizedSearchScope. Document interface invariants before adapters consume them.

Dependencies and gates

Engineering prerequisites: #6 (F01)

Synthetic-data development may proceed. Production use remains subject to the decision gates in the SRS.

Starting points

crates/domain/src/; crates/authorization/src/; crates/authorization/tests/

These are current files or proposed responsibility boundaries; finalize a focused implementation plan before coding. Existing local scaffolding is uncommitted and is not evidence of completion.

Acceptance criteria

  • Only verified identity/policy code constructs trusted subjects and search scopes; HTTP payloads cannot deserialize directly into trusted types.
  • Classification comparisons use configured ranks; resolve the existing TOP SECRET fixture spelling against the SRS placeholder TOP_SECRET without treating lexical string order as clearance order.
  • Malformed/missing/stale attributes and policy mismatch deny; org/tenant, compartments and need-to-know semantics are explicit.
  • Public contracts define authorization ordering, errors, cancellation/deadlines where applicable, and adapter substitution expectations without SDK/SQL types.

Verification

Red/green tests exercise unknown labels, lexical-order traps, malformed scope, stale snapshots, missing org and compartments; shared contract tests cover permit and deny matrices.

Behavior changes follow Red → Green → Refactor. Run affected Rust shared contract/unit tests and real PostgreSQL/Qdrant/runtime integration tests where applicable; frontend changes run typecheck/build and the relevant browser tests. Record exact commands/results in the implementation PR. Documentation/decision tasks use recorded review evidence.

Requirements and design

FR-AUTH-003–005, 009; NFR-MAINT-001–003; architecture §§5.3, 6

Sources: SRS, system design. Local planning context: docs/implementation-plan.md and docs/development-backlog.md (not published by this task).

Security impact: Use synthetic fixtures until approved for operational data. Preserve current authorization, markings, provenance and default-deny behavior; exclude protected payloads/secrets from operational telemetry. No classified-deployment or PQC-compliance claim is implied by closing this issue.

Parent roadmap: #1

Implementation status

Implemented in draft PR #38 on feat/7-security-contracts, head 1ec1176. All four acceptance criteria are verified. Push CI #4 and PR CI #5 passed both Rust/web jobs. Local fmt/Clippy, 17 behavioral test functions (including shared permit/deny matrices), six compile-fail checks and frontend typecheck/build passed.

Independent review found no current authorization bypass. Its adapter-test coverage finding was addressed by placing rank, scope constraints, lifetime, ownership and grant invariants in reusable &dyn PolicyDecider contract helpers. Organization/tenant semantics are one mandatory exact partition; missing organization denies rather than widening scope.

The focused plan is docs/superpowers/plans/2026-10-22-security-contracts.md and interface obligations are in crates/authorization/README.md on the PR branch. Production identity/revocation and actual PostgreSQL/Qdrant filter implementations remain later issues. Keep this issue open pending review and merge.

**Backlog ID:** F02 | **Priority:** P0 | **Phase:** M1 — Secure build and persistence foundation ## Outcome and scope Extend the existing policy skeleton with domain-owned identifiers, security markings, request context, freshness/version metadata, explicit actions and policy-owned AuthorizedSearchScope. Document interface invariants before adapters consume them. ## Dependencies and gates **Engineering prerequisites:** #6 (F01) Synthetic-data development may proceed. Production use remains subject to the decision gates in the SRS. ## Starting points crates/domain/src/; crates/authorization/src/; crates/authorization/tests/ These are current files or proposed responsibility boundaries; finalize a focused implementation plan before coding. Existing local scaffolding is uncommitted and is not evidence of completion. ## Acceptance criteria - [x] Only verified identity/policy code constructs trusted subjects and search scopes; HTTP payloads cannot deserialize directly into trusted types. - [x] Classification comparisons use configured ranks; resolve the existing TOP SECRET fixture spelling against the SRS placeholder TOP_SECRET without treating lexical string order as clearance order. - [x] Malformed/missing/stale attributes and policy mismatch deny; org/tenant, compartments and need-to-know semantics are explicit. - [x] Public contracts define authorization ordering, errors, cancellation/deadlines where applicable, and adapter substitution expectations without SDK/SQL types. ## Verification Red/green tests exercise unknown labels, lexical-order traps, malformed scope, stale snapshots, missing org and compartments; shared contract tests cover permit and deny matrices. Behavior changes follow Red → Green → Refactor. Run affected Rust shared contract/unit tests and real PostgreSQL/Qdrant/runtime integration tests where applicable; frontend changes run typecheck/build and the relevant browser tests. Record exact commands/results in the implementation PR. Documentation/decision tasks use recorded review evidence. ## Requirements and design FR-AUTH-003–005, 009; NFR-MAINT-001–003; architecture §§5.3, 6 Sources: [SRS](https://forgejo.primatekun.tech/primatekuntech/rag-rust/src/branch/main/docs/SRS.md), [system design](https://forgejo.primatekun.tech/primatekuntech/rag-rust/src/branch/main/docs/architecture.md). Local planning context: `docs/implementation-plan.md` and `docs/development-backlog.md` (not published by this task). **Security impact:** Use synthetic fixtures until approved for operational data. Preserve current authorization, markings, provenance and default-deny behavior; exclude protected payloads/secrets from operational telemetry. No classified-deployment or PQC-compliance claim is implied by closing this issue. **Parent roadmap:** #1 ## Implementation status Implemented in draft PR #38 on `feat/7-security-contracts`, head `1ec1176`. All four acceptance criteria are verified. [Push CI #4](https://forgejo.primatekun.tech/primatekuntech/rag-rust/actions/runs/4) and [PR CI #5](https://forgejo.primatekun.tech/primatekuntech/rag-rust/actions/runs/5) passed both Rust/web jobs. Local fmt/Clippy, 17 behavioral test functions (including shared permit/deny matrices), six compile-fail checks and frontend typecheck/build passed. Independent review found no current authorization bypass. Its adapter-test coverage finding was addressed by placing rank, scope constraints, lifetime, ownership and grant invariants in reusable `&dyn PolicyDecider` contract helpers. Organization/tenant semantics are one mandatory exact partition; missing organization denies rather than widening scope. The focused plan is `docs/superpowers/plans/2026-10-22-security-contracts.md` and interface obligations are in `crates/authorization/README.md` on the PR branch. Production identity/revocation and actual PostgreSQL/Qdrant filter implementations remain later issues. Keep this issue open pending review and merge.
Author
Owner

Implementation started on feat/7-security-contracts from merged main. Added validated domain identifiers, rank-free classifications, mandatory exact organization scope, typed validity/markings/actions, private verified identity promotion and policy-issued request-scoped search constraints. Red/green tests cover malformed attributes, stale/future snapshots, rank traps, all required grants, resource policy/status, deadlines and scope lifetime/ownership. Local workspace checks and frontend build pass; independent review and hosted CI are next. Production identity/revocation and real storage filters remain in F04/F05 and storage issues.

Implementation started on `feat/7-security-contracts` from merged main. Added validated domain identifiers, rank-free classifications, mandatory exact organization scope, typed validity/markings/actions, private verified identity promotion and policy-issued request-scoped search constraints. Red/green tests cover malformed attributes, stale/future snapshots, rank traps, all required grants, resource policy/status, deadlines and scope lifetime/ownership. Local workspace checks and frontend build pass; independent review and hosted CI are next. Production identity/revocation and real storage filters remain in F04/F05 and storage issues.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
primatekuntech/rag-rust#7
No description provided.