Skip to main content

Module module_lines

Module module_lines 

Source
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):

  1. a file may not grow past its ceiling;
  2. a file not listed may not reach THRESHOLD;
  3. an entry whose file is under THRESHOLD, or gone, or renamed, must be deleted;
  4. a file that shrinks but stays over keeps its looser ceiling until cargo xtask module-lines --apply rewrites 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§

ModuleLines
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), which read_ceilings would 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 every src/**/*.rs file 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
path relative to root, joined with / whatever the platform separator is. Built from components(), not by rewriting \\ in a string, so a literal backslash in a Unix file name is left alone and Path::display on 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 \\.