Standard production layout: the OKR app (was nested under AINative_OKR_CASAN5/) is now
the repository root. No more wrapper directory.
- Promote AINative_OKR_CASAN5/* -> repo root (backend/ frontend/ packages/ apps/
.specify/ docs/ infra/ nginx/ scripts/ + configs). Merge tool dirs: .gitea (kept the
active deploy ci.yml, added harness-ci.yml + runbooks), .claude (agents/commands +
launch.json), .github moved up.
- Remove redundant: 00_SUBMISSION_PACKAGE, scattered root notes (FPT_CASAN_Full.md,
tu-tuong-casan.md, casan-tu-sinh..., casan_harness_assessment.md, source-review...,
README_CASAN5_REFINED.md), casan-next-plans/ and optimize-docs/ (competition/planning
artifacts — roadmap + design history preserved in git log / commit messages).
- Update all references to the old layout:
- .gitea/workflows/{ci,harness-ci}.yml, .github/workflows/{ci,deploy}.yml:
working-directory .; drop AINative_OKR_CASAN5/ prefix; .specify/{tests,scripts}
-> packages/casan-harness/... (.specify/logs state kept)
- .claude/launch.json, .gitea/*-runbook.md: path prefixes
- CLAUDE.md, README.md: docs/input -> apps/okr/domain/input
- policy-bundle.yaml: 8 policy paths -> packages/casan-harness/...; manifest re-signed
- secrets-scan.sh: fixture excludes -> new package/domain paths.
Full gate from the new root: PASS=64 FAIL=0 SKIP=3.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
96 lines
3.9 KiB
Bash
Executable File
96 lines
3.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -uo pipefail
|
|
|
|
# CASAN Plan-10 — Traceability REQ→code→test MVP tests.
|
|
#
|
|
# Proves the matrix is generated from the real requirement document and the gate
|
|
# fails when any FR loses test coverage.
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$SCRIPT_DIR/../scripts/bash/casan-paths.sh"
|
|
PROJECT_ROOT="$CASAN_APP_ROOT"
|
|
S="$CASAN_HARNESS_ROOT/scripts/bash"
|
|
WORK="$(mktemp -d)"
|
|
trap 'rm -rf "$WORK"' EXIT
|
|
|
|
PASS=0; FAIL=0
|
|
pass() { echo "PASS: $1"; PASS=$((PASS + 1)); }
|
|
fail() { echo "FAIL: $1"; FAIL=$((FAIL + 1)); }
|
|
|
|
REQ="$CASAN_DOMAIN_ROOT/input/okr-requirement.md"
|
|
MAP="$CASAN_DOMAIN_ROOT/traceability-map.json"
|
|
OUT="$WORK/traceability-matrix.json"
|
|
|
|
echo "===== Plan-10 traceability matrix ====="
|
|
if python3 "$S/traceability-matrix.py" --requirements "$REQ" --map "$MAP" --out "$OUT" --gate >/dev/null 2>"$WORK/pass.err"; then
|
|
pass "complete FR→code→test matrix passes gate"
|
|
else
|
|
cat "$WORK/pass.err"
|
|
fail "complete traceability matrix rejected"
|
|
fi
|
|
|
|
COUNT="$(python3 -c "import json;d=json.load(open('$OUT'));print(d['summary']['requirements'])" 2>/dev/null)"
|
|
FAILED="$(python3 -c "import json;d=json.load(open('$OUT'));print(d['summary']['failed'])" 2>/dev/null)"
|
|
[[ "$COUNT" == "5" && "$FAILED" == "0" ]] \
|
|
&& pass "matrix captures all 5 FRs with zero failures" \
|
|
|| fail "matrix summary unexpected (requirements=$COUNT failed=$FAILED)"
|
|
|
|
BROKEN="$WORK/traceability-map-broken.json"
|
|
python3 - "$MAP" "$BROKEN" <<'PY'
|
|
import json, sys
|
|
d = json.load(open(sys.argv[1]))
|
|
d["FR-04"]["tests"] = []
|
|
json.dump(d, open(sys.argv[2], "w"), indent=2)
|
|
PY
|
|
set +e
|
|
python3 "$S/traceability-matrix.py" --requirements "$REQ" --map "$BROKEN" --out "$WORK/broken.json" --gate >/dev/null 2>"$WORK/broken.err"
|
|
RC=$?
|
|
set -e 2>/dev/null || true
|
|
[[ "$RC" -eq 1 ]] && grep -q "TRACEABILITY_FAIL FR-04" "$WORK/broken.err" \
|
|
&& pass "missing FR test coverage fails the gate" \
|
|
|| fail "missing test coverage did not fail as expected (rc=$RC)"
|
|
|
|
echo ""
|
|
echo "===== Plan-10 symbol/line-level traceability ====="
|
|
# The real map carries symbol refs for FR-01 (AuthService, login); the passing
|
|
# run above wrote $OUT from the real map, so those symbols must resolve.
|
|
SYM_FOUND="$(python3 -c "import json;print(json.load(open('$OUT'))['summary']['symbols_found'])" 2>/dev/null)"
|
|
SYM_MISS="$(python3 -c "import json;print(json.load(open('$OUT'))['summary']['symbols_missing'])" 2>/dev/null)"
|
|
[[ "${SYM_FOUND:-0}" -ge 2 && "${SYM_MISS:-1}" -eq 0 ]] \
|
|
&& pass "real map symbol refs resolved (found=$SYM_FOUND missing=$SYM_MISS)" \
|
|
|| fail "real map symbol refs unexpected (found=$SYM_FOUND missing=$SYM_MISS)"
|
|
|
|
SYMBROKEN="$WORK/map-badsym.json"
|
|
python3 - "$MAP" "$SYMBROKEN" <<'PY'
|
|
import json, sys
|
|
d = json.load(open(sys.argv[1]))
|
|
d["FR-01"]["code"] = [{"file": "backend/src/auth/auth.service.ts", "symbols": ["NoSuchSymbolXYZ"]}]
|
|
json.dump(d, open(sys.argv[2], "w"), indent=2)
|
|
PY
|
|
set +e
|
|
python3 "$S/traceability-matrix.py" --requirements "$REQ" --map "$SYMBROKEN" --out "$WORK/badsym.json" --gate >/dev/null 2>"$WORK/badsym.err"
|
|
RC=$?
|
|
set -e 2>/dev/null || true
|
|
[[ "$RC" -eq 1 ]] && grep -q "missing_symbols=1" "$WORK/badsym.err" \
|
|
&& pass "missing symbol fails the gate (symbol-level)" \
|
|
|| fail "missing symbol did not fail as expected (rc=$RC)"
|
|
|
|
LINEBROKEN="$WORK/map-badline.json"
|
|
python3 - "$MAP" "$LINEBROKEN" <<'PY'
|
|
import json, sys
|
|
d = json.load(open(sys.argv[1]))
|
|
d["FR-01"]["code"] = [{"file": "backend/src/auth/auth.service.ts", "lines": [999999]}]
|
|
json.dump(d, open(sys.argv[2], "w"), indent=2)
|
|
PY
|
|
set +e
|
|
python3 "$S/traceability-matrix.py" --requirements "$REQ" --map "$LINEBROKEN" --out "$WORK/badline.json" --gate >/dev/null 2>"$WORK/badline.err"
|
|
RC=$?
|
|
set -e 2>/dev/null || true
|
|
[[ "$RC" -eq 1 ]] && grep -q "missing_lines=1" "$WORK/badline.err" \
|
|
&& pass "out-of-range line ref fails the gate (line-level)" \
|
|
|| fail "line ref did not fail as expected (rc=$RC)"
|
|
|
|
echo ""
|
|
echo "===== TRACEABILITY SUMMARY: PASS=$PASS FAIL=$FAIL ====="
|
|
[[ "$FAIL" -eq 0 ]] || exit 1
|