interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

GitHub aien-dev/aien-sovereign-core-mv#231 (code only)

closed derived 796e61c5406e3c28 #231

Imported from GitHub aien-dev/aien-sovereign-core-mv#231 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 2d36d9c7db06279dc995c773815d85428d550424 · Head 9276f3f931bb77d5ae9c0e9b734070d95656ba41

Apply it

git checkout -b patch-796e61c5406e3c28 2d36d9c7db06279dc995c773815d85428d550424
curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/796e61c5406e3c28.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/aien-sovereign-core-mv
231
9276f3f931bb77d5ae9c0e9b734070d95656ba41
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":231,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/231","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:24Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index 3414d45e..9c1fe1a9 100644
--- a/.crumb
+++ b/.crumb
@@ -77,14 +77,14 @@
         }
       ],
       "children_root": "sha256:5bc6c40c7fc034d6f7a949a438fcc78ed8c452232e3a6ab7bb6ef6b622ebaf49",
-      "compiled_at": "2026-10-06T18:31:26Z",
+      "compiled_at": "2026-10-06T18:51:57Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:8c7e1a8094ee53e872e485943889986935b7dd055deae3692ae7a4e506a7c0d9",
+      "digest": "sha256:54cd4945e3020f6412ee3b7aea24bb578f3f59beb74e864a4741129f4fffd7e4",
       "evidence_files": 24,
       "evidence_root": "sha256:16192fc4be2f886385affd6e26faae4b831eb62b87ceac4ab39d662e0859d7f8",
-      "files": 783,
-      "generated_at_commit": "73907553e105a2dabbfafb8bee07a6d6ccc2ee8c",
-      "source_tree": "sha256:f6a4720c836cdb4f64f804b4f1d9225dca886b6f00dd3f31f2967bc607b63012"
+      "files": 798,
+      "generated_at_commit": "58e8af47cd808aa2065293df58258d0630f3a041",
+      "source_tree": "sha256:eed86a0ef151ec7ad3407131991f1bdcbe6a761ac64d182023b49584347daf2f"
     }
   },
   "history": [],
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 187dcbe1..e3468192 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -33,6 +33,9 @@ jobs:
       - name: Verify Piped Installer Bootstrap
         run: bash scripts/test-install.sh
 
+      - name: Verify Scoring Contract v5 (negative tests)
+        run: bash docs/campaigns/scoring/test-scoring-v5.sh
+
       - name: Cargo Workspace Check
         run: cargo check --workspace --all-targets
 
