diff --git a/docs/qualification/CANDIDATE.md b/docs/qualification/CANDIDATE.md new file mode 100644 index 0000000..81a8637 --- /dev/null +++ b/docs/qualification/CANDIDATE.md @@ -0,0 +1,58 @@ +# Qualification candidate pinning (C2) + +Status: spec, part of the AIEN Convergence Plan task C2. +Scope: how one exact integrated AIEN build is named, frozen, and judged. + +## Why this exists + +`CURRENT_EXECUTION_PLAN.md` line 45 says the R16 receipt binds candidate `850fc545`, that every candidate-bound R13 to R16 receipt predates omega `#126` (`4f8485b`), and that the current living build is IMPLEMENTED / NOT QUALIFIED until re-qualified. The same line records that omega `#112` merged with its `evidence-immutable` check failed. Both problems come from judging code that was not the code being shipped. A candidate manifest closes that gap. + +## Reuse, no parallel format + +Results are `EvidenceReceiptV1` receipts from `aien-sovereign-core/crates/aien-proof` (`src/evidence.rs`: fields `repo`, `commit`, `dirty`, `toolchain`, `procedure`, `machine`, `env_class`, `input_artifacts`, `output_artifacts`, `assertions`, `output_digest`, `result`). Formal proofs use the `formal-oracle-binding` receipt kind (`src/formal.rs`, `KIND`). This spec adds only the candidate manifest and the rules below. It does not define a new receipt. + +## The candidate manifest + +A candidate is a TOML file `qualification/candidates/CAND-.toml`, schema `CandidateManifestV1`, with: + +- `schema`, `id`, `status`, `created`. +- `[commits]`: one full 40-hex commit per repo: `omega`, `aienos`, `aien-sovereign-core` (FORGE and `aien-proof`), `aien-protocols`, `aien-architecture`. The contracts and wire schemas live in `aien-protocols`, so its pin is the contracts pin. UNVERIFIED: no separate contracts repo appears in `gh repo list aien-dev`. +- `[executables]`: a content digest for every built binary or image under test. `UNBUILT` is allowed only while status begins with `draft`. + +`status` is one of: `draft, not frozen`, `frozen`, `superseded`. Only a `frozen` candidate may be qualified. + +## Freeze rules during a campaign + +1. A campaign runs against exactly one frozen candidate. Any change to a pinned commit or executable digest creates a new candidate id; the old one is `superseded`, never edited. +2. Unrelated development continues on other branches and on `main`. Freezing pins commits; it does not lock repos. +3. A fix found by the campaign lands on main as usual, then a new candidate is cut and the affected results are rerun. +4. A frozen manifest is immutable. Edits to it are rejected, the same as evidence. + +## Required fields on every result + +Each result (a receipt, or the campaign table row pointing to one) carries: + +| Field | Meaning | EvidenceReceiptV1 home | +|---|---|---| +| source commits | the candidate id and each pinned commit used | `repo`, `commit`, `dirty` (must be false), `external_refs` carries the candidate id | +| executable digest | digest of the binary or image run | `input_artifacts` | +| execution environment | host, QEMU, or physical GB10 | `env_class`, `machine` | +| inputs | data, models, seeds | `input_artifacts` | +| commands | exact procedure | `procedure`, `toolchain` | +| raw output location | where the full output is stored | `output_artifacts`, `output_digest` | +| acceptance criteria | the pass condition, written before the run | `assertions` | +| status | `PASS`, `FAIL`, `SKIPPED`, or `BLOCKED` | `result` | + +A result with a missing field, a dirty tree, or a commit not in the manifest is not a PASS. `SKIPPED` and `BLOCKED` are never reported as PASS. Note: `Verdict` in `evidence.rs` also has `INCOMPLETE`; for campaign tables treat it as not-PASS and report it as `BLOCKED`. + +## Old receipts + +Receipts for earlier code stay valid history. They prove what they bound. They never qualify new code: a receipt counts toward a candidate only if its `commit` and executable digest match that candidate's manifest. + +## Promotion checks and exceptions + +Promotion checks (for example `evidence-immutable`) are mandatory. A bypass needs a written exception under `qualification/exceptions/`, committed before or in the same change as the bypass. See `qualification/exceptions/0001-r16-immutability.md`. + +## Checker + +`scripts/check_candidate.sh ` verifies that all required fields are present, that each pinned commit is 40 hex digits and exists in its repo, and that a non-draft manifest has real executable digests. Test: `scripts/test_check_candidate.sh`. Wiring into CI is not done and needs Drake's approval. diff --git a/qualification/candidates/CAND-0.toml b/qualification/candidates/CAND-0.toml new file mode 100644 index 0000000..ed43f11 --- /dev/null +++ b/qualification/candidates/CAND-0.toml @@ -0,0 +1,20 @@ +# Candidate manifest, schema CandidateManifestV1. See docs/qualification/CANDIDATE.md. +schema = "CandidateManifestV1" +id = "CAND-0" +status = "draft, not frozen" +created = "2026-10-01" +note = "First manifest. Heads taken from main on 2026-10-01 with gh api repos/aien-dev//commits/main. Not a qualification candidate until frozen." + +[commits] +omega = "25b4a51141fa48be01d1cdbac8617d41065e523d" +aienos = "bb3a5f4efb4c632d8485f9d05f615f466aff0f69" +aien-sovereign-core = "e58742acbb781ad4e472b3355b9b6ac8624617d9" +aien-protocols = "4a4877a88e141cb0c2d397191459912b8bfa993a" +aien-architecture = "f11ac55bd96908e004af625c8b53dc02b6188bca" + +# Executable digests (SHA-256 or BLAKE3 hex of each built binary or image). +# "UNBUILT" is allowed only while status starts with "draft". +[executables] +omega-runtime = "UNBUILT" +aienos-boot-image = "UNBUILT" +aien-proof = "UNBUILT" diff --git a/qualification/exceptions/0001-r16-immutability.md b/qualification/exceptions/0001-r16-immutability.md new file mode 100644 index 0000000..aa6cd61 --- /dev/null +++ b/qualification/exceptions/0001-r16-immutability.md @@ -0,0 +1,24 @@ +# Exception 0001: R16 merge with failed evidence-immutable check + +Status: recorded after the fact. Recorded in the plan 2026-10-01 (Lane 33). + +## What happened + +Quoted from `CURRENT_EXECUTION_PLAN.md` line 45: "`#112` merged with its `evidence-immutable` check FAILED (run `36799862685`) because `evidence/R16/inventory.json` was edited in place by commits `1edb56b` and `6831117`; the PR did not record this." + +Verified with commands on 2026-10-01: +- `gh pr checks 112 -R aien-dev/omega` shows `evidence-immutable fail` at https://github.com/aien-dev/omega/actions/runs/36799862685/job/110171540034. +- `gh api repos/aien-dev/omega/pulls/112` gives merge commit `3dd5eaa171ea095862f319def757f620380e3afb` and PR head `6831117682cad4f8e2daa191be6377ab21a0d0cc`. +- PR: https://github.com/aien-dev/omega/pull/112. + +UNVERIFIED: who approved the merge, and whether the in-place edit changed the meaning of the receipt. This record does not decide either. + +## Effect + +The R16 receipt is kept as history but its inventory file was mutated after the fact, and it binds candidate `850fc545`, which predates later runtime changes. It must not be used to qualify new code. + +## Rule going forward + +1. Promotion checks are mandatory. A merge with a failing promotion check is not allowed. +2. Any bypass needs a written exception in this directory, naming the check, run, PR, reason, approver, and effect on evidence, committed before or with the bypass. +3. Evidence is never edited in place. A correction is a new receipt that links to the old one. diff --git a/scripts/check_candidate.sh b/scripts/check_candidate.sh new file mode 100755 index 0000000..70c8ede --- /dev/null +++ b/scripts/check_candidate.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +# check_candidate.sh: validate a candidate manifest (docs/qualification/CANDIDATE.md). +# Usage: scripts/check_candidate.sh +# Exit 0 = valid, 1 = invalid. Pure bash; sha existence is checked with +# `gh api repos/aien-dev//commits/`. Override with env var +# CAND_SHA_CHECK (a command run as: $CAND_SHA_CHECK ) for tests. +set -u +f="${1:-}" +[ -f "$f" ] || { echo "usage: $0 " >&2; exit 1; } +fail=0 +err() { echo "FAIL: $*" >&2; fail=1; } + +sha_exists() { + if [ -n "${CAND_SHA_CHECK:-}" ]; then $CAND_SHA_CHECK "$1" "$2" + else gh api "repos/aien-dev/$1/commits/$2" -q .sha >/dev/null 2>&1; fi +} + +# Parse: "section.key" -> value, for lines `key = "value"`. +declare -A kv +sec="" +while IFS= read -r line; do + line="${line%%#*}" + line="$(echo "$line" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + [ -z "$line" ] && continue + if [[ "$line" =~ ^\[([A-Za-z0-9_.-]+)\]$ ]]; then sec="${BASH_REMATCH[1]}."; continue; fi + if [[ "$line" =~ ^([A-Za-z0-9_.-]+)[[:space:]]*=[[:space:]]*\"(.*)\"$ ]]; then + kv["${sec}${BASH_REMATCH[1]}"]="${BASH_REMATCH[2]}" + fi +done < "$f" + +for k in schema id status created; do + [ -n "${kv[$k]:-}" ] || err "missing field: $k" +done +[ "${kv[schema]:-}" = "CandidateManifestV1" ] || err "schema must be CandidateManifestV1" +case "${kv[status]:-}" in + "draft, not frozen"|frozen|superseded) ;; + *) err "status must be 'draft, not frozen', 'frozen' or 'superseded'" ;; +esac + +for r in omega aienos aien-sovereign-core aien-protocols aien-architecture; do + s="${kv[commits.$r]:-}" + if [ -z "$s" ]; then err "missing commit: $r"; continue; fi + [[ "$s" =~ ^[0-9a-f]{40}$ ]] || { err "commit for $r is not 40 lowercase hex: $s"; continue; } + sha_exists "$r" "$s" || err "commit $s not found in aien-dev/$r" +done + +nexe=0 +for k in "${!kv[@]}"; do + [[ "$k" == executables.* ]] || continue + nexe=$((nexe+1)) + v="${kv[$k]}" + if [ "$v" = "UNBUILT" ]; then + [[ "${kv[status]:-}" == draft* ]] || err "$k is UNBUILT but status is not draft" + else + [[ "$v" =~ ^[0-9a-f]{64}$ ]] || err "$k digest is not 64 lowercase hex" + fi +done +[ "$nexe" -gt 0 ] || err "no [executables] entries" + +[ "$fail" -eq 0 ] && echo "OK: $f" && exit 0 +exit 1 diff --git a/scripts/test_check_candidate.sh b/scripts/test_check_candidate.sh new file mode 100755 index 0000000..531a8f6 --- /dev/null +++ b/scripts/test_check_candidate.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# Test for check_candidate.sh using a stub sha checker (no network). +set -u +here="$(cd "$(dirname "$0")" && pwd)" +chk="$here/check_candidate.sh" +tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT +stub="$tmp/stub.sh" +cat > "$stub" <<'S' +#!/usr/bin/env bash +[ "$2" != "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef" ] +S +chmod +x "$stub"; export CAND_SHA_CHECK="$stub" +good="$here/../qualification/candidates/CAND-0.toml" +pass=0; bad=0 +expect() { # expect <0|1>