Skip to content

fix(prune): preserve case-equivalent GitHub dependencies - #3158

Closed
Shaurya Saria (icecold009) wants to merge 1 commit into
microsoft:mainfrom
icecold009:codex/apm-prune-github-casing
Closed

Shaurya Saria (icecold009) wants to merge 1 commit into
microsoft:mainfrom
icecold009:codex/apm-prune-github-casing

Conversation

@icecold009

Copy link
Copy Markdown
Contributor

Description

After installing microsoft/apm, changing the manifest to Microsoft/APM could make apm prune delete that still-declared package. Prune now recognizes its existing case-equivalent materialization while preserving the actual directory spelling.

This opts only prune into the existing host-aware materialization matcher. Direct and lockfile-retained transitive dependencies use the same comparison. Aliases, local packages, case-sensitive hosts and in-repository path casing keep their existing rules. Ambiguous case variants fail before cleanup. No rename or global lowercasing is introduced.

Issue and approved scope

Fixes #3034.

Human approval: #3034 (comment)
Coordination comment: #3034 (comment)

Completes the approved scope: dependency preservation, actual orphan removal, host-sensitive regressions and directly related prune documentation. Review contact: Daniel Meppiel (@danielmeppiel).

Type of change

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

Testing

  • Tested locally
  • Added regression coverage
  • All existing tests pass (full suite not run)

Exact head: c347ee3d5dbea58b2ad984b90af96d5559d536af, based on 18c4c43c924ceae890fe0f2038806690e5b2d6c8.

Clean uv sync --frozen --extra dev environment, Python 3.12.14; Ruff 0.15.12 matches the lockfile.

  • Focused prune, command-helper, materialization and prune lifecycle suites: 187 passed, 2 skipped.
  • tests/quality and tests/spec_conformance/test_lockfile_reqs.py: 100 passed, 1 skipped.
  • Final new-case rerun: 19 passed. Temporarily disabling the prune opt-in made all 10 command regressions fail, then exact source bytes were restored.
  • Full-scope Ruff lint/format, pylint R0801, architecture, assertion-quality, exact-duplicate and auth-signal checks passed. YAML-I/O, 2100-line and portable-relative-path CI predicates passed.
  • uv build --no-build-isolation built the source distribution and wheel.
  • git diff --check passed.

The CLI cases use the canonical apm_engine_command fixture, shared lifecycle runner and isolated environment with networking disabled. They execute the source-installed CLI; frozen-binary and remote-CI results are not claimed.

Scenario evidence

Promise Evidence
Both casing directions preserve package bytes and manifest; real orphans still disappear Eight command cases, dry-run/real prune, with/without lockfile
Lock-pinned transitive package remains installed Transitive command regression
Real CLI preserves declared dependency and removes only actual orphan Two isolated CLI subprocess cases
Unknown hosts, aliases, local paths and virtual suffixes retain casing rules Host-sensitive helper and command regressions
Ambiguous variants cannot trigger deletion Real matcher with a platform-neutral duplicate listing; files and lockfile unchanged

AI disclosure: Codex generated this patch and performed the checks above. Jev jev-1.13.0 reviewed the complete six-file diff with no exclusions and no clear issue; advisory review does not replace maintainer review.

Spec conformance (OpenAPM v0.1)

No normative requirement is amended. This restores existing host-aware identity behavior; the existing lockfile conformance suite passed as part of the validation above.

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

In prune.py the new _build_expected_install_paths(..., preserve_installed_case=True) call sits inside the except Exception that logs Failed to parse apm.yml: {e}. So the ambiguous-casing case prints "Failed to parse apm.yml: Found multiple package directories...", which points users at the manifest rather than apm_modules. Catching MaterializationPathCollisionError separately would match the new docs. The unit test only checks the substring, so it passes either way.

@danielmeppiel

Copy link
Copy Markdown
Collaborator

APM Review Panel: ship_with_followups

Preserving case-equivalent GitHub dependencies fixes a real data-loss risk; the remaining diagnostic and documentation fixes are prepared locally, not on the PR branch.

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

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

The panel found no supply-chain regression: prune reuses the existing host-aware materialization matcher, retains case-sensitive boundaries, and stops on ambiguity before cleanup. The coverage review confirmed the collision test did not catch the misleading Failed to parse apm.yml prefix, also identified by the human review. The packaged command guide needed the matching casing behavior documented.

