From 0a3ee0791fcf123d88388f39f9b56753659c289d Mon Sep 17 00:00:00 2001 From: Duncan Tourolle Date: Thu, 30 Jul 2026 10:30:20 +0200 Subject: [PATCH] chore(scripts): remove three broken, orphaned traceability scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All three shared one root cause: an unscoped `grep -r src-tauri/`, which walks ~40GB of target/ build artifacts. - check-req-coverage.sh: also read README.md, which has held zero requirement rows since they moved to docs/requirements.md. Reported "Total Requirements: 1", zeros in every category, then printed "All requirements have implementations!" — the opposite of a warning, from an empty result set. - check-test-coverage.sh: hung indefinitely, no output at all. - find-req-implementations.sh: same hang. None was referenced by CI, package.json, or the docs. They were salvageable — the greps just needed scoping — but they read an undocumented `@req:` / `@req-test:` tag convention parallel to `TRACES:` (146 and 76 occurrences, described in no doc; CLAUDE.md documents only TRACES). Repairing them would re-establish the second source of truth that let "1 requirement" and "211 requirements" coexist unnoticed. extract-traces.ts is now the single owner of coverage reporting. The existing @req:/@req-test: comments are left in place: harmless as prose, several encode useful test intent, and stripping 222 comments is a large diff with no functional gain. They are simply no longer read. --- scripts/README.md | 18 ++++++- scripts/check-req-coverage.sh | 84 ----------------------------- scripts/check-test-coverage.sh | 40 -------------- scripts/find-req-implementations.sh | 56 ------------------- 4 files changed, 17 insertions(+), 181 deletions(-) delete mode 100755 scripts/check-req-coverage.sh delete mode 100755 scripts/check-test-coverage.sh delete mode 100755 scripts/find-req-implementations.sh diff --git a/scripts/README.md b/scripts/README.md index 17f18518..d4aa371c 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -69,13 +69,29 @@ Extract requirement IDs (TRACES) from source code and generate a traceability ma bun run traces # Generate markdown report bun run traces:json # Generate JSON report bun run traces:markdown # Save to docs/traceability.md +bun run traces:coverage # Coverage gate — exits non-zero below 50% ``` -The script scans all TypeScript, Svelte, and Rust files looking for `TRACES:` comments and generates a comprehensive mapping of: +The script scans all TypeScript, Svelte, and Rust files (plus `scripts/`) +looking for `TRACES:` comments and generates a comprehensive mapping of: - Which code files implement which requirements - Line numbers and code context - Coverage summary by requirement type (UR, IR, DR, JA) +**`bun run traces:coverage` is the supported way to check requirement coverage +locally** — it runs the same computation CI does. Coverage denominators are +derived from `docs/requirements.md` at run time; they are never hardcoded. An ID +that appears in a `TRACES:` comment but is not defined in `requirements.md` is +reported as *orphaned* and does not count toward coverage (see DR-093). + +> **Removed:** `check-req-coverage.sh`, `check-test-coverage.sh`, and +> `find-req-implementations.sh` were deleted in July 2026. They read an +> undocumented `@req:` tag convention parallel to `TRACES:`, grepped `src-tauri/` +> unscoped (hanging on ~40 GB of `target/` artifacts), and in one case reported +> "all requirements implemented" from an empty result set. `extract-traces.ts` is +> the single source of truth for requirement coverage. See +> [docs/specs/req-coverage-script-removal.md](../docs/specs/req-coverage-script-removal.md). + Example TRACES comment in code: ```typescript // TRACES: UR-005, UR-026 | DR-029 diff --git a/scripts/check-req-coverage.sh b/scripts/check-req-coverage.sh deleted file mode 100755 index 12252f32..00000000 --- a/scripts/check-req-coverage.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -# -# Requirements Coverage Checker -# Extracts @req tags from codebase and compares with README.md -# - -set -e - -REQUIREMENTS_FILE="README.md" -SOURCE_DIRS="src-tauri/ src/" - -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo " Requirements Coverage Report" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo "" - -# Extract requirement IDs from README.md (UR-, IR-, DR-, JA-) -echo "📊 Scanning requirements from $REQUIREMENTS_FILE..." -requirements=$(grep -E "^\| (UR|IR|DR|JA)-[0-9]+" "$REQUIREMENTS_FILE" | \ - sed -E 's/^\| ([A-Z]+-[0-9]+).*/\1/' | \ - sort -u) - -total_reqs=$(echo "$requirements" | wc -l) -implemented=0 -partial=0 -planned=0 -missing=0 - -echo "" -echo "Category Breakdown:" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" - -for category in UR IR DR JA; do - cat_count=$(echo "$requirements" | grep "^$category-" | wc -l) - printf "%-4s %3d requirements\n" "$category:" "$cat_count" -done - -echo "" -echo "Implementation Status:" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" - -for req in $requirements; do - # Count full implementations - full_count=$(grep -r "@req: $req" $SOURCE_DIRS 2>/dev/null | grep -v "@req-partial" | grep -v "@req-planned" | wc -l) - - # Count partial implementations - partial_count=$(grep -r "@req-partial: $req" $SOURCE_DIRS 2>/dev/null | wc -l) - - # Count planned - planned_count=$(grep -r "@req-planned: $req" $SOURCE_DIRS 2>/dev/null | wc -l) - - if [ "$full_count" -gt 0 ]; then - echo "✅ $req: $full_count implementation(s)" - ((implemented++)) - elif [ "$partial_count" -gt 0 ]; then - echo "🔶 $req: $partial_count partial implementation(s)" - ((partial++)) - elif [ "$planned_count" -gt 0 ]; then - echo "📋 $req: Planned (not yet implemented)" - ((planned++)) - else - echo "❌ $req: No implementation found" - ((missing++)) - fi -done - -echo "" -echo "Summary:" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -printf "Total Requirements: %3d\n" "$total_reqs" -printf "✅ Fully Implemented: %3d (%.0f%%)\n" "$implemented" "$(echo "scale=0; $implemented * 100 / $total_reqs" | bc)" -printf "🔶 Partially Implemented: %3d (%.0f%%)\n" "$partial" "$(echo "scale=0; $partial * 100 / $total_reqs" | bc)" -printf "📋 Planned: %3d (%.0f%%)\n" "$planned" "$(echo "scale=0; $planned * 100 / $total_reqs" | bc)" -printf "❌ Missing: %3d (%.0f%%)\n" "$missing" "$(echo "scale=0; $missing * 100 / $total_reqs" | bc)" -echo "" - -# Exit code based on missing critical requirements -if [ "$missing" -gt 0 ]; then - echo "⚠️ Warning: $missing requirements have no implementation" - exit 1 -else - echo "✨ All requirements have implementations!" - exit 0 -fi diff --git a/scripts/check-test-coverage.sh b/scripts/check-test-coverage.sh deleted file mode 100755 index 5dd8e2ff..00000000 --- a/scripts/check-test-coverage.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# -# Test Coverage Report -# Links test requirements to implementations -# - -echo "Test Coverage Report" -echo "====================" -echo "" - -test_reqs=$(grep -rh "@req-test:" src-tauri/ 2>/dev/null | \ - sed 's/.*@req-test: \([A-Z][A-Z]-[0-9]*\).*/\1/' | \ - sort -u) - -total_tests=0 -covered=0 -uncovered=0 - -for req in $test_reqs; do - test_count=$(grep -r "@req-test: $req" src-tauri/ 2>/dev/null | wc -l) - impl_count=$(grep -r "@req: $req" src-tauri/ src/ 2>/dev/null | wc -l) - - ((total_tests++)) - - if [ "$test_count" -gt 0 ] && [ "$impl_count" -gt 0 ]; then - echo "✅ $req: $test_count test(s), $impl_count implementation(s)" - ((covered++)) - elif [ "$impl_count" -eq 0 ]; then - echo "⚠️ $req: $test_count test(s) but no implementation" - ((uncovered++)) - fi -done - -echo "" -echo "Summary:" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -printf "Total Test Requirements: %3d\n" "$total_tests" -printf "✅ With Implementation: %3d (%.0f%%)\n" "$covered" "$(echo "scale=0; $covered * 100 / $total_tests" | bc)" -printf "⚠️ No Implementation: %3d (%.0f%%)\n" "$uncovered" "$(echo "scale=0; $uncovered * 100 / $total_tests" | bc)" -echo "" diff --git a/scripts/find-req-implementations.sh b/scripts/find-req-implementations.sh deleted file mode 100755 index 703a4eaf..00000000 --- a/scripts/find-req-implementations.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# -# Find all files implementing a specific requirement -# -# Usage: ./find-req-implementations.sh UR-004 -# - -if [ $# -eq 0 ]; then - echo "Usage: $0 " - echo "Example: $0 UR-004" - exit 1 -fi - -REQ_ID=$1 - -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo " Implementations of $REQ_ID" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo "" - -# Full implementations -echo "Full Implementations:" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -grep -rn "@req: $REQ_ID" src-tauri/ src/ 2>/dev/null | \ - grep -v "@req-partial" | \ - grep -v "@req-planned" | \ - sed 's/src-tauri\/src\///' | \ - sed 's/src\///' || echo " (none)" - -echo "" - -# Partial implementations -echo "Partial Implementations:" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -grep -rn "@req-partial: $REQ_ID" src-tauri/ src/ 2>/dev/null | \ - sed 's/src-tauri\/src\///' | \ - sed 's/src\///' || echo " (none)" - -echo "" - -# Planned -echo "Planned Implementations:" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -grep -rn "@req-planned: $REQ_ID" src-tauri/ src/ 2>/dev/null | \ - sed 's/src-tauri\/src\///' | \ - sed 's/src\///' || echo " (none)" - -echo "" - -# Tests -echo "Test Cases:" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -grep -rn "@req-test: $REQ_ID" src-tauri/ 2>/dev/null | \ - sed 's/src-tauri\/src\///' || echo " (none)" - -echo ""