# Internal Engineering Guidelines ## Rust file sizing and layout - Soft cap: keep Rust source files at or below ~400 lines; if a change would exceed that, split into modules first. - Hard cap: avoid exceeding 650 lines in any Rust file; refactor before merging (main.rs should stay <350 lines). - Single-responsibility: group code by concern (config, TLS/setup, auth/session, storage adapters, RPC handlers, CLI parsing) instead of piling into one file. - Structure new features as small modules wired from the entrypoint rather than expanding existing large files. - Co-locate unit tests with their module; keep integration tests in `crates/*/tests` with focused scopes. - Prefer descriptive module names and re-exports over deep `mod` trees that hide logic in `main.rs`.