Skip to content

test(install): assert one targeted install reconciles a dropped dependency - #3635

Merged
Daniel Meppiel (danielmeppiel) merged 1 commit into
mainfrom
danielmeppiel-fix-3502-single-run-reconcile
Nov 12, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 1 commit into
mainfrom
danielmeppiel-fix-3502-single-run-reconcile

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR

Tightens the #3502 real-CLI regression from #3528 to assert the record's Done-when literally: one apm install PKG / apm install -g PKG after a local package drops a dependency reconciles the lock, apm_modules/ and deployed skills. #3528 had to run the install twice because the first run read the stale materialized manifest (#3401); #3571 fixed that, so the second run is now dead weight that would mask a #3401 regression. No source change — behavior already holds on main.

Fixes #3502

Description

The regression tests/integration/test_targeted_install_dropped_dependency_lifecycle.py now runs the targeted install once after the drop (both user-scope and project-scope parameters) and keeps every existing assertion: dropped lock entry / apm_modules copy / deployed skill gone, shared child kept and re-anchored to sibling, sibling and bystander lock entries byte-identical, apm deps tree no longer lists the dropped child.

Issue and approved scope

Issue: Fixes #3502

Human scope-approval comment: #3502 (comment) (apm-scope:v1, approver and review contact Daniel Meppiel (@danielmeppiel)). Eligibility re-checked from a trusted origin/main copy: state: record-present, authorizes_implementation: false; fresh responsible-human confirmation relayed for exactly this scope after #3571 landed.

Does this PR complete the issue? Yes. #3528 delivered the reconciliation (Refs #3502); #3571 delivered the out-of-scope stale-read fix (#3401). This PR supplies the remaining Done-when evidence: "after a local package drops a dependency one apm install -g PATH (and apm install PATH) removes…". Out of scope and untouched: apm prune --global, prune algorithm, lockfile schema.

