Skip to content

refactor(xtask): extract the 47k-line test module out of main.rs (#2119) - #2184

Merged
EffortlessSteven merged 1 commit into
mainfrom
codex/xtask-extract-tests
Jul 22, 2026
Merged

EffortlessSteven merged 1 commit into
mainfrom
codex/xtask-extract-tests

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Summary

First behavior-preserving decomposition slice of #2119: the 120,652-line xtask/src/main.rs monolith was roughly 74k lines of production code + one 47k-line mod tests block. That single test module moves verbatim to xtask/src/tests.rs, still declared mod tests; from the crate root — every test name and the crate::tests module path are unchanged. main.rs drops to ~74k lines; further decomposition (production areas, test areas) is follow-up work.

Zero behavior change is the proof, per the AGENTS.md monolith doctrine:

  • 1213/1213 xtask tests pass at the same names.
  • rustfmt did the reindentation, so raw-string fixtures are byte-identical (a scripted de-indent corrupted them on the first attempt — rustfmt is string-literal-safe; noted in the commit message).
  • Allowlist paths that pinned findings inside the test module were repointed, nothing else changed:
    • 20 semantic entries in policy/no-panic-allowlist.toml (xtask/src/main.rs → xtask/src/tests.rs, exactly the entries the checker reported stale after the move).
    • New devtools entry in .ripr/static-language-allowlist.toml for xtask/src/tests.rs (the regression tests that intentionally contain prohibited terms, moved verbatim).

Validation

  • cargo test -p xtask — 1213 passed, 0 failed
  • cargo clippy -p xtask --all-targets -- -D warnings — clean
  • cargo fmt --check — clean
  • cargo xtask precommit / goldens check / fixtures / dogfood — all exit 0

Follow-ups (not in this PR)

  • Splitting main.rs's 74k production lines by area (policy checks, reports, repo-ops).
  • Splitting tests.rs by area when the next test module hits the module-health threshold.

First behavior-preserving decomposition slice of the 120k-line xtask
monolith: the single mod tests block (46.8k lines) moves verbatim to
xtask/src/tests.rs, declared as mod tests from the crate root, so every
test name and the module path (crate::tests) are unchanged. main.rs
drops to ~74k lines. rustfmt did the reindentation so raw-string
fixtures are byte-identical (a scripted de-indent corrupted them the
first attempt; rustfmt is string-literal-safe). Allowlist paths that
pinned findings in the test module were repointed: 20 semantic entries
in policy/no-panic-allowlist.toml and the devtools entry in
.ripr/static-language-allowlist.toml (new entry naming the moved
regression tests). Zero behavior change: 1213 xtask tests pass, and
precommit, goldens check, fixtures, dogfood, clippy, and fmt are all
clean.
@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 20ca37d9-6087-4cf6-8b67-68a988463b15

📥 Commits

Reviewing files that changed from the base of the PR and between c920d9c and 570c114.

📒 Files selected for processing (4)
  • .ripr/static-language-allowlist.toml
  • policy/no-panic-allowlist.toml
  • xtask/src/main.rs
  • xtask/src/tests.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • EffortlessMetrics/ripr (auto-detected)
  • EffortlessMetrics/perl-lsp (auto-detected)
  • EffortlessMetrics/unsafe-review (auto-detected)
  • EffortlessMetrics/ub-review (auto-detected)

Summary by CodeRabbit

  • Tests
    • Updated static-analysis test configuration to support regression tests containing intentionally prohibited terminology.
    • Corrected panic-policy allowlist references so test-related exceptions point to their current source location.

Walkthrough

Allowlist configuration now recognizes xtask/src/tests.rs as the source of intentional prohibited vocabulary and remaps affected no-panic entries from xtask/src/main.rs to that test file.

Changes

Allowlist relocation

Layer / File(s) Summary
Update xtask test allowlists
.ripr/static-language-allowlist.toml, policy/no-panic-allowlist.toml
Adds a static-language exception for xtask/src/tests.rs and updates affected panic allowlist paths to the same test file.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related issues

  • Issue 2119 — Relocates allowlist references to xtask/src/tests.rs, matching the proposed decomposition of xtask/src/main.rs.

Poem

A rabbit hops through policy lines,
Where test code keeps its quoted signs.
Panic paths now point true,
Static words get clearance too—
Carrots cheer the tidy vines!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary and validation, but it omits most required template sections like scope, links, rollback, and traceability. Add the missing template sections, especially source-of-truth links, scope classification, policy/CI impact, proof, rollback, and traceability.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: extracting the xtask test module from main.rs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/xtask-extract-tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.44.1)
xtask/src/main.rs

ast-grep timed out on this file


Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@EffortlessSteven
EffortlessSteven merged commit b29e755 into main Jul 22, 2026
24 of 25 checks passed

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decision

  • Needs reviewer attention before upstream: findings remain.

Confirmed findings

  • PR body says 1213/1213 tests pass and CI is green; the lane-level public-route check is whether the new mod tests declaration in main.rs and any required [[test]] entry in Cargo.toml still let cargo test --locked --package xtask --test tests resolve the same fixture surface. Run that one focused command before approving the public split; no semantic change is implied.

