Skip to content

refactor: Round-trip build- and host-packages of conda source packages - #5958

Merged
baszalmstra merged 4 commits into
prefix-dev:feature/lockfile-v7from
hunger:push-lqqlxtykmkkx
Apr 24, 2026
Merged

baszalmstra merged 4 commits into
prefix-dev:feature/lockfile-v7from
hunger:push-lqqlxtykmkkx

Conversation

@hunger

@hunger hunger commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Description

Round trip build- and host packages from the LockFile all the way through pixi.

The biggest challenge is to not map the same data into the different Arcs (inside *PixiRecord) over and over again.

How Has This Been Tested?

Some new tests:-)

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: Claude

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added sufficient tests to cover my changes.
  • I have verified that changes that would impact the JSON schema have been made in schema/model.py.

hunger added 3 commits April 24, 2026 12:10
…ersal

Resolving build_packages/host_packages from a lockfile requires walking the
full package table to match handles to UnresolvedPixiRecord values. Without a
resolver, every call site does its own ad-hoc scan.

This commit introduces LockFileResolver which builds once in DFS post-order
(so dependencies are ready before dependents) and caches the result per
package via pointer-offset arithmetic — O(1) lookup with no HashMap
allocation. Cycle detection gives a named path for debugging.
Now that LockFileResolver exists, thread it through the update pipeline so
every satisfiability check and record-lookup goes through a single,
lazily-built resolver rather than constructing per-package scans ad-hoc.

LockFileDerivedData holds a OnceCell<Arc<LockFileResolver>> populated on first
use; UpdateContext carries an optional pre-seeded resolver for cases where the
caller already built one. This eliminates the repeated full-table scans that
the old locked_packages_to_unresolved_records helper performed.
When writing the lock file, source packages must carry their build_packages
and host_packages as PackageHandle references so downstream solvers can
reconstruct the build graph. Previously these fields were populated on read
but dropped on write.

This change wires UnresolvedPixiRecord::into_conda_package_data through the
LockFileBuilder so each source record registers its deps recursively before
returning its own handle.
Add fixture-driven round-trip tests that load a .lock file, run the
satisfiability resolver, and verify that the re-serialised lockfile is
byte-identical to the fixture.

The nested_source_build_dep fixture specifically exercises the recursive
case where a source package lists another source package as a build
dependency, ensuring the DFS traversal in LockFileResolver actually fires
on the recursive branch.
@hunger
hunger force-pushed the push-lqqlxtykmkkx branch from 0021da7 to 3369e96 Compare April 24, 2026 12:58
@baszalmstra
baszalmstra merged commit 322f5d3 into prefix-dev:feature/lockfile-v7 Apr 24, 2026
36 of 37 checks passed
@hunger
hunger deleted the push-lqqlxtykmkkx branch April 24, 2026 13:34
baszalmstra added a commit to baszalmstra/pixi that referenced this pull request Apr 24, 2026
Integrates prefix-dev#5958 on top of source-build-compute-engine. Adds:

- LockFileResolver: single-pass topological walk of lock-file packages
  that produces UnresolvedPixiRecord with build_packages/host_packages
  populated from predecessors. Built once per update/satisfiability run
  and shared across platforms.
- Hash/Eq/PartialEq on PixiRecord, UnresolvedPixiRecord, SourceRecord<D>
  (HashMap<String,SourceLocationSpec> -> BTreeMap for Hash).
- SourceRecordRequiresRebuild pessimistic stopgap for mutable/partial
  records in satisfiability (matches upstream). TODO to replace with
  backend-spec-vs-locked-packages check lives with the code.
- resolve_dev_dependencies takes a single WorkspaceEnvRef instead of
  channels/build_env/variants; adapted both call sites (satisfiability
  and update's spawn_extract_environment_task).
- Test fixtures for nested source-build deps and round-tripped build/host
  packages.

Adapts to the Key-based dispatcher API on this branch: uses
SolvePixiEnvironmentKey + EnvironmentRef/EnvironmentSpec in place of the
retired command_dispatcher.solve_pixi_environment; uses
engine().with_ctx(...).pin_and_checkout for source pinning.
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