refactor: split satisfiability/mod.rs into focused submodules#5993
Merged
baszalmstra merged 4 commits intoprefix-dev:mainfrom May 1, 2026
Merged
Conversation
The 5304-line `crates/pixi_core/src/lock_file/satisfiability/mod.rs` grown during the lockfile-v7 refactor is split along natural seams into six sibling files behind a thin orchestrator: - `errors.rs` (700 LOC): EnvironmentUnsat, PlatformUnsat, SolveGroupUnsat, mismatch structs, fmt helpers, From impls. - `environment.rs` (380 LOC): verify_environment_satisfiability, PypiNoBuildCheck, PypiWheelTagsCheck, verify_pypi_indexes, verify_exclude_newer. - `pypi.rs` (827 LOC): pypi_satisfies_*, lock_pypi_packages, read_local_package_metadata, BuildMetadataContext. - `platform.rs` (1293 LOC): VerifySatisfiabilityContext, verify_platform_satisfiability, the main package walker, dev-deps, conda matchers, solve-group verifier. - `source_record.rs` (788 LOC): backend re-verification of partial / mutable source records. - `tests.rs` (1423 LOC): all `#[cfg(test)]` content. `mod.rs` is reduced to 44 lines of submodule declarations and `pub use` re-exports preserving every existing import path; downstream callers (`lock_file::mod.rs`, `outdated.rs`, `update.rs`, etc.) and the snapshot files under `satisfiability/snapshots/` are unaffected. Pure relocation — no logic changes. https://claude.ai/code/session_01B5cagUz7KyQdqu7qXiV8sS
Following the file split, the giant `tests.rs` is broken up so each
module owns its own `#[cfg(test)] mod tests { ... }`:
- `pypi.rs`: `pypi_satisfies_*` checks, index-mismatch regressions,
`PypiNoBuildCheck` regression test, plus the `lock_for_test` helper.
- `source_record.rs`: the entire `backend_verification` test set
(`variants_equivalent`, `verify_locked_against_backend_specs`,
`diff_dep_sequences`, `verify_locked_run_deps_against_backend`,
`build_full_source_record_from_output`).
- `tests.rs`: kept for the cross-cutting orchestration tests
(`test_good_satisfiability`, `test_failing_satisfiability`, `q`)
plus the `verify_lockfile_satisfiability` harness and
`LockfileUnsat` shim. Module path is preserved so the existing
`satisfiability/snapshots/*.snap` files keep matching.
With tests living next to their code, items previously promoted to
`pub(crate)` so an out-of-module `tests` could see them
(`variants_equivalent`, `diff_dep_sequences`,
`verify_locked_against_backend_specs`,
`verify_locked_run_deps_against_backend`,
`build_full_source_record_from_output`, `DepDiff`) revert to private
visibility — children of a module can see its private items.
The `#[cfg(test)] pub(super) use source_record::*` trampoline in
`mod.rs` is no longer needed.
127 satisfiability tests pass against the new layout.
https://claude.ai/code/session_01B5cagUz7KyQdqu7qXiV8sS
Three CI failures caught after the colocate split:
1. `cargo fmt` reformatted import groups across the new files: a single
`cargo fmt -p pixi_core` run reproduces upstream's preferred ordering
(mixing `crate::*` with third-party imports inside one block, single-
line `use foo::{a, b}` where it fits 100 cols, etc.).
2. Clippy's `doc_lazy_continuation` flagged the `tests.rs` module-level
`//!` doc comment because the wrapped lines look like list-item
continuations. Switched to a regular `//` block comment — the prose
isn't really API docs and doesn't need rendering.
3. `test_unix_absolute_path_handling` failed on Windows because the
`#[cfg(not(target_os = "windows"))]` attribute was lost when the
test was extracted from the colocated split: the `sed` range I used
started one line below the cfg attr. Restored it.
`cargo fmt --check`, `cargo clippy --workspace --tests -- -D warnings`,
and `cargo test -p pixi_core --lib lock_file::satisfiability` (127
passed) all green.
https://claude.ai/code/session_01B5cagUz7KyQdqu7qXiV8sS
Audit of the relocation flagged three faithfulness deviations:
1. `registry_requirement_with_index` lost its single-line `///` doc
comment when the pypi tests were extracted into `pypi.rs::tests`.
Restored verbatim from baseline.
2. The original `mod tests` in the monolithic file had a nested
`mod backend_verification {}` wrapper carrying a 3-line doc comment.
With the source-record tests now living in their own dedicated
`source_record::tests` module, the wrapper's grouping role is gone,
so the doc comment is reattached to the `mod tests` block itself.
3. `errors.rs` had CRLF line terminators (single sibling in the
directory with that quirk — every other file uses LF). Normalized
to LF so future diffs aren't poisoned.
`cargo fmt --check` clean, 127 satisfiability tests pass.
https://claude.ai/code/session_01B5cagUz7KyQdqu7qXiV8sS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The 5304-line
crates/pixi_core/src/lock_file/satisfiability/mod.rsgrown over time is split along natural seams into six sibling files behind a thin orchestrator:errors.rs(700 LOC): EnvironmentUnsat, PlatformUnsat, SolveGroupUnsat, mismatch structs, fmt helpers, From impls.environment.rs(380 LOC): verify_environment_satisfiability, PypiNoBuildCheck, PypiWheelTagsCheck, verify_pypi_indexes, verify_exclude_newer.pypi.rs(827 LOC): pypi_satisfies_*, lock_pypi_packages, read_local_package_metadata, BuildMetadataContext.platform.rs(1293 LOC): VerifySatisfiabilityContext, verify_platform_satisfiability, the main package walker, dev-deps,conda matchers, solve-group verifier.
source_record.rs(788 LOC): backend re-verification of partial / mutable source records.tests.rs(1423 LOC): all#[cfg(test)]content.mod.rsis reduced to 44 lines of submodule declarations andpub usere-exports preserving every existing import path; downstream callers (lock_file::mod.rs,outdated.rs,update.rs, etc.) and the snapshot files undersatisfiability/snapshots/are unaffected.Pure relocation, no logic changes.