Verification questions

  • Confirm splitting tests.rs into a sibling module keeps crate::tests paths, and the only behavior-shaped file in the change is policy/no-panic-allowlist.toml (20 path renames + 1 new entry).
  • Confirm xtask::tests is a self-contained submodule that imports only via super::* (dispatch, gates, helpers) and extern crates (serde_json, etc.); the test bodies reference symbols that must still resolve through crate::tests after the split.
  • Confirm the 51+ tests in this file mostly stub inputs and assert structural keys/values or simple counts. They are deterministic on the input shape but do not exercise the production code paths through the actual function arguments; risk of tautological pass if inputs are themselves wrong.
  • Confirm module-level test-name slugs (badge_basics_summary_markdown_omits_forbidden_terms, ci_full_evidence_gate_runner_names_failing_gate, etc.) already pin module::test ordering invariants; moving them wholesale to xtask::tests preserves the gate contract — but no test inside tests.rs asserts that super::SomeType is pub used before being referenced, so if a refactor downstream turns a sibling-in-fixture helper pub-private the test still compiles while the production helper stops being reachable. Verifying the new tests.rs is wired up via mod tests; (not just #[cfg(test)] mod tests;) is the bare minimum.
  • Confirm public API surface in tests.rs mirrors the public API of the file it split from: any super::dispatch, super::Type, super::XtaskCommand the tests need is only reachable if super:: is still pub at the call site. Since the tests body was originally inline in mod tests, the gate was: if main.rs compiles for cargo test --workspace --test, it compiles. After the split, mod tests; declarations in main.rs must compile against the pub use boundary of the new tests.rs file (its own private items are not reachable to siblings), so the same suite that previously was 'just inside the same file' now has to satisfy crate's pub export list. The PR diff does not show pub use changes for the super::dispatch/super::Type/super::XtaskCommand lines that the test body was calling.
  • Confirm main.rs mod tests; now reads only tests; after the move; sibling tests block is the only other mod tests; in the tree.
  • Confirm pR moves a 47,094-line mod tests block out of main.rs to xtask/src/tests.rs verbatim. main.rs drops to ~74,072 lines (~73,000 lines of non-test code). Net: removes 47k lines from main.rs; adds 47k lines to tests.rs.
  • Confirm new tests.rs imports 333 items from super (super::regress, super::test_efficiency_entry, super::fetched_lsp_cockpit_json_value, etc.). This is a single-file super::import surface duplication of every private item the old mod tests used. Adding a new internal helper anywhere in main.rs requires it to be visible to tests.rs (private(crate), or duplicated, or pub use-re-exported.
  • Confirm the 1213+ test names are preserved verbatim across the move; we only confirmed the move is byte-for-byte at the function-name level via grep, not via a green test run. Need a locked cargo test to prove parity.
  • Confirm extracting 47k lines into xtask::tests is a high-risk refactor by line volume. The lane cannot statically prove that no symbol resolution or path-handling code moved between the two files. Central should run the lane1 CI test command + the project's precommit gate to confirm the module compiles, the runtime tests pass, and that downstream crates consuming crate::tests::* symbols see no observable change.

Refuted

Test proof

Parked follow-ups

[review body truncated; see review artifacts]

[review body truncated; see review artifacts]

@EffortlessSteven
EffortlessSteven deleted the codex/xtask-extract-tests branch July 22, 2026 02:59
EffortlessSteven added a commit that referenced this pull request Jul 23, 2026
…main.rs (#2119) (#2283)

Behavior-preserving module extraction, following the #2184/#2221
protocol. The evidence-promotion-honesty gate cluster (honesty options
parsing, corpus validation, typed semantic assertions, pinned external
checkout machinery, external run report, corpus summary report, and the
report-local evidence_promotion_* helpers) moves from main.rs
(37943 -> 33694 lines) into the new flat module
xtask/src/evidence_promotion.rs (4276 lines): 95 top-level fns, 7
structs, 2 enums, and 12 consts, including
parse_json_rejecting_duplicate_keys (#2279).

Moved blocks are byte-identical except visibility widening for the
items main.rs and tests.rs reach through the crate root
(pub(crate) on 10 fns, 5 types, 3 consts, and the fields of the four
structs tests.rs constructs literally). main.rs additions are exactly
the mod declaration plus two re-export blocks (one #[cfg(test)]);
dispatch.rs and tests.rs compile unchanged.

No no-panic, process, or static-language allowlist repoints were
needed: the cluster contains no panic-family calls, no Command::new,
and no prohibited vocabulary, and none of the 17 main.rs-pinned
no-panic containers live in this cluster.

Verified: cargo test -p xtask -- --list count 1262 == base 1262
(sorted lists byte-identical), cargo test -p xtask exit 0 (1260
passed, 0 failed); check-evidence-promotion-honesty and module-health
stdout plus evidence-promotion-honesty.md and corpus-summary.{json,md}
byte-identical to the base build; fmt --check, precommit, and goldens
check (pass, 186 fixtures, zero drift) all exit 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant