# How it is tested

Every guarantee below has a test that runs in CI. A failure in any workflow of a commit stops its deploy.

## The guarantees, and what proves them

| Guarantee | Proved by | Where |
|---|---|---|
| Signed documents, levels, limits, replay and revocation are checked exactly as the specifications say | Conformance vectors: 453 verifier cases and 122 runtime cases, in all eight SDKs; `vectors/verify.py`, a second verifier that shares no code with the first | `vectors/`; each `sdk-*` workflow; `test` |
| A test notices when the verifier is broken | Mutation testing: every small breaking change to the verifier must fail a test | `tools/mutate.py`; workflow `assurance` |
| An SDK works with a real node, a real agent and a person with a passkey | End-to-end test: 26 scenarios for services, 7 for agents | `sdks/interop/`; each `sdk-*` workflow |
| A request cannot go around the route map | 31 variants of protected requests (paths, methods, overrides) sent to every SDK, none served | `sdks/interop/`, scenario "NO WAY AROUND"; each adapter's own tests |
| The whole product works: node, wallet, approvals, organisations, identity, logs | 225 end-to-end scenarios | `demo/e2e.py`; job `test` |
| Identity sources and their cryptography (eID, passports, wallets, MDS3, signatures) | Unit tests against simulators that sign for real | `demo/tests/`; job `test` |
| The security code stays covered | A floor per module, lines and branches | `tools/coverage_floors.json`; job `test` |
| Two instances starting together share one key | Threads and processes racing to create the key file, in every SDK | each `sdk-*` workflow |
| No known vulnerability, no secret in the repository | Dependency audit, static analysis, secret scan of the history | job `security` |
| The documentation is true | Links, anchors, code blocks, error tables against the verifier, counts, installs; examples compared with files that CI runs | `tools/docs.py`, job `quality`; `test_docs` of each SDK |
| The reference matches the code | Generated, and compared in CI | `tools/build_reference.py`, job `reference` |
| Specifications are versioned | Change log and version of every changed document | `tools/check_versions.py`, job `test` |
| Every change is read critically | AI review of each pull request; a blocking finding fails it | workflow `ai review` |

## Mutation testing

`tools/mutate.py` makes one small change at a time to `verifier.py` (and to `agent.py`, the runtime): a comparison reversed, a condition dropped, a refusal
removed. A test must fail. When it was first run, 1103 of 1614 changes were noticed. The missing tests were written, most
of them as vectors so that every SDK is held to them, and redundant code was deleted. Now every change is noticed except
the ones in `tools/mutants_equivalent.txt`, each with the reason it changes no behaviour. Writing them found two defects,
both fixed: a document dated in the future was accepted, and a vouch signed with a revoked key still counted.

The complete run takes place every week; a pull request that changes the verifier runs one eighth of it.

## Stability

The end-to-end demo runs 20 times in a row every week. A test that fails once is a defect to find, not to retry.

## What is not covered

- **No independent security audit** has been made. The reviews are automated.
- **Hardware attestation** (TPM, Secure Enclave, cloud KMS) and **qualified signatures** are tested with simulated
  certificate chains; the real ones need vendor hardware and EU trusted lists.
- **Identity providers** are tested against their sandboxes or simulators, not in production.
- **Mutation testing covers the verifier and the agent** of the Python reference. The other SDKs are held to the same vectors, but
  their own code is not mutated.
- **`node.py`, the node, is at 81% coverage**, and it is tested by the end-to-end scenarios rather than by vectors.
- **Load**: the tests check that 20 parallel agents work, not a production load.
- **Windows and macOS**: the SDKs run mainly on Linux in CI; .NET also runs on Windows.

## Run it yourself

```bash
pip install -r requirements.txt
python demo/e2e.py                                   # the whole product
python vectors/verify.py                             # every vector, with the second verifier
python sdks/python/tests/conformance.py              # every vector, with the Python SDK
python sdks/interop/interop.py --cmd "python sdks/interop/reference_app.py"
python tools/docs.py check                           # the documentation
python tools/mutate.py sdks/python/src/allowedby/verifier.py --no-e2e   # about an hour on 8 cores
python tools/mutate.py sdks/python/src/allowedby/agent.py --no-e2e      # about 10 minutes
```
