# Qualification

---

# Test Ownership

_Peios / Developing for Peios / Qualification_

> Where Peios tests, fixtures, and qualification machinery belong.

Keep a test beside the component whose contract it checks. A test that needs
a VM still belongs to that component if its assertions concern that
component's behavior. The VM is apparatus, not an ownership rule.

## Choose an owner

| Test or helper | Owner |
| --- | --- |
| Unit tests and isolated API checks | The component |
| Native contract tests using a real kernel | The component |
| Behavior across several real services | Integration Tests |
| Complete boot, upgrade, and release qualification | Integration Tests |
| Generic VM lifecycle and host utilities | Provium |
| Component-specific fixtures and helpers | The component |

For example, a resolver test using a stub network manager belongs to
resolvd. A scenario asserting behavior across real resolvd and netd belongs
to Integration Tests. An authd event test can use eventd as observation
apparatus while checking authd's documented event contract.

## Keep one maintained copy

A component exports its suite through `tests/integration/suite.json`.
The kernel uses `peios/tests/integration/suite.json`. The manifest lists
owned test files and maps helper and fixture sources into a virtual layout.
Cross-component scenarios have a manifest in the central repository.

The central `suites.lock.json` records each repository's exact commit and
manifest hash. The runner reads files from those Git objects and assembles
the layout in a fresh run directory. It rejects duplicate export paths.
Shared helpers come from their owning repositories, not copied snapshots
inside each consumer.

Keep fast checks in ordinary component CI. Run native conformance with
supplied images and tools. Use the central runner for both component and
system selections, so both produce the same provenance and result format.

## Preserve migration evidence

The migration map accounts for 604 imported test files. Imported assertions
retain their historical specification references. One resolver test moves
its inline probe into a supplied tool; its assertions remain unchanged. The
map records source paths and hashes; helper adaptations are listed
separately in `migration-adaptations.json`.

The central legacy package-event scenario exercises `.peipkg`. It does not
establish compatibility with PPK blobs and manifests. Archived recipes
preserve fixture requirements without activating retired image builders.

---

# Running Conformance Tests

_Peios / Developing for Peios / Qualification_

> Run component or system suites against supplied, recorded inputs.

Run the host checks before using the qualification runner. They need
pekit on a Linux host:

```sh
pekit test
```

The qualification runner itself needs Python 3.11 or later and Git.

A native run also needs a suitable QEMU host, the required privileges,
networking tools, and Peios images. Provium checks host prerequisites.
Prepare images outside the runner, with the fixtures and services described
by the selected suite. The archived profile recipes document those inputs.

## Prepare the composition

Copy `examples/composition.json`. Replace every placeholder with a supplied
path, its hash, and the exact component source revisions in the image.
Calculate a file or directory hash with:

```sh
./peios-qualify hash /path/to/artifact
```

Supply signed guest tools when a test requests them. Their signatures must
match the image's trust policy. The runner checks hashes, not signatures;
verify signature authority when preparing the supplied artifacts.

Use `kernel-only` for kernel and network apparatus, `prelude` for early
boot, and `peinit` for full-system service tests. A component selection can
need more than one profile. Prelude tests also require `PT_MKIRF` to name a
recorded artifact; no sibling build or host-path fallback is used.

## Select and run tests

Keep all repositories named by the lock available, including helper owners.
The runner reads their recorded Git objects without switching branches.
List a component's test files:

```sh
./peios-qualify list --lock suites.lock.json --suite authd
```

Stage a run without starting Provium:

```sh
./peios-qualify prepare --lock suites.lock.json --suite authd \
  --composition /path/to/composition.json --output /path/to/prepared-run
```

Run with a fresh output directory. Avoid single quotes and control
characters in that path because the imported helpers use shell commands:

```sh
./peios-qualify run --lock suites.lock.json --suite authd \
  --composition /path/to/composition.json --output /path/to/run \
  --timeout-seconds 3600
```

Repeat `--suite` for several components. Select `system` for the central
scenarios; omit `--suite` for all test files. An empty selection is an error.
Slow cases are included. A timeout stops the runner and its child processes.

Component bundles also expose a `check-integration` script.
Set `PEIOS_QUALIFY` to the central executable and supply the same lock,
composition, and fresh output path. These entry points do not build images.

## Test a candidate

Commit the candidate suite and use a clean checkout. Add an explicit
`--candidate authd=/path/to/authd` to select its committed test source.
This overrides one suite pin and records the selected commit. It does not
replace the image or infer which binaries the image contains.

Update the supplied composition when testing candidate binaries. Keep the
test revision and image component revision distinct in the result record.
After reviewing permanent suite changes, refresh the lock deliberately:

```sh
./peios-qualify pin --catalog suites.json --output suites.lock.json
```

Review the lock diff before committing it. Pin updates are separate from
running tests and do not publish any repository.

---

# Composition Format

_Peios / Developing for Peios / Qualification_

> Supplied artifact and profile fields for the qualification runner.

A composition is a JSON object with `format` set to `1`.
Paths in `artifacts` are absolute or relative to the composition file.
Every artifact has a `path` and `sha256`. Other fields refer to an artifact
with an object such as `{"artifact": "kernel"}`.

## Fields

