Skip to content

Cargo: force --precise fallback for lockstep family updates - #16115

Draft
kbukum1 wants to merge 1 commit into
mainfrom
kbukum1/cargo-futures-lockstep-precise-update
Draft

Cargo: force --precise fallback for lockstep family updates#16115
kbukum1 wants to merge 1 commit into
mainfrom
kbukum1/cargo-futures-lockstep-precise-update

Conversation

@kbukum1

@kbukum1 kbukum1 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Fixes #16092

What are you trying to accomplish?

  • Problem: when a dependency's target version requires sibling crates to move in lockstep (e.g. futures 0.3.34 requires futures-* at ^0.3.34) and those siblings are shared across workspace members, a plain single-package cargo update can't move them and silently leaves the line unchanged.
  • Result: validation sees the dependency still at its old version and errors out.
  • Fix: fall back to a --precise retry only when the plain update leaves the dependency stuck, forcing the coordinated family update.

Anything you want to highlight for special attention from reviewers?

  • Targeted fallback, not a change to the happy path — the --precise retry fires only when the dep is still pinned at its previous version.
  • The "did the plain update move it?" decision compares the dependency's [[package]] entries and its incoming edges before/after, so an edge repointed onto an already-present target entry is correctly treated as a real move (avoids forcing a doomed --precise when the target already coexists).
  • No-regression by design: constraint-driven "Cargo chose a different valid version" and git-dependency paths are intentionally left untouched.

How will you know you've accomplished your goal?

  • New regression test reproduces the stuck lockstep case and asserts the --precise retry resolves it.
  • An unstubbed real-cargo test runs against a workspace fixture built from the actual reproduction, confirming the fallback works end-to-end (not just against a mock).
  • Guard tests confirm the fallback does not fire when the plain update already worked, when Cargo legitimately resolved to a different version, or when the target version already coexists and only an edge is repointed.
  • Validated locally: cargo suite, Sorbet, and RuboCop all pass.

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

Copilot AI balanced review requested due to automatic review settings August 31, 2026 19:04
@kbukum1
kbukum1 requested a review from a team as a code owner August 31, 2026 19:04
@github-actions github-actions Bot added the L: rust:cargo Rust crates via cargo label Aug 31, 2026
@kbukum1
kbukum1 force-pushed the kbukum1/cargo-futures-lockstep-precise-update branch from ea57e6a to adaab52 Compare August 31, 2026 19:07

This comment was marked as resolved.

Copilot AI review requested due to automatic review settings August 31, 2026 19:07

This comment was marked as resolved.

@kbukum1
kbukum1 marked this pull request as draft August 31, 2026 19:11
Copilot AI review requested due to automatic review settings August 31, 2026 19:28
@kbukum1
kbukum1 force-pushed the kbukum1/cargo-futures-lockstep-precise-update branch from adaab52 to 366c51a Compare August 31, 2026 19:28

This comment was marked as resolved.

@kbukum1
kbukum1 force-pushed the kbukum1/cargo-futures-lockstep-precise-update branch from 366c51a to 331bee4 Compare August 31, 2026 20:11
Copilot AI review requested due to automatic review settings August 31, 2026 20:11

This comment was marked as resolved.

Copilot AI review requested due to automatic review settings August 31, 2026 20:27
@kbukum1
kbukum1 force-pushed the kbukum1/cargo-futures-lockstep-precise-update branch from 331bee4 to a51ef7d Compare August 31, 2026 20:27

This comment was marked as resolved.

Copilot AI review requested due to automatic review settings August 31, 2026 20:48
@kbukum1
kbukum1 force-pushed the kbukum1/cargo-futures-lockstep-precise-update branch from a51ef7d to 6f76c1e Compare August 31, 2026 20:48

This comment was marked as resolved.

Copilot AI review requested due to automatic review settings August 31, 2026 21:00
@kbukum1
kbukum1 force-pushed the kbukum1/cargo-futures-lockstep-precise-update branch from 6f76c1e to db216a1 Compare August 31, 2026 21:00

This comment was marked as resolved.

