# Open PR verification records, version 1

These account-independent JSON records describe approved intent, exact PR subjects,
source-test execution claims and scoped verification decisions. The reference
implementation is `agentone.verification`. The format does not require a vendor URL,
UUID, cloud provider, image artifact, or hosted account.

The format specification, JSON Schemas and examples in this directory are dedicated
to the public domain under CC0-1.0; see [LICENSE](LICENSE). This dedication does not
license the application, its tests, or third-party artwork.

## Documents and compatibility

| Identifier | Schema | Meaning |
| --- | --- | --- |
| `pr-subject.v1` | `pr-subject.v1.schema.json` | Immutable repository, PR and complete comparison identities |
| `intent-record.v1` | `intent-record.v1.schema.json` | Revisioned desired and forbidden outcomes, source references, approval claim |
| `pr-policy.v1` | `pr-policy.v1.schema.json` | Owner-approved outcome-to-suite/test/reporter mappings and check prerequisites |
| `pr-validation.v1` | `pr-validation.v1.schema.json` | Exact-subject named test execution claim |
| `verification-record.v1` | `verification-record.v1.schema.json` | Decision, scope, coverage, evidence, expiry and provenance |

Schemas use JSON Schema draft 2020-12. Required core fields are closed: unknown
properties are rejected. Importing a record validates its structure, not its truth
or its author's authority. Semantic constraints such as distinct IDs, safe finding
paths and execution time ordering are also checked by the reference models and
verifier. Schema validation alone is not the conformance gate.

All model exports include default fields, including empty `extensions` objects.
A consumer must preserve core fields and unknown vendor extensions on a lossless
round trip. Optional vendor data lives only under namespaced `extensions` keys,
for example `example.org:ui`. It cannot override a verdict or any core field.
Implementations MUST ignore extensions when deciding satisfaction. A core-field,
encoding, or verdict-semantics change requires a new identifier/version; do not
silently widen v1. New optional information can use a vendor extension. An
implementation that cannot interpret a required version returns unknown or a
validation error, never a pass.

## Exact subjects, intent and approval

Repository ID is a provider-qualified immutable identity such as `github:42`.
The readable repository label is additional context, not authority. Head, base,
comparison and merge-base are full lowercase 40- or 64-character Git object IDs.
The subject comparison is exact across all fields; merge candidates require their
own subject and are not certified by a PR-head result.

Intent contains stable requirement IDs, a desired outcome, forbidden outcomes,
declared scope, source references, a revision, proposer identity and optional
approval provenance. Empty intent and draft/code-derived proposals are valid
records but cannot satisfy a gate. The approval's `revision_digest` binds the
complete exported intent with only `approval` removed; all other defaults remain.
The whole intent digest includes approval. The approver must differ from the
proposer. This identity distinction is necessary but is not authentication:
backend membership and authorization determine independent owner approval.

A `pr-policy.v1` document pins the whole intent digest, owner approval time and
expiry. Every intent requirement must have exactly one rule mapping to the immutable
approved suite, explicit distinct positive AND negative test IDs, and independently
enrolled reporter identity/generation. Policy approval covers the suite and mappings;
the suite is held outside PR control. `accepted_trust_levels` explicitly records the
owner's acceptance of `enrolled_runner_claim` (the reference default).

## Trusted admission input, not client claims

`evaluate(subject, intent, receipts, checks, *, at, gaps, findings, policy)` is pure.
It does not authenticate, enroll a reporter, approve intent, fetch GitHub state,
run repository code, or reuse image-target receipt assumptions. The backend supplies
a current canonical subject and builds these **internal-only** envelopes from its
authenticated, authorized storage. Never forward client-supplied admission fields.
An arbitrary caller can construct a false envelope; its output is not authoritative.

`policy` is an `EvaluationPolicy` object serialized as a dictionary:

```json
{
  "policy": {"record_type": "pr-policy.v1", "...": "complete policy fields"},
  "intent_admission": {
    "intent_digest": "sha256:<whole intent hash>",
    "approved_by": "owner identity",
    "approved_at": "2026-11-07T23:58:00Z",
    "valid_until": "2026-11-08T01:00:00Z"
  },
  "request_id": "request:1",
  "run_id": "run:1",
  "provenance_mode": "current_evaluation"
}
```

Each `receipts` entry has `receipt` (the full normalized `pr-validation.v1` document)
and `admission` with `receipt_digest`, `reporter_subject`, `reporter_generation`,
`admitted_at`, `valid_until`, `trust_level: "enrolled_runner_claim"`, and
`authority_reference`. A payload's reporter identity is only a claim; the admission
identity is independently derived by the backend, and both must match the policy.
Admission must bind exactly the receipt digest. The backend must recheck enrollment,
repository/suite/receipt-type authority, enabled state, generation and revocation;
the model does not claim to perform those operations. Admission expiry cannot extend
the receipt expiry. Receipt/admission times must not be future-dated, and execution
must follow both intent and policy approval.

Checks are optional additional owner-policy prerequisites, never a behavioral receipt
substitute. Each `checks` entry has `check` (`PRCheckResult`) and `admission`
(`CheckAdmission`). Admission pins `check_digest`, provider readback authority,
`admitted_at`, `valid_until`, and backend-established `unique_latest: true`. A required
check must have the exact name, App ID, subject and unique latest completed success.
Ambiguous duplicates, missing runs, neutral/skipped/cancelled runs and the publisher's
own `Impersonal Agent / Verify` check cannot satisfy it. The backend owns canonical
latest-run discovery and source authority; a raw successful check is not admitted.

See `examples/admitted-evaluation.v1.json` for complete executable inputs. This fixture
is simulated, not a live execution or an authenticated production approval.

