Skip to content

fix(uninstall): import the survivor reader from local_survivors - #5081

Merged
Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
fix-local-reanchor-survivor-import
Nov 23, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
fix-local-reanchor-survivor-import

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

apm uninstall fails with ImportError: cannot import name '_read_survivor_direct_refs' whenever it reaches the local re-anchor path. #4964 added local_reanchor.py, which imports _read_survivor_direct_refs from the uninstall engine; #4596, merged just before it, moved that reader to local_survivors.read_survivor_direct_refs. Each PR was green on its own; the combination on main is not.

The fix imports read_survivor_direct_refs from local_survivors (local_reanchor.py:357) and renames the call at :377. No other caller of the old name remains on main.

Failing-first proof:

Cell main (5fab3e6) this head
tests/integration/test_uninstall_local_reanchor_lifecycle.py (all cells) fail: Error uninstalling packages: cannot import name '_read_survivor_direct_refs' pass
tests/unit/test_uninstall_local_reanchor_refusals.py::test_a_local_row_without_a_path_is_unverified_offline (existing) fail: ImportError at local_reanchor.py:357 pass
tests/unit/test_uninstall_local_reanchor_refusals.py::test_the_survivor_read_drives_the_offline_reach_check (new, no subprocess, under 1 s) fail: ImportError at local_reanchor.py:357 pass

The new unit cell was committed first (21af4be) and fails on main; the fix follows (785ebcb).

Issue and approved scope

Issue: Refs #4889 (the collision between #4964 and #4596 on main)

Human scope-approval comment: maintainer-directed hotfix for a red main; no closing keyword.

Does not complete an issue; it restores the #4889 re-anchor path on main.

Type of change

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

Testing

  • Tested locally

  • All existing tests pass

  • Added tests for new functionality (if applicable)

  • pytest tests/unit/test_uninstall_local_reanchor_refusals.py -> 7 passed (2 failed on main with ImportError).

  • APM_BINARY_PATH=.venv/bin/apm pytest tests/integration/test_uninstall_local_reanchor_lifecycle.py tests/unit/commands -n 8 -> pass except one self-update unit that is flaky under xdist and passes alone (unrelated).

  • Lint mirror: ruff 0.15.12 check and format, pylint R0801, lint-auth-signals.sh, complexity ratchet against origin/main, architecture linter, tests.quality.taxonomy --changed -> clean.

Changelog

  • One fragment per section
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

Fails on main with ImportError: the re-anchor imports the survivor
reader from engine, which no longer defines it.

Co-authored-by: Copilot App <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
The re-anchor of a still-needed local dependency imported
_read_survivor_direct_refs from the uninstall engine; that reader now
lives in local_survivors as read_survivor_direct_refs, so every
uninstall reaching the re-anchor failed with ImportError.

Co-authored-by: Copilot App <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[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 local dependency re-anchor change.

No open issues 🎉

What changed in this PR

Restores the local dependency re-anchor path in apm uninstall after overlapping changes left it importing a moved helper from the uninstall engine.

Changes:

  • Imports and calls read_survivor_direct_refs from its current owner, local_survivors.
  • Adds a regression test confirming that a surviving local dependency causes the offline dry-run check to keep a still-needed package.
File Description
tests/​unit/​test_uninstall_local_reanchor_refusals.py Adds coverage for survivor-driven offline refusal.
src/​apm_cli/​commands/​uninstall/​local_reanchor.py Corrects the survivor reader import and call.

Review effort: Balanced

…ivor-read cell

Co-authored-by: Copilot App <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[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 block the survivor-reader import correction and its added regression coverage.

No open issues 🎉

Review effort: Balanced

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit bb12288 into main Nov 23, 2026
140 of 142 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the fix-local-reanchor-survivor-import branch November 23, 2026 17:34
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 23, 2026
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 23, 2026
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 23, 2026
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.

2 participants