| Field | Meaning |
| --- | --- |
| `mode` | `system` by default; `harness` for local runner checks |
| `artifacts` | Named regular files or directory trees and their hashes |
| `runner` | Artifact reference for the executable Provium runner |
| `components` | Image component names mapped to exact Git commit IDs |
| `profiles` | Named boot profiles using recorded artifact references |
| `host_tools` | Executable names mapped to supplied artifact references |
| `guest_tools` | Test tool names with `unsigned` and optional `signed` inputs |
| `environment` | Explicit `PT_*` and supported `*_TEST_*` artifacts |
| `packages` | Optional declared package identities and manifest references |
| `file_timeout_seconds` | Per-file timeout; default 300 seconds |

System mode requires a declared component composition, boot profiles, and a
recorded `qemu-system-x86_64` executable. Harness mode uses Provium's local
backend, skips VM host preflight, and never produces OS qualification.
The host runtime remains a dependency in either mode. Local mode requires
selected test manifests to declare `harness_only: true`; ordinary native
suites cannot run on the local backend.

The image composition is an operator declaration. The runner does not
inspect an image to prove that its binaries came from those commits.
Package declarations use `name`, `version`, `arch`, and `manifest`.
The runner checks that each supplied manifest has the declared identity;
it does not resolve dependencies, install packages, or verify image contents.

## Profile inputs

A profile accepts `kernel`, `initrd`, `root`, `cmdline_file`, and
`agent_overlay_path` as artifact references. It also accepts `cmdline`,
`guest_os`, `inject_agent`, and `agent_boot_timeout` as ordinary values.
Every profile needs a kernel or a root containing one. Agent injection
requires an explicit agent overlay.

A `disks` entry accepts `path`, `id`, `readonly`, and `mediated`.
Its path is an artifact reference. Writable disks use separate working
copies; read-only media keep their supplied snapshot. Final working-disk
hashes are recorded separately from original input hashes.

Build commands and profile discovery directories are rejected. The runner
passes `--no-build` to Provium and writes its own explicit configuration.
The historical `build.sh` and `sign.sh` helper names resolve supplied guest
tools; they do not build or sign anything.

## Hashes and storage

A file hash is SHA-256 of its bytes. A directory hash covers sorted relative
paths, modes, file hashes, and link targets using the runner's canonical
JSON encoding. Use `peios-qualify hash` for trees. Links must be relative and
remain inside the tree. Special files and symlink artifact roots are rejected.

Each run copies and verifies supplied artifacts before execution. Keep
enough disk space for those copies and writable disk snapshots. The output
directory must not already exist. Preserve the result directory with the
release evidence; its hashes are useful only while the corresponding inputs
remain available.

Candidate binary inputs include `PEINIT_TEST_BINARY`, `TRUSTD_TEST_BINARY`,
`LOREGD_TEST_BINARY`, `NETD_TEST_BINARY`, `RESOLVD_TEST_BINARY`,
`NSS_NET_TEST_BINARY`, and `NSS_IDENTITY_TEST_BINARY`. Service seed inputs
use `NETD_TEST_SERVICE` or `RESOLVD_TEST_SERVICE`. All are artifact
references.
The resolver probe uses `guest_tools.pt-nss.unsigned`; its source and dynamic
linking requirements are in the resolver's integration bundle.

---

# Qualification Results

_Peios / Developing for Peios / Qualification_

> Interpret pass, failure, skipped cases, and recorded provenance.

The runner writes `run.json` before staging inputs and updates it as the run
progresses. It records suite commits, source hashes, supplied artifact
hashes, the composition, command, environment, and host details.
`stdout.jsonl` preserves Provium's per-file reports. `stderr.log` preserves
diagnostics, and `events.msgpack` preserves the event stream.

## Status and exit codes

| Status | Meaning | Exit code |
| --- | --- | --- |
| `prepared` | Inputs staged; no tests executed | 0 |
| `passed` | Every selected file reported successful cases | 0 |
| `incomplete` | At least one case was skipped | 3 |
| `failed` | Failure, timeout, missing report, or changed immutable input | 1 |
| `blocked` | Inputs could not be staged or validated | 2 |
| `interrupted` | The user interrupted execution | 130 |

Malformed arguments also return 2. A file with no reported cases is a
failure. Missing or duplicated file reports fail the run. A zero exit code
from Provium cannot hide failed cases or an incomplete report set.

`qualification` is true only for a passed system-mode run. It applies to
the recorded selection and supplied composition, not an entire OS release.
A harness run can pass while `qualification` remains false.

## Release evidence

Keep component fast checks, native conformance, system scenarios, and
release acceptance as separate gates. A successful host check establishes
runner behavior; it does not establish that a Peios image boots or that its
services work together.

Review the selected suites and skipped cases before accepting a release.
Also review the provenance declaration: hashes identify bytes, but do not
establish signing authority or prove the declared source-to-image mapping.
The runner records selected host executable hashes; host libraries, QEMU
data files, privileges, and kernel behavior remain environmental inputs.

Candidate overlays, such as `PT_EVENTD_ROOT`, must be supplied as hashed
artifacts. A test that requires an absent candidate overlay can skip; the
result then remains incomplete. Do not treat that as a successful release
gate or suppress the skip to make the result green.
