Scrub references to older versions
Quality Gate / gate (push) Successful in 2m39s

This commit is contained in:
Jim Lancaster
2026-09-02 17:02:48 -05:00
parent eeb1888aa3
commit 065acad125
20 changed files with 70 additions and 545 deletions
+47
View File
@@ -69,6 +69,19 @@ _BASELINE_CLAIM = re.compile(
r"\b(?:Current Baseline:\s*|current\s+|active\s+|canonical\s+)V(\d+(?:\.\d+)?)",
re.IGNORECASE,
)
_LEGACY_VERSION_REFERENCE = re.compile(r"\b[Vv](4(?:\.\d+)?|5(?:\.\d+)?|6\.0)\b|test_v42_evidence|test_v45_candidates")
LEGACY_VERSION_REFERENCE_EXCLUSIONS = frozenset(
{
".github/workflows/quality-gate.yml",
"docs/data_migration.md",
"docs/requirements.md",
"docs/reviews",
"docs/roadmap_plan.md",
"docs/schema.md",
"src/transcription/db/operations.py",
"tests/test_meta_contract_guards.py",
}
)
def _declared_baseline() -> str:
@@ -112,6 +125,40 @@ def test_canonical_docs_declare_one_consistent_baseline():
)
def test_legacy_version_markers_are_scoped_to_allowed_historical_files():
"""Version labels from older project baselines should not linger in active files.
Historical references are allowed only where the old version is the subject matter:
roadmap planning, dated reviews, stable requirement IDs, and explicit migration or
compatibility notes.
"""
scanned: list[Path] = []
for root in (
PROJECT_ROOT / ".github",
PROJECT_ROOT / "docs",
PROJECT_ROOT / "src",
PROJECT_ROOT / "tests",
):
scanned.extend(path for path in root.rglob("*") if path.suffix in {".md", ".py", ".yml", ".yaml"})
scanned.extend((PROJECT_ROOT / "AGENTS.md", PROJECT_ROOT / ".pre-commit-config.yaml"))
violations: dict[str, list[str]] = {}
for path in sorted(set(scanned)):
relative = path.relative_to(PROJECT_ROOT).as_posix()
if any(
relative == excluded or relative.startswith(f"{excluded}/")
for excluded in LEGACY_VERSION_REFERENCE_EXCLUSIONS
):
continue
matches = sorted(
{match.group(0) for match in _LEGACY_VERSION_REFERENCE.finditer(path.read_text(encoding="utf-8"))}
)
if matches:
violations[relative] = matches
assert violations == {}, f"Legacy version markers remain in active files: {violations}"
def test_active_contract_files_are_present():
"""Guard the guard: ensure all expected authority files are scanned."""
missing = [path for path in ACTIVE_CONTRACT_FILES if not (PROJECT_ROOT / path).exists()]