writeonce/scripts/skill-catalog-accept.sh
shoney.arickathil 5941a092f7 feat(query-corpus): iteration 9g corpus #1 — skillhost needs no new query grammar
- resolved 9g's forks EMPIRICALLY against the running compiler:
  - count(<query>) and len(<query>) already work (fork 2 collapses to
    zero code)
  - skillhost's correlated NOT EXISTS is a backlink emptiness in
    writeonce (`where len(x.children) == 0`), using only 9b machinery
    (fork 1) — verified on a self-referential ?ref/backlink table
  => corpus #1 forces NO new grammar; per the method ("add only what a
     corpus uses"), exists/not-exists was NOT built
- docs/examples/skill-catalog: mirrors skillhost's `skills` table
  (name @unique, description/location/root, parent ?ref Skill, children
  backlink) and translates all five of its SQL statements 1:1
  (insert+dup-trap, get-by-name, list, roots via backlink-emptiness,
  count); scripts/skill-catalog-accept.sh 7/0, WAL-durable, dup trap
  persists across restart
- fixture run/db-query-corpus (count(query) + backlink NOT EXISTS);
  just skill-catalog module; target/ gitignored
- general exists/not-exists left unbuilt and recorded as "enters when a
  corpus forces a non-relation correlation"
- gates: oop-e2e 80/0, woc-test 566/0, skill-catalog 7/0; story + board
  record the finding

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 4c82461634d45f11eca1a252702031c03d999c7f)
2026-09-15 01:15:30 +02:00

34 lines
1.9 KiB
Bash
Executable file

#!/usr/bin/env bash
# scripts/skill-catalog-accept.sh — iteration 9g acceptance: every skillhost
# catalog operation, translated to writeonce, produces the expected result on
# the 9b query surface (no new grammar). WAL-durable; a second seed proves the
# @unique trap persists across a process restart.
set -uo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
WOC="$ROOT/compiler/_build/default/bin/woc"
WOVM="$ROOT/runtime/wovm"
pass=0; fail=0
ok() { echo "ok $1"; pass=$((pass+1)); }
bad() { echo "FAIL $1 -- $2"; fail=$((fail+1)); }
[[ -x "$WOC" && -x "$WOVM" ]] || { echo "build woc+wovm first" >&2; exit 1; }
WORK="$(mktemp -d "${TMPDIR:-/tmp}/skillcat.XXXXXX")"; DATA="$WORK/d"; mkdir -p "$DATA"
IMG="$WORK/sc.wob"
trap '[[ -n "${SKILLCAT_KEEP:-}" ]] && echo "kept $WORK" || rm -rf "$WORK"' EXIT
if "$WOC" --emit "$ROOT/docs/examples/skill-catalog" -o "$IMG" >"$WORK/c.out" 2>&1; then
ok "compile ($(stat -c%s "$IMG") bytes)"
else bad "compile" "$(head -1 "$WORK/c.out")"; echo; echo "skill-catalog-accept: $pass/$((pass+fail))"; exit 1; fi
run() { WO_DATA="$DATA" "$WOVM" "$IMG" "$@"; }
run seed | grep -q "SEEDED 4 skills" && ok "seed (insert)" || bad "seed" "no SEEDED"
[[ "$(run count)" == "4" ]] && ok "count (COUNT(*) -> count(query))" || bad "count" "not 4"
[[ "$(run list | head -1)" == docker* ]] && ok "list (ORDER BY name)" || bad "list" "not name-ordered"
if [[ "$(run roots | tr '\n' ',')" == "docker,git-commit,git-rebase," ]]; then
ok "roots (NOT EXISTS -> backlink emptiness)"
else bad "roots" "got: $(run roots | tr '\n' ',')"; fi
run get git | grep -q "^git version control" && ok "get by name (WHERE name = ?)" || bad "get" "wrong row"
out="$(run seed 2>&1)"; rc=$?
[[ "$out" == *SEED-DUP* && $rc -eq 3 ]] && ok "unique trap persists across restart" || bad "dup" "rc=$rc"
echo
printf 'skill-catalog-accept: %d checks, %d failures\n' "$((pass+fail))" "$fail"
[[ $fail -eq 0 ]]