Skip to content

Expose resolved_ephemerals on pyrer.SolveResult#85

Merged
doubleailes merged 4 commits into
mainfrom
copilot/expose-resolved-ephemerals
May 16, 2026
Merged

Expose resolved_ephemerals on pyrer.SolveResult#85
doubleailes merged 4 commits into
mainfrom
copilot/expose-resolved-ephemerals

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 16, 2026

pyrer.SolveResult had no way to read back the ephemeral packages a solve landed on, blocking drop-in compatibility with rez's Solver.resolved_ephemerals (downstream ResolvedContext.resolved_ephemerals, env-var exports, etc.). The solver already tracked them internally — only the PyO3 surface and the Rust accessor were missing.

Changes

  • rer-resolver: ResolvePhase::solved_ephemerals() walks the final phase's scopes and collects each ephemeral scope's intersected Requirement via the existing PackageScope::get_solved_ephemeral. Solver::resolved_ephemerals() -> Option<Vec<Requirement>> mirrors resolved_packages()None unless Solved.
  • rer-python: new resolved_ephemerals: list[str] field on SolveResult, stringified via Requirement's Display (rez requirement form). Empty list for failed / error.
  • Tests: Rust unit tests + Python tests for request-only intersection, package-requires-contributed ephemerals, empty when no ephemerals participated, and empty/None on failure.

Example

import pyrer

r = pyrer.solve([".feature-1+<3", ".feature-2+", "foo"],
                [pyrer.PackageData("foo", "1.0")])
assert r.status == "solved"
assert r.resolved_ephemerals == [".feature-2+<3"]  # intersected range

Encoding matches resolved / failure_description: rez-style strings the caller re-parses with rez.version.Requirement.

Agent-Logs-Url: https://github.com/doubleailes/rer/sessions/ca234794-b68f-4bbf-832b-9be9ee11ca99

Co-authored-by: doubleailes <23233470+doubleailes@users.noreply.github.com>
Copilot AI changed the title [WIP] Expose resolved ephemerals from pyrer.SolveResult Expose resolved_ephemerals on pyrer.SolveResult May 16, 2026
Copilot AI requested a review from doubleailes May 16, 2026 11:11
doubleailes and others added 2 commits May 16, 2026 16:24
…hemerals

The Vec-returning accessors (`Solver::resolved_packages` /
`resolved_ephemerals`, `ResolvePhase::solved_variants` /
`solved_ephemerals`) force callers that only need to iterate to pay
for an intermediate `Vec` plus, for ephemerals, an owning clone of
each `Requirement`. Add borrowing-iterator siblings so future
consumers can stream without allocating.

New API, additive — every existing Vec method keeps its signature:

  Solver::resolved_packages_iter()  -> Option<impl Iterator<Item = Rc<PackageVariant>>>
  Solver::resolved_ephemerals_iter() -> Option<impl Iterator<Item = &Requirement>>

  ResolvePhase::iter_solved_variants()   -> impl Iterator<Item = Rc<PackageVariant>>
  ResolvePhase::iter_solved_ephemerals() -> impl Iterator<Item = &Requirement>

`iter_solved_variants` still has to clone `self.scopes` internally
because `get_solved_variant` takes `&mut self` (it triggers a
deferred sort on the variant slice); the saving vs the Vec form is
the trailing `.collect()`. `iter_solved_ephemerals` is the bigger
win — pure borrow, zero allocation, no per-element clone.

Refactor the existing Vec methods to delegate to the iter forms so
there's one implementation of the filter logic.

## pyrer wired through

`crates/rer-python/src/lib.rs` switches its `SolveResult` build to
use `resolved_packages_iter` / `resolved_ephemerals_iter`. Two
intermediate `Vec`s skipped per solved result; for ephemerals every
entry is now read by reference instead of cloned then stringified.

## Tests

- `test_iter_resolved_packages_matches_vec_form` and
  `test_iter_resolved_ephemerals_matches_vec_form` in
  `solver::tests` — confirm iter and Vec forms agree on the same
  input and that the iter form returns `None` on a failed solve.
- Existing 5 Python tests for `resolved_ephemerals` still pass
  (the FFI surface is unchanged; just the implementation under it).

## Verification

- `cargo test` (Rust): 41/41 unit tests pass (was 39 + 2 new).
- `cargo test … --ignored` (188-case differential): 188/188 still
  match rez 1:1 in 17.68 s.
- `pytest tests/` (all Python): 80/80.

## Perf (188-case benchmark, same machine as README reference)

| | Total | Mean | Median |
|---|---:|---:|---:|
| README reference (post-#73)          | 11.35 s | 60 ms | 30 ms |
| This branch, pre iter-forms (run 1)  | 11.19 s | 60 ms | 28 ms |
| This branch, pre iter-forms (run 2)  | 11.27 s | 60 ms | 33 ms |
| This branch, post iter-forms (run 1) | 10.90 s | 58 ms | 28 ms |
| This branch, post iter-forms (run 2) | 11.16 s | 59 ms | 30 ms |

Within run-to-run noise; if anything a slight improvement from the
avoided allocations. No regression.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Picks up the resolved_ephemerals feature (issue #84) plus the
borrowing-iterator API additions (`resolved_packages_iter` /
`resolved_ephemerals_iter` on Solver, `iter_solved_variants` /
`iter_solved_ephemerals` on ResolvePhase). The docs version pill,
homepage `repo_version`, and the Quick Start `rer-resolver` dep
example are bumped along with the workspace version so they stay
in sync.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@doubleailes doubleailes marked this pull request as ready for review May 16, 2026 14:28
@qodo-code-review
Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@doubleailes doubleailes merged commit 24babca into main May 16, 2026
23 checks passed
@doubleailes doubleailes deleted the copilot/expose-resolved-ephemerals branch May 16, 2026 14:31
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.

Expose resolved_ephemerals from pyrer.SolveResult

2 participants