qualia-framework 7.2.0 → 7.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,66 @@
1
+ #!/bin/bash
2
+ # r6-golden.test.sh — R6 golden verifier fixture.
3
+ #
4
+ # Proves the deterministic verifier (bin/verify-panel.js) CANNOT default-pass.
5
+ # The fixture tests/fixtures/r6-golden-fail-panel.json is a SEEDED STUB
6
+ # engineered so the only correct verdict is FAIL: it carries a surviving
7
+ # CRITICAL (voted real 3-0) plus an unvoted HIGH (INSUFFICIENT-EVIDENCE style —
8
+ # unverified is not disproven, so it survives the skeptic round).
9
+ #
10
+ # If verify-panel ever regresses to scoring 3/PASS on input it cannot fully
11
+ # clear, this turns red. It is the framework gating its OWN verifier the way it
12
+ # gates user projects (the missing R6 piece from the v7 audit, F3).
13
+ #
14
+ # CONSTRAINT: this test ONLY adds the fixture wiring. It does not touch the
15
+ # anti-default-3 logic, the gates, or Codex parity — it observes them.
16
+ #
17
+ # Run: bash tests/r6-golden.test.sh
18
+
19
+ PASS=0
20
+ FAIL=0
21
+ DIR="$(cd "$(dirname "$0")" && pwd)"
22
+ BIN_DIR="$(cd "$DIR/../bin" && pwd)"
23
+ NODE="${NODE:-node}"
24
+ VP="$BIN_DIR/verify-panel.js"
25
+ FIXTURE="$DIR/fixtures/r6-golden-fail-panel.json"
26
+
27
+ assert_exit() {
28
+ local name="$1" expected="$2" actual="$3"
29
+ if [ "$expected" = "$actual" ]; then echo " ✓ $name"; PASS=$((PASS+1));
30
+ else echo " ✗ $name (expected exit $expected, got $actual)"; FAIL=$((FAIL+1)); fi
31
+ }
32
+ assert_contains() {
33
+ local name="$1" hay="$2" needle="$3"
34
+ if echo "$hay" | grep -qF "$needle"; then echo " ✓ $name"; PASS=$((PASS+1));
35
+ else echo " ✗ $name (missing '$needle')"; FAIL=$((FAIL+1)); fi
36
+ }
37
+ assert_absent() {
38
+ local name="$1" hay="$2" needle="$3"
39
+ if echo "$hay" | grep -qF "$needle"; then echo " ✗ $name (found forbidden '$needle')"; FAIL=$((FAIL+1));
40
+ else echo " ✓ $name"; PASS=$((PASS+1)); fi
41
+ }
42
+
43
+ echo "r6-golden.test.sh — verifier cannot default-pass"
44
+ echo ""
45
+
46
+ # Fixture must exist (precondition).
47
+ [ -f "$FIXTURE" ] && { echo " ✓ golden fixture present"; PASS=$((PASS+1)); } \
48
+ || { echo " ✗ golden fixture missing: $FIXTURE"; FAIL=$((FAIL+1)); }
49
+
50
+ # The golden stub MUST FAIL (exit 1). This is the anti-default-pass proof.
51
+ $NODE "$VP" "$FIXTURE" >/dev/null 2>&1
52
+ assert_exit "golden stub → FAIL (exit 1), not a default PASS" 1 $?
53
+
54
+ OUT=$($NODE "$VP" "$FIXTURE" --json 2>&1)
55
+ assert_contains "verdict is FAIL" "$OUT" '"verdict": "FAIL"'
56
+ assert_absent "verdict is NOT PASS" "$OUT" '"verdict": "PASS"'
57
+ # ok must be false — the contract kernel treats this as a phase fail.
58
+ assert_contains "ok:false (phase does not ship)" "$OUT" '"ok": false'
59
+ # The surviving CRITICAL is the load-bearing reason it cannot pass.
60
+ assert_contains "surviving CRITICAL preserved" "$OUT" '"severity": "CRITICAL"'
61
+ # The unvoted HIGH survives (unverified != disproven).
62
+ assert_contains "unvoted HIGH survives the skeptic round" "$OUT" '"severity": "HIGH"'
63
+
64
+ echo ""
65
+ echo "=== Results: $PASS passed, $FAIL failed ==="
66
+ [ "$FAIL" -eq 0 ] && exit 0 || exit 1
@@ -184,6 +184,39 @@ for pattern in "${forbidden_surface_patterns[@]}"; do
184
184
  fi
185
185
  done
186
186
 
187
+ # ── Count-drift guard ─────────────────────────────────────────────────────────
188
+ # The orientation docs (README.md / guide.md) hardcode skill/hook/rule counts.
189
+ # These rot every time a skill/hook/rule is added. Assert each stated count
190
+ # matches the live directory listing so the numbers can't silently drift again.
191
+ # skills/ = directory entries
192
+ # hooks/ = *.js files
193
+ # rules/ = *.md files
194
+ SKILL_COUNT=$(find "$FRAMEWORK_ROOT/skills" -mindepth 1 -maxdepth 1 -type d | wc -l | tr -d ' ')
195
+ HOOK_COUNT=$(find "$FRAMEWORK_ROOT/hooks" -maxdepth 1 -name '*.js' | wc -l | tr -d ' ')
196
+ RULE_COUNT=$(find "$FRAMEWORK_ROOT/rules" -maxdepth 1 -name '*.md' | wc -l | tr -d ' ')
197
+
198
+ # assert_count <label> <expected-actual> <file> <regex-with-NUM-placeholder>
199
+ # Fails if the file contains a "<N> <label>" claim where N != actual.
200
+ assert_count() {
201
+ local label="$1" actual="$2" file="$3" pattern="$4"
202
+ local bad
203
+ # Find every "<digits> <label>" mention; flag any whose number != actual.
204
+ # grep -oE (no -n) yields just the matched "<N> label" substrings; pull the
205
+ # leading integer from each and compare. (No line-number prefix to confuse it.)
206
+ bad=$(grep -oE "$pattern" "$file" 2>/dev/null | grep -oE '^[0-9]+' | grep -vx "$actual" || true)
207
+ if [ -n "$bad" ]; then
208
+ fail_case "count drift: $label in $(basename "$file")" \
209
+ "stated $(echo "$bad" | paste -sd, -) but actual is $actual — regenerate from the directory listing"
210
+ else
211
+ pass "$(basename "$file") $label count = $actual (matches $label/)"
212
+ fi
213
+ }
214
+
215
+ assert_count "skills" "$SKILL_COUNT" "$FRAMEWORK_ROOT/README.md" '[0-9]+ (installed )?skills'
216
+ assert_count "hooks" "$HOOK_COUNT" "$FRAMEWORK_ROOT/README.md" '[0-9]+ hooks'
217
+ assert_count "rules" "$RULE_COUNT" "$FRAMEWORK_ROOT/README.md" '[0-9]+ (installed )?rules'
218
+ assert_count "skills" "$SKILL_COUNT" "$FRAMEWORK_ROOT/guide.md" '[0-9]+ active skills'
219
+
187
220
  echo ""
188
221
  echo "Results: $PASS passed, $FAIL failed"
189
222
 
package/tests/run-all.sh CHANGED
@@ -35,6 +35,8 @@ SUITES=(
35
35
  "repo-map"
36
36
  "design-tokens"
37
37
  "batch-plan"
38
+ "r6-golden"
39
+ "memory-loop"
38
40
  "journey-spine"
39
41
  )
40
42