Fix transitive dependency handling in compile and orphan detection#111
Fix transitive dependency handling in compile and orphan detection#111danielmeppiel merged 10 commits intomainfrom
Conversation
Read from apm.lock (which tracks transitive deps) in addition to apm.yml: - get_dependency_declaration_order() now includes transitive deps for compile - _check_orphaned_packages() no longer flags transitive deps as orphaned - prune command accounts for transitive deps in expected_installed set - Added get_lockfile_installed_paths() helper to lockfile module - Added 17 unit tests covering all transitive dependency scenarios Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
- Wrap get_lockfile_installed_paths() in try/except to handle all errors - Use ImportError instead of broad Exception in callers - Update docs for transitive dep discovery Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes apm compile, orphan detection, and apm prune so they account for transitive dependencies by incorporating apm.lock (in addition to apm.yml) when determining expected installed dependency paths.
Changes:
- Extend dependency discovery order to append transitive deps from
apm.lockafter direct deps fromapm.yml. - Update orphan detection and prune logic to treat lockfile-listed deps as expected (avoiding false orphan reports).
- Add a lockfile helper for resolving installed paths and introduce targeted unit/integration tests + docs update.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/test_transitive_deps.py | Adds unit tests covering lockfile path resolution, transitive ordering, and orphan detection behavior. |
| tests/test_enhanced_discovery.py | Expands discovery tests to validate transitive dependency inclusion and primitive scanning. |
| src/apm_cli/primitives/discovery.py | Appends transitive dependency install paths from apm.lock to discovery order. |
| src/apm_cli/deps/lockfile.py | Adds get_lockfile_installed_paths() helper to convert lock entries into install paths. |
| src/apm_cli/deps/init.py | Exposes get_lockfile_installed_paths as part of the deps package API. |
| src/apm_cli/cli.py | Updates orphan detection and prune to include lockfile dependencies as expected installs. |
| docs/enhanced-primitive-discovery.md | Documents updated behavior: direct deps from apm.yml, transitives appended from apm.lock. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Move get_lockfile_installed_paths logic into LockFile.get_installed_paths() method (foutoucour review) - Use .as_posix() for Windows-safe path normalization (copilot-reviewer) - Narrow except Exception to specific error types (copilot-reviewer) - Move inline imports to top-level in discovery.py and cli.py (foutoucour) - Remove unused imports in test file (tempfile, pytest)
…e-dependencies-issue
Summary of additional fixes since initial PRBeyond the original transitive dependency fix, this PR now includes several follow-up fixes addressing review feedback and CI issues: 1.
|
🐛 Bug Fix
Problem
apm compileonly scans direct dependencies fromapm.yml, silently skipping transitive deps. Orphan detection (_check_orphaned_packages) andapm prunealso only checkapm.yml, incorrectly flagging transitive deps as orphaned.Example: package A → B → C. Only A is in
apm.yml. Afterapm install, B and C are installed and tracked inapm.lockwithdepth: 2+, butapm compileignores their primitives and reports them as orphans.Solution
Read
apm.lock(which already tracks transitive deps with depth info) in addition toapm.ymlin the three affected code paths:get_dependency_declaration_order()(discovery.py): Appends transitive deps from lockfile after direct deps, preserving priority ordering_check_orphaned_packages()(cli.py): Includes lockfile deps inexpected_installedsetprune()command (cli.py): Same lockfile inclusion for expected depsget_lockfile_installed_paths()(lockfile.py): New helper that convertsLockedDependencyentries to their filesystem install paths viaDependencyReference.get_install_path(), handling regular, virtual, and ADO package layoutsTesting
17 new unit tests across two files:
tests/unit/test_transitive_deps.py— lockfile path resolution, multi-level transitive discovery, orphan detection with/without lockfiletests/test_enhanced_discovery.py— 4 additional tests for transitive primitive scanning817 total unit tests pass, CodeQL clean.
Checklist
bugorfixlabel to this PROriginal prompt
This section details on the original issue you should resolve
<issue_title>[BUG] transitive packages</issue_title>
<issue_description>Describe the bug
I don't have the same result if I use transitive dependencies or direct dependencies of the same packages.
dependencies
team-cot-agent-instructionsdivision-ime-agent-instructionsautodesk-agent-instructionsapm.yml files
To Reproduce
Steps to reproduce the behaviour:
Expected behaviour
In the case of direct dependencies
In the case of transitive dependencies