feat(deps): SemVer merge — Level 2 of multi-version resolution#18
Merged
Sunrisepeak merged 1 commit intomainfrom May 9, 2026
Merged
feat(deps): SemVer merge — Level 2 of multi-version resolution#18Sunrisepeak merged 1 commit intomainfrom
Sunrisepeak merged 1 commit intomainfrom
Conversation
When the transitive walker encounters the same package twice with different pinned versions, AND-combine the two original constraints and re-query the index for a single satisfying version. Bare exact pins like `0.0.1` are treated as `=0.0.1` so they participate cleanly in the AND. If the merged pin differs from the previously-recorded one, the dep is re-fetched at the merged version: the slot in `dep_manifests`/`packages` is replaced in-place, the old `[build].include_dirs` entries are evicted from the main manifest, the new ones are appended, and the new manifest's children are pushed onto the worklist. Same pin → just record the new consumer; no overlap → hard error with a Level-1 mangling hint. Code shape: - `mcpp.pm.resolver::try_merge_semver` is the new public helper. - `cli.cppm`'s resolve loop tracks `originalConstraint` per WorkItem and `constraint` / `depIndex` / `includeDirsAdded` per ResolvedRecord. - The version-source manifest acquisition (install + xpkg-lua field dispatch) is factored into `loadVersionDep` so the merger can re-use it. Tests: new `32_semver_merge.sh` covers the compatible-merge happy path (`=0.0.1` ⨯ `>=0.0.1, <1` → 0.0.1, with the previously-pinned 0.0.2 slot overwritten) and the irreconcilable case (`=0.0.1` ⨯ `=0.0.2` still errors). Existing 31_transitive_deps stays green. CHANGELOG: opens 0.0.3 entry covering both PR #17 (transitive walker) and this one (SemVer merge); the Level-1 mangling fallback follows in a separate PR before tagging 0.0.3.
This was referenced May 9, 2026
Merged
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.
Summary
Layer 2 of the 0.0.3 dep-resolution work (Level 1, multi-version mangling, follows in a separate PR).
When the transitive walker hits the same package twice with different pinned versions, AND-combine the two original constraints, re-query the index, and pick the single concrete version that satisfies both. Bare exacts like
0.0.1are promoted to=0.0.1so they cleanly participate in the AND. If the merged pin differs from what was previously recorded, the dep is re-fetched and its slot indep_manifests/packagesis replaced in-place — the old[build].include_dirsentries are evicted from the root manifest, the new ones appended, and the new manifest's children re-walked.Three outcomes:
=0.0.1⨯=0.0.2) → hard error, with a hint that cross-major / non-overlapping cases land in the upcoming Level-1 mangling fallback PRTest plan
tests/e2e/32_semver_merge.sh— compatible-merge happy path + irreconcilable hard-errortests/e2e/31_transitive_deps.shstill green (path-dep semantics unchanged)