diff --git a/docs/campaigns/scoring/SCORING-v5.md b/docs/campaigns/scoring/SCORING-v5.md
new file mode 100644
index 00000000..a579f360
--- /dev/null
+++ b/docs/campaigns/scoring/SCORING-v5.md
@@ -0,0 +1,77 @@
+# Scoring contract v5 (shared by campaigns)
+
+```text
+contract      = "scoring-v5"
+status        = FROZEN at the commit that adds this file
+scorer        = docs/campaigns/scoring/score-rows.sh (shell + jq)
+tests         = docs/campaigns/scoring/test-scoring-v5.sh
+reason        = NEXT-PHASE-2 v4 review: next-phase-2/make-receipt.sh scores a row PASS when
+                every repetition it finds is PASS, whatever their number. A row with 2 of
+                3 required repetitions, or 1 of 3, scores PASS.
+applies_to    = receipts of NEXT-PHASE-2 v5 and later; NEXT-PHASE-1 v6 may adopt it
+```
+
+## 1. What is not changed
+
+`next-phase-2/make-receipt.sh`, receipt `e401fffe...`, `VERDICT-v4.md` and `ACCEPTANCE-v4.md`
+are untouched. The v4 receipt stays reproducible because its scorer is the same bytes. v4 is a
+v4 result under the v4 rule; scored under this contract it also PASSes (section 6).
+`next-phase-1/` is not touched.
+
+## 2. Declaration
+
+The case set is read from a frozen declaration file (JSON), never inferred from the results.
+It is transcribed from the frozen acceptance file and names that file (`frozen_by`).
+
+```text
+{ contract: "scoring-v5", campaign: <name>, frozen_by: <acceptance file>,
+  rows: [ { row, role: "case"|"control", reps: <integer >= 1>, expected: "PASS",
+            control: <row id> | "F0" | null, not_applicable: <bool> } ] }
+```
+
+`expected` must be `"PASS"`. A bad declaration (missing field, reps < 1, duplicate row id,
+a control that names no declared row) gives verdict ERROR. `"F0"` is an external control: its
+value is passed in a third file (`{"F0": true}`); absent means false.
+
+## 3. Results
+
+One JSON object per line, one line per run: `row`, `rep` (integer >= 1), `verdict` (PASS,
+FAIL, NOT_RUN, NOT_APPLICABLE or UNVERIFIED). A NOT_APPLICABLE run also needs a non-empty
+`outcome`, which is its stated reason. A run id is `(row, rep)`.
+
+## 4. Row rules (first matching rule wins)
+
+1. Two records with the same run id: ERROR. Never counted twice.
+2. Any counted repetition FAIL: FAIL.
+3. NOT_APPLICABLE on a row whose declaration does not list `not_applicable`: FAIL.
+4. A record of the row that is not well formed (no integer `rep`, no valid `verdict`, a
+   NOT_APPLICABLE without reason), or any UNVERIFIED run: INCOMPLETE.
+5. Fewer than `reps` distinct required repetitions (1..reps): INCOMPLETE; none at all: NOT_RUN.
+6. Any NOT_RUN repetition: NOT_RUN.
+7. NOT_APPLICABLE runs: NOT_APPLICABLE only if every repetition is NOT_APPLICABLE; mixed with
+   PASS it is INCOMPLETE. NOT_APPLICABLE never counts as PASS and never satisfies a required
+   repetition.
+8. Otherwise (exactly `reps` repetitions, all PASS): PASS.
+
+Control: a row with a `control` whose rule 8 result is PASS or NOT_APPLICABLE is NOT_RUN
+unless its control row scored PASS (a control row must have its declared expected result,
+PASS) or its external control is true. A control row that does not score PASS is itself FAIL,
+INCOMPLETE, ERROR or NOT_RUN by the rules above.
+
+Extra runs: a run with `rep` above `reps`, or for a row not in the declaration, is listed
+under `extras` and never counted. It cannot raise or lower a verdict.
+
+## 5. Campaign verdict
+
+PASS only if there is no malformed line (a line that is not a JSON object with a string
+`row`) and every row is PASS, or NOT_APPLICABLE where declared (named in `not_applicable`,
+not counted as a PASS). Otherwise the first of: ERROR, FAIL, INCOMPLETE, NOT_RUN. The scorer
+exits 0 only for PASS, 1 for any other verdict, 2 if it cannot score (fail closed).
+
+## 6. Check against v4
+
+`declarations/np2-v4.decl.json` is the v4 case set (27 cases, 7 control rows; 3 repetitions
+per injected row, C6i once, controls once; C6d may be NOT_APPLICABLE). The v4 receipt's
+`controls` and `rows` scored with it and `F0 = true`: PASS, C6d NOT_APPLICABLE, 33 rows PASS.
+The same runs with one C7c repetition removed: INCOMPLETE. The C3 control row (fixture
+backend) is a receipt-level check and stays outside this scorer.
diff --git a/docs/campaigns/scoring/declarations/np2-v4.decl.json b/docs/campaigns/scoring/declarations/np2-v4.decl.json
new file mode 100644
index 00000000..bfa97949
--- /dev/null
+++ b/docs/campaigns/scoring/declarations/np2-v4.decl.json
@@ -0,0 +1,280 @@
+{
+  "contract": "scoring-v5",
+  "campaign": "next-phase-2",
+  "frozen_by": "docs/campaigns/next-phase-2/ACCEPTANCE-v4.md (sections 4, 5, 6) over ACCEPTANCE-v3.md and ACCEPTANCE-v2.md",
+  "note": "Case set, repetitions (3 per injected row, C6i exactly once, one control per case family) and the C6d guard are transcribed from those frozen files and from the run order in make-receipt.sh. External control F0 = fixture.s3_committed. The C3 control row (fixture backend) stays a receipt-level check outside this scorer.",
+  "rows": [
+    {
+      "row": "control-C1",
+      "role": "control",
+      "reps": 1,
+      "expected": "PASS",
+      "control": null,
+      "not_applicable": false
+    },
+    {
+      "row": "control-C2",
+      "role": "control",
+      "reps": 1,
+      "expected": "PASS",
+      "control": null,
+      "not_applicable": false
+    },
+    {
+      "row": "control-C4",
+      "role": "control",
+      "reps": 1,
+      "expected": "PASS",
+      "control": null,
+      "not_applicable": false
+    },
+    {
+      "row": "control-C5",
+      "role": "control",
+      "reps": 1,
+      "expected": "PASS",
+      "control": null,
+      "not_applicable": false
+    },
+    {
+      "row": "control-C6",
+      "role": "control",
+      "reps": 1,
+      "expected": "PASS",
+      "control": null,
+      "not_applicable": false
+    },
+    {
+      "row": "control-C7",
+      "role": "control",
+      "reps": 1,
+      "expected": "PASS",
+      "control": null,
+      "not_applicable": false
+    },
+    {
+      "row": "control-C8",
+      "role": "control",
+      "reps": 1,
+      "expected": "PASS",
+      "control": null,
+      "not_applicable": false
+    },
+    {
+      "row": "C1a",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C1",
+      "not_applicable": false
+    },
+    {
+      "row": "C1b",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C1",
+      "not_applicable": false
+    },
+    {
+      "row": "C2a",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C2",
+      "not_applicable": false
+    },
+    {
+      "row": "C2b",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C2",
+      "not_applicable": false
+    },
+    {
+      "row": "C2c",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C2",
+      "not_applicable": false
+    },
+    {
+      "row": "C2d",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C2",
+      "not_applicable": false
+    },
+    {
+      "row": "C3a",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "F0",
+      "not_applicable": false
+    },
+    {
+      "row": "C3b",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "F0",
+      "not_applicable": false
+    },
+    {
+      "row": "C4",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C4",
+      "not_applicable": false
+    },
+    {
+      "row": "C5a",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C5",
+      "not_applicable": false
+    },
+    {
+      "row": "C5b",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C5",
+      "not_applicable": false
+    },
+    {
+      "row": "C5c",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C5",
+      "not_applicable": false
+    },
+    {
+      "row": "C6a",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C6",
+      "not_applicable": false
+    },
+    {
+      "row": "C6b",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C6",
+      "not_applicable": false
+    },
+    {
+      "row": "C6c",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C6",
+      "not_applicable": false
+    },
+    {
+      "row": "C6c-ctl",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C6",
+      "not_applicable": false
+    },
+    {
+      "row": "C6d",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C6",
+      "not_applicable": true
+    },
+    {
+      "row": "C6e",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C6",
+      "not_applicable": false
+    },
+    {
+      "row": "C6f",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C6",
+      "not_applicable": false
+    },
+    {
+      "row": "C6g",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C6",
+      "not_applicable": false
+    },
+    {
+      "row": "C6h",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C6",
+      "not_applicable": false
+    },
+    {
+      "row": "C6i",
+      "role": "case",
+      "reps": 1,
+      "expected": "PASS",
+      "control": "control-C6",
+      "not_applicable": false
+    },
+    {
+      "row": "C7a",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C7",
+      "not_applicable": false
+    },
+    {
+      "row": "C7b",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C7",
+      "not_applicable": false
+    },
+    {
+      "row": "C7c",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C7",
+      "not_applicable": false
+    },
+    {
+      "row": "C8a",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C8",
+      "not_applicable": false
+    },
+    {
+      "row": "C8b",
+      "role": "case",
+      "reps": 3,
+      "expected": "PASS",
+      "control": "control-C8",
+      "not_applicable": false
+    }
+  ]
+}
diff --git a/docs/campaigns/scoring/score-rows.sh b/docs/campaigns/scoring/score-rows.sh
new file mode 100755
index 00000000..29defc68
--- /dev/null
+++ b/docs/campaigns/scoring/score-rows.sh
@@ -0,0 +1,98 @@
+#!/usr/bin/env bash
+# Scoring contract v5 scorer (docs/campaigns/scoring/SCORING-v5.md). Shell + jq only.
+# Usage: score-rows.sh DECLARATION.json RESULTS.jsonl [EXTERNAL.json]
+#   DECLARATION  frozen declaration of the case set (see SCORING-v5.md section 2)
+#   RESULTS      one JSON object per line, one line per run
+#   EXTERNAL     optional JSON object of external controls, e.g. {"F0":true};
+#                an external control that is absent counts as false (fail closed)
+# Prints one JSON verdict on stdout. Exit 0 only if the campaign verdict is PASS,
+# 1 for any other verdict, 2 for a bad declaration, unreadable input or a jq failure.
+# Nothing here reads the older make-receipt.sh scorers; they stay as they were.
+set -u
+DECL=${1:?DECLARATION.json} RES=${2:?RESULTS.jsonl} EXT=${3:-}
+[ -f "$DECL" ] && [ -f "$RES" ] || { echo "score-rows: input not found" >&2; exit 2; }
+if [ -n "$EXT" ]; then [ -r "$EXT" ] || { echo "score-rows: external file not found" >&2; exit 2; }; else EXT=/dev/null; fi
+# Results are read as raw lines so that one bad line is a malformed record, not a crash.
+out=$(jq -n --slurpfile decl "$DECL" --rawfile raw "$RES" --slurpfile ext "$EXT" '
+  ($decl[0]) as $d
+  | ($ext[0] // {}) as $x
+  | def isint: type == "number" and . == floor and . >= 1;
+    def nonempty: type == "string" and (gsub("\\s"; "") | length) > 0;
+  # ---- declaration must be valid, else the whole scoring is an error ----
+  ( (($d.rows | map(.row?) + ["F0"]) as $ids2 | if ($d | type) != "object" or $d.contract != "scoring-v5" or ($d.campaign | nonempty | not)
+        or ($d.rows | type) != "array" or ($d.rows | length) == 0 then "contract/campaign/rows missing"
+    elif ($d.rows | map(.row) | (length != (unique | length))) then "duplicate row id in declaration"
+    elif ($d.rows | all(
+            (.row | nonempty) and (.reps | isint) and .expected == "PASS"
+            and ((.control // null) == null or (.control | type) == "string")
+            and ((.not_applicable // false) | type) == "boolean")) | not then "bad row entry (row, reps >= 1, expected PASS)"
+    elif ([$d.rows[] | .control | select(. != null and (. as $c | $ids2 | index($c) | not))] | length) > 0
+         then "control names an undeclared row"
+    else null end) ) as $derr
+  | if $derr != null then {contract:"scoring-v5", verdict:"ERROR", declaration_error:$derr, rows:[], extras:[], malformed:[]}
+    else
+    # ---- parse results line by line ----
+    ( $raw | split("\n") | map(select(gsub("\\s"; "") | length > 0)) | to_entries
+      | map(. as $e | ($e.value | try fromjson catch null) as $o | {line:($e.key + 1), o:$o}) ) as $lines
+    | ($d.rows | map(.row)) as $declared
+    | ($lines | map(select((.o | type) != "object" or ((.o.row | type) != "string")
+                          ))) as $noid
+    | ($lines | map(select((.o | type) == "object" and (.o.row | type) == "string"))) as $withrow
+    # a well-formed record: integer rep >= 1, verdict in the enum, NOT_APPLICABLE carries an outcome (the reason)
+    | def wellformed: (.rep | isint)
+        and (.verdict | IN("PASS","FAIL","NOT_RUN","NOT_APPLICABLE","UNVERIFIED"))
+        and (if .verdict == "NOT_APPLICABLE" then (.outcome | nonempty) else true end);
+      ($withrow | map(select(.o | wellformed | not))) as $bad
+    | ($withrow | map(select(.o | wellformed)) | map(.o + {line:.line})) as $good
+    | ($d.rows | map(. as $r
+        | ($good | map(select(.row == $r.row))) as $mine
+        | ($mine | map(select(.rep <= $r.reps))) as $in
+        | ($mine | map(select(.rep > $r.reps)) | map({row, rep, verdict, line})) as $extra
+        | ($in | group_by(.rep) | map(select(length > 1) | .[0].rep)) as $dups
+        | ($in | map(.rep) | unique) as $have
+        | ([range(1; $r.reps + 1)] | map(select(. as $k | $have | index($k) | not))) as $missing
+        | ($bad | map(select(.o.row == $r.row)) | map(.line)) as $badlines
+        | ($in | map(select(.verdict == "FAIL"))) as $failed
+        | ($in | map(select(.verdict == "NOT_APPLICABLE"))) as $na
+        | { row:$r.row, role:($r.role // "case"), control:($r.control // null), required_reps:$r.reps,
+            counted_reps:($have | length), missing_reps:$missing, duplicate_reps:$dups,
+            incomplete_record_lines:$badlines, extra_runs:$extra,
+            na_declared:($r.not_applicable // false),
+            own:(
+              if ($dups | length) > 0 then "ERROR"
+              elif ($failed | length) > 0 then "FAIL"
+              elif ($na | length) > 0 and (($r.not_applicable // false) | not) then "FAIL"
+              elif ($badlines | length) > 0 then "INCOMPLETE"
+              elif ($in | any(.verdict == "UNVERIFIED")) then "INCOMPLETE"
+              elif ($missing | length) > 0 then (if ($have | length) == 0 then "NOT_RUN" else "INCOMPLETE" end)
+              elif ($in | any(.verdict == "NOT_RUN")) then "NOT_RUN"
+              elif ($na | length) > 0 then (if ($na | length) == ($in | length) then "NOT_APPLICABLE" else "INCOMPLETE" end)
+              else "PASS" end) } )) as $own
+    # a control must itself have scored PASS (its declared expected result) for its rows to count
+    | ($own | map({(.row): .own}) | add) as $ownmap
+    | ($own | map(. as $r
+        | (if $r.control == null then true
+           elif $r.control == "F0" then ($x.F0 == true)
+           else ($ownmap[$r.control] == "PASS") end) as $cok
+        | $r + {control_pass:$cok,
+                verdict:(if ($r.own == "PASS" or $r.own == "NOT_APPLICABLE") and ($cok | not) then "NOT_RUN" else $r.own end)}
+        | del(.own))) as $rows
+    | ($d.rows | map(.row)) as $ids
+    | ($good | map(select(.row as $k | $ids | index($k) | not)) | map({row, rep, verdict, line})) as $unrequested
+    | ( $rows | map(.verdict) ) as $vs
+    | { contract:"scoring-v5", campaign:$d.campaign,
+        verdict:(if ($noid | length) > 0 then "INCOMPLETE"
+                 elif ($vs | any(. == "ERROR")) then "ERROR"
+                 elif ($vs | any(. == "FAIL")) then "FAIL"
+                 elif ($vs | any(. == "INCOMPLETE")) then "INCOMPLETE"
+                 elif ($vs | any(. == "NOT_RUN")) then "NOT_RUN"
+                 else "PASS" end),
+        rows:$rows,
+        not_applicable:($rows | map(select(.verdict == "NOT_APPLICABLE") | .row)),
+        extras:($unrequested + ($rows | map(.extra_runs[]))),
+        malformed:($noid | map({line, why:"not a JSON object with a string row"})) }
+    end' 2>/dev/null) || { echo "score-rows: jq failed (fail closed)" >&2; exit 2; }
+printf '%s\n' "$out"
+v=$(printf '%s' "$out" | jq -r .verdict 2>/dev/null) || exit 2
+[ "$v" = PASS ] && exit 0
+exit 1
diff --git a/docs/campaigns/scoring/test-scoring-v5.sh b/docs/campaigns/scoring/test-scoring-v5.sh
new file mode 100755
index 00000000..651b20ab
--- /dev/null
+++ b/docs/campaigns/scoring/test-scoring-v5.sh
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+# Negative tests for scoring contract v5 (SCORING-v5.md). Shell + jq only.
+# Usage: test-scoring-v5.sh   Exit 0 only if every fixture gives its expected verdict.
+set -u
+HERE=$(cd "$(dirname "$0")" && pwd)
+S=$HERE/score-rows.sh T=$HERE/tests-v5
+pass=0 fail=0
+# expect NAME FIXTURE CAMPAIGN_VERDICT EXPECTED_ROW_VERDICTS(ctl,A,B) [EXTRA_JQ_TEST]
+expect() {
+  local name=$1 fx=$2 want=$3 rows=$4 out got grows
+  out=$("$S" "$T/decl.json" "$T/$fx.jsonl" 2>/dev/null); local rc=$?
+  got=$(jq -r .verdict <<<"$out"); grows=$(jq -r '[.rows[].verdict] | join(",")' <<<"$out")
+  local wantrc=1; [ "$want" = PASS ] && wantrc=0
+  if [ "$got" = "$want" ] && [ "$grows" = "$rows" ] && [ "$rc" = "$wantrc" ]; then pass=$((pass + 1)); echo "ok   $name: $got ($grows) exit $rc"
+  else fail=$((fail + 1)); echo "FAIL $name: want $want ($rows) exit $wantrc, got $got ($grows) exit $rc"; fi
+}
+expect "positive: every rep present, NA declared with reason"  pass              PASS       "PASS,PASS,NOT_APPLICABLE"
+expect "missing required run (A has 2 of 3)"                  missing-run       INCOMPLETE "PASS,INCOMPLETE,PASS"
+expect "duplicate run id (A rep 2 twice)"                     duplicate-run     ERROR      "PASS,ERROR,NOT_APPLICABLE"
+expect "failed repetition (A rep 2)"                          failed-run        FAIL       "PASS,FAIL,PASS"
+expect "incomplete run record (B rep 2 has no verdict)"       incomplete-run    INCOMPLETE "PASS,PASS,INCOMPLETE"
+expect "NOT_APPLICABLE on undeclared case (A)"                na-undeclared     FAIL       "PASS,FAIL,PASS"
+expect "control mismatch (ctl FAIL)"                          control-mismatch  FAIL       "FAIL,NOT_RUN,NOT_RUN"
+expect "NOT_APPLICABLE without a reason"                      na-no-reason      INCOMPLETE "PASS,PASS,INCOMPLETE"
+expect "NOT_APPLICABLE mixed with PASS never satisfies a rep" na-mixed          INCOMPLETE "PASS,PASS,INCOMPLETE"
+# extra runs are reported, not counted, and do not change the verdict
+out=$("$S" "$T/decl.json" "$T/extra-runs.jsonl" 2>/dev/null); rc=$?
+if [ "$rc" = 0 ] && [ "$(jq -r .verdict <<<"$out")" = PASS ] && [ "$(jq '.extras | length' <<<"$out")" = 2 ] \
+   && [ "$(jq '.rows[] | select(.row == "A") | .counted_reps' <<<"$out")" = 3 ]; then
+  pass=$((pass + 1)); echo "ok   extra unrequested runs reported (2), not counted"
+else fail=$((fail + 1)); echo "FAIL extra runs: rc $rc"; fi
+# external control F0 absent counts as false (fail closed)
+printf '%s\n' '{"contract":"scoring-v5","campaign":"x","rows":[{"row":"Q","role":"case","reps":1,"expected":"PASS","control":"F0","not_applicable":false}]}' >"$T/.f0.decl"
+printf '%s\n' '{"row":"Q","rep":1,"verdict":"PASS","outcome":"ok"}' >"$T/.f0.res"
+echo '{"F0":true}' >"$T/.f0.ext"
+a=$("$S" "$T/.f0.decl" "$T/.f0.res" 2>/dev/null | jq -r .verdict); b=$("$S" "$T/.f0.decl" "$T/.f0.res" "$T/.f0.ext" 2>/dev/null | jq -r .verdict)
+rm -f "$T"/.f0.decl "$T"/.f0.res "$T"/.f0.ext
+if [ "$a" = NOT_RUN ] && [ "$b" = PASS ]; then pass=$((pass + 1)); echo "ok   external control F0 absent NOT_RUN, present PASS"
+else fail=$((fail + 1)); echo "FAIL external F0: absent=$a present=$b"; fi
+# a bad declaration is an error, never a PASS
+echo '{"contract":"scoring-v5","campaign":"x","rows":[{"row":"Q","reps":0,"expected":"PASS"}]}' >"$T/.bad.decl"
+v=$("$S" "$T/.bad.decl" "$T/pass.jsonl" 2>/dev/null | jq -r .verdict); rm -f "$T/.bad.decl"
+if [ "$v" = ERROR ]; then pass=$((pass + 1)); echo "ok   bad declaration (reps 0) is ERROR"; else fail=$((fail + 1)); echo "FAIL bad declaration: $v"; fi
+# the real NEXT-PHASE-2 v4 results (receipt e401fffe) scored with the v4 declaration
+R=$HERE/../next-phase-2/e401fffe189506ecc0152f82bfe895c1374842746ae7cf4b5ac83462ccafe13c.json
+tmp=$(mktemp -d); jq -c '(.controls + .rows)[]' "$R" >"$tmp/res.jsonl"
+jq -c '{F0: .fixture.s3_committed}' "$R" >"$tmp/ext.json"
+out=$("$S" "$HERE/declarations/np2-v4.decl.json" "$tmp/res.jsonl" "$tmp/ext.json" 2>/dev/null); rc=$?
+if [ "$rc" = 0 ] && [ "$(jq -r .verdict <<<"$out")" = PASS ] && [ "$(jq -c .not_applicable <<<"$out")" = '["C6d"]' ]; then
+  pass=$((pass + 1)); echo "ok   v4 receipt e401fffe inputs: PASS (C6d NOT_APPLICABLE, 33 rows PASS)"
+else fail=$((fail + 1)); echo "FAIL v4 inputs: rc $rc $(jq -c '{verdict}' <<<"$out")"; fi
+# the same v4 runs with one repetition dropped must not PASS
+jq -c 'select(.row != "C7c" or .rep != 3)' "$tmp/res.jsonl" >"$tmp/short.jsonl"
+v=$("$S" "$HERE/declarations/np2-v4.decl.json" "$tmp/short.jsonl" "$tmp/ext.json" 2>/dev/null | jq -r .verdict); rm -rf "$tmp"
+if [ "$v" = INCOMPLETE ]; then pass=$((pass + 1)); echo "ok   v4 inputs minus C7c rep 3: INCOMPLETE (old scorer would PASS)"
+else fail=$((fail + 1)); echo "FAIL v4 short: $v"; fi
+echo "scoring-v5 tests: $pass passed, $fail failed"
+[ "$fail" = 0 ]
diff --git a/docs/campaigns/scoring/tests-v5/control-mismatch.jsonl b/docs/campaigns/scoring/tests-v5/control-mismatch.jsonl
new file mode 100644
index 00000000..a060e274
--- /dev/null
+++ b/docs/campaigns/scoring/tests-v5/control-mismatch.jsonl
@@ -0,0 +1,6 @@
+{"row":"ctl","rep":1,"verdict":"FAIL","outcome":"ok"}
+{"row":"A","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":2,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":3,"verdict":"PASS","outcome":"ok"}
+{"row":"B","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"B","rep":2,"verdict":"PASS","outcome":"ok"}
diff --git a/docs/campaigns/scoring/tests-v5/decl.json b/docs/campaigns/scoring/tests-v5/decl.json
new file mode 100644
index 00000000..d9a900ce
--- /dev/null
+++ b/docs/campaigns/scoring/tests-v5/decl.json
@@ -0,0 +1,4 @@
+{"contract":"scoring-v5","campaign":"scoring-selftest","rows":[
+ {"row":"ctl","role":"control","reps":1,"expected":"PASS","control":null,"not_applicable":false},
+ {"row":"A","role":"case","reps":3,"expected":"PASS","control":"ctl","not_applicable":false},
+ {"row":"B","role":"case","reps":2,"expected":"PASS","control":"ctl","not_applicable":true}]}
diff --git a/docs/campaigns/scoring/tests-v5/duplicate-run.jsonl b/docs/campaigns/scoring/tests-v5/duplicate-run.jsonl
new file mode 100644
index 00000000..a3e1c7df
--- /dev/null
+++ b/docs/campaigns/scoring/tests-v5/duplicate-run.jsonl
@@ -0,0 +1,7 @@
+{"row":"ctl","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":2,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":3,"verdict":"PASS","outcome":"ok"}
+{"row":"B","rep":1,"verdict":"NOT_APPLICABLE","outcome":"guard: nothing to spill"}
+{"row":"B","rep":2,"verdict":"NOT_APPLICABLE","outcome":"guard: nothing to spill"}
+{"row":"A","rep":2,"verdict":"PASS","outcome":"ok"}
diff --git a/docs/campaigns/scoring/tests-v5/extra-runs.jsonl b/docs/campaigns/scoring/tests-v5/extra-runs.jsonl
new file mode 100644
index 00000000..0b03ce87
--- /dev/null
+++ b/docs/campaigns/scoring/tests-v5/extra-runs.jsonl
@@ -0,0 +1,8 @@
+{"row":"ctl","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":2,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":3,"verdict":"PASS","outcome":"ok"}
+{"row":"B","rep":1,"verdict":"NOT_APPLICABLE","outcome":"guard: nothing to spill"}
+{"row":"B","rep":2,"verdict":"NOT_APPLICABLE","outcome":"guard: nothing to spill"}
+{"row":"A","rep":4,"verdict":"FAIL","outcome":"ok"}
+{"row":"Z","rep":1,"verdict":"FAIL","outcome":"ok"}
diff --git a/docs/campaigns/scoring/tests-v5/failed-run.jsonl b/docs/campaigns/scoring/tests-v5/failed-run.jsonl
new file mode 100644
index 00000000..be3f0191
--- /dev/null
+++ b/docs/campaigns/scoring/tests-v5/failed-run.jsonl
@@ -0,0 +1,6 @@
+{"row":"ctl","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":2,"verdict":"FAIL","outcome":"ok"}
+{"row":"A","rep":3,"verdict":"PASS","outcome":"ok"}
+{"row":"B","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"B","rep":2,"verdict":"PASS","outcome":"ok"}
diff --git a/docs/campaigns/scoring/tests-v5/incomplete-run.jsonl b/docs/campaigns/scoring/tests-v5/incomplete-run.jsonl
new file mode 100644
index 00000000..964dee22
--- /dev/null
+++ b/docs/campaigns/scoring/tests-v5/incomplete-run.jsonl
@@ -0,0 +1,6 @@
+{"row":"ctl","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":2,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":3,"verdict":"PASS","outcome":"ok"}
+{"row":"B","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"B","rep":2}
diff --git a/docs/campaigns/scoring/tests-v5/missing-run.jsonl b/docs/campaigns/scoring/tests-v5/missing-run.jsonl
new file mode 100644
index 00000000..2c1749f0
--- /dev/null
+++ b/docs/campaigns/scoring/tests-v5/missing-run.jsonl
@@ -0,0 +1,5 @@
+{"row":"ctl","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":2,"verdict":"PASS","outcome":"ok"}
+{"row":"B","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"B","rep":2,"verdict":"PASS","outcome":"ok"}
diff --git a/docs/campaigns/scoring/tests-v5/na-mixed.jsonl b/docs/campaigns/scoring/tests-v5/na-mixed.jsonl
new file mode 100644
index 00000000..684b4be8
--- /dev/null
+++ b/docs/campaigns/scoring/tests-v5/na-mixed.jsonl
@@ -0,0 +1,6 @@
+{"row":"ctl","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":2,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":3,"verdict":"PASS","outcome":"ok"}
+{"row":"B","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"B","rep":2,"verdict":"NOT_APPLICABLE","outcome":"guard"}
diff --git a/docs/campaigns/scoring/tests-v5/na-no-reason.jsonl b/docs/campaigns/scoring/tests-v5/na-no-reason.jsonl
new file mode 100644
index 00000000..dda830de
--- /dev/null
+++ b/docs/campaigns/scoring/tests-v5/na-no-reason.jsonl
@@ -0,0 +1,6 @@
+{"row":"ctl","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":2,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":3,"verdict":"PASS","outcome":"ok"}
+{"row":"B","rep":1,"verdict":"NOT_APPLICABLE","outcome":""}
+{"row":"B","rep":2,"verdict":"NOT_APPLICABLE"}
diff --git a/docs/campaigns/scoring/tests-v5/na-undeclared.jsonl b/docs/campaigns/scoring/tests-v5/na-undeclared.jsonl
new file mode 100644
index 00000000..32d2a5b2
--- /dev/null
+++ b/docs/campaigns/scoring/tests-v5/na-undeclared.jsonl
@@ -0,0 +1,6 @@
+{"row":"ctl","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":2,"verdict":"NOT_APPLICABLE","outcome":"claimed"}
+{"row":"A","rep":3,"verdict":"PASS","outcome":"ok"}
+{"row":"B","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"B","rep":2,"verdict":"PASS","outcome":"ok"}
diff --git a/docs/campaigns/scoring/tests-v5/pass.jsonl b/docs/campaigns/scoring/tests-v5/pass.jsonl
new file mode 100644
index 00000000..f424db68
--- /dev/null
+++ b/docs/campaigns/scoring/tests-v5/pass.jsonl
@@ -0,0 +1,6 @@
+{"row":"ctl","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":1,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":2,"verdict":"PASS","outcome":"ok"}
+{"row":"A","rep":3,"verdict":"PASS","outcome":"ok"}
+{"row":"B","rep":1,"verdict":"NOT_APPLICABLE","outcome":"guard: nothing to spill"}
+{"row":"B","rep":2,"verdict":"NOT_APPLICABLE","outcome":"guard: nothing to spill"}