Copilot AI review requested due to automatic review settings August 31, 2026 21:16
@kbukum1
kbukum1 force-pushed the kbukum1/cargo-futures-lockstep-precise-update branch from db216a1 to 6d65198 Compare August 31, 2026 21:17
@kbukum1
kbukum1 requested review from Copilot and removed request for Copilot August 31, 2026 21:17
@kbukum1
kbukum1 force-pushed the kbukum1/cargo-futures-lockstep-precise-update branch from 6d65198 to 9396d70 Compare August 31, 2026 21:23
@kbukum1
kbukum1 requested a balanced review from Copilot and removed request for Copilot August 31, 2026 21:23
@kbukum1
kbukum1 requested a balanced review from Copilot and removed request for Copilot August 31, 2026 21:24

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 3 Medium severity

New issues introduced by this change (3)
Severity Finding
Medium severity cargo/​lib/​dependabot/​cargo/​file_updater/​lockfile_updater.rb — The signature includes each package block verbatim, so a change to the package's outgoing…
Medium severity cargo/​lib/​dependabot/​cargo/​file_updater/​lockfile_updater.rb — This collects only the referenced target strings and discards the parent package for each incoming…
Medium severity cargo/​spec/​dependabot/​cargo/​file_updater/​lockfile_updater_spec.rb — This spec explicitly resolves against the live crates.io registry, making the Cargo suite…
Issues resolved since last review (1)
Severity Finding
Low severity cargo/​spec/​dependabot/​cargo/​file_updater/​lockfile_updater_spec.rb--precise 0.3.34 constrains only the selected futures package; its sibling requirements are… View resolved comment

Comment thread cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb Outdated
Comment thread cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb Outdated
Comment on lines +528 to +530
# exact version and checksum. The siblings are pulled via `^0.3.34`
# requirements and may legitimately resolve to a newer 0.3.x from the
# live registry, so only assert that none of them are left at 0.3.33.
- Enhance lockfile updater to force precise updates for dependencies requiring coordinated version changes.
- Add tests to validate behavior for shared dependency families in various workspace scenarios.
- Introduce necessary fixture files for testing lockstep updates across multiple crates.
Copilot AI review requested due to automatic review settings August 31, 2026 21:45
@kbukum1
kbukum1 force-pushed the kbukum1/cargo-futures-lockstep-precise-update branch from 9396d70 to b31ffc5 Compare August 31, 2026 21:45

Copilot AI 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.

Copilot review overview

🔵 Needs a closer look

Review tier: Balanced
Findings: 1 Medium severity

Pre-existing issues (1)
Severity Finding
Medium severity cargo/​spec/​dependabot/​cargo/​file_updater/​lockfile_updater_spec.rb — This spec explicitly resolves against the live crates.io registry, making the Cargo suite… View comment
Issues resolved since last review (2)
Severity Finding
Medium severity cargo/​lib/​dependabot/​cargo/​file_updater/​lockfile_updater.rb — This collects only the referenced target strings and discards the parent package for each incoming… View resolved comment
Medium severity cargo/​lib/​dependabot/​cargo/​file_updater/​lockfile_updater.rb — The signature includes each package block verbatim, so a change to the package's outgoing… View resolved comment
Suppressed comments (2)

cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb:135

  • This only compares the state immediately around the current command. In a grouped update, an earlier dependency command can already repoint this dependency to the target while retaining the old entry for another constrained consumer; the current plain command then makes no change, this condition returns true, and --precise is run against the legitimately retained old package—the same doomed operation the edge check is intended to avoid. Preserve a pre-run signature (or otherwise detect movement that occurred before this command) and cover the retained-old-entry, multi-dependency case.
          return false if dependency_move_signature(lockfile_before, dependency) !=
                          dependency_move_signature(lockfile_after, dependency)

          package_version_count(lockfile_after, dependency, previous_version).positive?

cargo/lib/dependabot/cargo/file_updater/lockfile_updater.rb:807

  • The parent qualifier omits source, although Cargo can contain two parent packages with the same name/version from different sources. If those parents swap foo versions, both edge arrays sort to the same values, so a real edge move is misclassified as a no-op and the fallback may force a doomed update. Include the parent's source in its identity.
            parent_id = [block[/^name = "[^"]+"$/], block[/^version = "[^"]+"$/]].compact.join(" ")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L: rust:cargo Rust crates via cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cargo updater fails lockstep futures workspace update with unknown_error

2 participants