Repos
Shell
3.5 KB60 lines Opens in site
Directory
Raw
Download
#!/bin/bash
# <!-- doc: scripts/check-spec.sh | version: 1.0 | updated: 2026-10-28 -->
# Mechanical doc checks for the seriousdevelopment method. Structure checks only:
# this does NOT test Wayland or container behaviour (nothing is built yet).
# Exit 0 = all pass, 1 = at least one FAIL. Run from the repo root.
set -u
cd "$(dirname "$0")/.." || exit 1
fail=0
ok() { echo "PASS $1"; }
bad() { echo "FAIL $1"; fail=1; }
# Docs under the method (research/ is excluded: governed by research/README.md, see UPGRADE-REPORT conflicts).
DOCS="SPEC.md BUILD-TRACK.md CHANGELOG.md AGENTS.md UPGRADE-REPORT.md boxes.md host_environment.md docs/INSTALL-xfwl4.md"
DOCS="$DOCS $(ls docs/adr/*.md 2>/dev/null)"
# 1. version header on every governed doc
miss=""; for f in $DOCS; do [ -f "$f" ] || { miss="$miss $f(missing)"; continue; }; head -1 "$f" | grep -q '^<!-- doc: .* | version[: ]' || miss="$miss $f"; done
[ -z "$miss" ] && ok "doc headers on $(echo $DOCS | wc -w) docs" || bad "doc header missing:$miss"
# 2. normative ID definitions are unique (definition = list item or table row start)
dups=$(grep -hoE '^(- |\| )(FR|SEC|OPS|NFR|UX|PG|D|PIN|A|TRK|DOC|G|NG|R)-[0-9]+' SPEC.md | sed -E 's/^(- |\| )//' | sort | uniq -d)
[ -z "$dups" ] && ok "ID definitions unique" || bad "duplicate ID definitions: $dups"
# 3. changelog versions strictly ascending top to bottom
vers=$(grep -oE '^\| [0-9]+\.[0-9]+\.[0-9]+' CHANGELOG.md | tr -d '| ')
sorted=$(echo "$vers" | sort -V)
[ "$vers" = "$sorted" ] && ok "CHANGELOG ascending ($(echo "$vers" | tail -1) newest)" || bad "CHANGELOG not ascending"
top=$(grep -m1 -oE '^- Version: [0-9.]+' SPEC.md | grep -oE '[0-9.]+$'); last=$(echo "$vers" | tail -1)
[ "$top" = "$last" ] && ok "SPEC version $top equals newest CHANGELOG row" || bad "SPEC version $top != CHANGELOG $last"
# 4. forbidden patterns in governed docs: TBD and em dash (U+2014)
EMD=$'\xe2\x80\x94'
hits=$(grep -nE "TBD|$EMD" $DOCS 2>/dev/null | head -5)
[ -z "$hits" ] && ok "no placeholder word or em dash in governed docs" || bad "forbidden pattern: $hits"
# 5. every D-ID defined in SPEC section 9 has an ADR listing it
missing=""; for d in $(grep -oE '^- D-[0-9]+' SPEC.md | sed 's/- //'); do
grep -lE "^- Spec IDs:.*\b$d\b" docs/adr/*.md >/dev/null 2>&1 || missing="$missing $d"; done
[ -z "$missing" ] && ok "every D-ID has an ADR" || bad "D-ID without ADR:$missing"
# 6. ADR numbers cited in SPEC exist as files
miss=""; for n in $(grep -oE 'ADR [0-9]{4}' SPEC.md | awk '{print $2}' | sort -u); do ls docs/adr/$n-*.md >/dev/null 2>&1 || miss="$miss $n"; done
[ -z "$miss" ] && ok "cited ADR numbers exist" || bad "cited ADR missing:$miss"
# 7. track sheet: valid status enum, STALE rule (7 days) for started rows
today=$(date -u +%F); stale=""; badstatus=""
while IFS='|' read -r _ ms owner status upd rest; do
status=$(echo "$status" | xargs); upd=$(echo "$upd" | xargs); ms=$(echo "$ms" | xargs)
case "$ms" in Milestone|-----*|"") continue;; esac
case "$status" in NOT-STARTED|IN-PROGRESS|BLOCKED|IN-REVIEW|DONE) ;; *) badstatus="$badstatus $ms"; continue;; esac
if [ "$status" != NOT-STARTED ] && [ "$status" != DONE ] && [ "$upd" != "-" ]; then
age=$(( ( $(date -u -d "$today" +%s) - $(date -u -d "$upd" +%s) ) / 86400 ))
[ "$age" -gt 7 ] && stale="$stale $ms(${age}d)"
fi
done < <(grep -E '^\| ' BUILD-TRACK.md)
[ -z "$badstatus" ] && ok "track statuses valid" || bad "invalid status:$badstatus"
[ -z "$stale" ] && ok "no STALE track rows" || bad "STALE rows:$stale"
[ "$fail" = 0 ] && echo "check-spec: ALL PASS (structure only)" || echo "check-spec: FAIL"
exit $fail