✓
Passing This code compiles and runs correctly.
Code
// The git-gate refuses: a "git-gate"-tagged invariant whose check exits
// non-zero makes `invariants gate` exit non-zero, name the violated
// invariant, and print the check's output as evidence. An invariant NOT
// tagged "git-gate" stays out of the gate even when its check would fail.
//
// fixture.zig carries three `while (` sites against a declared ceiling of
// two — the ratchet shape the emit-for-not-while citizen uses.
//
// Run: koruc input.kz invariants gate
~import std/invariants
~std/invariants:inferred {
"name": "counted-loops-are-for",
"tags": ["git-gate"],
"rule": "A counted loop is a for; a while is legitimate only where the trip count is not known up front.",
"check": "c=$(grep -c 'while (' fixture.zig); echo while sites: $c of 2; [ $c -le 2 ]"
}
~std/invariants:inferred {
"name": "not-gated",
"rule": "This invariant is declared but not tagged for the gate.",
"check": "false"
}
~tor main {}
~proc main|zig {
}
~main()
Flows
flow ~inferred click a branch to expand · @labels scroll to their anchor
inferred (source: "name": "counted-loops-are-for",
"tags": ["git-gate"],
"rule": "A counted loop is a for; a while is legitimate only where the trip count is not known up front.",
"check": "c=$(grep -c 'while (' fixture.zig); echo while sites: $c of 2; [ $c -le 2 ]")
flow ~inferred click a branch to expand · @labels scroll to their anchor
inferred (source: "name": "not-gated",
"rule": "This invariant is declared but not tagged for the gate.",
"check": "false")
flow ~main click a branch to expand · @labels scroll to their anchor
main
Test Configuration
Post-validation Script:
#!/bin/bash
# A violated git-gate invariant is a non-zero exit that names the invariant
# and shows the check's evidence. Untagged invariants do not gate.
set -e
OUT=$(koruc "$KORU_INPUT" invariants gate 2>&1) && RC=0 || RC=$?
[ "$RC" -ne 0 ] \
|| { echo "FAIL: gate exited 0 with a violated git-gate invariant"; echo "$OUT"; exit 1; }
echo "$OUT" | grep -q "counted-loops-are-for" \
|| { echo "FAIL: violated invariant not named"; echo "$OUT"; exit 1; }
echo "$OUT" | grep -q "VIOLATED" \
|| { echo "FAIL: violation verdict not reported"; echo "$OUT"; exit 1; }
echo "$OUT" | grep -q "while sites: 3 of 2" \
|| { echo "FAIL: check evidence not shown"; echo "$OUT"; exit 1; }
echo "$OUT" | grep -q "1 violated" \
|| { echo "FAIL: untagged failing check leaked into the gate tally"; echo "$OUT"; exit 1; }
echo "=== Test passed: gate refused and named the violation ==="