Files
evig/scripts/ci/docs-paths-exist.sh
GandClaude Fable 5 fe811bcfc2 docs: correct the design-system section that described a deleted file (#370)
CLAUDE.md carried a full 'Layer 2 — tailwind.config.ts' section for a file
Tailwind v4 removed, plus a token table naming --color-bg / --color-surface
/ --color-border (zero occurrences in globals.css; the real names are
--surface-base, --text-primary, --border-default), a dark-mode mechanism
that does not exist (it claimed @layer utilities auto-remaps bg-white —
globals.css contains no 'bg-white'), and a green #f0fdf4..#14532d palette
for a brand that is Ion Lime. Five false claims in sixty lines, in the
file every agent session reads first.

Also corrected: Tailwind 3.4 -> 4 and React 18 -> 19 in the stack tables;
the .claude/CLAUDE.md ADMIN_SECTIONS table (10 rows, wrong paths, ids that
no longer exist — 'products' and 'finances' are gone, and granting
'workshops' grants nothing because the admin section is 'workshops-admin')
replaced by a pointer to sections.ts and the two rules that do not change;
the dev-DB row that said Neon while CLAUDE.md said Docker:5433;
002-simplified-auth.sql -> 002b-; repairer_profiles -> technician_profiles
(renamed by migration 105); and a Revamp-IT street address in
SHARED_CONTEXT that org.ts explicitly forbids publishing.

scripts/ci/docs-paths-exist.sh closes the class: every backticked repo path
in the docs must exist. CLAUDE.md, .claude/CLAUDE.md and README.md are held
at ZERO; the 68 stale references in older reference docs are ratcheted so
they can fall but never rise. Historical plans and audits are excluded —
a June plan naming files that later moved is history, not a defect.
Proven by mutation: a planted bad path in CLAUDE.md exits 1.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-24 20:33:37 +02:00

108 lines
4.2 KiB
Bash

#!/usr/bin/env bash
# Every repo path named in the docs must exist.
#
# The docs had drifted into describing a codebase that moved on: a whole
# "Layer 2 — tailwind.config.ts" section for a file Tailwind v4 removed,
# `src/lib/design/design-system.ts` (it is `src/lib/design-system.ts`),
# `002-simplified-auth.sql` (it is `002b-`), `repairer_profiles` (renamed to
# `technician_profiles` by migration 105). Each one sends the next reader — or
# the next agent session — somewhere that does not exist, and the design-system
# section was confidently wrong about the token names too.
#
# A path in backticks is a checkable claim, so check it. Prose is left alone.
#
# No `set -e`: this script decides its own verdict and must report ALL misses,
# not die on the first grep that finds nothing.
set -uo pipefail
cd "$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" || exit 1
# The LIVING docs — the ones a reader is meant to act on today.
#
# Deliberately excluded: docs/development, docs/archive, docs/projects and the
# AUDIT_*/PLAN-style files. Those are point-in-time records (a plan written in
# June describing files that later moved is not wrong, it is history), and
# gating them would force rewriting the past to keep CI green.
DOCS=(CLAUDE.md .claude/CLAUDE.md README.md)
while IFS= read -r f; do
case "$f" in
*AUDIT*|*_PLAN.md|*PLAN_*.md) continue ;;
esac
DOCS+=("$f")
done < <(find docs -maxdepth 1 -name '*.md' 2>/dev/null)
for dir in docs/guides docs/operations docs/components docs/features; do
[ -d "$dir" ] || continue
while IFS= read -r f; do DOCS+=("$f"); done < <(find "$dir" -name '*.md' 2>/dev/null)
done
missing=0
primary_missing=0
checked=0
# The docs an agent session reads first. These are held at ZERO, not ratcheted:
# a wrong path here sends the next session to a file that does not exist.
is_primary() {
case "$1" in
CLAUDE.md|.claude/CLAUDE.md|README.md) return 0 ;;
*) return 1 ;;
esac
}
for doc in "${DOCS[@]}"; do
[ -f "$doc" ] || continue
# Backticked tokens that look like repo paths: contain a slash or a known
# source extension, and no spaces, globs, URLs or shell/regex punctuation.
while IFS= read -r path; do
case "$path" in
*' '*|*'*'*|*'$'*|*'|'*|*'('*|*'<'*|*http*|*'{'*|*'\'*) continue ;;
*/) continue ;;
esac
# Only paths that plausibly point into this repo.
case "$path" in
src/*|scripts/*|docs/*|messages/*|public/*|.github/*|packages/*|tests/*) ;;
*) continue ;;
esac
checked=$((checked + 1))
if [ ! -e "$path" ]; then
echo " ✗ $doc → $path"
missing=$((missing + 1))
is_primary "$doc" && primary_missing=$((primary_missing + 1))
fi
done < <(grep -oE '`[^`]+`' "$doc" 2>/dev/null | tr -d '`' | sort -u)
done
echo "docs-paths: checked $checked path references across ${#DOCS[@]} docs"
# A sweep that checks nothing passes trivially — say so loudly instead.
if [ "$checked" -lt 20 ]; then
echo "docs-paths: FAIL — only $checked references found; the extractor is broken, not the docs"
exit 1
fi
# Ratchet, like the card-shell gate: the three agent-facing docs (CLAUDE.md,
# .claude/CLAUDE.md, README.md) are at ZERO and must stay there; the long tail
# in older reference docs is pinned at a baseline that may fall or hold, never
# rise. Blocking on all of them today would have meant not shipping the gate.
BASELINE_FILE="scripts/ci/docs-paths-baseline.txt"
baseline=$(cat "$BASELINE_FILE" 2>/dev/null || echo 0)
echo "docs-paths: $missing stale reference(s) (baseline $baseline), $primary_missing in the primary docs (must be 0)"
if [ "$primary_missing" -gt 0 ]; then
echo "docs-paths: FAIL — CLAUDE.md / .claude/CLAUDE.md / README.md name $primary_missing path(s) that do not exist."
echo " These are the first files an agent session reads; they are held at zero."
exit 1
fi
if [ "$missing" -gt "$baseline" ]; then
echo "docs-paths: FAIL — stale documented paths rose $baseline → $missing"
echo " Fix the doc (or restore the file). Stale docs teach the wrong thing."
exit 1
fi
if [ "$missing" -lt "$baseline" ]; then
echo "docs-paths: count fell — lower the baseline to $missing in $BASELINE_FILE (same PR)."
fi
echo "docs-paths: OK"