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): refuse a still-needed local dependency before any write (#4882) - #4890
Stacked on #4870 (Fixes#4833): it contains #4870's commits until that lands, so review only the commits after fa1a547 (this fix and its changelog fragment). Land after #4870.
apm uninstall ./vendor/e, where ./vendor/e is a direct local dependency that another installed package (./vendor/d) still needs, removed only the apm.yml declaration (#4749's declaration-only path). A local lock key includes declaring_parent and anchored_local_path, so the kept row no longer matched the transitive identity install derives (local:vendor/e). apm install --frozen then failed: "local:vendor/e is declared in apm.yml but missing from apm.lock.yaml". A probe found no file deleted or kept wrongly in any follow-up (uninstall/prune, with and without reinstall). The defect was the frozen failure and lock drift.
Ruling (P3, B-safe for 0.38.0): when a still-needed root is LOCAL, uninstall refuses before any write:
[x] ./vendor/e stays: ./vendor/d still needs it; apm.yml and apm.lock.yaml were not changed.
Uninstall the package that still needs it first, or keep the local declaration in apm.yml.
Exit 1. Remote dependencies keep the declaration-only removal. Full local re-anchoring (re-key the row, ledger owners, receipt re-binding) is tracked in #4889.
Human scope-approval comment: P3 ruling (B-safe) relayed to Intake for the #4882 apm-scope record; see the #4882 comment linking #4889.
Does this PR complete the issue, or what remains? It completes the 0.38.0 scope (refusal). Full local re-anchoring remains in #4889.
apm-spec-waiver: uninstall refuses a still-needed local dependency before any write; 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-I3 / I7 -- install --frozen keeps passing; a refused command preserves state (source: .agents/skills/apm-lifecycle-tests/SKILL.md)
cell: OP=uninstall SRC=local LOCK=consistent GRAPH=direct ./vendor/e also needed by dev ./vendor/d owner: commands/uninstall/cli.py (_split_still_needed_packages) on install/orphans.py decision
instrument: today test -> tests/integration/test_uninstall_shared_direct_dependency_lifecycle.py::test_uninstall_refuses_a_local_dependency_another_package_still_needs (extends the module)
oracles: [I3, I7, snapshot-absence] decisive: exit 1 with the refusal + remedy lines, tree digest unchanged, then install --frozen exit 0
failing-before: CI=true pytest <node> -n 0 -> 1 failed (uninstall exited 0, removed ./vendor/e from apm.yml)
passing-after: CI=true module + test_uninstall_engine_validation + test_uninstall_shared_diamond_dependency + test_uninstall_transitive_cleanup + install/test_orphan_removal_owner + test_uninstall_local_survivor_source_lifecycle, -n 2 -> 65 passed
guard+mutation: n/a ledger: 4882
hints executed: the remedy is prose (no apm command 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.
Keeping a direct LOCAL dependency that another installed package still
needs changes its lock identity (local keys include declaring_parent and
anchored_local_path), which uninstall cannot re-key yet; the declaration-
only removal left a lockfile that apm install --frozen rejected. Uninstall
now refuses before any change, names the package that still needs it and
how to proceed. Remote dependencies keep the declaration-only removal
(#4749). Full local re-anchoring is tracked in #4889.
Fixes#4882
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The uninstall refusal occurs after pre-uninstall hooks, allowing a hook to modify the manifest, lockfile, or deployed files before the command fails and claims the manifest and lockfile were unchanged.
This PR adds a safety refusal for uninstalling a local dependency that another installed package still needs, avoiding lock identity drift and subsequent frozen-install failures. It is stacked on #4870, which repairs retained dependencies’ metadata graph-wide; full local re-anchoring remains deferred to #4889.
Changes:
Adds a local-dependency refusal with an explanation and recovery guidance, while preserving remote declaration-only removal.
Adds regression coverage for unchanged project state and a successful subsequent frozen install.
Updates uninstall documentation and records the fixes in changelog fragments and lifecycle bug ledgers.
…nstall scripts run
The refusal ran after the pre-uninstall lifecycle scripts, so a trusted
script could write before uninstall exited 1 saying nothing changed. The
removal split (and its refusal) now runs before the scripts fire; it
repeats after them, since scripts may edit apm.yml. Red-first cell: a
trusted pre-uninstall script writing a marker; the marker existed before
the fix and the tree is byte-identical after.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Uninstall can bypass dependency protection and run hooks when only apm_modules/ is missing, and refusal messages can expose machine-specific parent paths.
When the surviving local parent was declared with an absolute, Windows-drive, or ~ path, this prints that machine-specific path in the refusal. This bypasses uninstall's path-safe label contract (engine.py:204-218), covered by tests/unit/commands/test_uninstall_atomic_selection.py:233-273. Route the parent through _dependency_public_label so relative declarations remain readable while machine-specific paths use the portable package key.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The uninstall refusal exposes machine-specific paths for surviving local parents declared with absolute or home-relative paths, violating the portable diagnostic contract instead of using _dependency_public_label.
Copilot review on #4890: the still-needed local refusal printed the
absolute local_path of the parent. Use the public dependency label.
Co-authored-by: Copilot App <[email protected]>
Move the #4678, #4890, #4892, #4912 and #4934 lines into [0.38.1]: they merged before the v0.38.1 tag and shipped in it. [0.38.2] keeps #4920.
Co-authored-by: Copilot App <[email protected]>
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 #4870 (Fixes #4833): it contains #4870's commits until that lands, so review only the commits after fa1a547 (this fix and its changelog fragment). Land after #4870.
apm uninstall ./vendor/e, where./vendor/eis a direct local dependency that another installed package (./vendor/d) still needs, removed only theapm.ymldeclaration (#4749's declaration-only path). A local lock key includesdeclaring_parentandanchored_local_path, so the kept row no longer matched the transitive identity install derives (local:vendor/e).apm install --frozenthen failed: "local:vendor/e is declared in apm.yml but missing from apm.lock.yaml". A probe found no file deleted or kept wrongly in any follow-up (uninstall/prune, with and without reinstall). The defect was the frozen failure and lock drift.Ruling (P3, B-safe for 0.38.0): when a still-needed root is LOCAL, uninstall refuses before any write:
Exit 1. Remote dependencies keep the declaration-only removal. Full local re-anchoring (re-key the row, ledger owners, receipt re-binding) is tracked in #4889.
Docs:
reference/cli/uninstall.md: Behavior step 1.commands.md: uninstall row.Issue and approved scope
Issue: Fixes #4882
Human scope-approval comment: P3 ruling (B-safe) relayed to Intake for the #4882 apm-scope record; see the #4882 comment linking #4889.
Does this PR complete the issue, or what remains? It completes the 0.38.0 scope (refusal). Full local re-anchoring remains in #4889.
apm-spec-waiver: uninstall refuses a still-needed local dependency before any write; 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