Repository navigation
fix(xtask): R6 by liveness, test regions in all their forms, refuse a stale gate binary (audit T, U, X) - #249
Merged
Merged
Conversation
… in all their forms; refuse a stale gate binary (audit T, U, X) R6 counted a name's occurrences: a definition counted as a use, so did a same-named function, a call from a dead function and a `use` line. Orphan chains, same-named functions with no caller and attribute-prefixed or split definitions all got through (audit T, X). Now a liveness pass: live contexts are code outside functions, main, trait-impl methods and attribute strings; a function is live when its name occurs in a live context, and its body then counts. Recursion of a uniquely named function does not keep it alive; a same-named call may be delegation and counts. Test regions (audit U): cfg(all(test, ..)) and any(..) of test-only parts are test code, any(test, feature) and not(test) are not; an inner #![cfg(test)] covers the file; an item's end ignores commas in its generics; out-of-line test modules (`#[cfg(test)] mod tests;`) are excluded from R6. Fixtures: 11 functions that must be flagged and 7 that must stay live. The old gate, run on the same fixtures, flagged only chain_top (and wrongly the attribute-string function by_attribute). On main the new R6 finds four real orphans, now baselined with reasons: encode_kz and encode_kzl (only the dormant send_cw / set_cw_delay call them), luminance (only the baselined contrast), poll_cat (test convenience; hidden by the trait default's name). R3, R4, R5 and R7 are unchanged on main. xtask now refuses to run when cargo starts a binary built for another checkout: with a shared target dir, target/debug/xtask is re-linked only on rebuild, and main's gate silently checked a worktree (2026-10-16). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma4bQKqGNFTYyVSEKPcXRk
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma4bQKqGNFTYyVSEKPcXRk
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the R6/R7 class from the audit (issue #242: T, U, X; V documented).
R6 used to count a name's occurrences. A definition counted as a use, and so did a same-named function, a call from a dead function, and a
useline. Now it runs a liveness pass over a name-level call graph:main, methods of animpl Trait for Typeblock, and attribute strings (deserialize_with = "…").Primitive::preparecallsGpu::prepare. My first version got that wrong; the fix came before commit.Test regions (U) are now recognised in all their forms, which feeds R3, R5 and R6:
cfg(all(test, …)), andany(…)whose every part is test-only.any(test, feature)andnot(test)stay live code.#![cfg(test)]covers the whole file.#[cfg(test)] mod tests;) are excluded from R6.A stale gate binary is refused. With one target directory shared between checkouts,
target/debug/xtaskis re-linked only on a rebuild.cargo run -p xtaskin main ran the worktree's binary and reported the worktree's baseline as main's. xtask now exits 2 when cargo starts a binary built for another checkout (reproduced). CI was never affected, because each job has a fresh target directory.Evidence:
Fixtures: 11 functions that must be flagged and 7 that must stay live. The old gate, run on the same fixtures in a scratch copy, flagged only
chain_top, and wrongly flaggedby_attribute.Region sabotages, run under
hold-checkout.sh, each a single-line change:all()requiring every argument;Each turned its tests red and was restored green.
On main, four real orphans, now in the baseline (26 → 30):
encode_kzandencode_kzl: only the dormantsend_cwandset_cw_delaycall them;luminance: only the baselinedcontrastcalls it;poll_cat: a test convenience, hidden until now by the trait default's name.R3, R4, R5 and R7 are unchanged on main, compared with a separate target directory per checkout.
Workspace: 616 passed (+4 xtask tests), clippy clean, gate OK, all with
--locked.Ledger 4.55. The audit status table is updated: T, U, X fixed; V documented; W fixed by #248.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Ma4bQKqGNFTYyVSEKPcXRk