fix(re): the capture check was red on a clean tree
Some checks failed
CI / Native — linux (pull_request) Failing after 1h1m57s
CI / WASM — Web (pull_request) Successful in 24m51s
CI / Formatting (pull_request) Successful in 28s

`committed()` built the directory set from `range(4, len(parts))`. Index 3 is
`docs/re/captures` itself, so every SUB-directory was registered and the root
never was. Eight pages cite the directory as a whole -- PROTOCOL's evidence
table, CONSOLIDATION, CONTAINERS-AND-AGENTS, decoder-loop, both HANDOFFs,
BLOCKED, verify-screen-blend-divergence -- and each of those looked like a
citation of a file that does not exist. `check-capture-citations` exited 1 on a
correct checkout, which is the failure mode its own comments warn about: "a
gate that is red on every clean checkout" teaches people to ignore it.

The selftest could not see this. It takes `next(iter(dirs))`, and an arbitrary
member of that set is always a sub-directory -- the one case that works. It now
asserts the root explicitly, with and without its trailing slash. Both new cases
were confirmed to FAIL against the unfixed function before the fix went in; a
selftest case that passes either way is decoration.

Measured: full check 203 citations, 212 captures, 0 dangling, 0 tracked assets,
exit 0. Before: exit 1.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-09-21 18:12:27 +02:00
parent f732b5ac1a
commit 43f0a905a0

View File

@@ -82,10 +82,16 @@ def committed() -> tuple[set[str], set[str]]:
if fn == ".gitignore":
continue
files.add(os.path.join(dirpath, fn).replace(os.sep, "/"))
# 🔴 START AT 3, NOT 4 — 3 is `docs/re/captures` ITSELF. Starting at 4 built
# every sub-directory and never the root, so the eight pages that cite the
# directory as a whole ("evidence lives in `docs/re/captures/`") each looked
# like a citation of a file that does not exist, and the gate was red on a
# clean, correct tree. The selftest could not see it either: it took an
# arbitrary member of `dirs`, which is always a sub-directory.
dirs = set()
for f in files:
parts = f.split("/")
for i in range(4, len(parts)): # docs/re/captures/<dir>/...
for i in range(3, len(parts)): # docs/re/captures[/<dir>/...]
dirs.add("/".join(parts[:i]) + "/")
return files, dirs
@@ -182,6 +188,9 @@ def selftest() -> int:
("real file passed", real_file, True),
("directory reference passed", real_dir, True),
("directory without slash passed", real_dir.rstrip("/"), True),
# The root is the case the arbitrary `real_dir` above can never be.
("captures root itself passed", ROOT, True),
("captures root without slash passed", ROOT.rstrip("/"), True),
("sentence punctuation stripped", real_file + ".", True),
]
# 🔴 THE SELFTEST USED TO PASS WHILE THE SCAN RETURNED NOTHING. It exercised