You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(uninstall): resolve repaired parents by exact lock key for virtual siblings (#4823) - #4848
Stacked on #4811 (Fixes#4804): it contains #4811's commits until that lands, so review only the last commit (d68b449) and its changelog fragment. Land after #4811.
Sibling virtual packages from one repository (for example test/mono/d and test/mono/e) share the legacy parent identity test/mono, their repo_url. When apm uninstall test/mono/e kept e because d still needs it, the depth repair looked parents up by that shared identity, could take e as its own parent, and recorded depth 3 instead of 2. The next full install then rewrote the lock.
deps/reachability.py: the walk records each node's exact parent lock key (ReachabilityResult.parent_keys), which is also the nearest-parent tie key, as in install's _select_nearest_parent.
install/orphans.py: a rescued root resolves its parent by that exact key. Recorded legacy edges go through the lock parent placement owner (deps/lock_parent_placement.py) with installed-manifest evidence. An entry is never its own parent; an unresolved parent keeps the recorded depth.
No file is deleted and no lock row is kept by this change. The lockfile format and dependency resolution are unchanged.
Human scope-approval comment: #4823 (apm-scope:v1 record, first comment)
Does this PR complete the issue, or what remains? It completes the issue.
apm-spec-waiver: uninstall lock-metadata repair resolves parents by exact lock key; no OpenAPM-observable behaviour changes
Type of change
Bug fix
New feature
Documentation
Maintenance / refactor
Testing
Tested locally
All existing tests pass
Added tests for new functionality (if applicable)
promise: P-INV-I2 -- the lock after uninstall equals what a following full install (--no-frozen) writes (source: .agents/skills/apm-lifecycle-tests/SKILL.md)
cell: OP=uninstall SRC=git(virtual subdirectory) LOCK=legacy(no replacements) GRAPH=sibling d -> e, both direct owner: install/orphans.py (decide_orphan_removal) + deps/reachability.py
instrument: today test -> tests/integration/test_uninstall_shared_direct_dependency_lifecycle.py::test_uninstall_of_a_virtual_sibling_never_parents_it_to_itself (extends the #4749/#4804 module)
oracles: [I2] decisive: e row depth == 2 and lock bytes unchanged by `apm install --no-frozen`
failing-before: pytest <node> -n 0 -> 1 failed (assert 3 == 2)
passing-after: module + test_deps_reachability + test_uninstall_shared_diamond_dependency + test_uninstall_transitive_cleanup + install/test_orphan_removal_owner + deps/test_lock_parent_placement, CI=true, -n 2 -> 55 passed
guard+mutation: n/a ledger: 4823
hints executed: none printed
Lint chain (local), all clean:
ruff check / format --check (0.15.12)
lint_architecture_boundaries.py --root .
pylint R0801
lint-auth-signals
complexity ratchet
tests.quality.taxonomy --changed
check_test_assertions.py
tests.lifecycle.generator --check
Changelog
One fragment per section, changelog.d/<pr>.<section>.md, holding
one line: user-visible effect first, 25 words or fewer, ending with (#PR); breaking changes only under upgrade notes; no Highlights; no
new lines under ## [Unreleased]. See changelog.d/README.md and .github/instructions/changelog.instructions.md.
After apm uninstall keeps a dependency a surviving package still needs
(#4749), the repaired lock metadata now matches a fresh install:
- the reachability walk applies install's nearest-parent tie rule
(lowest parent key at equal depth),
- depths are computed over the repaired parent graph, parents first,
so chained rescued roots nest correctly,
- dev-only status is repaired across the rescued subtree while any
surviving production path keeps an entry production.
Lifecycle cells assert the lock after uninstall is byte-identical to
what a following full apm install writes.
Fixes#4804
Co-authored-by: Copilot App <[email protected]>
… only from proof
Review follow-ups on #4811:
- The walk's nearest-parent rule ranks by depth then parent key,
regardless of each path's dev status, as the resolver does; a
lifecycle cell with production b and dev a both needing e asserts a
byte-identical reinstall (red before: install rewrote resolved_by).
- Still-needed rows take dev status only from the decision's proven
rescued_dev, never from the first edge's flag.
Virtual-sibling identity depth: #4823.
Co-authored-by: Copilot App <[email protected]>
…esolves
Under CI=true an install with an existing lockfile defaults to frozen
and withholds lockfile writes, which made the byte-identical reinstall
oracle vacuous in CI.
Co-authored-by: Copilot App <[email protected]>
…l siblings
Sibling virtual packages from one repository share the legacy parent
identity (their repo_url), so the depth repair could take a rescued
package as its own parent. The reachability walk now records each
node's exact parent lock key (also the nearest-parent tie key, as in
install), rescued roots resolve their parent by it, and recorded legacy
edges go through the lock parent placement owner; an entry is never its
own parent. A lifecycle cell with test/mono/d declaring test/mono/e
asserts a byte-identical reinstall after uninstalling test/mono/e.
Fixes#4823
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The local-parent fallback records an absolute path instead of its lock key, preventing parent resolution and leaving a rescued dependency at the wrong depth after uninstall.
This PR addresses #4823 by resolving repaired parents through exact lock keys, preventing virtual sibling packages from being mistaken for their own parents during uninstall. It builds on #4811's lock-metadata repairs without changing the lockfile format or dependency resolution.
Changes:
Carry exact parent keys through the reachability walk.
Resolve legacy parent edges through the existing placement owner, preserving depth when a parent cannot be resolved.
Add a virtual-sibling lifecycle regression that checks lockfile stability after a full reinstall.
…ement when nothing is rescued
- A surviving local parent is not in the walk's candidate directory
index, so its recorded parent key was an absolute path and the depth
repair could not find the row. The walk falls back to the parent's
own unique key, and the resolver falls back to the repaired identity
when an exact key is not a lock row. Red-first cell: ./vendor/d
declaring test/e, uninstall test/e, depth 2 and byte-identical
reinstall (depth stayed 1 before).
- The depth repair returns early without rescued roots and reads
installed manifests for legacy placement only when a descendant needs
it, so uninstalls that rescue nothing do no extra manifest I/O (this
also restores the MagicMock-lockfile engine unit tests).
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Unresolved legacy placement can incorrectly attach a descendant to a rescued sibling and change its recorded depth; it should use _UNKNOWN_PARENT to preserve depth while retaining None for direct rows.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Preserve recorded depth for unresolved legacy placement
src/apm_cli/install/orphans.py:708
When legacy placement cannot disambiguate a recorded edge, key in placed() is false and the fallback selects the last sibling with that repository identity anyway. If a sibling's installed manifest is unreadable, this can attach a descendant to a rescued sibling and change its depth from 2 to 3 without establishing its actual parent. Treat unresolved legacy placement as _UNKNOWN_PARENT so the recorded depth stays unchanged, while retaining None for direct rows.
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
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.
Description
Stacked on #4811 (Fixes #4804): it contains #4811's commits until that lands, so review only the last commit (d68b449) and its changelog fragment. Land after #4811.
Sibling virtual packages from one repository (for example
test/mono/dandtest/mono/e) share the legacy parent identitytest/mono, theirrepo_url. Whenapm uninstall test/mono/ekeptebecausedstill needs it, the depth repair looked parents up by that shared identity, could takeeas its own parent, and recorded depth 3 instead of 2. The next full install then rewrote the lock.deps/reachability.py: the walk records each node's exact parent lock key (ReachabilityResult.parent_keys), which is also the nearest-parent tie key, as in install's_select_nearest_parent.install/orphans.py: a rescued root resolves its parent by that exact key. Recorded legacy edges go through the lock parent placement owner (deps/lock_parent_placement.py) with installed-manifest evidence. An entry is never its own parent; an unresolved parent keeps the recorded depth.No file is deleted and no lock row is kept by this change. The lockfile format and dependency resolution are unchanged.
Issue and approved scope
Issue: Fixes #4823
Human scope-approval comment: #4823 (apm-scope:v1 record, first comment)
Does this PR complete the issue, or what remains? It completes the issue.
apm-spec-waiver: uninstall lock-metadata repair resolves parents by exact lock key; no OpenAPM-observable behaviour changes
Type of change
Testing
Lint chain (local), all clean:
ruff check/format --check(0.15.12)lint_architecture_boundaries.py --root .lint-auth-signalstests.quality.taxonomy --changedcheck_test_assertions.pytests.lifecycle.generator --checkChangelog
changelog.d/<pr>.<section>.md, holdingone line: user-visible effect first, 25 words or fewer, ending with
(#PR); breaking changes only under upgrade notes; no Highlights; nonew lines under
## [Unreleased]. Seechangelog.d/README.mdand.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regenerated