Revision boundary: this recommendation describes remote head c347ee3d5dbea58b2ad984b90af96d5559d536af. Local candidate 3bfede3d54a65a58924348816ff05204eaa47bf2 contains both fixes after a clean merge of main 56660176f8bab352de1130e8801d8395632477f4. It has not been pushed. The fork has maintainer_can_modify=false, and the authenticated account has no fork push permission. Existing requested reviewers, including Daniel Meppiel (@danielmeppiel), remain unchanged.

Aligned with: portability by manifest, fail-closed dependency preservation, and actionable CLI errors.

Panel summary

Persona B R N Takeaway
Supply Chain Security Expert 0 0 0 Canonical path checks and host-specific casing rules are preserved.
Test Coverage Expert 0 1 0 Strengthen the collision diagnostic assertion; source-installed CLI preservation cases exist and were executed.

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

Top 2 follow-ups

  1. [Test Coverage Expert] Transfer the prepared collision-specific catch and dry-run/real-prune regression assertions to the fork. This fixes the misleading manifest-parse message without changing cleanup behavior.
  2. [Test Coverage Expert] Transfer the prepared packaged usage-guide update and matching prune reference clarification.

Recommendation

The core fix is sound. Apply the retained follow-ups to the author branch, then have an authorized human decide whether to allow the fork workflows to execute. Current technical CI has not run successfully. This worker did not push, request reviewers, approve workflows, or merge.

Folded in this run

Both follow-ups are implemented in local-only commit 3bfede3d54a65a58924348816ff05204eaa47bf2; they remain outstanding on the remote PR. No in-scope item was deferred.

Copilot signals reviewed

Copilot supplied only a quota-limit notice, with no inline findings. There are no unresolved inline review threads.

Regression-trap evidence (mutation-break gate)

  • Removing the collision-specific exception handler makes both strengthened diagnostic cases fail on the wrong parse-error prefix.
  • Removing prune's case-preserving opt-in makes 13 component/real-CLI cases fail; 7 unaffected cases pass. Both mutations were restored.

Lint contract

On local candidate 3bfede3d54a65a58924348816ff05204eaa47bf2, all seven current canonical lint checks passed: Ruff check/format with architecture-linter paths, pylint R0801, auth signals, and YAML-I/O/2100-line/portable-relative-path predicates. Architecture boundaries, assertion quality, exact-duplicate checks, and git diff --check passed.

Focused prune/helper/materialization/lifecycle, test-quality, and lockfile-conformance suites: 286 passed, 1 skipped. The passing component cases exercise real fixtures; the two source-installed CLI cases use the existing isolated lifecycle runner. These are local results, not remote CI or frozen-binary evidence.

CI

All six technical workflow runs at remote head c347ee3d5dbea58b2ad984b90af96d5559d536af conclude action_required:

Eligibility and CLA results do not substitute for these technical runs. GitHub reports no merge conflicts; workflow execution and publishing the local follow-ups still require authorized action.


Full per-persona findings

Supply Chain Security Expert

No findings. The existing matcher enforces path containment, host identity rules, and ambiguity refusal; no new authentication or deletion mechanism is introduced.

Test Coverage Expert

  • [recommended] The collision regression accepted the misleading manifest-parse prefix at tests/unit/test_prune_casing.py. Catch MaterializationPathCollisionError separately and reject that prefix in the test.
    Proof: baseline had 19 passing cases despite the wrong diagnostic. The prepared test covers both dry-run and normal prune; removing the prepared handler produces 2 failures, while restoring it passes.

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-merge-worker. This comment is AI-generated and may contain errors.

@danielmeppiel

Daniel Meppiel (danielmeppiel) commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Thank you Shaurya Saria (@icecold009) for the original fix. The retained work was published in #3241 because this fork does not allow maintainer modifications and the publishing account has no fork push permission.

Your original commit c347ee3d5dbea58b2ad984b90af96d5559d536af remains unchanged in the successor PR history. The merged successor also carries the collision diagnostic, regression assertions and packaged documentation follow-ups, with contributor attribution retained in the merge commit.

#3241 merged in 4037af112df9727df33ab0ac12fe0740001e0a53, and #3034 is completed. At the maintainer's request to reconcile campaign status, this superseded PR is now being closed rather than left awaiting the earlier handoff decision.

No contributor-fork changes, force push, branch deletion or second merge are performed.


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

Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Oct 15, 2026
…3158) (#3241)

Preserve still-declared GitHub dependencies across casing-only changes while retaining genuine collision refusal and strict default materialization behavior.

Supersedes #3158. Original contributor commits remain preserved in the successor PR history.

Co-authored-by: Shaurya Saria <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
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] prune marks a declared GitHub package orphaned after a casing-only manifest change

4 participants