Repository navigation
fix(prune): preserve case-equivalent GitHub dependencies (supersedes #3158) - #3241
Daniel Meppiel (danielmeppiel) merged 9 commits into
Conversation
Co-authored-by: Copilot App <[email protected]> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Address the PR 3158 panel follow-ups and human review by reporting materialization collisions without blaming a valid manifest. Cover dry-run and real prune with a mutation-proven diagnostic regression and synchronize the packaged usage guide. Co-authored-by: Copilot App <[email protected]> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Preserve the retained PR 3158 history and incorporate current main without changing the scoped implementation. Co-authored-by: Copilot App <[email protected]> Copilot-Session: be82c181-49dd-4b8f-9e95-fca488acafe1
Publish the retained work from #3158 as a successor for #3034. Original contributor commit c347ee3 and subsequent scoped follow-up remain unchanged. This commit changes no files. Co-authored-by: Shaurya Saria <[email protected]> Co-authored-by: Copilot App <[email protected]> Copilot-Session: be82c181-49dd-4b8f-9e95-fca488acafe1
Retain the scoped prune implementation and original contributor history while integrating the newly merged MCP changes. Co-authored-by: Copilot App <[email protected]> Copilot-Session: be82c181-49dd-4b8f-9e95-fca488acafe1
There was a problem hiding this comment.
🟡 Changes recommended
The lookup treats case-equivalent owner prefixes as collisions even when complete package paths are distinct, blocking valid prune operations.
1 open finding
What changed in this PR
Fixes #3034 by making prune preserve GitHub dependencies after owner/repository casing changes, without renaming installed directories.
Changes:
- Opts prune into host-aware installed-path matching.
- Adds collision-specific diagnostics and regression coverage.
- Updates prune reference and packaged usage documentation.
| File | Description |
|---|---|
| tests/unit/test_prune_casing.py | Covers casing preservation, boundaries, and collisions. |
| tests/integration/test_prune_casing_cli.py | Exercises dry-run and actual CLI cleanup. |
| tests/helpers/prune_casing.py | Shares package and orphan fixtures. |
| src/apm_cli/commands/prune.py | Enables matching and handles collisions separately. |
| src/apm_cli/commands/_helpers.py | Adds opt-in case-preserving path lookup. |
| packages/apm-guide/.apm/skills/apm-usage/commands.md | Updates packaged prune guidance. |
| docs/src/content/docs/reference/cli/prune.md | Documents casing behavior and collision recovery. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ollisions Fold review 4284092621 within the approved #3034 scope. Reuse canonical full-path selection only for prune; preserve strict relocation defaults and genuine duplicate refusal. Add portable reader-seam and required Linux native-filesystem regressions for both prune modes. Co-authored-by: Shaurya Saria <[email protected]> Co-authored-by: Copilot App <[email protected]> Copilot-Session: be82c181-49dd-4b8f-9e95-fca488acafe1
Retain the scoped prune correction alongside the #3100 and #3222 changes. Co-authored-by: Copilot App <[email protected]> Copilot-Session: be82c181-49dd-4b8f-9e95-fca488acafe1
Preserve #3237 linked-resource lifetime guidance without changing the scoped prune correction. Co-authored-by: Copilot App <[email protected]> Copilot-Session: be82c181-49dd-4b8f-9e95-fca488acafe1
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Supply Chain Security | 0 | 0 | 0 | Complete-path opt-in preserves containment, collision detection, and write-path isolation; no supply-chain surface regression at b5ec1ac. |
| Test Coverage | 0 | 0 | 0 | All critical prune-casing surfaces have regression traps at floor tier; portable seam, native HFS+ e2e, and six targeted mutations confirm every path is load-bearing; ship. |
| Python Architect | 0 | 0 | 0 | Owner extension is structurally clean: opt-in complete-path traversal reuses existing policy primitives; strict default relocation unchanged; no split authority introduced. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Recommendation
All three delta specialists returned zero findings on the corrective successor head. The one legitimate inline finding was corrected in bff4. Six standard workflows succeeded; targeted mutations, native Linux lifecycle smoke, and macOS HFS+ execution all confirm the change is load-bearing and sound. Owner verification shows two existing owners with no new authority. The validated base is 2a8213a; main has since advanced to f65ac26, so a fresh mergeability preview against latest main is warranted before landing, but no code, security, or architecture concern remains from this panel.
Full per-persona findings
Python Architect
No findings.
Supply Chain Security
No findings.
Test Coverage
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.

fix(prune): preserve case-equivalent GitHub dependencies
Description
TL;DR
Prune now keeps an installed GitHub dependency when only its owner/repository casing changes in
apm.yml, without renaming its directory. Distinct repositories under case-variant owner prefixes remain valid; genuinely duplicate complete paths stop cleanup with a path-specific error. This supersedes #3158, preserving Shaurya Saria (@icecold009)'s original fix and adding scoped diagnostic, regression, documentation, and review follow-ups.Important
Original contributor commit
c347ee3d5dbea58b2ad984b90af96d5559d536afis preserved unchanged, not squashed or recreated. #3158 remains open pending a separate maintainer handoff decision. This PR does not authorize a merge.Problem (WHY)
microsoft/apmtoMicrosoft/APM; prune then incorrectly reports the still-declared directory as orphaned.Failed to parse apm.yml, although the problem was conflicting materializations.Microsoft/APMbesidemicrosoft/Other, preventing real orphan cleanup.maintainer_can_modify=false, and the publishing account has no push access to its contributor fork. Prepared follow-ups therefore remained local.The issue and human review are the canonical task evidence. Validation below follows the Agent Skills guidance to "Read agent execution traces, not just final outputs.", rather than treating the earlier advisory or passing eligibility check as runtime proof.
Approach (WHAT)
MaterializationPathCollisionErrorseparately and refuse cleanup before any removal.Implementation (HOW)
src/apm_cli/commands/_helpers.pysrc/apm_cli/commands/prune.pysrc/apm_cli/models/dependency/materialization.pytests/helpers/prune_casing.pytests/unit/test_prune_casing.pytests/integration/test_prune_casing_cli.pytests/unit/models/test_dependency_materialization.pydocs/src/content/docs/reference/cli/prune.mdpackages/apm-guide/.apm/skills/apm-usage/commands.mdNo CHANGELOG edit is carried; this remains the approved #3034 bug-fix scope.
Diagram
Complete-path lookup preserves spelling and accepts distinct repositories; duplicate full paths stop orphan cleanup. Dashed nodes mark the changed behavior.
flowchart LR subgraph Selection["Expected installed paths"] P["prune"] --> E["_build_expected_install_paths<br/>preserve_installed_case=True"] E --> G{"No alias and case-insensitive repo identity?"} G -->|Yes| M["Canonical materialization matcher<br/>match_complete_path=True"] G -->|No| D["Declared install path"] M -->|"Unique existing path"| C["Preserve installed spelling"] M -->|"No existing path"| D end subgraph Outcome["Prune outcome"] C --> O["_find_orphaned_packages"] D --> O O --> R["Preview or remove only orphan roots"] M -->|"Duplicate full paths"| X["Report MaterializationPathCollisionError<br/>exit 1 before cleanup"] end classDef added stroke-dasharray: 5 5; class E,M,X added;Trade-offs
Benefits
Issue and approved scope
Fixes #3034. Supersedes #3158.
Human scope-approval comment: #3034 (comment)
This completes the approved host-aware prune correction, regression fixtures, actual-orphan behavior, case-sensitive boundaries, and affected documentation. Review contact: Daniel Meppiel (@danielmeppiel).
The renewed approval preserves the original scope verbatim. Global lowercasing, case-sensitive-host identity changes, unrelated prune redesign, and removal of user-managed files are outside this change.
Original implementation: Shaurya Saria (@icecold009), commit
c347ee3d5dbea58b2ad984b90af96d5559d536af. Prepared follow-up:3bfede3d54a65a58924348816ff05204eaa47bf2. Both remain unchanged ancestors of this branch.Type of change
Testing
Validation
Publication head:
b5ec1acd45e32ed7b8220ccbba85966c3696b21d, integrated with main2a8213ac39d6ba862fca6eddd28c7f4653950bfb.The full suite and frozen-binary suite were not run locally. All six exact-head technical workflows passed: CI, CodeQL, spec conformance, docs, NOTICE, and Merge Gate.
Windows attempt 1 had one
gh.exe --versiontimeout in unchanged discovery code (786 passed, 1 failed, 2 skipped). The single failed-job rerun passed 787 tests with 2 skips; the dependent check also passed on rerun. No code or policy was changed for recovery.uv run --frozen --extra dev pytest -p no:cacheprovider -q -rs tests/unit/models/test_dependency_materialization.py tests/unit/test_command_helpers.py tests/unit/test_prune_command.py tests/unit/test_prune_casing.py tests/integration/test_prune_casing_cli.py tests/quality/test_ci_topology.py --junitxml=/Users/danielmeppiel/.copilot/session-state/be82c181-49dd-4b8f-9e95-fca488acafe1/files/fold-final-tests.xml— passed:The JUnit report proves exact-head local execution; it does not relabel the four skipped native cases as passes.
The separate native HFS+ JUnit receipt
fold-native-restored-tests.xmlrecords 6 passed in 31.32s after restoring both mutation probes. The temporary case-sensitive volume was removed afterward.Required Linux lifecycle execution ran
uv run --extra dev pytest -p no:cacheprovider -q --strict-markers -n 4 --dist loadgroup -m 'lifecycle_smoke and not lifecycle_merge_group' tests/integration: 244 passed, 1 skipped. The sole skip is the selected remote-marketplace metadata-outage test, whose requiredAPM_RUN_INTEGRATION_TESTS=1is absent. This accounts for every skip, proving all six selected prune CLI nodes passed, including the four native case-sensitive cases. The workflow emits no per-node JUnit; the receipt retains this explicit outcome-accounting proof rather than inventing one.Exact lint and static-check commands and results
Each command below exited 0 on the publication head:
uv run --frozen --extra dev ruff check src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.pyAll checks passed!uv run --frozen --extra dev ruff format --check src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py1940 files already formatteduv run --frozen --extra dev python -m pylint --disable=all --enable=R0801 --min-similarity-lines=10 --fail-on=R0801 src/apm_cli/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.pybash scripts/lint-auth-signals.shbash scripts/lint-architecture-boundaries.shuv run --frozen python scripts/check_test_assertions.pyuv run --frozen python scripts/check_exact_test_duplicates.pygit diff --checkgit diff --check 2a8213ac39d6ba862fca6eddd28c7f4653950bfb...HEADThe YAML-I/O, 2100-line, and raw
str(relative_to)CI predicates also passed. The two GNU-grep predicates were executed as equivalent line-based Python regular expressions on macOS; their original exclusions and failure conditions were retained.The deterministic owner gate detected two existing owners: dependency identity/materialization and orphan selection. Version-2 evidence was schema-validated and semantically checked against fresh base/head detection and seven actual passing JUnit nodes, including both CLI modes, portable positive/negative cases and strict-default refusal.
Scenario Evidence
Types below use the repository's actual module-level behavioral markers.
tests/unit/test_prune_casing.py::test_prune_preserves_casing_equivalent_github_package(regression-trap for #3034)tests/unit/test_prune_casing.py::test_prune_retains_case_equivalent_transitive_dependencytests/unit/test_prune_casing.py::test_prune_does_not_casefold_sensitive_materialization,::test_prune_does_not_preserve_case_changed_unknown_host_package,::test_prune_preserves_virtual_path_casetests/unit/test_prune_casing.py::test_prune_ambiguous_casing_fails_before_cleanuptests/integration/test_prune_casing_cli.py::test_prune_casing_real_clitests/unit/test_prune_casing.py::test_prune_complete_paths_with_portable_reader_seamtests/integration/test_prune_casing_cli.py::test_prune_complete_paths_on_case_sensitive_filesystem(four passes on native HFS+ and required Linux; ordinary macOS capability skips remain separately reported)Retained review and mutation evidence, with revision boundary
The prior lean advisory on #3158 was
ship_with_followups. It is historical, not a new independent review of this publication head.Both recommendations are implemented in retained commit
3bfede3d54a65a58924348816ff05204eaa47bf2: collision-specific reporting with stronger assertions, and packaged command documentation.At that retained revision, removing the collision handler caused 2 failures; disabling the case-preserving prune opt-in caused 13 failures with 7 unaffected cases passing. Restoring both produced 20 passing cases. A broader retained run recorded 286 passed and 1 skipped.
Review fold
bff4acf844e09e1615a7e466aad0f0048e6d6daeadds the complete-path opt-in. Before the fix, four new positive regressions failed. Disabling genuine-duplicate refusal made all four negative cases fail; relaxing the strict default made its dedicated regression fail. Each guard was restored. The final main merge left these guarded source/test files unchanged, and the exact merged-head suite passed above.No second broad code panel ran. The genuine bounded delta review ran supply-chain, test-coverage and Python-architecture specialists with zero findings, followed by actual CEO synthesis returning
ship_now. The inline finding is resolved. Historical review/test results are not relabeled as executions of this head.How to test
uv sync --frozen --extra devto prepare the source-installed CLI environment.microsoft/apmalready installed, change only its declaration toMicrosoft/APM; runuv run apm prune --dry-runand confirm the declared package is not reported as an orphan.uv run --frozen --extra dev pytest -q -m 'lifecycle_smoke and not lifecycle_merge_group' tests/integration/test_prune_casing_cli.pyon Linux; expect all six native CLI cases to pass.Spec conformance (OpenAPM v0.1)
If this PR changes behaviour that an OpenAPM v0.1
req-XXXcovers,confirm the three-step ritual in the
development guide:
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.
This repairs prune's use of existing host-aware identity and materialization rules; it adds no normative requirement or format. Spec-conformance CI remains part of the successor's technical verification.
Co-authored-by: Copilot [email protected]