roadmap BUILT

878. The line editor's inline modules move to their own files

(The title and slug are provisional.)

line_editor's src/lib.rs is 2,290 lines at 396187b0b. §266 (a Rust source file stays under 2,000 lines) sets the ceiling. Milestone 840 (the scheduler file is split along its seams) is the model for this block.

The cut and every file name below are calef's call. A lane routes them to calef as the routing tenet says, before it moves a line.

The lane wrote it up on 2026-10-12 (UTC) as §295 (the line editor's crate root splits into module files). It asked nothing, because three later decisions answer its questions, and the maintainer recorded it as settled by precedent on #1969 on 2026-10-12 (UTC). They are §274 (the filesystem-protocol crate root splits into its module files), §275 (the file server core's tests move into child modules by topic) and §282 (when a file is split, the parent becomes an index). §282 takes the cut further than the layout below. LineDisc, RawQueue and the output side leave lib.rs too, and it becomes an index. §295 has the layout as built.

Reuse: not applicable; this moves code and adds none. The seams are already drawn: the file holds three public inline modules, proto, component and handoff. The last two came with milestone 23 (a capability-routed component OS with live replacement) on 2026-09-27, which is most of the growth.

What is in the file

Measured on 396187b0b from the file's own top-level items. Ranges are approximate at the edges, where a doc comment belongs to the item below it.

lines count what
1 to 144 144 crate docs, #![no_std]
145 to 330 186 pub mod proto: the terminal contract's opcodes, flags and word packing
332 to 828 497 Sink, the limits, Event, LineDisc and its one impl block
830 to 898 69 RawQueue
900 to 948 49 expand_output and the cursor-move helpers
950 to 1134 185 pub mod component: the two capability declarations and their const checks
1136 to 1310 175 pub mod handoff: the state blob a replacement reads
1312 to 2290 979 mod tests, 54 #[test] functions

Of the 54 tests, two test proto alone (24 lines) and six test handoff (182 lines). The other 46 test LineDisc, RawQueue and expand_output. component has no #[test]; its checks are ten const assertions inside it, which travel with it.

The verdict: split along the three modules, and keep the editor's tests beside it

Two axes were weighed.

The recommendation is by module. It is the cut the code already made, and it keeps each piece's tests beside it. LineDisc is one type and is not cut. Its tests could leave as well, which would take lib.rs to about 770. Nothing needs that, and it can wait for the file to grow again.

RawQueue stays in lib.rs. handoff saves and restores its private fields, and a sibling module could not see them without pub(crate).

A proposed layout

Every name here is provisional. The three modules stay pub mod in lib.rs, so line_editor::proto, line_editor::component and line_editor::handoff resolve as today.

file, provisional from the table about
lib.rs 1 to 144, 332 to 948, the 46 editor tests 1,540
proto.rs 145 to 330, with its 2 tests 215
component.rs 950 to 1134 185
handoff.rs 1136 to 1310, with its 6 tests 365

Two of the six handoff tests drive a LineDisc on the tests' Screen model. Screen and feed_all become pub(super) inside #[cfg(test)] mod tests, so handoff's own test module can reach them. That widens test code only.

What an architect has to rule

  1. By module, or tests only. The recommendation is by module, for the reasons above. They hold at equal cost, so the recommendation is not about effort.
  2. Whether the editor's 46 tests stay in lib.rs or move to tests.rs. The recommendation is that they stay, since lib.rs ends 460 lines under the ceiling.
  3. Every file name in the table. The module names are unchanged.

No public crate API, wire format or system call changes under any answer here.

What moving the code breaks

Found with grep at 396187b0b. A lane has to carry each one.

Done when

  1. line_editor's src/lib.rs is under 2,000 lines, and no new file is over 1,500.
  2. The crate's 54 host tests and its doc tests pass with no test body changed.
  3. No Rust file outside line_editor's src/ changes, and no shipped item's visibility widens.
  4. script/lint passes with the file-length row gone, and the mutation ledger's keys match cargo mutants --list.
  5. cargo doc for the crate reports no broken intra-doc link.
  6. script/test passes on aarch64, riscv64 and x86_64.

What was built

Built 2026-10-12 (UTC) on 17b23264e. lib.rs went from 2,290 lines to 198, an index with no exception, and its file-length row is gone. The largest new file is line_disc/tests.rs at 576. The crate's 54 tests and 3 doc tests pass with no test body changed, and cargo doc reports no broken link. The 12 mutation-ledger keys that lost their handoff:: prefix are rewritten. Every new module and file name is provisional.

Follow-on

Index row

The line editor's file is 2,290 lines, and most of its growth is two modules added inline for live replacement. This moves proto, component and handoff into their own files, each with its tests, behind unchanged public paths. Under §282 LineDisc, RawQueue and the output side move too, and lib.rs becomes a 198-line index. Every file name is provisional.