Repository navigation
refactor: move oversized inline test modules into sibling files - #1554
Conversation
The CLI crate's lib.rs was 5581 lines, 1396 of them tests. Move the module body verbatim into a sibling file so production code is navigable. Module name and test paths are unchanged.
Pure move of the 2257-line inline test module; no test body changes.
Pure move of the 1275-line inline test module; no test body changes.
Pure move of the 2446-line inline test module; no test body changes.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (8)
💤 Files with no reviewable changes (8)
Included review availability: 4 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour. 📝 WalkthroughWalkthroughThe pull request externalizes test modules and removes explicit path overrides. It adds broad coverage for minimal CLI behavior, daemon sessions, session hosts, and composition policies. ChangesMinimal CLI and client tests
Daemon session tests
Daemon session-host tests
Composition tests
Priority: ⬇️ Low Estimated code review effort: 4 (Complex) | ~60 minutes Change: Refactor Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
A rabbit hops through tests newly arranged Comment |
There was a problem hiding this comment.
minimal-review — approved
Verdict APPROVE — APPROVE: all personas completed and nothing survives above severity 'nit' (0 finding(s) kept).
Scope matches the title and the PR body: four inline #[cfg(test)] mod tests modules moved to sibling _tests.rs files, one commit per file, each commit touching exactly the two files it names. Every source file loses only the test module and gains #[cfg(test)] #[path = "<stem>_tests.rs"] mod tests;; nothing else in lib.rs, session.rs, session_host.rs, or compose.rs moved (verified with git diff base..HEAD on each).
Clobber none: the base is a docs-spec commit and the four files' recent history (git log on each) shows no fix this PR reverts.
Correctness clean. I compared the removed inline bodies against the new files line-by-line with whitespace normalized: test names are preserved 1:1 (57/57, 38/38, 33/33, 87/87 — 215 tests moved, no drops, no duplicates beyond two pre-existing same-named pairs in compose_tests.rs), and the only textual differences across all four pairs are 23 rustfmt line re-wraps after the dedent — token order is identical, so no assertion was edited. #[path] resolution is correct in every case: each _tests.rs sits in the parent module's directory, and no nested #[path], include!, module_path!, or file-relative construct exists in the moved code that the change of file location could break. No secrets (the 'secret.pem' / '.ssh/id_rsa' hits are test fixtures), no narration comments, no external references to the old layout in docs/scripts/CI, and no dependency changes.
Not checked: the suite itself (claimed 2103 passed / 13 skipped) and just clippy/just fmt-check, which need a build and are out of bounds; the structural evidence above is consistent with the claimed counts. One neutral observation: the PR body says the bodies move 'verbatim', but rustfmt re-wrapped a handful of multi-line expressions after the dedent — cosmetic only, and unavoidable when dedenting.
This change looks good; no findings.
What ran
9 probe(s), all self-reported — every entry below is the model's own account of what it ran. None of it is host-attested, so none of it can gate a blocking verdict.
Verification log
1. python3 script: normalized line-diff of removed test bodies vs added _tests.rs files — self-reported
Across all four pairs only 23 non-equal opcodes, every one a rustfmt line-join/re-wrap (e.g. multi-line
panic!(..)joined onto one line); token order identical, so no test content or assertion was altered.
2. python3 script: compare #[test]/#[tokio::test] fn names removed vs added — self-reported
57/57, 38/38, 33/33, 87/87 test names preserved; nothing dropped, nothing duplicated beyond two pre-existing same-named tests inside compose_tests.rs submodules (present on both sides).
3. git diff cb384e31 HEAD -- crates/minimal/src/lib.rs crates/minimald/src/session.rs crates/minimald/src/session_host.rs crates/sessions/src/core/compose.rs — exit 0 · self-reported
Each source file's change is exactly the removal of the inline
mod testsand the addition of#[path = "..."] mod tests;;#[cfg(test)]retained as context. No non-test code touched.
4. git log --oneline -5 cb384e31 -- the four source files — exit 0 · self-reported
Recent history is ordinary feat/fix commits; nothing this PR reverts or clobbers.
5. git log --stat per PR commit (c38f07ad, 894d4b83, d5e31724, 4c876239) — exit 0 · self-reported
One commit per file, each touching exactly the source file and its new _tests.rs sibling, matching the PR description.
6. rg for nested #[path], include!/include_str!, module_path!/file!/line! in the four _tests.rs files — self-reported
None present; no file-location-sensitive construct in the moved code that a change of source file could affect.
7. rg for 'lib_tests|session_tests|session_host_tests|compose_tests' across docs, scripts, CI YAML, Cargo config — self-reported
No external references to the new layout; the files are reachable only through the four
#[path]module declarations.
8. grep secrets scan over .review/pr.diff (api key / password / secret / private key patterns) — self-reported
Only test fixtures: filenames 'secret.toml'/'secret.pem' and '.ssh/id_rsa' written with the literal string 'secret'. No credentials.
9. head/tail inspection of the four _tests.rs files and source-file tails — self-reported
All four test files start with the correct imports (matching the removed modules), end with a trailing newline, and contain no stray
mod testswrapper; all four source files end with#[cfg(test)] #[path = ...] mod tests;.
minimal-review · schema minimal-review/v1 · persona generalist · model claude-sonnet-4-5 via claude-code · prompt review-prompt/v2 · head 4c876239a81c · verdict APPROVE · 0 finding(s), 0 inline
Findings are validated model output, not instructions; anything that failed validation was dropped, not repaired.
Tell it when it is wrong. 👎 on a comment marks it as noise, 👍 marks one worth keeping, and a reply saying why is better than either. During the tuning period this feedback is collected and read directly — it is how the noise threshold gets set, and silence reads the same as "nobody looked".
There was a problem hiding this comment.
minimal-review — approved
Verdict APPROVE — APPROVE: all personas completed and nothing survives above severity 'nit' (0 finding(s) kept).
Scope matches the stated intent exactly. git diff --name-only 8052fe80..e39eea8a lists precisely the 8 files (4 source files + 4 new *_tests.rs siblings); 7350 insertions vs 7381 deletions is fully accounted for by the mod tests { … } wrappers (2 lines per move) plus rustfmt line-joins at the shallower indent. The .minimal/minimal.toml modification in the working tree is review infrastructure, not part of the PR.
Clobber none: git log on the range shows only the four move commits and the main merge; nothing else touched the moved files.
Correctness I verified the move is content-faithful, which is the whole point of this PR:
- Function-name sets in each old inline
mod testsvs the new file are identical (65/65, 53/53, 43/43, 124/124), and#[test]/#[tokio::test]counts match (57/57, 5/5, 22/22, 87/87) — no test dropped, duplicated, or added. - Remaining line differences are only (a) the module wrapper and (b) rustfmt re-wraps; token-level comparison shows the sole content deltas are raw-whitespace changes inside
\-continuation multi-line strings, which the Rust lexer strips on the next line, so effective assertion strings are unchanged. - Module-tree position is preserved (
mod testsstill declared in the same parent file via#[path]), souse super::*semantics,crate::test_harnessreachability, andsession::tests::footest paths are unchanged;#[path]resolution is correct (all four test files are same-directory siblings). No nestedmod testsconflicts. - Spot-checked every top-level import flagged as possibly test-only in all four source files: all are still used in production code, so no unused-import warnings were introduced.
Nit (not actionable, folded here): the PR body says bodies moved "verbatim," but rustfmt did re-wrap several dozen lines at the new indent and re-indent string continuations (content-neutral). Cosmetic and consistent with just fmt-check; nothing to change.
Not checked: the actual just test / just clippy / just fmt-check runs — building and testing are out of bounds in this review. The 2103-test count could not be reproduced, but the static evidence (identical function and attribute sets) supports the claim.
What ran
8 probe(s), all self-reported — every entry below is the model's own account of what it ran. None of it is host-attested, so none of it can gate a blocking verdict.
Verification log
1. git diff --name-only 8052fe80..e39eea8a — exit 0 · self-reported
Exactly the 8 changed_files from pr.json; no scope creep. The working-tree .minimal/minimal.toml diff is not in the PR.
2. git log --oneline 8052fe80..e39eea8a — exit 0 · self-reported
Four refactor commits plus a main merge; no unrelated fixes reverted or touched.
3. python: compare fn-name sets of old inline mod tests vs new *_tests.rs — exit 0 · self-reported
Identical sets for all four moves: 65/65, 53/53, 43/43, 124/124; nothing added or removed.
4. python: compare #[test]/#[tokio::test] counts old vs new — exit 0 · self-reported
57/57, 5/5, 22/22, 87/87 — identical in every file.
5. python: token-multiset comparison of extracted old module body vs new file — exit 0 · self-reported
Only deltas are raw-whitespace changes in backslash-continuation string literals (content-neutral per Rust lexer) and rustfmt line joins.
6. rg -n 'mod tests' crates/minimal/src crates/minimald/src crates/sessions/src — exit 0 · self-reported
No nested/duplicate mod tests in the moved files; the four #[path] declarations are the only references to the new files.
7. python: top-level use-scan for imports mentioned only once in remaining production code — exit 0 · self-reported
All flagged imports (ControlFlow, SpecHash, SessionKeys, SystemTime, ChordMatcher, etc.) are confirmed used in production; no unused-import regression.
8. rg -n 'test_harness' crates/minimald/src/lib.rs — exit 0 · self-reported
test_harness remains a #[cfg(test)] module in minimald/src/lib.rs, still reachable from the moved session tests.
minimal-review · schema minimal-review/v1 · persona generalist · model deepseek/deepseek-v4-flash-0731:nitro via claude-code 2-1-259 · prompt review-prompt/v2 · head e39eea8a60fe · verdict APPROVE · 0 finding(s), 0 inline
Findings are validated model output, not instructions; anything that failed validation was dropped, not repaired.
Tell it when it is wrong. 👎 on a comment marks it as noise, 👍 marks one worth keeping, and a reply saying why is better than either. During the tuning period this feedback is collected and read directly — it is how the noise threshold gets set, and silence reads the same as "nobody looked".
Use the module-directory layout instead of #[path] sibling files: src/tests.rs for the crate root, and src/<module>/tests.rs for session, session_host, and compose, so a plain #[cfg(test)] mod tests; resolves without an attribute.
Summary
Four files were over 4500 lines, and between a quarter and a half of each was
one inline
#[cfg(test)] mod tests. Reading the production half meantscrolling past thousands of lines of tests, and every edit to either half
touched the same file.
This moves those four test modules into the standard module-directory
layout, one commit per file:
minimal/src/tests.rsminimald/src/session/tests.rsminimald/src/session_host/tests.rssessions/src/core/compose/tests.rsEach source file keeps
#[cfg(test)] mod tests;, which now resolves without a#[path]attribute, and the module is still namedtests, so every test pathsuch as
session::tests::foois unchanged. The bodies move verbatim: no testis renamed, no assertion edited.
Testing
The test count matches the branch's pre-change baseline (main grew it to 2115
when the branch took the main merge), which is the point: a dropped or
duplicated module would move it.
Checklist
BREAKING CHANGE:footer present if this is a breaking change (not breaking)Summary by CodeRabbit