From b42df5f15fc29a86a90b6eba2c0135d755d643be Mon Sep 17 00:00:00 2001 From: Timothy Date: Sun, 26 Jul 2026 01:24:17 +0200 Subject: [PATCH] fix(621): close a depth blind spot in the record-wing scan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adversarial self-review: the archive side used `glob("*/*.md")` while records used rglob. Both exempt the top-level stripped legacy files correctly, but the one-level glob would ALSO skip anything nested deeper, letting a record at archive///x.md escape the check entirely. A path silently escaping the scan is precisely the failure mode this guard exists to close, so the exemption is now expressed as the actual condition — "directly in archive/" — rather than a glob shape that happens to match today's layout. Test added and mutation-verified: reverting to the one-level glob turns it red. 120 passed. Refs #621 --- scripts/decisions_validate.py | 8 +++++++- scripts/tests/test_decisions_validate.py | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/scripts/decisions_validate.py b/scripts/decisions_validate.py index c96243e97..0800fa128 100644 --- a/scripts/decisions_validate.py +++ b/scripts/decisions_validate.py @@ -432,7 +432,13 @@ def record_wing_files(records_dir: Path | None = None, archive_dir: Path | None if records_dir.exists(): files += sorted(records_dir.rglob("*.md")) if archive_dir.exists(): - files += sorted(archive_dir.glob("*/*.md")) # area-nested only — see docstring + # rglob + "not directly in archive/", NOT glob("*/*.md"). Both exempt the top-level + # stripped legacy files, but a one-level glob would ALSO skip anything nested deeper — + # letting a record at `archive///x.md` escape the check entirely. Silently + # skipping a path is the exact failure mode this function exists to close, so the + # exemption is expressed as the precise condition (depth-1 file) rather than a shape that + # happens to match today's layout. + files += sorted(p for p in archive_dir.rglob("*.md") if p.parent != archive_dir) return [p for p in files if p.name not in dl._NON_DECISION_FILES] diff --git a/scripts/tests/test_decisions_validate.py b/scripts/tests/test_decisions_validate.py index 565c761e6..90cc1a7d0 100644 --- a/scripts/tests/test_decisions_validate.py +++ b/scripts/tests/test_decisions_validate.py @@ -818,3 +818,19 @@ def test_real_repo_record_wings_are_all_parseable(): files = dv.record_wing_files() assert len(files) > 100, f"record wings look empty ({len(files)} files) — check is vacuous" assert dv.record_wing_faults() == [] + + +def test_wing_faults_sees_a_DEEPER_nested_archive_record(tmp_path): + """A one-level `archive/*/*.md` glob would exempt the top-level stripped files correctly but + silently skip anything nested deeper — a path escaping the check, which is the very failure + mode this guard exists to close. The exemption must be 'directly in archive/', not 'exactly + one level down'.""" + records, archive = _wing(tmp_path) + (records / "ci" / "good.md").write_text(_GOOD) + (archive / "api.md").write_text("# api\n\n## Records formerly in this file\n") # still exempt + deep = archive / "ci" / "sub" + deep.mkdir(parents=True) + (deep / "broken.md").write_text("# not a record\n") + + faults = dv.record_wing_faults(records, archive) + assert len(faults) == 1 and "broken.md" in faults[0], faults