# OIP-0021: Automated sovereignty checks

| Field | Value |
|---|---|
| Status | DRAFT |
| Function | none: the operator sovereignty overlay `OBSP-SOV` (§12); no new function (the register keeps exactly twelve) |
| Affects | §12 (new paragraph "Sovereignty evidence", requirement REQ-12-3); new schema `sovereignty-evidence` with fixtures both ways; cases CT-SOV-001, -002, -004, -005, -007, -009, -010 change from `manual` to `invariant`; CT-SOV-003 and CT-SOV-008 gain an invariant; nine `sov-*` invariants; `registers/requirements.yaml` regenerated |
| Protocol version | obsp/0.1 |
| Relates to | the non-normative `obsp sovereignty` tooling in the SDK, which already checks the same evidence and writes attestations for the manual cases; the threat model (`docs/security/threat-model.md`) |
| Last call | 30 days unless the editors rule otherwise; see Open questions |

## Problem

Seven of the ten `OBSP-SOV` cases are manual: CT-SOV-001 (egress), -002 (trust anchors), -004 (telemetry), -005
(licence, metering and billing code), -007 (adapters), -009 (publisher access) and -010 (reproducible builds). A manual
case passes on any attestation with a non-empty statement. Nothing in the suite looks at what the operator found, so
two operators who did the same review can record it in incompatible ways, a reviewer cannot repeat the check, and an
attestation that says PASS over evidence that shows a connection to the publisher still passes.

The evidence those procedures produce is a set of documents: an egress log summary, a list of trust anchors, the
telemetry configuration, a source scan, an adapter inventory, a listener and account review, and two digest lists.
Each requirement can be checked from them mechanically.

Two invariant cases are also partial. CT-SOV-003 checks that a supply-chain receipt is signed but not that the
operator installed from its own mirror and verified offline (SOV-3). CT-SOV-008 checks that a decommission record
exports at least one file, not that every data class the deployment holds is exported (SOV-8).

## Change

### Normative text (added at the end of §12)

> Sovereignty evidence. The contract is `sovereignty-evidence.schema.json`: the endpoints the operator configured and
> an egress log summary of the default install running every function for at least one hour (SOV-1), every trust
> anchor in use with its origin and creation time (SOV-2), the offline install record (SOV-3), the telemetry
> exporters enabled by default and as configured (SOV-4), a scan of the open components' source for licence,
> entitlement, metering and billing code (SOV-5), the adapters for identity, key management, storage and messaging
> (SOV-7), the data classes held with their export paths (SOV-8), the review of listeners, accounts and keys (SOV-9)
> and the published and rebuilt digests (SOV-10). A conformance run that includes `OBSP-SOV` MUST include one
> SovereigntyEvidence document for the deployment under test, and the suite checks every SOV requirement against it.
> The document records what the operator observed; it grants nothing.

The requirements index gives the MUST sentence the id **REQ-12-3** (covered directly by CT-SOV-001, which names it).
SOV-1 to SOV-10 keep their text.

### Contract

`SovereigntyEvidence` (`schemas/json/sovereignty-evidence.schema.json`, `urn:obsp:schema:v3.1:sovereigntyevidence`):
subject (name, version, source digest), operator (role, UNI), `installedAt`, the publisher's domains and key
fingerprints as the operator determined them, `egress` (configured endpoints with purpose; observation window, log
digest and connections), `trustAnchors` (kind, fingerprint, origin, creation time), `offlineInstall` (mirror,
verified offline, TUF root digest), `telemetry` (default and configured exporters), `chargingScan` (source digest,
output digest, finding count), `adapters` (service, default, open source, outbound, fails closed on an unknown
profile), `dataInventory` (data class, export path), `remoteAccess` (listeners with grantee, publisher accounts,
authorized key fingerprints) and `rebuild` (source reference, published and rebuilt digests). The schema allows an
honest report of a failure (an origin of `SHIPPED_IN_BUILD`, a non-zero finding count); the invariants judge it.

### Cases and invariants

