aboutsummaryrefslogtreecommitdiff
path: root/scripts/check-trace.sh
diff options
context:
space:
mode:
authorrottedfm <rottedfm@proton.me>2026-08-19 11:24:55 -0400
committerrottedfm <rottedfm@proton.me>2026-08-19 11:24:55 -0400
commit8e16347b0eb329e84892af8ece36886324c95f62 (patch)
treebe1267972b5de2f1ae592577dfabce67f1fe6e87 /scripts/check-trace.sh
parentc6ae4660d1cc2414b22c492c5e819d009c8187c2 (diff)
parentea0bd36167b684c0accdb5ce2b2e21b8d84aeb25 (diff)
Merge branch 'buffer-implementation'HEADmain
Establishes the first working baseline: moji <file> opens a file into a ropey rope and edits it with Helix selection-first modal editing, under a DO-178C DAL-C requirements and traceability process. Prior to this, main tracked four files and src/main.rs was still println!("Hello, world!") — there was no buildable state to build on. Verified on a fresh clone of the branch with no untracked files: cargo build; clippy --all-targets -D warnings clean; 294 tests passing; scripts/check-trace.sh reports 98/98 requirements traced in both directions. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'scripts/check-trace.sh')
-rwxr-xr-xscripts/check-trace.sh59
1 files changed, 59 insertions, 0 deletions
diff --git a/scripts/check-trace.sh b/scripts/check-trace.sh
new file mode 100755
index 0000000..bc026d4
--- /dev/null
+++ b/scripts/check-trace.sh
@@ -0,0 +1,59 @@
+#!/usr/bin/env bash
+#
+# Bidirectional traceability check (docs/process.md §5).
+#
+# Verifies HLR -> LLR -> source -> test in both directions:
+# - every low-level requirement is implemented and tested
+# - every requirement a test names actually exists
+#
+# The third check is the one that is easy to omit and that fails silently when
+# omitted: it catches stale references left behind by a renumbered or withdrawn
+# requirement.
+#
+# Exits non-zero if any check fails, so it can gate a commit or CI job.
+
+set -euo pipefail
+
+cd "$(dirname "$0")/.."
+
+tmp=$(mktemp -d)
+trap 'rm -rf "$tmp"' EXIT
+
+grep -ohE 'MJB-LLR-[0-9]+' docs/requirements/llr.md | sort -u > "$tmp/defined"
+grep -rohE 'MJB-LLR-[0-9]+' src/ | sort -u > "$tmp/tagged"
+grep -rohE 'mjb_llr_[0-9]+' src/ tests/ \
+ | sed 's/mjb_llr_/MJB-LLR-/' | sort -u > "$tmp/tested"
+
+defined=$(wc -l < "$tmp/defined")
+tagged=$(wc -l < "$tmp/tagged")
+tested=$(wc -l < "$tmp/tested")
+
+printf 'defined=%s tagged=%s tested=%s\n\n' "$defined" "$tagged" "$tested"
+
+status=0
+
+report() { # $1=label $2=file $3=explanation
+ if [ -s "$2" ]; then
+ printf '%s:\n' "$1"
+ sed 's/^/ /' "$2"
+ printf ' -> %s\n\n' "$3"
+ status=1
+ fi
+}
+
+comm -23 "$tmp/defined" "$tmp/tagged" > "$tmp/untagged"
+comm -23 "$tmp/defined" "$tmp/tested" > "$tmp/untested"
+comm -13 "$tmp/defined" "$tmp/tested" > "$tmp/unknown"
+
+report "Requirements with no implementation" "$tmp/untagged" \
+ "tag the implementing item with // MJB-LLR-nnn"
+report "Requirements with no test" "$tmp/untested" \
+ "add a test named mjb_llr_nnn_<description>"
+report "Tests naming a requirement that does not exist" "$tmp/unknown" \
+ "typo, or a stale reference to a withdrawn requirement"
+
+if [ "$status" -eq 0 ]; then
+ echo "OK: traceability complete in both directions."
+fi
+
+exit "$status"