Repository navigation
fix(uninstall): derive kept rows' parent, depth and dev status graph-wide (#4833) - #4870
Merged
Daniel Meppiel (danielmeppiel) merged 3 commits intoNov 23, 2026
Conversation
…wide After a declaration-only uninstall, the repair followed only the kept dependency's recorded subtree. The reachability walk now records every declaring edge and solves shortest depth and nearest parent (lowest key at equal depth) over the whole graph from the surviving direct declarations, independent of dev-status propagation. Uninstall repairs parent, depth and dev status for every row the walk reaches from the kept dependencies; replacement root requests are still dropped only for the removed declarations. Lifecycle cells (descendant re-parenting, a shorter dev path through an already-walked package, shared-descendant dev status) assert a byte-identical full reinstall; all three failed before. Fixes #4833 Co-authored-by: Copilot App <[email protected]>
…eppiel-4833-graph-wide-lock-repair
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 23, 2026 00:59
Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A shared local descendant can incorrectly remain marked as production after its last production path is removed, requiring exact lock-key matching and a regression test.
1 open issue
What changed in this PR
Updates declaration-only apm uninstall metadata repair to follow the surviving dependency graph, aiming to keep retained lock rows consistent with a full install and address #4833.
Changes:
- Computes shortest depths and nearest parents across all recorded declaring edges.
- Applies parent, depth and dev-status repairs beyond the recorded subtree, preserving surviving replacement root requests.
- Adds three lifecycle regression cases, a bug-ledger entry and a changelog fragment.
| File | Description |
|---|---|
tests/integration/test_uninstall_shared_direct_dependency_lifecycle.py |
Adds three cases checking metadata and byte-stable reinstall. |
tests/fixtures/lifecycle_bug_ledger/bugs/4833.json |
Records failure modes and regression coverage. |
src/apm_cli/install/orphans.py |
Derives repair metadata for graph-reachable affected rows. |
src/apm_cli/deps/reachability.py |
Records declaring edges and solves graph-wide placement. |
src/apm_cli/commands/uninstall/cli.py |
Applies repairs and limits root-request removal to removed declarations. |
changelog.d/4870.fixed.md |
Documents the uninstall metadata fix. |
Review effort: Balanced
This was referenced Nov 23, 2026
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-4833-graph-wide-lock-repair
branch
November 23, 2026 06:49
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.

Description
After a declaration-only
apm uninstall(the dependency stays because a surviving package still needs it, #4749), the lock repair followed only the kept dependency's recordedresolved_bysubtree. Three cases left metadata that differed from what a full install writes (#4833).Fix:
deps/reachability.py: the walk records every declaring edge (_ParentGraph) and, after the walk, solves shortest depth over the whole graph from the surviving direct declarations, production and dev alike. Each node's parent is its nearest declaring parent, ties to the lowest key, asAPMDependencyResolver._select_nearest_parentdoes. NewReachabilityResult.depthsandgraph_children. Dev status keeps the walk's own production-first propagation.install/orphans.py: the decision returnsrescued_parents,rescued_depthsandrescued_devfor every row the walk reaches from the kept dependencies, not only the recorded subtree. A partial walk repairs only the reached roots and proves production, never its absence. This replaces fix(uninstall): resolve repaired parents by exact lock key for virtual siblings (#4823) #4848's subtree and placement resolver, whose cells still pass.commands/uninstall/cli.py: applies parent, depth and dev status to every affected row. Replacement root requests are dropped only for the removed declarations.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 #4833
Human scope-approval comment: #4833 (apm-scope:v1 record)
Does this PR complete the issue, or what remains? It completes the issue.
apm-spec-waiver: uninstall lock-metadata repair mirrors existing install resolver rules; 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