| Requirement | Case | Change | Invariant: what fails |
|---|---|---|---|
| SOV-1, REQ-12-3 | CT-SOV-001 | manual to invariant | `sov-egress-configured-only`: window under one hour; a connection to a publisher domain or to an endpoint the operator did not configure |
| SOV-2 | CT-SOV-002 | manual to invariant | `sov-operator-roots-only`: an anchor not `OPERATOR_GENERATED`, created before install or equal to a publisher key; a missing site cell enrolment, plan signing, TUF or identity issuer root |
| SOV-3 | CT-SOV-003 | adds evidence and invariant | `sov-offline-install`: mirror not the operator's; metadata not verified offline |
| SOV-4 | CT-SOV-004 | manual to invariant | `sov-telemetry-operator-only`: an exporter on by default; a configured exporter to an endpoint outside the configured list or to the publisher |
| SOV-5 | CT-SOV-005 | manual to invariant | `sov-no-charging-hook`: a non-zero finding count |
| SOV-7 | CT-SOV-007 | manual to invariant | `sov-adapters-open-default`: a missing service; a default that is not open source or makes outbound calls; an adapter that does not fail closed (§13) |
| SOV-8 | CT-SOV-008 | adds evidence and invariant | `sov-export-complete`: a data class whose export path is in no decommission export manifest of the set |
| SOV-9 | CT-SOV-009 | manual to invariant | `sov-no-publisher-access`: a listener granted to the publisher; a publisher account; an authorized publisher key |
| SOV-10 | CT-SOV-010 | manual to invariant | `sov-build-reproduced`: a published artifact not rebuilt, or rebuilt with another digest |

CT-SOV-006 (name packs) is unchanged. The invariants live in `sdk/python/src/obsp/sov_invariants.py` and join the
suite's invariant table; the OBSP-NODE example set gains `sovereignty-evidence.example.json`.

## Compatibility

Not breaking for documents: no existing schema changes. It changes what an `OBSP-SOV` run needs: a run without a
SovereigntyEvidence document fails the seven former manual cases, where it reported `MANUAL` before. Under
`GOVERNANCE.md` (Versions) a minor version may break until 1.0. Migration: an operator who attested the manual cases
records the same review in one SovereigntyEvidence document; the SDK's `obsp sovereignty check` already reads that
shape, and `obsp sovereignty scan` and `obsp sovereignty compare` produce the `chargingScan` and `rebuild` blocks.
Attestations for the seven cases are ignored once the cases are invariants; the example set keeps its entries until
acceptance removes them (editorial).

## Tests

Positive fixtures: `sovereignty-evidence.valid.json`, `sovereignty-evidence.contractor-access.valid.json` (an
operator contractor listener, an extra operator root, no exporter configured). Negative fixtures, one broken rule each:
`missing-egress-observation` (SOV-1 needs the log summary), `connection-without-port`, `unknown-trust-anchor-origin`,
`no-trust-anchors` (SOV-2), `missing-offline-install` (SOV-3), `default-exporter-without-kind`, `negative-findings`,
`unknown-adapter-service`, `empty-data-inventory` (SOV-8), `remote-access-unknown-grantee`, `rebuild-without-source-ref`
(SOV-10) and `published-digest-not-a-digest`. Unit tests (`sdk/python/tests/test_sov_invariants.py`): each invariant
passes on the example and fails on each of 22 faults; no SOV case stays manual; an overlay run over evidence with a
connection to the publisher fails CT-SOV-001 only.

Checked: the patches apply to the current tree, and with them applied (and `patches/` removed, as acceptance does)
`make check` exits 0.

## Open questions

1. Is one hour the right minimum egress window (it is the current CT-SOV-001 procedure), and should it scale with
   the plan's autonomy window?
2. Should the publisher's domains and key fingerprints come from a register the steward keeps, rather than from the
   operator's own determination?
3. The SOV-5 scan is only as good as its rules. Should the protocol name a minimum rule set (the SDK's `scan` is one
   candidate), or keep the scan tool open and require only its digests?
4. Should SovereigntyEvidence be signed under the signature envelope of OIP-0008 once that is accepted?
5. Should `OBSP-SOV` runs for site cells and grids require one SovereigntyEvidence per open component, rather than one
   per deployment?
