#!/usr/bin/env bash # test-sc1-dogfood-log.sh — Verifies SC1 (operator-attested dogfood log) in REMEMBER.md # # Usage: # bash tests/test-sc1-dogfood-log.sh # missing block = WARN, exit 0 # bash tests/test-sc1-dogfood-log.sh --strict # missing block = FAIL, exit 1 # # Expects in REMEMBER.md (plugin root, gitignored): # - A fenced section with heading `## Dogfood log — v0.1 slides run` # - Five mechanically-checkable fields inside the section: # artifact_type: # refine_rounds: # final_prompt: # ``` # # ``` # shipped: yes (or `shipped: equivalent`) # comparison_to_unaided: # # REMEMBER.md is gitignored — this evidence is local-only. The script # validates format only; the outcome judgement is operator-attested. set -euo pipefail LC_ALL=en_US.UTF-8 RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' PLUGIN_ROOT="$(cd "$(dirname "$0")/.." && pwd)" PASS=0 FAIL=0 WARN=0 pass() { printf "${GREEN} ✓ %s${NC}\n" "$1"; PASS=$((PASS + 1)); } fail() { printf "${RED} ✗ %s${NC}\n" "$1"; FAIL=$((FAIL + 1)); } warn() { printf "${YELLOW} ⚠ %s${NC}\n" "$1"; WARN=$((WARN + 1)); } STRICT=false for arg in "$@"; do case "$arg" in --strict) STRICT=true ;; esac done echo "=== test-sc1-dogfood-log ===" echo "Plugin root: $PLUGIN_ROOT" echo "Strict mode: $STRICT" echo "" REMEMBER_FILE="$PLUGIN_ROOT/REMEMBER.md" COVERAGE_FILE="$PLUGIN_ROOT/.coverage.md" # ------------------------------------------------------- # Locate REMEMBER.md # ------------------------------------------------------- if [ ! -f "$REMEMBER_FILE" ]; then if $STRICT; then fail "REMEMBER.md missing (strict mode — required)" echo "" echo "=== Summary ===" printf "Pass: %d Fail: %d Warn: %d\n" "$PASS" "$FAIL" "$WARN" exit 1 else warn "REMEMBER.md missing (advisory until operator dogfood step)" echo "" echo "=== Summary ===" printf "Pass: %d Fail: %d Warn: %d\n" "$PASS" "$FAIL" "$WARN" exit 0 fi fi # ------------------------------------------------------- # Extract fenced block between dogfood heading and next H2 (or EOF) # ------------------------------------------------------- BLOCK="$(awk ' /^## Dogfood log — v0\.1 slides run$/ { capture = 1; next } capture && /^## / { exit } capture { print } ' "$REMEMBER_FILE")" if [ -z "$BLOCK" ]; then if $STRICT; then fail "REMEMBER.md missing dogfood block '## Dogfood log — v0.1 slides run' (strict mode — required)" echo "" echo "=== Summary ===" printf "Pass: %d Fail: %d Warn: %d\n" "$PASS" "$FAIL" "$WARN" exit 1 else warn "REMEMBER.md missing dogfood block (advisory until operator dogfood step)" echo "" echo "=== Summary ===" printf "Pass: %d Fail: %d Warn: %d\n" "$PASS" "$FAIL" "$WARN" exit 0 fi fi pass "found '## Dogfood log — v0.1 slides run' block" # ------------------------------------------------------- # Field 1: artifact_type — must match a preset name from .coverage.md # ------------------------------------------------------- ARTIFACT_TYPE="$(printf '%s\n' "$BLOCK" | awk -F': *' '/^artifact_type:/ { print $2; exit }' | tr -d '[:space:]')" if [ -z "$ARTIFACT_TYPE" ]; then fail "artifact_type: field missing or empty" else # extract preset names from .coverage.md table column 1 if [ -f "$COVERAGE_FILE" ]; then PRESETS="$(awk -F'|' ' /^\| [a-z]/ { gsub(/^ +| +$/, "", $2); print $2 } ' "$COVERAGE_FILE")" FOUND=false while IFS= read -r preset; do [ -z "$preset" ] && continue if [ "$preset" = "$ARTIFACT_TYPE" ]; then FOUND=true break fi done < <(printf '%s\n' "$PRESETS") if $FOUND; then pass "artifact_type='$ARTIFACT_TYPE' matches a preset in .coverage.md" else fail "artifact_type='$ARTIFACT_TYPE' does not match any preset in .coverage.md" fi else fail ".coverage.md missing — cannot validate artifact_type" fi fi # ------------------------------------------------------- # Field 2: refine_rounds — integer # ------------------------------------------------------- REFINE_ROUNDS_LINE="$(printf '%s\n' "$BLOCK" | grep -E '^refine_rounds:[[:space:]]*[0-9]+[[:space:]]*$' || true)" if [ -n "$REFINE_ROUNDS_LINE" ]; then pass "refine_rounds: matches integer regex" else fail "refine_rounds: missing or not an integer" fi # ------------------------------------------------------- # Field 3: final_prompt: followed by non-empty fenced code block # ------------------------------------------------------- HAS_FINAL_PROMPT="$(printf '%s\n' "$BLOCK" | grep -c '^final_prompt:' || true)" if [ "$HAS_FINAL_PROMPT" -ge 1 ]; then # check that a fenced code block (```) appears after final_prompt: FENCE_AFTER="$(awk ' /^final_prompt:/ { found = 1; next } found && /^```/ { fence_open = !fence_open; if (fence_open) { in_fence = 1 } else { exit } } found && in_fence && fence_open && /./ { content_lines++ } END { print content_lines + 0 } ' <<<"$BLOCK")" if [ -z "$FENCE_AFTER" ]; then FENCE_AFTER=0; fi if [ "$FENCE_AFTER" -ge 1 ]; then pass "final_prompt: followed by non-empty fenced code block ($FENCE_AFTER content line(s))" else fail "final_prompt: not followed by a non-empty fenced code block" fi else fail "final_prompt: field missing" fi # ------------------------------------------------------- # Field 4: shipped — yes or equivalent # ------------------------------------------------------- SHIPPED_LINE="$(printf '%s\n' "$BLOCK" | grep -E '^shipped:[[:space:]]*(yes|equivalent)[[:space:]]*$' || true)" if [ -n "$SHIPPED_LINE" ]; then pass "shipped: matches 'yes' or 'equivalent'" else fail "shipped: missing or not 'yes'/'equivalent'" fi # ------------------------------------------------------- # Field 5: comparison_to_unaided — non-empty sentence >=10 chars ending with . # ------------------------------------------------------- COMP_LINE="$(printf '%s\n' "$BLOCK" | awk -F': *' '/^comparison_to_unaided:/ { for (i=2;i<=NF;i++) printf "%s%s", $i, (i=10)" elif [ "${COMP_TRIMMED: -1}" != "." ]; then fail "comparison_to_unaided: does not end with '.'" else pass "comparison_to_unaided: non-empty, $COMP_LEN chars, ends with '.'" fi # ------------------------------------------------------- # Summary # ------------------------------------------------------- echo "" echo "=== Summary ===" printf "Pass: %d Fail: %d Warn: %d\n" "$PASS" "$FAIL" "$WARN" if [ "$FAIL" -gt 0 ]; then exit 1 fi exit 0