Problem (WHY)

  • The approved Done-when asks for a single install run; the merged regression ran two and documented why (# The first run may still read the previously materialized parent manifest (#3401)).
  • With two runs, reverting fix(install): resolve transitive deps from the manifest this run installs #3571's local-package recheck still passes the test — the regression no longer guards the user-visible promise in the issue title.

Approach (WHAT)

Test-only: drop the second scenario.install(parent) and replace the #3401 caveat comment with the single-run invariant. Additive: see Implementation.

Implementation (HOW)

File Change
tests/integration/test_targeted_install_dropped_dependency_lifecycle.py Module docstring says "one apm install"; the post-drop step calls scenario.install(parent) once. All assertions unchanged.

Diagram

Legend: the post-drop lifecycle the test now asserts, in one install run.

flowchart LR
    A["install parent, sibling, bystander"] --> B["drop child-dropped from parent apm.yml"]
    B --> C["ONE apm install parent (-g or project)"]
    C --> D["lock, apm_modules, skills, deps tree reconciled"]
Loading

Trade-offs

Benefits

  1. The regression asserts the approved Done-when verbatim (single run, both scopes).
  2. A [BUG] apm install keeps transitive dependencies of a local package after the package's manifest stops declaring them #3401-style stale-manifest regression on local packages now fails this test (mutation evidence below) instead of being masked by a second run.
  3. Saves one apm install subprocess per parameter in CI.

Validation

Note

Local preflight skipped by maintainer instruction (2026-11-12); CI is the gate.

# Scenario (user promise) Principle(s) Test(s) proving it Type
1 After I drop a dependency from my local package, one apm install -g PKG removes it from lock, apm_modules and ~/.claude/skills, keeps shared deps and leaves other packages' lock entries alone Governed by policy; DevX tests/integration/test_targeted_install_dropped_dependency_lifecycle.py::test_targeted_install_removes_dependency_dropped_by_selected_package[user-scope] e2e
2 Same promise at project scope with apm install PKG Governed by policy; DevX ...::test_targeted_install_removes_dependency_dropped_by_selected_package[project-scope] e2e
Commands and results
$ APM_BINARY_PATH=$PWD/.venv/bin/apm .venv/bin/python -m pytest \
    tests/integration/test_targeted_install_dropped_dependency_lifecycle.py -p no:xdist -q
..                                                                       [100%]
2 passed in 109.82s

# Mutation: restore pre-#3571 drift.should_force_ref_recheck local branch
# (local deps rechecked only when they carry a replacement)
$ <same command>
E  AssertionError: assert 'child-dropped' not in {...}
FAILED ...[user-scope]
FAILED ...[project-scope]
2 failed in 58.25s
# mutation reverted (git checkout src/apm_cli/drift.py)

$ ruff check / ruff format --check (CI paths)      -> All checks passed / 2153 files already formatted
$ pylint R0801 (CI paths)                          -> clean
$ bash scripts/lint-auth-signals.sh                -> clean

How to test

  • APM_BINARY_PATH=$PWD/.venv/bin/apm uv run --extra dev pytest tests/integration/test_targeted_install_dropped_dependency_lifecycle.py -p no:xdist -q → 2 passed.
  • Optional mutation: in src/apm_cli/drift.py::should_force_ref_recheck, change if dep_ref.is_local: to if dep_ref.is_local and dep_ref.replacement is not None: and return False for locals below → both parameters fail on child-dropped.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass (CI is the authority; full suite not run locally by maintainer instruction)
  • Added tests for new functionality (if applicable)

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour.

Co-authored-by: Copilot [email protected]

…dency

#3528 ran the install twice because the first run could read the
previously materialized manifest (#3401). With #3571 merged, assert the
record's Done-when directly: a single apm install PKG / apm install -g PKG
after the drop removes the lock entry, apm_modules copy and deployed skill.

Fixes #3502

Co-authored-by: Copilot App <[email protected]>

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.

🟢 Approval recommended

No active review issues remain for the test-only update requiring reconciliation after a single targeted install.

No open issues 🎉

What changed in this PR

Tightens the existing regression for #3502 to require reconciliation after one targeted install, now that #3571 fixed stale local-manifest reads. This is a test-only change; production behavior is unchanged.

Changes:

  • Removes the second post-drop install in both project- and user-scope scenarios.
  • Updates the docstring and comment to state the single-run requirement while preserving all cleanup and dependency-retention assertions.
File Description
tests/​integration/​test_targeted_install_dropped_dependency_lifecycle.py Requires one targeted install to remove the dropped dependency while retaining shared and unrelated packages.

Review effort: Balanced

@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_now

Clean panel: test-only PR correctly tightens the single-install invariant with zero findings.

panel-mode=lean; personas=test-coverage-expert,apm-ceo

cc Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

One panelist spawned (test-coverage-expert, lean mode); zero findings returned. The PR removes the second post-drop scenario.install(parent) call that was a workaround for the stale-manifest bug #3401, which has since been resolved by #3571. Leaving the redundant install in the test would mask a future #3401 regression by silently refreshing the manifest before the assertion fires, defeating the purpose of the regression trap. With the workaround removed, the lifecycle test now exercises #3502's Done-when clauses with a single install at both user and project scope. All assertions are unchanged, and mutation evidence (pre-#3571 drift.py) confirms both parameter paths fail when the production fix is absent. Lint is clean. Copilot review: approval recommended, no inline items.

Aligned with: Portable by manifest -- a single install at each scope resolves the dependency graph after a dropped dependency, reinforcing the manifest-driven install contract. Pragmatic as npm -- one install, correct result, matching the real user workflow.

Panel summary

Persona B R N Takeaway
Test Coverage Expert 0 0 0 All six Done-when clauses have lifecycle-tier assertions exercised with a single install at both scopes; mutation evidence confirms regression-trap; no guard weakened.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Recommendation

Test-only change, zero findings, clean lint, mutation-verified regression trap. No reason to defer.


Full per-persona findings

Test Coverage Expert

No findings.

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.


Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 0d214b8 into main Nov 12, 2026
25 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-fix-3502-single-run-reconcile branch November 12, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Global install never removes a dependency dropped from a local package, and prune doesn't find it

2 participants