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

branch main Branches Tags History

aien-sovereign-core-mv / docs / campaigns / scoring / test-scoring-v5.sh

77 lines · 5656 bytes Raw Blame History
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.
19set -u
20HERE=$(cd "$(dirname "$0")" && pwd)
21S=$HERE/score-rows.sh T=$HERE/tests-v5
22pass=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.
25W=$(mktemp -d) || exit 1
26trap 'rm -rf "$W"' EXIT
27# expect NAME FIXTURE CAMPAIGN_VERDICT EXPECTED_ROW_VERDICTS(ctl,A,B) [EXTRA_JQ_TEST]
28expect() {
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}
36expect "positive: every rep present, NA declared with reason" pass PASS "PASS,PASS,NOT_APPLICABLE"
37expect "missing required run (A has 2 of 3)" missing-run INCOMPLETE "PASS,INCOMPLETE,PASS"
38expect "duplicate run id (A rep 2 twice)" duplicate-run ERROR "PASS,ERROR,NOT_APPLICABLE"
39expect "failed repetition (A rep 2)" failed-run FAIL "PASS,FAIL,PASS"
40expect "incomplete run record (B rep 2 has no verdict)" incomplete-run INCOMPLETE "PASS,PASS,INCOMPLETE"
41expect "NOT_APPLICABLE on undeclared case (A)" na-undeclared FAIL "PASS,FAIL,PASS"
42expect "control mismatch (ctl FAIL)" control-mismatch FAIL "FAIL,NOT_RUN,NOT_RUN"
43expect "NOT_APPLICABLE without a reason" na-no-reason INCOMPLETE "PASS,PASS,INCOMPLETE"
44expect "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
46out=$("$S" "$T/decl.json" "$T/extra-runs.jsonl" 2>/dev/null); rc=$?
47if [ "$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"
50else fail=$((fail + 1)); echo "FAIL extra runs: rc $rc"; fi
51# external control F0 absent counts as false (fail closed)
52printf '%s\n' '{"contract":"scoring-v5","campaign":"x","rows":[{"row":"Q","role":"case","reps":1,"expected":"PASS","control":"F0","not_applicable":false}]}' >"$W/.f0.decl"
53printf '%s\n' '{"row":"Q","rep":1,"verdict":"PASS","outcome":"ok"}' >"$W/.f0.res"
54echo '{"F0":true}' >"$W/.f0.ext"
55a=$("$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)
56rm -f "$W"/.f0.decl "$W"/.f0.res "$W"/.f0.ext
57if [ "$a" = NOT_RUN ] && [ "$b" = PASS ]; then pass=$((pass + 1)); echo "ok external control F0 absent NOT_RUN, present PASS"
58else fail=$((fail + 1)); echo "FAIL external F0: absent=$a present=$b"; fi
59# a bad declaration is an error, never a PASS
60echo '{"contract":"scoring-v5","campaign":"x","rows":[{"row":"Q","reps":0,"expected":"PASS"}]}' >"$W/.bad.decl"
61v=$("$S" "$W/.bad.decl" "$T/pass.jsonl" 2>/dev/null | jq -r .verdict); rm -f "$W/.bad.decl"
62if [ "$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
64R=$HERE/../next-phase-2/e401fffe189506ecc0152f82bfe895c1374842746ae7cf4b5ac83462ccafe13c.json
65tmp=$(mktemp -d); jq -c '(.controls + .rows)[]' "$R" >"$tmp/res.jsonl"
66jq -c '{F0: .fixture.s3_committed}' "$R" >"$tmp/ext.json"
67out=$("$S" "$HERE/declarations/np2-v4.decl.json" "$tmp/res.jsonl" "$tmp/ext.json" 2>/dev/null); rc=$?
68if [ "$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)"
70else 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
72jq -c 'select(.row != "C7c" or .rep != 3)' "$tmp/res.jsonl" >"$tmp/short.jsonl"
73v=$("$S" "$HERE/declarations/np2-v4.decl.json" "$tmp/short.jsonl" "$tmp/ext.json" 2>/dev/null | jq -r .verdict); rm -rf "$tmp"
74if [ "$v" = INCOMPLETE ]; then pass=$((pass + 1)); echo "ok v4 inputs minus C7c rep 3: INCOMPLETE (old scorer would PASS)"
75else fail=$((fail + 1)); echo "FAIL v4 short: $v"; fi
76echo "scoring-v5 tests: $pass passed, $fail failed"
77[ "$fail" = 0 ]