The internal evaluation envelope accepts `policy: null` for an unconfigured PR.
Its record has `policy_digest: null`, `policy_version: null`, and reason `policy_missing`.
State is `unknown`, or `stale` when supplied freshness gaps independently require it.
No supplied receipt/check can establish behavior without
that policy. Currentness is `unconfirmed` (or `historical` for a historical replay),
and `valid_until` equals the evaluation instant: no usable validity is granted.
Missing policy is never represented with an invented approver or approval time.
See the synthetic `examples/verification-unconfigured.v1.json` record.

## Decision and trust semantics

The v1 gate is **PR completion**. It omits deployment, runtime and experienced outcomes
explicitly. Full-lifecycle intent is not silently reduced to pre-merge requirements;
the current adapter returns unknown for that scope.

- `satisfied`: nonempty independently approved intent; complete matching owner policy;
  every required positive/negative case passed in a complete single admitted execution;
  required checks succeeded; no unresolved gaps; all authority/evidence current.
- `violated`: an admitted qualified mapped test failed or a required trusted check
  failed. The violation remains visible alongside unrelated missing evidence/gaps.
- `unknown`: intent, approval, policy coverage, execution, authority or required checks
  are missing, unsupported or incomplete. Skipped/error tests never satisfy coverage.
- `stale`: expired approval/evidence prevents a current decision, absent a qualified
  current violation. The original immutable record is not renewed in place.

Requirements sharing a suite digest, reporter identity and generation form one
approved execution group. A satisfying receipt must execute the combined required
test set for that group in one run; separate partial executions cannot be assembled
into a fictional complete successful run. A missing mapping for another requirement
prevents satisfaction and remains an explicit unknown coverage gap, while a qualified
mapped failure remains violated. Conflicting current failures are not hidden by
another passing execution.
Evidence references expose native IDs, digests, authority reference, expiry and trust.
`enrolled_runner_claim` means the independently enrolled supervisor asserted the exact
checkout/test result. It is not cryptographic proof of arbitrary execution. Source
presence, clean scans, generic CI success and model-only assertions cannot pass.

Coverage reports assessed requirements/test IDs, omitted requirements/test IDs and
out-of-scope lifecycle stages. Findings are advisory and do not mint behavioral
proof. Finding locations must be safe repository-relative paths and positive lines;
collectors must additionally verify that a path/line exists in the supported diff.
Callers must provide export-safe summaries/references, excluding raw secrets, source
bodies and private discussion text. This evaluator does not automatically sanitize
arbitrary caller-authored messages or authorize public export of private records.

`current_evaluation`, `historical_replay` and `re_evaluation` are explicit provenance
modes. Historical replay uses authority pinned at `at` and reports `currentness:
"historical"`, even for a historically satisfied result. It never grants current
completion. `currentness_token` binds subject, intent, policy, evidence and expiry;
it is a comparison token, not online proof or a signature. Fresh provider reads and
revocation/deadline handling remain backend responsibilities. Static records cannot
promise instant knowledge of missed events or remove a stale GitHub success during
a publisher/provider outage.

`exit_code(record)` returns 0 only for current satisfied, 1 for violated, and 2 for
unknown/stale/historical completion attempts. Client transport/internal errors (3)
and pending deadlines (4) are outside this completed-record evaluator.

## Canonical bytes and digests

The versioned encoding is **verification-json.v1**, not RFC 8785/JCS:

1. Input is a JSON object. Values are objects, arrays, Unicode scalar strings,
   booleans, null and integers in `[-9007199254740991, 9007199254740991]`.
   Reject floats (including integral floats, negative zero, NaN and infinities),
   non-string object keys, surrogate code points and non-JSON values.
2. Sort object keys lexicographically by Unicode scalar/code-point value (not UTF-16
   code-unit order). Preserve array order. Do not normalize Unicode or string values.
3. Encode JSON without whitespace or ASCII-escaping non-ASCII characters. Escape
   double quote/backslash; use `\b`, `\t`, `\n`, `\f`, `\r` for those controls and
   lowercase `\u00xx` for other U+0000–001F characters. Do not escape `/`.
4. Prepend the UTF-8 bytes `verification-json.v1` followed by one LF byte. SHA-256
   the resulting UTF-8 bytes; represent as `sha256:` plus 64 lowercase hex digits.

Record hashes bind the complete normalized model JSON export including default
fields. Timestamp fields export as RFC 3339; UTC uses `Z`. Normalize through the
reference model before hashing/enveloping; alternate equivalent timestamp strings
or omission of defaults are not alternative digests of the exported record.
The intent revision hash excludes only approval. Policy and receipt hashes include
all fields. `record_id` hashes the exported verification record with only
`record_id` removed. `evidence_set_digest` hashes an object containing the complete
input `receipts` and `checks` envelopes, each array sorted by member canonical digest;
thus rejected input and admission provenance also affect identity. Exported evidence references use a canonical ordering over every field, including
admission-limited expiry, so permutations of the same evidence inputs produce the
same record identity. These are content hashes, not signatures or proof of authenticity.

`examples/canonical-digests.json` contains independent literal-byte vectors for
implementations in other languages. Valid record examples round-trip through the
models; `invalid-verification-record.v1.json` intentionally uses an unsupported
verdict. Focused conformance: `python -m pytest tests/test_verification_records.py`.
The tests also compare checked-in schemas with Pydantic-generated schemas. Regenerate
a schema using `json.dumps(Model.model_json_schema(), indent=2)` plus a trailing LF;
regenerate examples from explicitly reviewed normalized inputs, never live credentials.
