fix core report inspection and vendored roots

This commit is contained in:
thanhnv
2026-07-29 12:29:18 +07:00
parent 1d6384d23c
commit 67d482ae7f
7 changed files with 64 additions and 2 deletions
@@ -11,6 +11,7 @@ import unittest
MODULE = Path(__file__).resolve().parents[1] / "scripts" / "python" / "local_report.py"
APP_JS = Path(__file__).resolve().parents[1] / "assets" / "local-viewer" / "app.js"
SPEC = importlib.util.spec_from_file_location("casan_local_report", MODULE)
REPORT = importlib.util.module_from_spec(SPEC)
assert SPEC.loader
@@ -153,6 +154,13 @@ class LocalReportTests(unittest.TestCase):
self.assertEqual(report["verdict"], "not_found")
self.assertFalse(report["source"]["trace_found"])
def test_trace_inspection_reveals_the_loaded_dossier(self):
script = APP_JS.read_text(encoding="utf-8")
self.assertIn('id="run-dossier"', script)
self.assertIn('tabindex="-1"', script)
self.assertIn('dossier.focus({ preventScroll: true })', script)
self.assertIn("dossier.scrollIntoView({", script)
if __name__ == "__main__":
unittest.main()
@@ -90,6 +90,35 @@ set -e 2>/dev/null || true
&& pass "out-of-range line ref fails the gate (line-level)" \
|| fail "line ref did not fail as expected (rc=$RC)"
echo ""
echo "===== Plan-10 vendored consumer root ====="
CONSUMER="$WORK/consumer"
python3 - "$CONSUMER" <<'PY'
import json
import os
import sys
root = sys.argv[1]
os.makedirs(os.path.join(root, "domain"), exist_ok=True)
os.makedirs(os.path.join(root, "src"), exist_ok=True)
os.makedirs(os.path.join(root, "tests"), exist_ok=True)
with open(os.path.join(root, "domain", "requirement.md"), "w", encoding="utf-8") as handle:
handle.write("| FR-01 | Consumer root must resolve | required |\n")
with open(os.path.join(root, "domain", "traceability-map.json"), "w", encoding="utf-8") as handle:
json.dump({"FR-01": {"code": ["src/app.py"], "tests": ["tests/test_app.py"]}}, handle)
for relative in ("src/app.py", "tests/test_app.py"):
with open(os.path.join(root, relative), "w", encoding="utf-8") as handle:
handle.write("# consumer fixture\n")
PY
if CASAN_APP_ROOT="$CONSUMER" python3 "$S/traceability-matrix.py" \
--requirements "$CONSUMER/domain/requirement.md" \
--map "$CONSUMER/domain/traceability-map.json" \
--out "$WORK/consumer-traceability.json" --gate >/dev/null; then
pass "explicit consumer root wins over vendored harness location"
else
fail "vendored traceability resolved files against the harness bundle"
fi
echo ""
echo "===== TRACEABILITY SUMMARY: PASS=$PASS FAIL=$FAIL ====="
[[ "$FAIL" -eq 0 ]] || exit 1