Background
PR #549 (merged, main @ 60245c5c) replaced the line-pinned ratchet anchors in tests/teardown_structure.rs with structural anchors. The post-merge review of that change surfaced 14 findings. The operator-facing triage fixed 9 of them (findings 1,2,3,4,5,8,9,11,12 — regression-class or grind-class defects) in the follow-up branch fix/teardown-anchor-followups. The remaining 4 findings are hardening work, deferred here.
This suite reads kernel source as text (no kernel compile involved) and runs host-side via cargo test --test teardown_structure.
Deferred hardening findings
1. (review finding 7) Add permanent in-file synthetic negatives for anchor families lacking mutation proof
Six anchor families in tests/teardown_structure.rs currently have no synthetic-negative (mutation) test proving the anchor actually catches a regression if the structural pattern it matches disappears or is malformed. The follow-up branch fix/teardown-anchor-followups proved these six families once, live, with one-off manual controls during the review — but that proof isn't durable: it doesn't live in the test file, so nothing stops a future edit from silently breaking one of these anchors without any test noticing.
Ask: for each of the six anchor families, add a permanent in-file synthetic-negative case (e.g. a small embedded fixture string, or a temp-file mutation harness) that asserts the anchor's validator fails when the expected structural pattern is absent/malformed, alongside the existing positive case.
2. (review finding 10) record_unit collapses ~20 validators to bare labels with no diff detail; 4 sites double-print
record_unit (the shared pass/fail recording helper used across the ~20 structural validators in tests/teardown_structure.rs) reduces every failure down to a bare label string, discarding any diff/context detail about what didn't match. When a validator fails, the test output tells you which named check failed but not why — no snippet of the offending source, no expected-vs-actual, nothing to start debugging from. Separately, four call sites in the file call both eprintln! and record_unit's own printing path for the same failure, producing duplicate console output.
Ask: thread failure detail (the specific line/snippet/expected-pattern that didn't match) through record_unit so failures are actionable without re-deriving context by hand, and remove the four duplicate eprintln! calls that double-print alongside record_unit.
3. (review finding 13) Census re-lexes the whole kernel tree ~20x per run — add a per-file mask/span cache
The structural "census" pass that walks the kernel source tree and builds the comment/string masks and code spans used by the validators is currently invoked independently by roughly 20 different validators in one test run, each re-lexing the entire kernel tree from scratch. This is pure repeated work — the source files don't change between validators within a single run.
Ask: add a per-file cache (keyed on file path, or path+mtime/hash) for the lexer mask/span output so it's computed once per file per run and reused across all validators, instead of ~20 redundant full-tree re-lexes.
4. (review finding 14) Two narrow lexer edge cases
item_segment fn-pointer parsing: the segment-item lexer/parser does not correctly handle function-pointer type syntax (e.g. fn(Args) -> Ret appearing inside a field/parameter position), which can misparse or mis-segment items that use fn-pointer types.
header_cfg raw-byte bracket scan ignores the code mask: the header/cfg bracket-matching scan operates on raw bytes and does not respect the comment/string code mask, so bracket characters appearing inside comments or string literals can be miscounted, throwing off the scan.
Ask: fix both parsing edge cases — make item_segment handle fn-pointer type syntax correctly, and make the header_cfg bracket scan mask-aware so it ignores brackets inside comments/strings.
References
Background
PR #549 (merged, main @
60245c5c) replaced the line-pinned ratchet anchors intests/teardown_structure.rswith structural anchors. The post-merge review of that change surfaced 14 findings. The operator-facing triage fixed 9 of them (findings 1,2,3,4,5,8,9,11,12 — regression-class or grind-class defects) in the follow-up branchfix/teardown-anchor-followups. The remaining 4 findings are hardening work, deferred here.This suite reads kernel source as text (no kernel compile involved) and runs host-side via
cargo test --test teardown_structure.Deferred hardening findings
1. (review finding 7) Add permanent in-file synthetic negatives for anchor families lacking mutation proof
Six anchor families in
tests/teardown_structure.rscurrently have no synthetic-negative (mutation) test proving the anchor actually catches a regression if the structural pattern it matches disappears or is malformed. The follow-up branchfix/teardown-anchor-followupsproved these six families once, live, with one-off manual controls during the review — but that proof isn't durable: it doesn't live in the test file, so nothing stops a future edit from silently breaking one of these anchors without any test noticing.Ask: for each of the six anchor families, add a permanent in-file synthetic-negative case (e.g. a small embedded fixture string, or a temp-file mutation harness) that asserts the anchor's validator fails when the expected structural pattern is absent/malformed, alongside the existing positive case.
2. (review finding 10)
record_unitcollapses ~20 validators to bare labels with no diff detail; 4 sites double-printrecord_unit(the shared pass/fail recording helper used across the ~20 structural validators intests/teardown_structure.rs) reduces every failure down to a bare label string, discarding any diff/context detail about what didn't match. When a validator fails, the test output tells you which named check failed but not why — no snippet of the offending source, no expected-vs-actual, nothing to start debugging from. Separately, four call sites in the file call botheprintln!andrecord_unit's own printing path for the same failure, producing duplicate console output.Ask: thread failure detail (the specific line/snippet/expected-pattern that didn't match) through
record_unitso failures are actionable without re-deriving context by hand, and remove the four duplicateeprintln!calls that double-print alongsiderecord_unit.3. (review finding 13) Census re-lexes the whole kernel tree ~20x per run — add a per-file mask/span cache
The structural "census" pass that walks the kernel source tree and builds the comment/string masks and code spans used by the validators is currently invoked independently by roughly 20 different validators in one test run, each re-lexing the entire kernel tree from scratch. This is pure repeated work — the source files don't change between validators within a single run.
Ask: add a per-file cache (keyed on file path, or path+mtime/hash) for the lexer mask/span output so it's computed once per file per run and reused across all validators, instead of ~20 redundant full-tree re-lexes.
4. (review finding 14) Two narrow lexer edge cases
item_segmentfn-pointer parsing: the segment-item lexer/parser does not correctly handle function-pointer type syntax (e.g.fn(Args) -> Retappearing inside a field/parameter position), which can misparse or mis-segment items that use fn-pointer types.header_cfgraw-byte bracket scan ignores the code mask: the header/cfg bracket-matching scan operates on raw bytes and does not respect the comment/string code mask, so bracket characters appearing inside comments or string literals can be miscounted, throwing off the scan.Ask: fix both parsing edge cases — make
item_segmenthandle fn-pointer type syntax correctly, and make theheader_cfgbracket scan mask-aware so it ignores brackets inside comments/strings.References
60245c5c): replaced line-pinned ratchet anchors with structural anchors intests/teardown_structure.rs.fix/teardown-anchor-followups: fixed the 9 regression/grind-class findings from the same review and proved (non-durably) the six anchor families referenced in finding 1 above.