From 55fc45955ee54ca5c0c5e9aa6d493f012cdffff1 Mon Sep 17 00:00:00 2001 From: repo-worker-code-k Date: Sun, 8 Nov 2026 13:13:50 -0600 Subject: [PATCH 1/2] docs(id): residency & boundaries framework skeleton design (#5683) Drafts the framework design record for #5683 step 1: the declaration model, evidence assurance levels (self / org-attested / provider-verified) with lifetime and privacy classes, public-IP-as-evidence limits and contradiction handling, sanctions boundaries modelled as versioned data with grandfathering and appeals, intranet mode with step-up and org-escrow proxying, intersection-only composability, and per-surface enforcement. Reuses pkgs/id/crates/id-core/src/residency.rs unchanged and extends it additively. Capabilities-never-defaults and basic-frameworks-first are restated as hard requirements. No implementation code. --- doc/2026-11-08_design_id5683.md | 522 ++++++++++++++++++++++++++++++++ 1 file changed, 522 insertions(+) create mode 100644 doc/2026-11-08_design_id5683.md diff --git a/doc/2026-11-08_design_id5683.md b/doc/2026-11-08_design_id5683.md new file mode 100644 index 0000000000..086e79b84b --- /dev/null +++ b/doc/2026-11-08_design_id5683.md @@ -0,0 +1,522 @@ +# Design: residency & boundaries framework — declarations, evidence, and enforcement skeleton + +- **Date:** 2026-11-08 +- **Status:** proposed design for review; no implementation is included here. +- **Issue:** [#5683](https://github.com/developing-today/code/issues/5683), + "design(id): residency & boundaries framework — opt-in capabilities, + framework-first". +- **Programme:** epic [#2056](https://github.com/developing-today/code/issues/2056). +- **Unifies:** [#2283](https://github.com/developing-today/code/issues/2283) + (jurisdiction-aware hosted stores), [#3397](https://github.com/developing-today/code/issues/3397) + (jurisdiction-partitioned worlds / blobs), + [#3398](https://github.com/developing-today/code/issues/3398) (residency + boundaries for bridge / federation / relays). All three are CLOSED + COMPLETED with their own per-thread design records; this record supplies + the shared vocabulary underneath them and does not re-decide them. +- **Landed component this record reuses:** `pkgs/id/crates/id-core/src/residency.rs` + (#3398 design step 1 via #5529) — `Plane`, `Jurisdiction`, `ResourceId`, + `Scope`, `Policy`, `PlanePolicy`, `Evidence`, `EvidenceVerifier`, `Hop`, + `DenyReason`, `Decision`, `evaluate()`. +- **Child already landed from the decomposition:** #5883 boundary audit & + appeals UX, `doc/2026-11-08T09-15-00Z_design_boundary_audit_appeals.md`. + That record *relies on* the parent decisions restated here (§1) and does + not replace this skeleton. +- **Evidence baseline:** `origin/main` at `26018ce4e7`, worktree + `~/git/fleet/queue-12757-5683-residency-framework` (laptop), 2026-11-08. + Verified at that baseline: no `5683` framework design record exists in + `doc/`; no open PR references #5683; `pkgs/id/crates/id-core/src/residency.rs` + is present with the vocabulary above. + +## Decision summary + +| Question | Decision | +| --- | --- | +| What this framework is | A **capability catalogue plus one declaration format**: the shared vocabulary every surface (#2283/#3397/#3398) uses to say *which boundary, on what evidence, enforced where, failing how*. It is not a policy engine and not a compliance product (§2) | +| Default state | **Off, always.** Every boundary is an opt-in capability an admin or user enables for a scope they control. No deployment inherits a boundary it did not choose. An enabled boundary with no declaration is a configuration error, not an implicit deny (§1, §2.3) | +| Subject / scope | A boundary is declared on a **scope** (server / world / account) for a **subject class** (user / org / server / world). Scope is assigned locally and a peer cannot remove it — the `Scope` type already encodes this (§2.2) | +| Evidence model | Evidence is a typed record with **assurance level** (self / org-attested / provider-verified), **provenance**, **lifetime** (expiry, renewal, revocation), and **privacy class**. Declarations are evidence; IP is weak evidence; signatures prove authorship, not location (§3) | +| Public IP | **Never sufficient alone** for a deny that removes existing access. It may corroborate, warn, or trigger step-up/review. Contradiction between declaration and IP resolves to **review**, not silent deny (§4) | +| Sanctions | The list is **data, not code**: versioned, dated, operator-supplied or shipped, with propagation, grandfathering, and an appeal path. A sanctions boundary declares which interactions it covers (§5) | +| Intranet mode | A boundary type over **network identity** (IP ranges / overlay / mTLS / org IdP assertion), gating generic activity, with 2FA step-up points, fail-closed default, and a logged break-glass (§6) | +| Composability | **Intersection, always.** Server ∧ world ∧ user preference can only narrow. A user preference can never widen a server boundary; a conflict is a deny-with-reason, not a merge (§7) | +| Enforcement | The existing `evaluate()` is the decision procedure at every surface; each surface supplies hops. Denials and step-ups are logged with the evidence *classes* used, never the dossier (§8) | +| Reuse vs new code | Reuse `residency.rs` unchanged for plane/jurisdiction/resource evaluation. Extend with an evidence-assurance layer and a declaration record — additions, not replacements (§9) | + +## 1. What is fixed before this record (not re-decided here) + +Drew's framing on #5683 is a hard requirement, restated so children can cite +it rather than re-derive it: + +1. **Capabilities, never defaults.** Restrictions are capabilities a server + admin or user enables for their server / world / account. Nothing turns a + restriction on by default, and no deployment inherits a boundary it did + not choose. +2. **Basic frameworks first.** Ship the declaration, evidence, and + enforcement skeleton in its simplest useful form before policy language, + automated classification, or jurisdiction-specific rule packs. +3. **Not a GDPR product.** EU privacy is one possible use, not the design + centre. Nothing here assumes a legal regime; the operator's obligations + are the operator's. + +Also fixed by the three closed source threads, cited not re-decided: + +- **#3398 / `residency.rs`:** four independent planes (storage, processing, + transport, metadata); a scoped path is denied unless every required plane + has current, trusted, resource-bound evidence in a permitted jurisdiction; + missing/unknown/expired/revoked/mismatched evidence all deny; a peer's own + location statement is never evidence. +- **#2283:** jurisdiction may pin where a user's store / world data lives. +- **#3397:** a world may be partitioned or pinned by jurisdiction. + +## 2. Framework shape + +### 2.1 Three layers, one vocabulary + +The framework is deliberately thin. It defines: + +1. **A capability catalogue** — the closed set of boundary types this + skeleton understands: `residency`, `citizenship`, `sanctions`, `network` + (intranet). Each is a capability with a declared default of *off*. +2. **One declaration format** (§2.3) shared by all surfaces. +3. **One decision procedure** — `residency.rs::evaluate()` (§8), extended + only where assurance and declaration lifetime require it. + +Surfaces (#2283 signup/login, #3397 world membership/blobs, #3398 bridge/ +federation/relay) do not each invent a model; they *supply hops* to the one +evaluator and *render* the one `Decision`. + +### 2.2 Scope and subject + +| Term | Meaning | Source | +| --- | --- | --- | +| **Scope** | The unit that *owns* a boundary: a server, a world, or an account. Assigned locally; a peer cannot remove it | `residency.rs::Scope` | +| **Subject** | What a boundary is *about*: a user, an org, a server, or a world | new `SubjectClass` | +| **Plane** | Which of storage / processing / transport / metadata a hop crosses | `residency.rs::Plane` | +| **Resource** | The exact store, host, relay or sink a hop uses | `residency.rs::ResourceId` | + +The distinction that keeps the model honest: **scope owns the rule, subject is +judged by it.** A world scope (a world) declares a residency boundary; the +subject is a user joining it. Conflating the two is what produces designs +where a user "has" a boundary rather than being subject to one. + +### 2.3 The declaration record + +One format, used by every capability: + +``` +BoundaryDeclaration { + id: DeclarationId // content-addressed; edits are new ids + capability: CapabilityKind // residency | citizenship | sanctions | network + scope: ScopeRef // server | world | account that owns it + subject_class: SubjectClass // user | org | server | world + evidence_req: EvidenceRequirement // minimum assurance + accepted sources (§3) + enforcement: [EnforcementPoint] // where checked (§8); empty = not enforced + failure: FailureBehaviour // deny | warn | step-up | quarantine (§2.4) + data_ref: Option // sanctions/network list version, if any + enabled: bool // MUST be true only by explicit admin/user action + version: u64 // monotone; every change is a new version + declared_by: ActorId // who enabled it + declared_at: Timestamp +} +``` + +Rules that follow from the framing: + +- **`enabled: false` is the only default.** A record with `enabled: true` and + empty `enforcement` is rejected at declaration time — a boundary nobody + enforces is a false promise, worse than no boundary. +- **Every change is a new version.** There is no in-place edit of a live + declaration; the version is what makes a logged decision reproducible + (the #5883 decision log records the version applied). +- **Declarations are data.** They are stored and replicated like other + scoped state, not compiled into the binary. The *capability kinds* are + code; *which* boundary a scope enables is data. + +### 2.4 Failure behaviours + +Four, and no more, in the skeleton: + +| Behaviour | Meaning | When appropriate | +| --- | --- | --- | +| `deny` | Refuse the action | A boundary whose whole point is exclusion, and whose evidence is strong enough (§3.4) | +| `warn` | Allow, tell the user, log | Weak evidence (IP) contradicting a declaration | +| `step-up` | Allow after a stronger authentication | Network boundaries, privilege escalation (§6) | +| `quarantine` | Allow into a holding state pending review | Contradictions needing a human (§4.3) | + +`deny` is the *strongest* action and therefore the one with the strictest +evidence bar. This ordering is the framework's main safety property: the +easier a signal is to spoof, the weaker the action it may drive. + +## 3. Evidence model + +### 3.1 What counts as evidence + +Evidence is a typed record, extending `residency.rs::Evidence` with the +fields the declaration model needs: + +| Field | Purpose | +| --- | --- | +| `issuer` | Locally trusted identity of who asserts this (already in `Evidence`) | +| `resource`, `plane`, `jurisdiction`, `source` | What it establishes (already in `Evidence`) | +| `expires_at`, `serial`, `signature` | Lifetime and authenticity (already in `Evidence`) | +| **`assurance`** | `Self` \| `OrgAttested` \| `ProviderVerified` — **new** | +| **`basis`** | Free-text/structured provenance: on what basis was this declared (§3.2) — **new** | +| **`privacy_class`** | `Exact` \| `Derived` \| `VerdictOnly` — what may be revealed downstream (§3.3) — **new** | +| **`subject`** | The user/org this evidence is about — **new** | + +The existing `EvidenceVerifier` trait already decides signature validity and +revocation; the assurance level is an *additional* operator-side judgement +about how the claim was established, not a cryptographic property. + +### 3.2 Assurance levels + +| Level | Meaning | Who can assert | Typical basis | +| --- | --- | --- | --- | +| `Self` | The subject says so | The subject | A form field | +| `OrgAttested` | An organisation vouches for the subject | An org the operator trusts | HR record, membership roster | +| `ProviderVerified` | A trusted third party verified a document or fact | A configured provider | Document check, government/IdP assertion | + +The framework **stores the level; it does not pretend the levels are equal.** +A declaration's `evidence_req` names the *minimum* level it accepts. A +sanctions boundary may accept `Self` plus review; a residency boundary that +pins storage may require `OrgAttested` or better. + +**Signatures prove authorship, not truth.** An `OrgAttested` claim signed by +an org proves that org said it — the operator's trust in that org is the +real content of the assurance. This is the same discipline `residency.rs` +already applies to location: "a signature proves authorship, not physical +location." + +### 3.3 Privacy of the declaration itself + +The evidence store must not become a dossier. Three privacy classes, chosen +per declaration by the declaring scope: + +- **`Exact`** — the value is stored and readable by the subject and by + scope admins. Never exposed to other subjects. +- **`Derived`** — only a derived form (e.g. country, not address) is stored. +- **`VerdictOnly`** — *nothing* about the value is stored beyond "satisfies + boundary X at time T". This is the default for IP evidence (§4). + +Cross-subject visibility is **never** granted by default: a user cannot learn +another user's declared citizenship. An admin sees evidence *classes* and +verdicts in the decision log (§8), not raw values, unless the declaration is +`Exact` and the admin's role specifically grants it. + +### 3.4 What each assurance may drive + +| Evidence | May `warn` | May `step-up` | May `quarantine` | May `deny` new access | May `deny` existing access | +| --- | --- | --- | --- | --- | --- | +| `Self` declaration | yes | yes | yes | only if `evidence_req` accepts it | **no** | +| `OrgAttested` | yes | yes | yes | yes | yes, with appeal path | +| `ProviderVerified` | yes | yes | yes | yes | yes, with appeal path | +| IP-derived (any) | yes | yes | yes | only as declared and only for new access | **no** | + +The last column is the load-bearing rule: **no weak signal removes access a +subject already has.** Removing existing access requires either strong +evidence or a human decision (§5.4, §4.3). + +## 4. Public IP as evidence + +### 4.1 What is derived + +The public IP a connection arrives from is a *signal*, never an identity. +The framework permits deriving, in increasing privacy: + +1. a **country/region verdict** (default), +2. a **boundary verdict** — "inside / outside boundary X" (`VerdictOnly`), +3. the **raw IP** only when a scope explicitly enables it for a stated + retention window and purpose. + +Default retention for derived IP evidence is **short** (the connection's +lifetime plus a bounded window), because IP is personal data in most +regimes and the framework's job is to need less of it, not more. + +### 4.2 Known error modes (must be stated in any UI that uses IP evidence) + +VPN / commercial proxy, CGNAT (many users behind one address), corporate +egress (all staff appear in one country), mobile networks (address changes +mid-session), satellite / Starlink (egress country ≠ user country), and +relay/bridge connections where **the visible IP is the relay's, not the +user's**. The last one means IP evidence is *structurally unavailable* on +federated paths — the framework must say so rather than silently treat a +relay's address as the user's. + +### 4.3 Contradiction handling + +When declared evidence and IP evidence disagree: + +| Situation | Behaviour | +| --- | --- | +| Declaration admits, IP contradicts, action is *new* access | `warn` by default; admin may raise to `step-up` or `quarantine` | +| Declaration admits, IP contradicts, action is *existing* access | `warn` only. Never deny on IP alone (§3.4) | +| No declaration, IP only | May gate *new* access per the declaration's `evidence_req`; never removes existing access | +| Two IP signals disagree (e.g. X-Forwarded-For vs socket) | Treat as **unknown** — unknown denies new access under a scoped policy, per `residency.rs` | + +**X-Forwarded-For trust is explicit and off by default.** A scope must +declare which proxies it trusts to set forwarding headers; an untrusted +header is ignored, not believed. This is the same "peer's own statement is +never evidence" rule `residency.rs` already enforces. + +## 5. Sanctions boundaries + +### 5.1 The list is data + +A sanctions boundary references a **versioned list**, never hard-coded +country or entity names: + +``` +ListVersion { id, source, effective_from, effective_to, entries, signature } +``` + +- **Source:** operator-supplied (their own list) or a list shipped with the + software as a *starting point*, clearly labelled as not legal advice. + The framework does not fetch external feeds in the skeleton — that is a + later step (§11). +- **Updates propagate as new versions.** A decision log entry names the list + version applied, so a past decision is reproducible against the list that + produced it. +- **Effective dates** are part of the data: a list entry may be scheduled. + +### 5.2 Scope of "interaction" + +A sanctions boundary must declare **which interactions it covers**, because +"interact" is not one thing: + +| Interaction | Typical default when a sanctions boundary is enabled | +| --- | --- | +| Account creation / signup | covered | +| Login to an existing account | covered, with grandfathering (§5.3) | +| World membership | covered | +| Blob storage | covered | +| Bridge / federation traffic | **declared explicitly** — often *not* covered, because transit ≠ service | +| Relay transit | **declared explicitly** — a relay transiting a jurisdiction it does not serve is a different act | + +An empty `enforcement` for an interaction means *not covered*, and the +declaration must say so rather than leave it ambiguous. + +### 5.3 Grandfathering and list changes + +When a list entry **appears**, existing accounts / worlds / federation links +are **grandfathered** by default: they keep working and are flagged for +review, rather than being cut off by a data update nobody was warned about. +When an entry is **removed**, grandfathered subjects are cleared and the +removal is logged. + +This is a deliberate asymmetry: adding a restriction must not silently +destroy existing work, and the framework's default is the gentler one. + +### 5.4 False positives and appeals + +Name collisions, dual citizens, residents vs citizens, and travellers +temporarily present are *expected*, not exceptional. The framework therefore +requires: + +- an **exception path** — a subject can be recorded as an exception to a + boundary, with the evidence and the actor, as a new declaration version; +- a **review queue** for flagged subjects (the #5883 audit/appeals design + supplies the UX; this skeleton supplies the data); +- **no hard block without recourse** — a `deny` on a sanctions boundary must + name the appeal path in the user-facing message. + +## 6. Intranet-mode servers + +### 6.1 Boundary definition + +A `network` capability whose boundary is declared as one or more of: + +| Mechanism | Strength | Note | +| --- | --- | --- | +| Source IP ranges | weak | spoofable at the edge; CGNAT/VPN error modes apply | +| VPN / overlay network membership | medium | identity of the overlay peer | +| mTLS client identity | strong | cryptographic client identity | +| Org IdP assertion | strong | signed assertion from a trusted IdP | + +An admin declares which mechanisms satisfy the boundary; the strongest +available should be used for privileged actions. + +### 6.2 Gating generic activity + +Connections from **outside** the declared boundary cannot perform ordinary +user activity. The framework does not invent a new gate: it supplies hops to +`evaluate()` with `Plane::Transport` and the declared boundary as the +resource, and the surface renders the `Decision`. + +### 6.3 2FA step-up points + +Step-up is required at, at minimum: + +- entering from a **new network** (first time from this boundary context), +- **privilege escalation**, +- **admin actions**. + +A step-up grants a bounded window (declared per scope, default short); after +it expires the next privileged action steps up again. Step-ups are logged. + +### 6.4 Org-escrowed credentials + +The org escrows credentials and **proxies required details** to the server on +the user's behalf, so the server can enforce its requirements without holding +raw user data it does not need: + +- **Escrowed:** the credential material, by the org, under the org's control. +- **Proxied:** *assertions* — "member of group G", "residency attested", + "identity verified" — not raw values, wherever an assertion suffices. +- **Audit:** every proxy use is logged with what was asserted and to whom. +- **User visibility:** the user can see what was shared about them and when. +- **Un-escrow:** the user (and the org, per its own policy) can revoke; the + server then loses the assertion and re-evaluates. + +Consent model (per-use vs standing vs org-authority-alone) is an open point +(§11) with a recorded default: **standing consent, visible and revocable**, +because per-use prompts train users to click through. + +### 6.5 Degraded behaviour + +Boundary unreachable, IdP down, VPN down: **fail closed for generic +activity** — the safe default, since the boundary's purpose is exclusion. +A **break-glass** path exists, held by a named role, its use logged loudly +and surfaced to admins. Break-glass is a human action, never an automatic +fallback. + +## 7. Composability + +Server boundary ∧ world boundary ∧ user preference. The rule is +**intersection, always**: + +``` +effective = server_boundary ∩ world_boundary ∩ user_preference +``` + +- A **user preference can never widen** a server or world boundary. It can + only add restrictions the user chooses for themselves. +- A **world cannot widen** its server's boundary. +- A **conflict is a deny with a reason** naming which scope denied, not a + silent merge. The user-facing message says which boundary excluded them + and offers the appeal path. +- The intersection is computed over the same `Policy`/`Plane` vocabulary, so + there is no second merge algorithm to reason about. + +A user belonging to worlds under contradictory boundaries is **allowed**: +the contradiction is resolved per-action by intersection, and the user sees +which world's boundary excluded them. It is not the framework's job to +forbid the membership. + +## 8. Enforcement surfaces + +Each surface supplies hops and renders the decision; none re-implements +evaluation. + +| Surface | Hops supplied | Extends | +| --- | --- | --- | +| **Signup / login** | transport (connection), storage (where the account store lives) | #2283 | +| **World membership / world blobs** | storage (world blob store), processing (world turn host) | #3397 | +| **Bridge / federation / relay** | transport (peer, relay, bridge), with **peer-asserted evidence marked unverified** unless the operator trusts that peer | #3398 | +| **Capability grants / delegation** | the boundary of the grantee and the exercise location | new, minimal | + +**Peer-asserted evidence** is the sharp edge: a federated peer's claim about +a user's location is `Self`-grade evidence from that peer until the operator +adds the peer to its trust roots. The skeleton's default is *unverified*. + +**Audit:** every decision that denies, steps up, or quarantines is logged +with the scope, the boundary version, the evidence **classes** and assurance +levels consulted, the outcome, and the actor — following the #5883 decision +log. Raw evidence values are not logged (§3.3). + +## 9. Reuse of `residency.rs` + +| Need | Reuse | Extend | +| --- | --- | --- | +| Plane / jurisdiction / resource vocabulary | `Plane`, `Jurisdiction`, `ResourceId` — unchanged | — | +| Scope ownership | `Scope::{Unscoped, Scoped}` — unchanged | — | +| Per-plane allow-lists, trust roots | `Policy`, `PlanePolicy` — unchanged | — | +| Evidence authenticity + revocation | `Evidence`, `EvidenceVerifier` — unchanged | add `assurance`, `basis`, `privacy_class`, `subject` | +| Decision procedure | `evaluate()`, `DenyReason`, `Decision` — unchanged | a thin pre-step that maps a declaration + subject evidence to the `Hop`s `evaluate()` consumes | + +The extension is deliberately **additive**: `evaluate()` keeps its current +signature and semantics, so #2283/#3397/#3398 code that already calls it is +unaffected. The new layer answers "which hops does this declaration imply, +and does the subject's evidence satisfy the assurance bar?" and then hands +off to the existing evaluator. No second evaluator is introduced. + +## 10. Worked examples + +### 10.1 A sanctions-enabled public server + +- Admin enables `sanctions` on the server scope, `enabled: true`, with a + list version `L7`, covering signup + login + world membership, **not** + federation transit. +- A new signup from a listed country: `deny` at signup, message names the + appeal path. +- An existing account whose country appears in `L8`: **grandfathered** — + flagged for review, access continues until a human decides. +- A dual citizen appeals; admin records an exception as a new declaration + version; the decision log shows the exception and who granted it. + +### 10.2 An intranet-mode org server + +- Admin enables `network` on the server scope with mTLS client identity as + the boundary mechanism; generic activity requires it. +- A connection from outside: `deny` for generic activity, with a message + naming the boundary — no silent failure. +- An admin action from inside still triggers `step-up` (2FA), window 15 + minutes, logged. +- The IdP goes down: generic activity **fails closed**; break-glass is + available to the named role and its use is logged and surfaced. + +### 10.3 A jurisdiction-pinned world + +- A world enables `residency` on its own scope, requiring `OrgAttested` + evidence for `Plane::Storage` in jurisdiction `eu`. +- A joining user with a `Self` declaration only: `deny` with reason + `NoEvidence(Storage)`-equivalent — the assurance bar is not met, and the + message says an org attestation is required. +- A user with `OrgAttested` eu storage evidence: `allow`; the world's blobs + land in the eu store per #3397 partitioning. +- The user's own preference adds a stricter metadata restriction: the + intersection applies; the user's preference narrows, never widens. + +## 11. Open points (with assumed defaults) + +| Question | Assumed default for the skeleton | Why | +| --- | --- | --- | +| Minimum evidence for a sanctions boundary | `Self` declaration + human review; IP may flag | Weak signals must not hard-block (§3.4) | +| Declaration vs IP disagreement | `warn` by default; admin may raise to step-up/quarantine | Contradiction is information, not proof (§4.3) | +| Who is authoritative for a sanctions list | Operator-supplied; shipped list is a labelled starting point | No external feed in the skeleton (§5.1) | +| Org-escrow consent model | Standing consent, visible and revocable | Per-use prompts train click-through (§6.4) | +| Contradictory world memberships | Allowed; resolved per-action by intersection | Forbidding membership over-reaches (§7) | +| Evidence retention after account closure | Derived/verdict evidence deleted with the account; `Exact` per operator policy | Least data (§3.3) | +| Federation peer assertions | Unverified (`Self`-grade) until the peer is a trust root | Peers are not evidence by default (§8) | +| External sanctions feeds | Out of scope for the skeleton; a later step | Basic frameworks first (§1) | + +## 12. Decomposition into implementation issues + +The skeleton is one design; its implementation splits along the seams above. +Issues are filed and linked from #5683 in the same pass as this record: + +1. **Evidence assurance layer** — `assurance`, `basis`, `privacy_class`, + `subject` on the evidence record; assurance-bar check before `evaluate()`. +2. **Declaration record** — the `BoundaryDeclaration` type, versioning, + `enabled`-only-by-explicit-action, rejection of empty `enforcement`. +3. **Public-IP evidence derivation** — country/boundary verdicts, retention, + X-Forwarded-For trust configuration, contradiction → `warn`. +4. **Sanctions list data model** — versioned lists, effective dates, + propagation, grandfathering, exception records. +5. **Intranet-mode gating** — network boundary mechanisms, step-up points, + fail-closed, break-glass logging. +6. **Surface wiring** — #2283 signup/login, #3397 world membership/blobs, + #3398 federation/relay, each supplying hops to `evaluate()`. + +Each is a separate implementation issue; none is implemented by this record. + +## 13. Non-goals + +- Turning any restriction on by default, for any deployment. +- Jurisdiction-specific rule packs (a GDPR compliance suite, a specific + country's sanctions enforcement) in this pass. +- Legal advice or a legal determination — the framework provides + capabilities; the operator's obligations are the operator's. +- Replacing #2283 / #3397 / #3398 — those remain the surface-specific + designs; this is their shared vocabulary. +- Fetching live external sanctions feeds, automated classification, or a + policy language. From 954e02e23a53691ee12c7e66c72a6179bb3b000e Mon Sep 17 00:00:00 2001 From: repo-worker-code-k Date: Sun, 8 Nov 2026 19:30:27 -0600 Subject: [PATCH 2/2] docs(id): reconcile residency framework design review --- doc/2026-11-08_design_id5683.md | 440 +++++++++++++++++++++----------- 1 file changed, 292 insertions(+), 148 deletions(-) diff --git a/doc/2026-11-08_design_id5683.md b/doc/2026-11-08_design_id5683.md index 086e79b84b..1d54da1643 100644 --- a/doc/2026-11-08_design_id5683.md +++ b/doc/2026-11-08_design_id5683.md @@ -26,21 +26,25 @@ Verified at that baseline: no `5683` framework design record exists in `doc/`; no open PR references #5683; `pkgs/id/crates/id-core/src/residency.rs` is present with the vocabulary above. +- **Revision:** 2026-11-09 (queue task 12757). Reconciles the #5883 IP-only + weak-evidence invariant, defines the shared `FrameworkOutcome` adapter, + makes all enforcement-affecting choices explicit, and identifies the + implementation follow-ups by issue number. ## Decision summary | Question | Decision | | --- | --- | | What this framework is | A **capability catalogue plus one declaration format**: the shared vocabulary every surface (#2283/#3397/#3398) uses to say *which boundary, on what evidence, enforced where, failing how*. It is not a policy engine and not a compliance product (§2) | -| Default state | **Off, always.** Every boundary is an opt-in capability an admin or user enables for a scope they control. No deployment inherits a boundary it did not choose. An enabled boundary with no declaration is a configuration error, not an implicit deny (§1, §2.3) | +| Default state | **Off, always.** Every boundary is an opt-in capability an admin or user enables for a scope they control. No deployment inherits a boundary it did not choose. An enabled boundary with missing policy choices is invalid rather than an implicit deny (§1, §2.3) | | Subject / scope | A boundary is declared on a **scope** (server / world / account) for a **subject class** (user / org / server / world). Scope is assigned locally and a peer cannot remove it — the `Scope` type already encodes this (§2.2) | | Evidence model | Evidence is a typed record with **assurance level** (self / org-attested / provider-verified), **provenance**, **lifetime** (expiry, renewal, revocation), and **privacy class**. Declarations are evidence; IP is weak evidence; signatures prove authorship, not location (§3) | -| Public IP | **Never sufficient alone** for a deny that removes existing access. It may corroborate, warn, or trigger step-up/review. Contradiction between declaration and IP resolves to **review**, not silent deny (§4) | +| Public IP | **Never sufficient alone** for a deny, including a deny of new access. It may corroborate, produce a non-blocking `warn`, or trigger a reversible step-up. Contradiction between declaration and IP resolves to warning/step-up, never silent deny or quarantine (§4), matching #5883 | | Sanctions | The list is **data, not code**: versioned, dated, operator-supplied or shipped, with propagation, grandfathering, and an appeal path. A sanctions boundary declares which interactions it covers (§5) | -| Intranet mode | A boundary type over **network identity** (IP ranges / overlay / mTLS / org IdP assertion), gating generic activity, with 2FA step-up points, fail-closed default, and a logged break-glass (§6) | -| Composability | **Intersection, always.** Server ∧ world ∧ user preference can only narrow. A user preference can never widen a server boundary; a conflict is a deny-with-reason, not a merge (§7) | -| Enforcement | The existing `evaluate()` is the decision procedure at every surface; each surface supplies hops. Denials and step-ups are logged with the evidence *classes* used, never the dossier (§8) | -| Reuse vs new code | Reuse `residency.rs` unchanged for plane/jurisdiction/resource evaluation. Extend with an evidence-assurance layer and a declaration record — additions, not replacements (§9) | +| Intranet mode | An explicitly enabled boundary type over **network identity** (IP ranges / overlay / mTLS / org IdP assertion), with configured 2FA step-up points and degraded-mode outcome; break-glass is separately enabled and logged (§6) | +| Composability | **Intersection, always.** Only explicitly enabled server/world boundaries and user preferences participate; an adverse result is combined through the shared outcome adapter and explained (§7) | +| Enforcement | The existing `evaluate()` remains the placement decision procedure; a small shared adapter maps its result plus the enabled declaration to one framework outcome used at every surface. Denials and step-ups are logged with evidence *classes*, never the dossier (§2.4, §8, §9) | +| Reuse vs new code | Reuse `residency.rs` unchanged for plane/jurisdiction/resource placement checks. Add typed predicates for other boundary kinds and a shared outcome adapter; do not fork or widen the placement evaluator's meaning (§9) | ## 1. What is fixed before this record (not re-decided here) @@ -51,6 +55,12 @@ it rather than re-derive it: admin or user enables for their server / world / account. Nothing turns a restriction on by default, and no deployment inherits a boundary it did not choose. + **Off is the only implicit default.** Any value that can change whether an + enabled boundary restricts an action (predicate, covered interaction, + evidence bar, failure outcome, degraded-mode behavior, or step-up event) + must be selected explicitly in that declaration. If a required choice is + absent, the declaration is invalid and the capability remains unenforced; + the framework does not fill the gap with a deny or other restrictive rule. 2. **Basic frameworks first.** Ship the declaration, evidence, and enforcement skeleton in its simplest useful form before policy language, automated classification, or jurisdiction-specific rule packs. @@ -60,10 +70,11 @@ it rather than re-derive it: Also fixed by the three closed source threads, cited not re-decided: -- **#3398 / `residency.rs`:** four independent planes (storage, processing, - transport, metadata); a scoped path is denied unless every required plane - has current, trusted, resource-bound evidence in a permitted jurisdiction; - missing/unknown/expired/revoked/mismatched evidence all deny; a peer's own +- **#3398 / `residency.rs`:** when an operator explicitly supplies a + `Scope::Scoped(Policy)`, four independent planes (storage, processing, + transport, metadata); the evaluator returns a placement denial unless every + required plane has current, trusted, resource-bound evidence in a permitted + jurisdiction. `Scope::Unscoped` adds no placement restriction; a peer's own location statement is never evidence. - **#2283:** jurisdiction may pin where a user's store / world data lives. - **#3397:** a world may be partitioned or pinned by jurisdiction. @@ -78,12 +89,17 @@ The framework is deliberately thin. It defines: skeleton understands: `residency`, `citizenship`, `sanctions`, `network` (intranet). Each is a capability with a declared default of *off*. 2. **One declaration format** (§2.3) shared by all surfaces. -3. **One decision procedure** — `residency.rs::evaluate()` (§8), extended - only where assurance and declaration lifetime require it. +3. **One placement decision procedure** — `residency.rs::evaluate()` — plus + one thin, shared adapter from placement result and declared failure mode to + a framework outcome (§2.4, §9). Other predicate kinds get typed inputs to + the adapter; they do not redefine placement evaluation. Surfaces (#2283 signup/login, #3397 world membership/blobs, #3398 bridge/ -federation/relay) do not each invent a model; they *supply hops* to the one -evaluator and *render* the one `Decision`. +federation/relay) do not each invent a model; they supply typed inputs and +placement hops to the shared framework adapter, then render the same +`FrameworkOutcome`. Only residency placement predicates call +`residency.rs::evaluate()`; sanctions, citizenship, and network predicates +remain explicit typed conditions rather than pretending to be placement hops. ### 2.2 Scope and subject @@ -109,28 +125,72 @@ BoundaryDeclaration { capability: CapabilityKind // residency | citizenship | sanctions | network scope: ScopeRef // server | world | account that owns it subject_class: SubjectClass // user | org | server | world - evidence_req: EvidenceRequirement // minimum assurance + accepted sources (§3) - enforcement: [EnforcementPoint] // where checked (§8); empty = not enforced + evidence_req: EvidenceRequirement // explicit minimum assurance + accepted sources (§3) + predicate: BoundaryPredicate // typed condition over shared vocabulary (§9), versioned with declaration + privacy: EvidencePrivacyPolicy // explicit class, purpose, retention, and readers per claim (§3.3) + enforcement: [EnforcementPoint] // explicit covered surfaces (§8); required and non-empty when enabled failure: FailureBehaviour // deny | warn | step-up | quarantine (§2.4) data_ref: Option // sanctions/network list version, if any enabled: bool // MUST be true only by explicit admin/user action version: u64 // monotone; every change is a new version + valid_from: Timestamp // declaration becomes evaluable at this time + valid_until: Option // expiry; expired declarations are not evaluated as satisfied (§3.1) + revocation_ref: Option // append-only event; old versions are never edited declared_by: ActorId // who enabled it declared_at: Timestamp } ``` +`BoundaryPredicate` is a closed typed value, not user-supplied code. For +`residency`, it carries the existing `Policy` (required planes and permitted +jurisdictions/resources); for sanctions it refers to a versioned list and +explicit interaction coverage; for network it names the declared boundary +mechanism and network identity; citizenship predicates name the declared +claim being considered. The declaration's monotone `version` versions the +predicate and all its other choices together, so a decision log can reproduce +the exact condition used. + +`EvidencePrivacyPolicy` is versioned with the declaration and contains an +explicit rule for every claim/evidence kind the predicate uses: + +``` +PrivacyRule { + class: PrivacyClass // Exact | Derived | VerdictOnly + purpose: Purpose // operator-declared use + retention: RetentionPolicy // NoPersistence | UntilExpiry | For(duration) + readers: [ReaderRole] // explicit subject/admin/service roles +} +``` + +The `privacy_class` carried on `SubjectEvidence` is the effective class from +this rule, not a value chosen by the issuer. An enabled declaration missing a +rule for an evidence kind it consumes is invalid; it cannot silently collect +or retain that value. + Rules that follow from the framing: -- **`enabled: false` is the only default.** A record with `enabled: true` and - empty `enforcement` is rejected at declaration time — a boundary nobody - enforces is a false promise, worse than no boundary. +- **`enabled: false` is the only implicit default.** An enabled declaration + requires an explicit predicate, evidence bar, privacy rule, failure + behaviour, and at least one enforcement point; missing configuration is + invalid, never an implicit deny. Each declaration explicitly states its covered interactions; + an omitted interaction is *not covered*, while an empty enforcement list + makes the enabled declaration invalid (§5.2). - **Every change is a new version.** There is no in-place edit of a live declaration; the version is what makes a logged decision reproducible - (the #5883 decision log records the version applied). + (the #5883 decision log records the version applied). Predicate, evidence + requirements, coverage, and lifetime changes are all new versions. - **Declarations are data.** They are stored and replicated like other scoped state, not compiled into the binary. The *capability kinds* are code; *which* boundary a scope enables is data. +- **Lifetime and revocation are append-only.** An expired declaration + (`now >= valid_until`) or a signed revocation event makes that version + ineligible at the next protected-action check. Revocation is a new event + referencing the declaration; it does not erase or mutate the prior record. + Renewal creates a new declaration version or evidence record with its own + validity interval; it never extends an old record in place. Existing actions + are not interrupted mid-operation. The next action is re-evaluated under the + declaration's explicitly selected outcome, with the #5883 explanation and + appeal path for any adverse result. ### 2.4 Failure behaviours @@ -147,26 +207,56 @@ Four, and no more, in the skeleton: evidence bar. This ordering is the framework's main safety property: the easier a signal is to spoof, the weaker the action it may drive. +**Framework outcome vs `evaluate()` result.** `residency.rs::Decision` stays +exactly `Allow | Deny(Vec)`: it answers only the placement +question "does the supplied evidence satisfy the scoped policy for these +hops?". Each typed predicate supplies a `PredicateResult` (`Satisfied`, +`Unsatisfied(reason)`, or `Indeterminate(reason)`); residency converts the +existing `Decision` to that result, while other predicates (sanctions, +citizenship, network identity) test only their own typed condition. One shared +adapter then applies the declaration's explicit evidence bar, configured +failure behaviour, and any configured step-up trigger to produce: + +``` +FrameworkOutcome = Allow | Deny(reasons) | Warn(reasons) + | StepUp(challenge) | Quarantine(review_ref) +``` + +This is not a second placement evaluator: `evaluate()` keeps its signature and +semantics, and no surface implements a separate outcome mapping. A satisfied +predicate can still yield `StepUp` at an explicitly configured trigger +(§6.3). An IP-only `Unsatisfied` or `Indeterminate` result can never become a +final `Deny`, whatever the configured failure value: it can only warn, request + a reversible step-up or warn (§3.4/§4.3 and #5883). A +step-up is pending until the challenge succeeds; quarantine is held for +review, not silently allowed. With no enabled declaration, no boundary +evaluation or enforcement is added. + ## 3. Evidence model ### 3.1 What counts as evidence -Evidence is a typed record, extending `residency.rs::Evidence` with the -fields the declaration model needs: +Subject-oriented claims use a new `SubjectEvidence` envelope; it does not +change the public shape of `residency.rs::Evidence`: -| Field | Purpose | +| Envelope field | Purpose | | --- | --- | -| `issuer` | Locally trusted identity of who asserts this (already in `Evidence`) | -| `resource`, `plane`, `jurisdiction`, `source` | What it establishes (already in `Evidence`) | -| `expires_at`, `serial`, `signature` | Lifetime and authenticity (already in `Evidence`) | -| **`assurance`** | `Self` \| `OrgAttested` \| `ProviderVerified` — **new** | -| **`basis`** | Free-text/structured provenance: on what basis was this declared (§3.2) — **new** | -| **`privacy_class`** | `Exact` \| `Derived` \| `VerdictOnly` — what may be revealed downstream (§3.3) — **new** | -| **`subject`** | The user/org this evidence is about — **new** | - -The existing `EvidenceVerifier` trait already decides signature validity and -revocation; the assurance level is an *additional* operator-side judgement -about how the claim was established, not a cryptographic property. +| `subject`, `claim` | The user/org and typed claim being asserted (residency, citizenship, sanctions-list match, or network identity) | +| `assurance`, `basis` | Assurance level and structured provenance: who attests and on what basis (§3.2) | +| `privacy_class` | `Exact` \| `Derived` \| `VerdictOnly` — what may be revealed downstream (§3.3) | +| `validity` | Explicit expiry and a reference to an append-only revocation event | +| `placement_evidence` | Optional, unchanged `residency.rs::Evidence` when the claim is about a resource's placement on a plane | + +For placement evidence, the existing `EvidenceVerifier` checks signature and +revocation, and `evaluate()` checks expiry and binding exactly as it does +today. Other subject claims use the same provenance/expiry/revocation +contract through an additive verifier adapter; assurance remains an +operator-side judgement about how the claim was established, not a +cryptographic property. Expired or revoked evidence cannot satisfy a later +check; renewal is a new record with a new validity interval. Existing access +is re-evaluated at the next protected action, not interrupted mid-operation; +the declaration's explicit failure behaviour governs that check and any +adverse result receives the #5883 explanation and appeal treatment. ### 3.2 Assurance levels @@ -193,15 +283,18 @@ The evidence store must not become a dossier. Three privacy classes, chosen per declaration by the declaring scope: - **`Exact`** — the value is stored and readable by the subject and by - scope admins. Never exposed to other subjects. + only the reader roles explicitly named by the declaration; it is never + exposed to other subjects unless the declaration expressly authorizes that. - **`Derived`** — only a derived form (e.g. country, not address) is stored. - **`VerdictOnly`** — *nothing* about the value is stored beyond "satisfies - boundary X at time T". This is the default for IP evidence (§4). + boundary X at time T". This is the recommended privacy floor for IP + evidence; the declaration must select it explicitly (§4). -Cross-subject visibility is **never** granted by default: a user cannot learn -another user's declared citizenship. An admin sees evidence *classes* and -verdicts in the decision log (§8), not raw values, unless the declaration is -`Exact` and the admin's role specifically grants it. +Cross-subject visibility is never granted unless the declaration's `readers` +explicitly authorizes it; a user cannot otherwise learn another user's +declared citizenship. Decision logs expose evidence *classes* and verdicts +(§8), not raw values, except where an `Exact` rule explicitly grants a reader +role access. ### 3.4 What each assurance may drive @@ -210,11 +303,13 @@ verdicts in the decision log (§8), not raw values, unless the declaration is | `Self` declaration | yes | yes | yes | only if `evidence_req` accepts it | **no** | | `OrgAttested` | yes | yes | yes | yes | yes, with appeal path | | `ProviderVerified` | yes | yes | yes | yes | yes, with appeal path | -| IP-derived (any) | yes | yes | yes | only as declared and only for new access | **no** | +| IP-derived (any, alone) | yes | yes (reversible, e.g. request a declaration) | **no** | **no** — IP alone never finally denies, including for new access | **no** | The last column is the load-bearing rule: **no weak signal removes access a -subject already has.** Removing existing access requires either strong -evidence or a human decision (§5.4, §4.3). +subject already has.** An IP-only decision cannot finally exclude even a new +subject; the most it may do is warn or request a reversible step-up, consistent +with #5883. Removing existing access requires evidence meeting the explicit +assurance bar or a human decision (§5.4, §4.3). ## 4. Public IP as evidence @@ -223,14 +318,14 @@ evidence or a human decision (§5.4, §4.3). The public IP a connection arrives from is a *signal*, never an identity. The framework permits deriving, in increasing privacy: -1. a **country/region verdict** (default), -2. a **boundary verdict** — "inside / outside boundary X" (`VerdictOnly`), +1. a **country/region verdict** only when requested by an enabled declaration, +2. a **boundary verdict** — "inside / outside boundary X" (`VerdictOnly`) only when requested, 3. the **raw IP** only when a scope explicitly enables it for a stated retention window and purpose. -Default retention for derived IP evidence is **short** (the connection's -lifetime plus a bounded window), because IP is personal data in most -regimes and the framework's job is to need less of it, not more. +The declaration must state the retention period and purpose for each derived +IP value. No raw or derived IP evidence is retained unless that enabled +declaration requests it; any retention period is bounded and auditable. ### 4.2 Known error modes (must be stated in any UI that uses IP evidence) @@ -248,14 +343,15 @@ When declared evidence and IP evidence disagree: | Situation | Behaviour | | --- | --- | -| Declaration admits, IP contradicts, action is *new* access | `warn` by default; admin may raise to `step-up` or `quarantine` | -| Declaration admits, IP contradicts, action is *existing* access | `warn` only. Never deny on IP alone (§3.4) | -| No declaration, IP only | May gate *new* access per the declaration's `evidence_req`; never removes existing access | -| Two IP signals disagree (e.g. X-Forwarded-For vs socket) | Treat as **unknown** — unknown denies new access under a scoped policy, per `residency.rs` | - -**X-Forwarded-For trust is explicit and off by default.** A scope must -declare which proxies it trusts to set forwarding headers; an untrusted -header is ignored, not believed. This is the same "peer's own statement is +| Declaration admits, IP contradicts, action is *new* access | The declaration must explicitly choose `warn` or reversible `step-up`; absence of a choice makes it invalid. IP alone cannot choose `deny` or `quarantine` | +| Declaration admits, IP contradicts, action is *existing* access | Explicitly configured `warn` or reversible `step-up`; never a final deny or quarantine on IP alone (§3.4, #5883) | +| Enabled declaration applies, subject has no declaration and IP is the only signal | At most a reversible `step-up` (e.g. request a declaration) or `warn`; never a final `deny` or `quarantine`. IP alone does not satisfy the declaration's `evidence_req` | +| Two IP signals disagree (e.g. X-Forwarded-For vs socket) | Treat as **unknown**. Under an enabled boundary with IP as the sole signal this may only warn or request reversible step-up; it cannot deny or quarantine (§3.4, #5883) | + +**X-Forwarded-For is not evidence unless explicitly trusted.** A declaration +must name which proxies may set forwarding headers; an untrusted header is +ignored, not believed. If no proxy is named, the socket peer is the only +available network observation. This is the same "peer's own statement is never evidence" rule `residency.rs` already enforces. ## 5. Sanctions boundaries @@ -283,29 +379,30 @@ ListVersion { id, source, effective_from, effective_to, entries, signature } A sanctions boundary must declare **which interactions it covers**, because "interact" is not one thing: -| Interaction | Typical default when a sanctions boundary is enabled | +| Interaction | Coverage choice that the declaration must state | | --- | --- | -| Account creation / signup | covered | -| Login to an existing account | covered, with grandfathering (§5.3) | -| World membership | covered | -| Blob storage | covered | -| Bridge / federation traffic | **declared explicitly** — often *not* covered, because transit ≠ service | -| Relay transit | **declared explicitly** — a relay transiting a jurisdiction it does not serve is a different act | +| Account creation / signup | covered or not covered | +| Login to an existing account | covered or not covered; transition behavior is explicit (§5.3) | +| World membership | covered or not covered | +| Blob storage | covered or not covered | +| Bridge / federation traffic | covered or not covered; transit may differ from service | +| Relay transit | covered or not covered; transit through a jurisdiction may differ from serving it | -An empty `enforcement` for an interaction means *not covered*, and the -declaration must say so rather than leave it ambiguous. +No interaction is covered by implication. Each enabled declaration must +record covered and not-covered interactions explicitly; an omitted interaction +is not covered. An empty overall `enforcement` list is invalid (§2.3). ### 5.3 Grandfathering and list changes -When a list entry **appears**, existing accounts / worlds / federation links -are **grandfathered** by default: they keep working and are flagged for -review, rather than being cut off by a data update nobody was warned about. -When an entry is **removed**, grandfathered subjects are cleared and the +When a list entry **appears**, the declaration's versioned transition policy +must explicitly choose how existing accounts / worlds / federation links are +handled (for example, grandfather them and flag for review, or re-evaluate at +the next protected action). A list update alone never cuts off existing work; +an omitted transition policy makes the new enforcement version invalid rather +than silently applying a new restriction. When an entry is **removed**, the +selected transition policy states whether exceptions are cleared and how the removal is logged. -This is a deliberate asymmetry: adding a restriction must not silently -destroy existing work, and the framework's default is the gentler one. - ### 5.4 False positives and appeals Name collisions, dual citizens, residents vs citizens, and travellers @@ -332,26 +429,35 @@ A `network` capability whose boundary is declared as one or more of: | mTLS client identity | strong | cryptographic client identity | | Org IdP assertion | strong | signed assertion from a trusted IdP | -An admin declares which mechanisms satisfy the boundary; the strongest -available should be used for privileged actions. +The enabled declaration names which mechanisms satisfy the boundary and which +ones are required at its listed enforcement points. No mechanism is selected +or upgraded solely because it is available; privileged-action requirements +must also be explicit. ### 6.2 Gating generic activity -Connections from **outside** the declared boundary cannot perform ordinary -user activity. The framework does not invent a new gate: it supplies hops to -`evaluate()` with `Plane::Transport` and the declared boundary as the -resource, and the surface renders the `Decision`. +For an enabled intranet declaration, connections from **outside** the declared +network boundary cannot perform ordinary user activity. Its network-identity +predicate (IP range, overlay membership, mTLS identity, or IdP assertion) is +evaluated as a typed `PredicateResult` and passed through the shared adapter; +it is not translated into a `residency.rs` placement hop. If the same action +also crosses a residency-scoped resource, that separate placement predicate +supplies `Plane::Transport` hops to `evaluate()`. The two results use the same +`FrameworkOutcome` adapter before the action proceeds. ### 6.3 2FA step-up points -Step-up is required at, at minimum: +The declaration explicitly enumerates the events requiring step-up. Possible +events include: - entering from a **new network** (first time from this boundary context), - **privilege escalation**, - **admin actions**. -A step-up grants a bounded window (declared per scope, default short); after -it expires the next privileged action steps up again. Step-ups are logged. +A step-up grants a bounded window whose duration the declaration must state; +after it expires the next configured privileged action steps up again. No +step-up event or duration is implied by enabling the network boundary alone. +Step-ups are logged. ### 6.4 Org-escrowed credentials @@ -362,27 +468,37 @@ raw user data it does not need: - **Escrowed:** the credential material, by the org, under the org's control. - **Proxied:** *assertions* — "member of group G", "residency attested", "identity verified" — not raw values, wherever an assertion suffices. -- **Audit:** every proxy use is logged with what was asserted and to whom. -- **User visibility:** the user can see what was shared about them and when. +- **Audit:** every proxy use records the claim kind, assurance level, issuer, + recipient, declaration version, and opaque assertion reference. Raw assertion + values are not copied into the audit log; only the declaration's explicit + privacy rule may authorize a value for a named reader. +- **User visibility:** the user can see which claim kinds and assurance levels + were shared, with whom, and when; any exact value shown follows the explicit + privacy rule. - **Un-escrow:** the user (and the org, per its own policy) can revoke; the server then loses the assertion and re-evaluates. Consent model (per-use vs standing vs org-authority-alone) is an open point -(§11) with a recorded default: **standing consent, visible and revocable**, -because per-use prompts train users to click through. +(§11) and must be explicitly selected before any credential is escrowed or +assertion proxied. Missing consent configuration means no proxy use is +authorized. ### 6.5 Degraded behaviour -Boundary unreachable, IdP down, VPN down: **fail closed for generic -activity** — the safe default, since the boundary's purpose is exclusion. -A **break-glass** path exists, held by a named role, its use logged loudly -and surfaced to admins. Break-glass is a human action, never an automatic -fallback. +Boundary unreachable, IdP down, VPN down: the enabled declaration must +explicitly select the degraded-mode outcome for generic activity. No +fail-closed or fail-open result is inferred from enabling intranet mode; a +missing outcome makes that declaration invalid. A **break-glass** path is a +separate opt-in capability with a named role; if enabled, its use is logged +loudly and surfaced to admins. Break-glass is a human action, never an +automatic fallback. ## 7. Composability -Server boundary ∧ world boundary ∧ user preference. The rule is -**intersection, always**: +Only explicitly enabled declarations participate. An absent or disabled +boundary contributes no new constraint; it does not synthesize a false +predicate or turn enforcement on. Among the enabled declarations and explicit +user preferences, the rule is **intersection, always**: ``` effective = server_boundary ∩ world_boundary ∩ user_preference @@ -391,9 +507,15 @@ effective = server_boundary ∩ world_boundary ∩ user_preference - A **user preference can never widen** a server or world boundary. It can only add restrictions the user chooses for themselves. - A **world cannot widen** its server's boundary. -- A **conflict is a deny with a reason** naming which scope denied, not a - silent merge. The user-facing message says which boundary excluded them - and offers the appeal path. +- A **conflict among enabled rules is an adverse outcome** named by the shared + adapter; a final deny requires a configured failure behaviour and evidence + bar. It is not a silent merge. The user-facing message says which boundary + applied and offers the #5883 appeal path. +- When multiple active declarations produce outcomes, combine only those + explicit outcomes in this order: `Deny` > `Quarantine` > `StepUp` > `Warn` + > `Allow`. An absent or disabled declaration contributes nothing. An + IP-only result is first restricted to `Warn` or reversible `StepUp` + (§3.4, #5883). - The intersection is computed over the same `Policy`/`Plane` vocabulary, so there is no second merge algorithm to reason about. @@ -404,19 +526,31 @@ forbid the membership. ## 8. Enforcement surfaces -Each surface supplies hops and renders the decision; none re-implements -evaluation. +Each surface declares its enforcement points and supplies typed inputs (plus +placement hops where relevant) to the shared adapter. Each renders the same +`FrameworkOutcome`; none re-implements evaluation or outcome mapping. -| Surface | Hops supplied | Extends | +| Surface | Enforcement point and user-visible behaviour | Inputs / prior work | | --- | --- | --- | -| **Signup / login** | transport (connection), storage (where the account store lives) | #2283 | -| **World membership / world blobs** | storage (world blob store), processing (world turn host) | #3397 | -| **Bridge / federation / relay** | transport (peer, relay, bridge), with **peer-asserted evidence marked unverified** unless the operator trusts that peer | #3398 | -| **Capability grants / delegation** | the boundary of the grantee and the exercise location | new, minimal | +| **Signup / login** | Check before account creation and on each login; render the selected outcome, reason and appeal path before refusing access | transport connection plus storage placement hops; extends #2283 | +| **World membership / world blobs** | Check before membership changes and before each protected blob read/write; explain the specific world boundary on deny, step-up, or quarantine | storage and processing hops; extends #3397 | +| **Bridge / federation / relay** | Use the #3398 decision points below; identify peer/relay as the observed endpoint, explain unavailable user-origin evidence, and do not treat a relay IP as the user's | transport placement hops where relevant; peer identity is a separate typed predicate; extends #3398 | +| **Capability grants / delegation** | Check both when granting and when exercising the capability; an adverse outcome names the grant scope and exercise boundary | grantee scope plus exercise location; new, minimal | + +For an enabled boundary on bridge/federation/relay traffic, check before +outbound enqueue/send and before inbound accept/ingest or persistence. Recheck +when a queued retry starts and when policy or evidence expires or is revoked +during a session. Include every applicable store, processing host, transport +hop, and metadata destination as separate plane/resource inputs. A refusal +must not persist the protected payload in a disallowed store or leave it in a +retry buffer; a relay cannot turn a denial into an allow. These are the +#3398 failure points, applied only at explicitly enabled scopes. **Peer-asserted evidence** is the sharp edge: a federated peer's claim about a user's location is `Self`-grade evidence from that peer until the operator -adds the peer to its trust roots. The skeleton's default is *unverified*. +explicitly adds the peer to its trust roots. A missing trust configuration +never activates a boundary; under an enabled declaration, an untrusted claim +cannot satisfy an evidence bar that requires a trusted issuer. **Audit:** every decision that denies, steps up, or quarantines is logged with the scope, the boundary version, the evidence **classes** and assurance @@ -430,45 +564,57 @@ log. Raw evidence values are not logged (§3.3). | Plane / jurisdiction / resource vocabulary | `Plane`, `Jurisdiction`, `ResourceId` — unchanged | — | | Scope ownership | `Scope::{Unscoped, Scoped}` — unchanged | — | | Per-plane allow-lists, trust roots | `Policy`, `PlanePolicy` — unchanged | — | -| Evidence authenticity + revocation | `Evidence`, `EvidenceVerifier` — unchanged | add `assurance`, `basis`, `privacy_class`, `subject` | -| Decision procedure | `evaluate()`, `DenyReason`, `Decision` — unchanged | a thin pre-step that maps a declaration + subject evidence to the `Hop`s `evaluate()` consumes | +| Evidence authenticity + revocation | `Evidence`, `EvidenceVerifier` — unchanged for signed placement evidence and revocation checks | add declaration assurance, provenance, privacy class, subject, and freshness metadata | +| Residency placement predicate | `evaluate()`, `DenyReason`, `Decision` — unchanged; remains the placement result only | typed `BoundaryPredicate::Residency(Policy)` maps into `Hop`s then converts `Decision` to `PredicateResult` | +| Other boundary predicates | no fit in the placement evaluator for sanctions, citizenship, or network identity | typed predicate checks yield `PredicateResult`; they do not create a parallel residency vocabulary/evaluator | +| Enforcement outcomes | not part of the placement evaluator | one shared adapter maps `PredicateResult`, configured failure behaviour, assurance and explicit step-up triggers to `FrameworkOutcome` | The extension is deliberately **additive**: `evaluate()` keeps its current signature and semantics, so #2283/#3397/#3398 code that already calls it is -unaffected. The new layer answers "which hops does this declaration imply, -and does the subject's evidence satisfy the assurance bar?" and then hands -off to the existing evaluator. No second evaluator is introduced. +unaffected. A typed predicate builder answers which placement hops a +declaration implies; `evaluate()` checks only those hops. The shared adapter +applies assurance and maps results to the common outcome wrapper. +Non-placement capabilities use their own typed predicates as inputs to that +same adapter; they do not invent a parallel residency vocabulary or a second +outcome procedure. ## 10. Worked examples ### 10.1 A sanctions-enabled public server - Admin enables `sanctions` on the server scope, `enabled: true`, with a - list version `L7`, covering signup + login + world membership, **not** - federation transit. -- A new signup from a listed country: `deny` at signup, message names the - appeal path. -- An existing account whose country appears in `L8`: **grandfathered** — - flagged for review, access continues until a human decides. + typed predicate referencing list version `L7`, explicitly covers signup + + login + world membership, explicitly excludes federation transit, and + requires `ProviderVerified` evidence with `deny` as its configured outcome. +- A new signup with verified evidence matching `L7`: `Deny` at signup; the + explanation names the evidence class and appeal path. A listed-country IP + signal without other qualifying evidence can only cause a warning or the + explicitly selected reversible step-up, never a final exclusion. +- Before accepting list version `L8`, the declaration explicitly selects + grandfather-and-review for existing accounts; they remain accessible until + the review decision, rather than being cut off by the data update alone. - A dual citizen appeals; admin records an exception as a new declaration version; the decision log shows the exception and who granted it. ### 10.2 An intranet-mode org server - Admin enables `network` on the server scope with mTLS client identity as - the boundary mechanism; generic activity requires it. -- A connection from outside: `deny` for generic activity, with a message - naming the boundary — no silent failure. -- An admin action from inside still triggers `step-up` (2FA), window 15 - minutes, logged. -- The IdP goes down: generic activity **fails closed**; break-glass is - available to the named role and its use is logged and surfaced. + the boundary mechanism, explicitly covers generic activity, and selects + `deny` for a connection that does not satisfy the mTLS predicate. +- A connection from outside receives the configured `Deny` outcome and a + message naming the boundary — no silent failure. +- The declaration explicitly selects admin actions as a `step-up` event and + sets a 15-minute challenge window; each step-up is logged. +- The declaration explicitly selects `deny` as the IdP-outage outcome; + break-glass is separately enabled for a named role and its use is logged + and surfaced. ### 10.3 A jurisdiction-pinned world -- A world enables `residency` on its own scope, requiring `OrgAttested` - evidence for `Plane::Storage` in jurisdiction `eu`. -- A joining user with a `Self` declaration only: `deny` with reason +- A world enables `residency` on its own scope with a typed predicate carrying + `Policy` for `Plane::Storage` in jurisdiction `eu`, requires `OrgAttested` + evidence, and explicitly selects `deny` when the evidence bar is unmet. +- A joining user with a `Self` declaration only: `Deny` with reason `NoEvidence(Storage)`-equivalent — the assurance bar is not met, and the message says an org attestation is required. - A user with `OrgAttested` eu storage evidence: `allow`; the world's blobs @@ -476,36 +622,34 @@ off to the existing evaluator. No second evaluator is introduced. - The user's own preference adds a stricter metadata restriction: the intersection applies; the user's preference narrows, never widens. -## 11. Open points (with assumed defaults) +## 11. Open points and required explicit choices + +These are not framework defaults. An enabled declaration must carry every +choice that affects its scope or enforcement. If a choice remains unresolved +for an operator, that declaration is invalid and adds no restriction. -| Question | Assumed default for the skeleton | Why | +| Question | Required explicit choice | Guardrail | | --- | --- | --- | -| Minimum evidence for a sanctions boundary | `Self` declaration + human review; IP may flag | Weak signals must not hard-block (§3.4) | -| Declaration vs IP disagreement | `warn` by default; admin may raise to step-up/quarantine | Contradiction is information, not proof (§4.3) | -| Who is authoritative for a sanctions list | Operator-supplied; shipped list is a labelled starting point | No external feed in the skeleton (§5.1) | -| Org-escrow consent model | Standing consent, visible and revocable | Per-use prompts train click-through (§6.4) | -| Contradictory world memberships | Allowed; resolved per-action by intersection | Forbidding membership over-reaches (§7) | -| Evidence retention after account closure | Derived/verdict evidence deleted with the account; `Exact` per operator policy | Least data (§3.3) | -| Federation peer assertions | Unverified (`Self`-grade) until the peer is a trust root | Peers are not evidence by default (§8) | -| External sanctions feeds | Out of scope for the skeleton; a later step | Basic frameworks first (§1) | +| Minimum evidence for a sanctions boundary | Each declaration names its accepted sources and minimum assurance | IP alone never produces a final exclusion (§3.4) | +| Declaration vs IP disagreement | Each declaration chooses `warn` or reversible `step-up` | IP-only input cannot select `deny` or `quarantine` (§4.3, #5883) | +| Who is authoritative for a sanctions list | Name the selected source and list version; shipped data is never applied implicitly | No external feed in the skeleton (§5.1) | +| Org-escrow consent model | Explicitly choose per-use, standing consent, or org authority | No credential escrow/proxy use without a configured authorization choice (§6.4) | +| Contradictory world memberships | Boundaries apply only to their explicitly covered actions; membership itself is not prohibited by this framework | Resolve enabled policies per action by intersection (§7) | +| Evidence retention after account closure | State the retention/deletion period for each privacy class | No unconfigured retention period is inferred (§3.3) | +| Federation peer assertions | Explicitly configure trusted issuers and the evidence bar they can satisfy | No boundary is active until enabled; peer assertions cannot silently satisfy a trust bar (§8) | +| External sanctions feeds | Out of scope for the skeleton; select a source explicitly in a later version | Basic frameworks first (§1) | ## 12. Decomposition into implementation issues The skeleton is one design; its implementation splits along the seams above. -Issues are filed and linked from #5683 in the same pass as this record: - -1. **Evidence assurance layer** — `assurance`, `basis`, `privacy_class`, - `subject` on the evidence record; assurance-bar check before `evaluate()`. -2. **Declaration record** — the `BoundaryDeclaration` type, versioning, - `enabled`-only-by-explicit-action, rejection of empty `enforcement`. -3. **Public-IP evidence derivation** — country/boundary verdicts, retention, - X-Forwarded-For trust configuration, contradiction → `warn`. -4. **Sanctions list data model** — versioned lists, effective dates, - propagation, grandfathering, exception records. -5. **Intranet-mode gating** — network boundary mechanisms, step-up points, - fail-closed, break-glass logging. -6. **Surface wiring** — #2283 signup/login, #3397 world membership/blobs, - #3398 federation/relay, each supplying hops to `evaluate()`. +Implementation issues are filed and natively linked as sub-issues of #5683: + +1. **Evidence assurance layer** — [#7783](https://github.com/developing-today/code/issues/7783): `assurance`, `basis`, `privacy_class`, `subject` on the evidence record; assurance-bar check before placement evaluation. +2. **Declaration record** — [#7782](https://github.com/developing-today/code/issues/7782): the `BoundaryDeclaration` type, predicate, version/lifetime, explicit enablement and enforcement coverage. +3. **Public-IP evidence derivation** — [#7784](https://github.com/developing-today/code/issues/7784): country/boundary verdicts, retention, X-Forwarded-For trust configuration, contradiction handling without IP-only denial. +4. **Sanctions list data model** — [#7785](https://github.com/developing-today/code/issues/7785): versioned lists, effective dates, propagation, explicit transition choices, and exception records. +5. **Intranet-mode gating** — [#7786](https://github.com/developing-today/code/issues/7786): network boundary mechanisms, explicitly configured step-up points/degraded behavior, and opt-in break-glass logging. +6. **Surface wiring** — [#7787](https://github.com/developing-today/code/issues/7787): #2283 signup/login, #3397 world membership/blobs, #3398 federation/relay, using typed predicates, placement hops where applicable, and the shared outcome adapter. Each is a separate implementation issue; none is implemented by this record.