# OIP-0023: PEER_TESTED level and plugfest records

| Field | Value |
|---|---|
| Status | DRAFT |
| Function | none added (the register keeps exactly twelve); the change is to §7.2 (conformance levels) |
| Affects | §7.2 (new level `PEER_TESTED` between `SELF_TESTED` and `LAB_TESTED`, three requirements); `registers/conformance-profiles.yaml` (level row); new schema `plugfest-result`; `conformance-claim` (level enum, `plugfestResultDigest`, one conditional rule); suite run levels (`obsp conformance run --level`); invariants `plugfest-independent-witnessed`, `peer-claim-cites-plugfest`; cases CT-PROVIDER-100, CT-PROVIDER-101; `docs/guides/conformance.md`, `docs/glossary.md` |
| Protocol version | obsp/0.1 |
| Relates to | the non-normative plugfest groundwork in `conformance/plugfest/` and the reference conformance runner in `services/conformance-runner/`, which land without this proposal; OIP-0008 (a signed plugfest record would carry its envelope) |

## Problem

The levels of §7.2 go from `SELF_TESTED` (a participant ran the open suite on its own evidence) straight to
`LAB_TESTED` (a qualified lab ran it). Nothing in between records that two independent implementations actually work
together. Interoperability is what buyers, operators and other implementers most want to know, and it is what a
plugfest shows: implementations of different participants run against each other, pair by pair, under a witness.

Today such an event leaves no protocol record. A runner report of one pairing exists (the reference runner can drive
one implementation's gateway with another implementation's documents), but it is the record of one run, made by one
party, and nothing says who witnessed it or that the two sides were independent. A participant who wants to cite a
plugfest can only do so as free text.

## Change

### Normative text (§7.2; the exact text is in `patches/spec.patch`)

The chain becomes `DECLARED → SELF_TESTED → PEER_TESTED → LAB_TESTED → QUALIFIED`, and §7.2 gains:

1. A `PEER_TESTED` level MUST rest on a plugfest record (`plugfest-result`) in which the claimed implementation is the
   initiator or the responder of a pairing of the claimed profile whose interoperability result is `PASS` and whose
   counterpart is an implementation of another participant, and which names at least one witness who is not a
   participant.
2. A claim at `PEER_TESTED` MUST carry the digest of its conformance report (`reportDigest`) and the digest of that
   plugfest record (`plugfestResultDigest`).
3. A conformance report on its own, including a report of one pairing, MUST NOT be presented as `PEER_TESTED` evidence.

The requirements index gives them the ids `REQ-7.2-1` to `REQ-7.2-3`. The sentence "A level is reached only with the
evidence named in the profile..." now opens with "Every level", unchanged in substance.

### Register

`registers/conformance-profiles.yaml` gains, between `SELF_TESTED` and `LAB_TESTED`:

| Id | Evidence |
|---|---|
| `PEER_TESTED` | conformance report (obsp conformance run) and a plugfest-result with a passing pairing of the claimed profile between the claimed implementation and another participant's implementation, named witnesses who are not participants, cited by digest in the claim |

### Contract: `plugfest-result` (schemaVersion 3.1.0)

| Property | Required | Shape |
|---|---|---|
| `resultUni` | yes | Uni |
| `event` | yes | `name`, `mode` (`ON_SITE`, `REMOTE`, `HYBRID`), `startedAt`, optional `endedAt` |
| `suiteVersion` | yes | the one suite version every report used |
| `participants` | yes, at least two | `participantUni`, `implementation` (`name`, `version`) |
| `witnesses` | yes, at least one | `witnessUni`, `statement` |
| `matrix` | yes, at least one cell | `profile`, `initiator`, `responder`, `independent`, `interop` (`PASS`, `FAIL`, `PARTIAL`, `NOT_RUN`), `checks` (`pass`, `fail`, `notRun`), optional `failedCases`, `reportDigests` (at least one) |
| `selfTests` | no | per implementation and profile: result and report digest |
| `reports` | yes, at least one | `reportUni`, `digest`, `mode` (`suite`, `live`), `signed` |
| `outcome` | yes | `pairings`, `independentPairings`, `passingIndependentPairings` |
| `recordedAt` | yes | Timestamp |

