Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mcp/blob/main/gates/maintenance-cases.sh # omega-mcp aien-dev/omega-mcp Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mcp / gates / maintenance-cases.sh` 56 lines ยท 3451 bytes Raw Blame History 1 #!/bin/sh 2 # gates/maintenance-cases.sh : the agent-maintenance gate with its negative control. Run in the repository 3 # root after build.sh (it uses build/agent-maintenance-mcp.om, build/agent-maintenance-mcp and build/omc). 4 # It writes a mutant of the built unit with the default-read-only write guard removed (am_canapply no 5 # longer asks for --allow-write and am_writemode no longer refuses without it), compiles it with the same 6 # build/omc, and runs gates/maintenance.py on the real binary with that mutant as the negative control: 7 # the gate must see the mutant really write a fixture file and its read-only check must reject it. 8 # An optional argument, a directory, adds the read-only pass over a real agent store (default none) and the 9 # size alarm: the server holds a file in fixed buffers of ammax bytes (const ammax in maintenance/state.om; 10 # Omega has no heap yet, so the buffers cannot be sized from the file). Each supported file in that 11 # directory (RULES.md, WATCHDOG.yml, config.yml, agents/*.md) over three quarters of ammax fails the gate 12 # with its size, so the limit is raised or removed before a real file meets it. 13 # Exit 0 only when every check prints PASS and none is NOT_RUN. 14 set -u 15 R=$(cd "$(dirname "$0")/.." && pwd) 16 U=$R/build/agent-maintenance-mcp.om 17 B=$R/build/agent-maintenance-mcp 18 O=$R/build/omc 19 [ -f "$U" ] && [ -x "$B" ] && [ -x "$O" ] || { echo "maintenance-cases: run sh build.sh first" >&2; exit 2; } 20 W=$(mktemp -d "${TMPDIR:-/tmp}/maintenance-cases.XXXXXX") || exit 2 21 trap 'rm -rf "$W"' EXIT 22 awk ' 23 /^fn am_canapply / { f = 1 } 24 /^fn am_writemode / { f = 2 } 25 f == 1 && $0 == "if or eq get amv amwrite 0 ne get amv amprot 0" { print "if ne get amv amprot 0"; f = 0; n++; next } 26 f == 2 && $0 == "if eq get amv amwrite 0" { print "if eq get amv amwrite 9"; f = 0; n++; next } 27 { print } 28 END { if (n != 2) exit 3 } 29 ' "$U" > "$W/mutant.om" || { echo "maintenance-cases: the guard lines were not found in $U (mutant not made)" >&2; exit 2; } 30 "$O" < "$W/mutant.om" > "$W/mutant" 2> "$W/omc.err" || { cat "$W/omc.err" >&2; echo "maintenance-cases: omc refused the mutant" >&2; exit 2; } 31 chmod 755 "$W/mutant" 32 cmp -s "$W/mutant" "$B" && { echo "maintenance-cases: the mutant is the same binary as the server" >&2; exit 2; } 33 real=${1:-} 34 alarm=0 35 if [ -n "$real" ]; then 36 max=$(sed -n 's/^const ammax ulong \([0-9][0-9]*\)$/\1/p' "$R/maintenance/state.om") 37 [ -n "$max" ] || { echo "maintenance-cases: const ammax not found in maintenance/state.om" >&2; exit 2; } 38 warn=$((max / 4 * 3)) 39 for f in "$real/RULES.md" "$real/WATCHDOG.yml" "$real/config.yml" "$real"/agents/*.md; do 40 [ -f "$f" ] || continue 41 n=$(wc -c < "$f") 42 if [ "$n" -gt "$warn" ]; then 43 echo "ALARM size $f is $n bytes; the maintenance server refuses files over $max (ammax, maintenance/state.om); alarm at $warn" 44 alarm=1 45 else 46 echo "size $f $n bytes (alarm at $warn, limit $max)" 47 fi 48 done 49 fi 50 set -- --binary "$B" --negative-control-binary "$W/mutant" ${real:+--real-root "$real"} 51 out=$(python3 "$R/gates/maintenance.py" "$@" 2>&1); rc=$? 52 echo "$out" 53 [ $rc -eq 0 ] || { echo "maintenance-cases: FAIL (gate exit $rc)"; exit 1; } 54 if echo "$out" | grep -q '"status": "NOT_RUN"'; then echo "maintenance-cases: FAIL (a check did not run)"; exit 1; fi 55 [ $alarm -eq 0 ] || { echo "maintenance-cases: FAIL (size alarm above)"; exit 1; } 56 echo "maintenance-cases: PASS checks=$(echo "$out" | grep -c '"status": "PASS"')"