Expand description
The module-size ratchet (#4085, slice 2.0 of the back-half paydown track, spine #3676).
Q5 of the track: no source file may newly cross THRESHOLD production lines, and an
existing one may not grow. This module measures production lines per src/**/*.rs file
(comments and blank lines count; #[cfg(test)] modules, whole-test files and files
declared away by #[cfg(test)] mod name; do not) and compares the back-half crates’
files (BACK_HALF_CRATES) at or over the threshold against the committed ceilings in
xtask/module-line-ceilings.txt. The module_lines trend probe reads the same
measure, workspace-wide, so the trend and the gate share one definition.
The rule is a ratchet in the way the function-length ratchet is (crate::fn_length):
- a file may not grow past its ceiling;
- a file not listed may not reach
THRESHOLD; - an entry whose file is under
THRESHOLD, or gone, or renamed, must be deleted; - a file that shrinks but stays over keeps its looser ceiling until
cargo xtask module-lines --applyrewrites the file from the tree.
The track’s exit cap is EXIT_CAP production lines: no entry may be at or over it. The
files that were already over it when the ratchet landed were exempt until Phase 2’s splits
took each one under; the last went in 2.5b (#4090), and the exemption was then retired.
Keys are crate/src/path.rs from the repository root with / separators on every
platform (repo_rel_slash); Windows CI runs the gate.
Structs§
- Module
Lines - One measured file.
Constants§
- BACK_
HALF_ CRATES - The crates of the “back half” (track §8): the ratchet’s scope and the probe’s back-half reading.
- CEILINGS_
FILE - The committed ceilings, relative to the repository root.
- EXIT_
CAP - The track’s exit target: no back-half file at or over this many production lines. It binds every ceiling.
- THRESHOLD
- Files of at least this many production lines are tracked.
Functions§
- malformed_
ceiling_ lines - Lines of the committed ceilings file that are neither blank, a comment nor
file = lines(foo.rs = 10,717), whichread_ceilingswould otherwise drop silently. - measure
- The ratchet’s universe: the back-half crates’ files at or over
THRESHOLD, longest first, ties by path. - measure_
workspace (path from the repo root, production lines)for everysrc/**/*.rsfile of every top-level crate in the workspace (the trend probe’s universe).- read_
ceilings - The committed ceilings:
file = lines, one per line;#starts a comment. - render_
ceilings - The ceilings file’s text for a measurement: every back-half file at or over the threshold, at its current length.
- repo_
rel_ slash pathrelative toroot, joined with/whatever the platform separator is. Built fromcomponents(), not by rewriting\\in a string, so a literal backslash in a Unix file name is left alone andPath::displayon Windows cannot leak a\\into a key (#4026).- violations
- What is wrong, if anything: a file past its ceiling, one that newly crossed the
threshold, an entry that no longer names a file over it, a new entry at or over
EXIT_CAP, and a key with a\\.