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
aien-sovereign-core-mv / docs / campaigns / scoring / test-scoring-v5.sh
| 1 | #!/usr/bin/env bash |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # Negative tests for scoring contract v5 (SCORING-v5.md). Shell + jq only. |
| 18 | # Usage: test-scoring-v5.sh Exit 0 only if every fixture gives its expected verdict. |
| 19 | set -u |
| 20 | HERE=$(cd "$(dirname "$0")" && pwd) |
| 21 | S=$HERE/score-rows.sh T=$HERE/tests-v5 |
| 22 | pass=0 fail=0 |
| 23 | # Scratch files go to a private temp dir, never into the tree: aien-test runs gates in parallel in one |
| 24 | # checkout, and a file here, even for a moment, fails another gate's clean-tree check. |
| 25 | W=$(mktemp -d) || exit 1 |
| 26 | trap 'rm -rf "$W"' EXIT |
| 27 | # expect NAME FIXTURE CAMPAIGN_VERDICT EXPECTED_ROW_VERDICTS(ctl,A,B) [EXTRA_JQ_TEST] |
| 28 | expect() { |
| 29 | local name=$1 fx=$2 want=$3 rows=$4 out got grows |
| 30 | out=$("$S" "$T/decl.json" "$T/$fx.jsonl" 2>/dev/null); local rc=$? |
| 31 | got=$(jq -r .verdict <<<"$out"); grows=$(jq -r '[.rows[].verdict] | join(",")' <<<"$out") |
| 32 | local wantrc=1; [ "$want" = PASS ] && wantrc=0 |
| 33 | if [ "$got" = "$want" ] && [ "$grows" = "$rows" ] && [ "$rc" = "$wantrc" ]; then pass=$((pass + 1)); echo "ok $name: $got ($grows) exit $rc" |
| 34 | else fail=$((fail + 1)); echo "FAIL $name: want $want ($rows) exit $wantrc, got $got ($grows) exit $rc"; fi |
| 35 | } |
| 36 | expect "positive: every rep present, NA declared with reason" pass PASS "PASS,PASS,NOT_APPLICABLE" |
| 37 | expect "missing required run (A has 2 of 3)" missing-run INCOMPLETE "PASS,INCOMPLETE,PASS" |
| 38 | expect "duplicate run id (A rep 2 twice)" duplicate-run ERROR "PASS,ERROR,NOT_APPLICABLE" |
| 39 | expect "failed repetition (A rep 2)" failed-run FAIL "PASS,FAIL,PASS" |
| 40 | expect "incomplete run record (B rep 2 has no verdict)" incomplete-run INCOMPLETE "PASS,PASS,INCOMPLETE" |
| 41 | expect "NOT_APPLICABLE on undeclared case (A)" na-undeclared FAIL "PASS,FAIL,PASS" |
| 42 | expect "control mismatch (ctl FAIL)" control-mismatch FAIL "FAIL,NOT_RUN,NOT_RUN" |
| 43 | expect "NOT_APPLICABLE without a reason" na-no-reason INCOMPLETE "PASS,PASS,INCOMPLETE" |
| 44 | expect "NOT_APPLICABLE mixed with PASS never satisfies a rep" na-mixed INCOMPLETE "PASS,PASS,INCOMPLETE" |
| 45 | # extra runs are reported, not counted, and do not change the verdict |
| 46 | out=$("$S" "$T/decl.json" "$T/extra-runs.jsonl" 2>/dev/null); rc=$? |
| 47 | if [ "$rc" = 0 ] && [ "$(jq -r .verdict <<<"$out")" = PASS ] && [ "$(jq '.extras | length' <<<"$out")" = 2 ] \ |
| 48 | && [ "$(jq '.rows[] | select(.row == "A") | .counted_reps' <<<"$out")" = 3 ]; then |
| 49 | pass=$((pass + 1)); echo "ok extra unrequested runs reported (2), not counted" |
| 50 | else fail=$((fail + 1)); echo "FAIL extra runs: rc $rc"; fi |
| 51 | # external control F0 absent counts as false (fail closed) |
| 52 | printf '%s\n' '{"contract":"scoring-v5","campaign":"x","rows":[{"row":"Q","role":"case","reps":1,"expected":"PASS","control":"F0","not_applicable":false}]}' >"$W/.f0.decl" |
| 53 | printf '%s\n' '{"row":"Q","rep":1,"verdict":"PASS","outcome":"ok"}' >"$W/.f0.res" |
| 54 | echo '{"F0":true}' >"$W/.f0.ext" |
| 55 | a=$("$S" "$W/.f0.decl" "$W/.f0.res" 2>/dev/null | jq -r .verdict); b=$("$S" "$W/.f0.decl" "$W/.f0.res" "$W/.f0.ext" 2>/dev/null | jq -r .verdict) |
| 56 | rm -f "$W"/.f0.decl "$W"/.f0.res "$W"/.f0.ext |
| 57 | if [ "$a" = NOT_RUN ] && [ "$b" = PASS ]; then pass=$((pass + 1)); echo "ok external control F0 absent NOT_RUN, present PASS" |
| 58 | else fail=$((fail + 1)); echo "FAIL external F0: absent=$a present=$b"; fi |
| 59 | # a bad declaration is an error, never a PASS |
| 60 | echo '{"contract":"scoring-v5","campaign":"x","rows":[{"row":"Q","reps":0,"expected":"PASS"}]}' >"$W/.bad.decl" |
| 61 | v=$("$S" "$W/.bad.decl" "$T/pass.jsonl" 2>/dev/null | jq -r .verdict); rm -f "$W/.bad.decl" |
| 62 | 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 |
| 63 | # the real NEXT-PHASE-2 v4 results (receipt e401fffe) scored with the v4 declaration |
| 64 | R=$HERE/../next-phase-2/e401fffe189506ecc0152f82bfe895c1374842746ae7cf4b5ac83462ccafe13c.json |
| 65 | tmp=$(mktemp -d); jq -c '(.controls + .rows)[]' "$R" >"$tmp/res.jsonl" |
| 66 | jq -c '{F0: .fixture.s3_committed}' "$R" >"$tmp/ext.json" |
| 67 | out=$("$S" "$HERE/declarations/np2-v4.decl.json" "$tmp/res.jsonl" "$tmp/ext.json" 2>/dev/null); rc=$? |
| 68 | if [ "$rc" = 0 ] && [ "$(jq -r .verdict <<<"$out")" = PASS ] && [ "$(jq -c .not_applicable <<<"$out")" = '["C6d"]' ]; then |
| 69 | pass=$((pass + 1)); echo "ok v4 receipt e401fffe inputs: PASS (C6d NOT_APPLICABLE, 33 rows PASS)" |
| 70 | else fail=$((fail + 1)); echo "FAIL v4 inputs: rc $rc $(jq -c '{verdict}' <<<"$out")"; fi |
| 71 | # the same v4 runs with one repetition dropped must not PASS |
| 72 | jq -c 'select(.row != "C7c" or .rep != 3)' "$tmp/res.jsonl" >"$tmp/short.jsonl" |
| 73 | v=$("$S" "$HERE/declarations/np2-v4.decl.json" "$tmp/short.jsonl" "$tmp/ext.json" 2>/dev/null | jq -r .verdict); rm -rf "$tmp" |
| 74 | if [ "$v" = INCOMPLETE ]; then pass=$((pass + 1)); echo "ok v4 inputs minus C7c rep 3: INCOMPLETE (old scorer would PASS)" |
| 75 | else fail=$((fail + 1)); echo "FAIL v4 short: $v"; fi |
| 76 | echo "scoring-v5 tests: $pass passed, $fail failed" |
| 77 | [ "$fail" = 0 ] |