Make four guards testable, and one guard see both spellings

The provenance guard knew one way to lose a frame's source offset —
writing it as absent. Omitting the field entirely does the same thing,
because the frame type fills it in by default, and the guard read straight
past that. A parser rewritten into the second spelling would have kept its
green light while its track silently went back to being placed by guesswork.
It now reports which spelling it found and where.

The title-count clamp was asserted over a fixture too small to hold more
titles than the cap allows, so the walk stopped when the buffer ran out and
the clamp was never what bounded it — the assertion held with the clamp
deleted. The fixture now carries more entries than the cap.

The subdirectory limit was checked by restating the constant's own
definition; the guard itself had never run, and deleting it changed
nothing. The limit is lowered under test so a real folder can exceed it,
and the test now walks one and requires the refusal.

One test also carried two unrelated grounding notes while the test they
described had none, so reading the note above a test told you about a
different one.
This commit is contained in:
Matthew Jackson
2026-08-08 19:06:37 -07:00
parent 109afcdcf7
commit 32824fba5b
3 changed files with 74 additions and 19 deletions
+16 -2
View File
@@ -465,9 +465,23 @@ mod provenance_guard {
// `PesFrame` in the tests of other modules is not ours; only
// codec `Frame` literals are scanned, and a test fixture that
// builds a PesPacket with `source: None` is legitimate.
if blk.contains("source: None") {
// Two spellings, not one. `source: None` is the obvious way to
// lose provenance; OMITTING the field entirely is the quiet
// one, because `Frame` derives Default, so
// `Frame { pts_ns, .. Default::default() }` compiles and
// yields `source: None` while containing no such text. A guard
// that only knew the first spelling would have watched a
// parser be rewritten into the second and stayed green.
let explicit_none = blk.contains("source: None");
let no_source_field = !blk.contains("source:");
if explicit_none || no_source_field {
let line = src[..src.find(blk).unwrap_or(0)].lines().count() + 1;
offenders.push(format!("{name}:{line}"));
let how = if explicit_none {
"source: None"
} else {
"no source field (Default fills in None)"
};
offenders.push(format!("{name}:{line} ({how})"));
}
}
}