Skip to content

refactor: split satisfiability/mod.rs into focused submodules#5993

Merged
baszalmstra merged 4 commits intoprefix-dev:mainfrom
baszalmstra:claude/split-satisfiability-module-7CU7r
May 1, 2026
Merged

refactor: split satisfiability/mod.rs into focused submodules#5993
baszalmstra merged 4 commits intoprefix-dev:mainfrom
baszalmstra:claude/split-satisfiability-module-7CU7r

Conversation

@baszalmstra
Copy link
Copy Markdown
Contributor

The 5304-line crates/pixi_core/src/lock_file/satisfiability/mod.rs grown 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.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.

claude added 2 commits May 1, 2026 14:22
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
@baszalmstra baszalmstra changed the title Claude/split satisfiability module 7 cu7r refactor: split satisfiability/mod.rs into focused submodules May 1, 2026
claude added 2 commits May 1, 2026 14:58
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
@baszalmstra baszalmstra merged commit 6ebf706 into prefix-dev:main May 1, 2026
37 checks passed
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.

2 participants