diff --git a/doc/2026-11-08_design_id5683.md b/doc/2026-11-08_design_id5683.md new file mode 100644 index 0000000000..1d54da1643 --- /dev/null +++ b/doc/2026-11-08_design_id5683.md @@ -0,0 +1,666 @@ +# 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. +- **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 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, 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 | 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) + +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. + **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. +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`:** 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. + +## 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 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 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 + +| 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 // 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 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). 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 + +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. + +**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 + +Subject-oriented claims use a new `SubjectEvidence` envelope; it does not +change the public shape of `residency.rs::Evidence`: + +| Envelope field | Purpose | +| --- | --- | +| `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 + +| 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 + 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 recommended privacy floor for IP + evidence; the declaration must select it explicitly (§4). + +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 + +| 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, 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.** 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 + +### 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** 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. + +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) + +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 | 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 + +### 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 | Coverage choice that the declaration must state | +| --- | --- | +| 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 | + +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**, 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. + +### 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 | + +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 + +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 + +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 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 + +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 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) 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: 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 + +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 +``` + +- 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 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. + +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 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 | Enforcement point and user-visible behaviour | Inputs / prior work | +| --- | --- | --- | +| **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 +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 +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 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. 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 + 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, 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 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 + 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 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 | Required explicit choice | Guardrail | +| --- | --- | --- | +| 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. +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. + +## 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.