`interop` `PASS` means every check run in the pairing passed and none was left unrun; it does not mean the profile is
covered. The shape is the non-normative draft `conformance/plugfest/plugfest-result.schema.json` with the repository's
`$id`, `SchemaVersion` and `Extensions` conventions; acceptance removes the draft copy and points
`conformance/plugfest/matrix.py` at `schemas/json/plugfest-result.schema.json` (an editor step: the draft copy is not in
the tree this proposal's patches are made against).

What the schema cannot express is an invariant: witnesses are not participants; a cell marked `independent` joins two
participants; at least one independent cell passes (`plugfest-independent-witnessed`); a `PEER_TESTED` claim cites a
record of the evidence set by digest, and that record has a passing independent pairing of the claimed profile in
which the claimed implementation, by name and version, takes part (`peer-claim-cites-plugfest`).

### Contract: `conformance-claim`

The `level` enum gains `PEER_TESTED`; a new optional `plugfestResultDigest` (Digest); the rule "SELF_TESTED and above
need `reportDigest`" includes `PEER_TESTED`; a new rule makes `reportDigest` and `plugfestResultDigest` required when a
profile is claimed at `PEER_TESTED`. `PEER_TESTED` does not require a third-party assessor: the witness is in the record.

### Suite: run levels

Cases already carry a `level`. Today every case of a profile runs. With this change a run includes the cases at or
below its level (`obsp conformance run --level`, default `SELF_TESTED`), so the `PEER_TESTED` cases do not hold a
participant that brings no plugfest record. A run at a higher level marks its report with
`extensions["obsp.suite"]["casesUpTo"]`; the report itself still grants nothing. `obsp conformance check-suite` refuses a
case whose level is not in the register. The level selection and the two invariants live in a new module
`sdk/python/src/obsp/peer.py`, merged into the invariant table after the `Case` class, so the edits to `conformance.py`
stay away from the lines other drafts change.

## Compatibility

Additive. Existing claims, reports and cases are unchanged and still valid; a default run selects exactly the cases it
selects today. A consumer that enumerated the four levels sees a fifth. No function is added. `registers/requirements.yaml`
is generated and is regenerated by `python3 tools/requirements.py`.

## Tests

| Requirement | Case | Kind |
|---|---|---|
| REQ-7.2-1 | CT-PROVIDER-100 (level `PEER_TESTED`, requirement `admit`: the pairing exercises the responder's admission of the initiator's provider manifest and receipts) | invariant `plugfest-independent-witnessed` over `plugfest-result` |
| REQ-7.2-1, REQ-7.2-2, REQ-7.2-3 | CT-PROVIDER-101 (level `PEER_TESTED`, requirement `describe`: the claim describes the implementation) | invariant `peer-claim-cites-plugfest` over `conformance-claim` and `plugfest-result` |

The two cases name §7.2 in their titles, so the index covers the three requirements at section level. REQ-7.2-3 is
also enforced by the schema: a `PEER_TESTED` claim without `plugfestResultDigest` does not validate, so a report alone
cannot stand in for the record.

Fixtures: positive `plugfest-result.valid`, `conformance-claim.peer-tested.valid`; negative
`plugfest-result.no-witness`, `.single-participant`, `.unknown-interop-result`, `.cell-without-report`,
`.cell-without-independence`, `conformance-claim.peer-tested-without-plugfest-result`,
`.peer-tested-without-report` (one broken rule each). The OBSP-PROVIDER example set gains a plugfest record and a
`PEER_TESTED` claim citing it; it passes at the default level (three cases) and at `PEER_TESTED` (five cases). Unit
tests in `sdk/python/tests/test_peer_level.py` (13): run levels, the register order, the command line, each invariant
holding on the examples and failing on one fault (witness who is a participant, one participant marked independent, no
passing independent pairing, a cell naming a stranger, a wrong digest, a claimed version that did not take part), and a
`PEER_TESTED` run failing on a broken record while the default run still passes.

## Open questions

1. Name and place: `PEER_TESTED` between `SELF_TESTED` and `LAB_TESTED`, as proposed, or an evidence qualifier on
   `SELF_TESTED` (`SELF_TESTED` with plugfest evidence) that leaves the four levels as they are?
2. Cases for the other profiles: the suite keys cases by function, and a level applies to every profile. This draft adds
   the two cases to `OBSP-PROVIDER` only (CT-PROVIDER-100, CT-PROVIDER-101). Should each profile get its pair
   (CT-NODE-1xx and so on), or should the suite allow level-wide cases that are not tied to a function?
3. Independence: the draft takes "another participant" (a different participant UNI) as independence. Should it also
   exclude participants under common control, and how would a record show that?
4. Witness: is one witness enough, and must the witness sign the record? Signing waits for OIP-0008; until then the
   witness statement is unsigned text.
5. Expiry: should a `PEER_TESTED` level lapse when the implementation version changes or after a time, as `validUntil`
   on the claim allows today?
6. Coverage: `interop` `PASS` covers only the operations the harness drives (seven gateway operations). Should
   `PEER_TESTED` require a minimum set of cells per profile once live cases exist for more functions?

Acceptance needs appointed editors and a last-call window. Until then this proposal stays at DRAFT and the live tree
keeps four levels.
