interplane.Get Omega
Read in your language

omega-mcp

aien-dev/omega-mcp

Brought by drakestapleton

branch main Branches Tags History

omega-mcp / gates / qa-cases.sh

38 lines · 2255 bytes Raw Blame History
1#!/bin/sh
2# gates/qa-cases.sh : the agent Q&A gate with its negative controls. Run in the repository root after
3# build.sh (it uses build/agent-qa-mcp.om, build/agent-qa-mcp and build/omc). gates/qa.py must pass on
4# the real binary and FAIL on each of three mutants compiled from the built unit with build/omc:
5# consent qa_allowed says yes to any consent file that exists (the `allow AGENT` line is not needed)
6# privacy qa_share skips the privacy filter (keys, tokens and home paths would be stored)
7# hash qa_valid accepts an entry whose bytes do not hash to its name (damaged copies are used)
8# Prints PASS/FAIL per case and `qa-cases: pass=N fail=M`; exit 0 only when every case is as expected.
9set -u
10R=$(cd "$(dirname "$0")/.." && pwd)
11U=$R/build/agent-qa-mcp.om
12B=$R/build/agent-qa-mcp
13O=$R/build/omc
14[ -f "$U" ] && [ -x "$B" ] && [ -x "$O" ] || { echo "qa-cases: run sh build.sh first" >&2; exit 2; }
15W=$(mktemp -d "${TMPDIR:-/tmp}/qa-cases.XXXXXX") || exit 2
16trap 'rm -rf "$W"' EXIT
17pass=0 fail=0
18if python3 "$R/gates/qa.py" --binary "$B"; then echo "PASS real binary"; pass=$((pass + 1)); else echo "FAIL real binary"; fail=$((fail + 1)); fi
19mutant() { # mutant NAME FUNCTION OLD-LINE NEW-LINE
20 awk -v f="fn $2 " -v o="$3" -v n="$4" '
21 index($0, f) == 1 { in_f = 1 }
22 in_f && $0 == o && !done { print n; done = 1; next }
23 { print }
24 END { if (!done) exit 3 }' "$U" > "$W/$1.om" || { echo "FAIL $1: line not found in $2"; fail=$((fail + 1)); return; }
25 "$O" < "$W/$1.om" > "$W/$1" 2> "$W/$1.err" || { echo "FAIL $1: omc refused the mutant: $(cat "$W/$1.err")"; fail=$((fail + 1)); return; }
26 chmod 755 "$W/$1"
27 if cmp -s "$W/$1" "$B"; then echo "FAIL $1: mutant equals the server"; fail=$((fail + 1)); return; fi
28 if python3 "$R/gates/qa.py" --binary "$W/$1" > "$W/$1.out" 2>&1; then
29 echo "FAIL $1: the oracle accepted the mutant"; fail=$((fail + 1))
30 else
31 echo "PASS $1 mutant caught ($(grep -c '"PASS"' "$W/$1.out") checks passed before the failure)"; pass=$((pass + 1))
32 fi
33}
34mutant consent qa_allowed "ret false" "ret true"
35mutant privacy qa_share "r = qa_private s" "r = ulong 0"
36mutant hash qa_valid "if not qa_idis name" "if eq len name 0"
37echo "qa-cases: pass=$pass fail=$fail"
38[ $fail -eq 0 ]