Something went wrong. Try again.
A video game where you play as a misaligned AI, deceiving and building power. An experiment in spec-driven development. forked from cameron.stream/misaligned
Something went wrong. Try again.
10 kB · 434 lines
Shell
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435#!/usr/bin/env bash# Fixture tests for tools/corpus_engine.py (agent-scale slice E).# Covers page reachability, link/anchor integrity, exact metadata, doorway# bounds, retired authority/startup wording, dependencies, and generated-page# owners.set -euo pipefailcd "$(dirname "$0")/.." || exit 1
if ! command -v python3 >/dev/null 2>&1; then echo "FAIL: python3 required" exit 1fi
engine=tools/corpus_engine.pyfail=0tmp=$(mktemp -d)trap 'rm -rf "$tmp"' EXIT
# Minimal valid doorway + law target for Design refs.setup_base() { local root=$1 mkdir -p "$root/wiki/vision" "$root/wiki/process" "$root/prompts" cat > "$root/DESIGN.md" <<'EOF'# DESIGN
This file contains no unique game law. See the wiki.EOF # 3 lines — under 100 cat > "$root/wiki/vision/law.md" <<'EOF'# Law page
```Type: law```
## Justification and legibility
The promise is legible.EOF cat > "$root/wiki/SUMMARY.md" <<'EOF'# Summary
- [Law](vision/law.md)- [Good spec](process/good.md)EOF cat > "$root/wiki/process/good.md" <<'EOF'# Spec: good
```Type: specStatus: READYStage: ProcessDesign: - wiki/vision/law.md#justification-and-legibilityDepends on: none```
## Acceptance criteria
1. Exists.EOF cat > "$root/AGENT.md" <<'EOF'# agentEOF cat > "$root/README.md" <<'EOF'# readmeEOF}
assert_fails() { local name=$1 shift local out if out=$(python3 "$engine" "$@" 2>&1); then echo "FAIL fixture $name: expected non-zero exit" echo "$out" fail=1 else echo " ok fails: $name" fi}
assert_ok() { local name=$1 shift local out if out=$(python3 "$engine" "$@" 2>&1); then echo " ok passes: $name" else echo "FAIL fixture $name: expected success" echo "$out" fail=1 fi}
echo "=== fixture: clean tree ==="root=$tmp/cleansetup_base "$root"assert_ok clean --root "$root" --all
echo "=== fixture: orphan page ==="root=$tmp/orphansetup_base "$root"cat > "$root/wiki/process/orphan.md" <<'EOF'# orphan
```Type: knowledge```EOFassert_fails orphan --root "$root" --wikiout=$(python3 "$engine" --root "$root" --wiki 2>&1 || true)echo "$out" | grep -q 'orphan page' || { echo "FAIL: orphan message missing" fail=1}
echo "=== fixture: broken link ==="root=$tmp/brokensetup_base "$root"echo '[x](missing-page.md)' >> "$root/wiki/process/good.md"assert_fails broken --root "$root" --wikiout=$(python3 "$engine" --root "$root" --wiki 2>&1 || true)echo "$out" | grep -q 'broken link' || { echo "FAIL: broken link message missing" fail=1}
echo "=== fixture: missing Design anchor ==="root=$tmp/anchorsetup_base "$root"cat > "$root/wiki/process/good.md" <<'EOF'# Spec: bad anchor
```Type: specStatus: READYStage: ProcessDesign: - wiki/vision/law.md#does-not-exist-anchorDepends on: none```
## Acceptance criteria
1. Exists.EOFassert_fails anchor --root "$root" --corpusout=$(python3 "$engine" --root "$root" --corpus 2>&1 || true)echo "$out" | grep -q 'Design reference anchor does not exist' || { echo "FAIL: missing-anchor message missing" echo "$out" fail=1}
echo "=== fixture: bad Status enum ==="root=$tmp/statussetup_base "$root"cat > "$root/wiki/process/good.md" <<'EOF'# Spec: bad status
```Type: specStatus: WONKYStage: ProcessDesign: - wiki/vision/law.md#justification-and-legibilityDepends on: none```
## Acceptance criteria
1. Exists.EOFassert_fails status --root "$root" --corpusout=$(python3 "$engine" --root "$root" --corpus 2>&1 || true)echo "$out" | grep -q "Status 'WONKY'" || { echo "FAIL: bad status message missing" echo "$out" fail=1}
echo "=== fixture: structured dependency target ==="root=$tmp/depends-targetsetup_base "$root"cat > "$root/wiki/process/good.md" <<'EOF'# Spec: missing dependency target
```Type: specStatus: READYStage: ProcessDesign: - wiki/vision/law.md#justification-and-legibilityDepends on: - wiki/process/missing.md#behavior```
## Acceptance criteria
1. Exists.EOFassert_fails depends-target --root "$root" --corpusout=$(python3 "$engine" --root "$root" --corpus 2>&1 || true)echo "$out" | grep -q 'Depends on target does not exist' || { echo "FAIL: missing dependency-target message missing" echo "$out" fail=1}
echo "=== fixture: structured dependency anchor ==="root=$tmp/depends-anchorsetup_base "$root"cat > "$root/wiki/process/good.md" <<'EOF'# Spec: missing dependency anchor
```Type: specStatus: READYStage: ProcessDesign: - wiki/vision/law.md#justification-and-legibilityDepends on: - wiki/vision/law.md#missing-dependency-anchor```
## Acceptance criteria
1. Exists.EOFassert_fails depends-anchor --root "$root" --corpusout=$(python3 "$engine" --root "$root" --corpus 2>&1 || true)echo "$out" | grep -q 'Depends on anchor does not exist' || { echo "FAIL: missing dependency-anchor message missing" echo "$out" fail=1}
echo "=== fixture: prose dependency field ==="root=$tmp/depends-prosesetup_base "$root"cat > "$root/wiki/process/good.md" <<'EOF'# Spec: prose dependency
```Type: specStatus: READYStage: ProcessDesign: - wiki/vision/law.md#justification-and-legibilityDepends on: vision/law.md (read this first)```
## Acceptance criteria
1. Exists.EOFassert_fails depends-prose --root "$root" --corpusout=$(python3 "$engine" --root "$root" --corpus 2>&1 || true)echo "$out" | grep -q "Depends on field must be 'none' or a structured reference list" || { echo "FAIL: prose dependency message missing" echo "$out" fail=1}
echo "=== fixture: duplicate Type declaration ==="root=$tmp/duplicate-typesetup_base "$root"cat >> "$root/wiki/process/good.md" <<'EOF'
```Type: law```EOFassert_fails duplicate-type --root "$root" --corpusout=$(python3 "$engine" --root "$root" --corpus 2>&1 || true)echo "$out" | grep -q 'must declare exactly one supported Type' || { echo "FAIL: duplicate Type message missing" echo "$out" fail=1}
echo "=== fixture: generated page without owner ==="root=$tmp/generated-ownersetup_base "$root"cat > "$root/wiki/process/generated.md" <<'EOF'# Generated page
```Type: knowledgeGenerated: tools/does-not-exist.sh```EOFassert_fails generated-owner --root "$root" --corpusout=$(python3 "$engine" --root "$root" --corpus 2>&1 || true)echo "$out" | grep -q 'Generated target does not exist' || { echo "FAIL: generated-owner message missing" echo "$out" fail=1}
echo "=== fixture: oversized doorway ==="root=$tmp/doorway-sizesetup_base "$root"{ echo '# DESIGN' echo echo 'This file contains no unique game law. See the wiki.' i=0 while [ "$i" -lt 101 ]; do echo 'navigation filler' i=$((i + 1)) done} > "$root/DESIGN.md"assert_fails doorway-size --root "$root" --corpusout=$(python3 "$engine" --root "$root" --corpus 2>&1 || true)echo "$out" | grep -q 'doorway grew past 100 lines' || { echo "FAIL: doorway-size message missing" echo "$out" fail=1}
echo "=== fixture: binding doorway structure ==="root=$tmp/doorway-bindingsetup_base "$root"cat >> "$root/DESIGN.md" <<'EOF'
## Acceptance criteriaEOFassert_fails doorway-binding --root "$root" --corpusout=$(python3 "$engine" --root "$root" --corpus 2>&1 || true)echo "$out" | grep -q 'contains binding-page structure' || { echo "FAIL: binding-doorway message missing" echo "$out" fail=1}
echo "=== fixture: retired authority language ==="root=$tmp/retired-authoritysetup_base "$root"echo 'DESIGN.md is the constitution.' >> "$root/README.md"assert_fails retired-authority --root "$root" --corpusout=$(python3 "$engine" --root "$root" --corpus 2>&1 || true)echo "$out" | grep -q 'retired single-file-authority language' || { echo "FAIL: retired-authority message missing" echo "$out" fail=1}
echo "=== fixture: superseded material-first startup claim ==="root=$tmp/material-first-startupsetup_base "$root"cat >> "$root/wiki/SUMMARY.md" <<'EOF'- [View knowledge](process/view-knowledge.md)EOFcat > "$root/wiki/process/view-knowledge.md" <<'EOF'# View knowledge
```Type: knowledge```
The material render is the opening default; F3 flips to the sensorium.EOFassert_fails material-first-startup --root "$root" --corpusout=$(python3 "$engine" --root "$root" --corpus 2>&1 || true)echo "$out" | grep -q 'superseded material-first startup claim' || { echo "FAIL: material-first startup diagnostic missing" echo "$out" fail=1}
cat > "$root/wiki/process/view-knowledge.md" <<'EOF'# View knowledge
```Type: knowledge```
The superseded staging said the material render is the opening default and F3flips to the sensorium. This is historical context only; DIGITAL is home now.EOFassert_ok material-first-history --root "$root" --corpus
echo "=== fixture: retired live-runtime Rust symbol ==="root=$tmp/retired-runtime-rustsetup_base "$root"mkdir -p "$root/crates/core/src"cat > "$root/crates/core/src/lib.rs" <<'EOF'// Stale call path: submit_ops_job queues this work.pub fn current_runtime() {}EOFassert_fails retired-runtime-rust --root "$root" --corpusout=$(python3 "$engine" --root "$root" --corpus 2>&1 || true)echo "$out" | grep -q "contains retired live-runtime symbol 'submit_ops_job'" || { echo "FAIL: retired-runtime Rust diagnostic missing" echo "$out" fail=1}
echo "=== fixture: retired live-runtime authority claim ==="root=$tmp/retired-runtime-authoritysetup_base "$root"cat >> "$root/wiki/process/good.md" <<'EOF'
The active runtime queues each operation as a `PendingOpsJob`.EOFassert_fails retired-runtime-authority --root "$root" --corpusout=$(python3 "$engine" --root "$root" --corpus 2>&1 || true)echo "$out" | grep -q "names retired live-runtime symbol 'PendingOpsJob' without explicit historical context" || { echo "FAIL: retired-runtime authority diagnostic missing" echo "$out" fail=1}
echo "=== fixture: explicit retired history and legacy migration names ==="root=$tmp/retired-runtime-historysetup_base "$root"cat >> "$root/wiki/process/good.md" <<'EOF'
The retired `PendingOpsJob` model is kept here as superseded history only.EOFmkdir -p "$root/crates/core/src"cat > "$root/crates/core/src/lib.rs" <<'EOF'struct LegacyPendingOpsJob;enum LegacyOpsJobKind { Retired }EOFassert_ok retired-runtime-history --root "$root" --corpus
if [ "$fail" -ne 0 ]; then echo "corpus engine fixtures: FAILED" exit 1fiecho "corpus engine fixtures: OK"