Skip to content

fix: dedup deployed_files and scope --update to named packages (closes #1558)#1567

Merged
danielmeppiel merged 3 commits into
mainfrom
bbs/fix-1558-update-dedup
Jun 1, 2026
Merged

fix: dedup deployed_files and scope --update to named packages (closes #1558)#1567
danielmeppiel merged 3 commits into
mainfrom
bbs/fix-1558-update-dedup

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

Context

Fixes #1558. Positional install requests that validate as already present now keep their canonical package selection, so apm install --update does not fall through to all manifest dependencies. Lockfile serialization also canonicalizes deployed_files by removing duplicate paths before writing.

How to test

  • uv run --locked --extra dev pytest tests/test_lockfile.py tests/unit/commands/test_install_phase3.py tests/unit/install/test_resolve_phase3w5.py -q
  • uv run --locked --extra dev ruff check src/ tests/
  • uv run --locked --extra dev ruff format --check src/ tests/
  • uv run --locked --extra dev python -m pylint --disable=all --enable=R0801 --min-similarity-lines=10 --fail-on=R0801 src/apm_cli/
  • bash scripts/lint-auth-signals.sh

Mutation-break verified for both new regression tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 1, 2026 09:18
@danielmeppiel danielmeppiel added the status/shepherding Actively being driven by an APM shepherd run label Jun 1, 2026
@danielmeppiel danielmeppiel self-assigned this Jun 1, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes apm install --update <pkg> behavior so a named positional package update remains scoped to that package (instead of falling back to “install everything in apm.yml” when validation says it’s already present). Also canonicalizes lockfile output by deduplicating deployed_files during serialization to avoid repeated-path churn.

Changes:

  • Add commands.install._only_packages_from_validation(...) and use it to compute InstallContext.only_packages based on validation outcomes (including “already present” packages).
  • Deduplicate LockedDependency.deployed_files at lockfile serialization time.
  • Add regression tests covering --update scoping and deployed_files deduplication.
Show a summary per file
File Description
src/apm_cli/commands/install.py Computes only_packages from validation outcomes so named --update stays scoped.
src/apm_cli/deps/lockfile.py Deduplicates deployed_files when serializing a lock entry.
tests/unit/commands/test_install_phase3.py Adds a regression test ensuring --update owner/target only installs that package.
tests/test_lockfile.py Adds a regression test asserting deployed_files is serialized as a sorted, unique list.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 2

Comment on lines +631 to +639
with (
patch("apm_cli.commands.install._validate_package_exists", return_value=True),
patch(
"apm_cli.commands.install._install_apm_dependencies",
return_value=InstallResult(installed_count=1, diagnostics=None),
) as install_apm,
):
result = CliRunner().invoke(install, ["--update", "owner/target"])

Comment on lines +640 to +641
assert result.exit_code == 0, result.output
assert install_apm.call_args.args[3] == ["owner/target"]
danielmeppiel and others added 2 commits June 1, 2026 12:00
Addresses Copilot review on the update scoping test by making argv deterministic and avoiding brittle positional call assertions. Also folds the panel lockfile consistency follow-up by deduplicating deployed_files in memory before serialization.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Addresses the CI install.py line-budget failure by moving scoped package selection into apm_cli.install while preserving the Click boundary behavior covered by the regression test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@danielmeppiel
Copy link
Copy Markdown
Collaborator Author

BBS shepherd final advisory: ship_now

The shepherd pass folded the in-scope Copilot and panel follow-ups for the #1558 scoped-update and deployed_files dedup fix. CI is green on head 5edc25c.

Folded in this run

  1. [Copilot] Made the CliRunner test argv deterministic by patching _get_invocation_argv. Resolved in 140ddf6.
  2. [Copilot] Replaced brittle positional call_args indexing with an InstallService request capture. Resolved in 140ddf6.
  3. [Panel] Deduplicated LockedDependency.deployed_files in memory before serialization. Resolved in 140ddf6.
  4. [CI recovery] Extracted scoped package selection to apm_cli.install.package_selection to satisfy the install.py architecture budget. Resolved in 5edc25c.

Copilot signals reviewed

  1. 3333028580 LEGIT: test argv could be polluted by process sys.argv; folded.
  2. 3333028624 LEGIT: positional call_args indexing was brittle; folded.

Deferred

None.

Lint evidence

Full lint contract passed locally: ruff check, ruff format --check, pylint R0801, and lint-auth-signals.

CI evidence

GitHub checks are green: 13 successful, 0 failing, 0 pending. CI run: https://github.com/microsoft/apm/actions/runs/26748437952

Mergeability

PR head CEO stance iterations folds deferrals copilot rounds ci status mergeable merge state status notes
#1567 5edc25c ship_now 1 4 0 2 green MERGEABLE BLOCKED pending required review

@danielmeppiel danielmeppiel removed the status/shepherding Actively being driven by an APM shepherd run label Jun 1, 2026
@danielmeppiel danielmeppiel merged commit 1330d2b into main Jun 1, 2026
14 checks passed
@danielmeppiel danielmeppiel deleted the bbs/fix-1558-update-dedup branch June 1, 2026 14:00
danielmeppiel added a commit that referenced this pull request Jun 1, 2026
* fix(tests): skip POSIX execute-bit assertions on Windows

Two unit tests asserted st_mode & 0o111 == 0o111, which fails on
Windows because NTFS does not honor POSIX execute bits. Guard both
with pytest.mark.skipif(sys.platform == 'win32'), matching the
existing convention used elsewhere in the suite.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix(scripts): guard empty PYTEST_EXTRA_ARGS array under bash 3.2

scripts/test-integration.sh runs under `set -euo pipefail`. On macOS
the default /bin/bash is 3.2, where expanding an empty array with a
bare "${arr[@]}" raises an unbound-variable error. Local integration
runs (PYTEST_EXTRA_ARGS unset) aborted before pytest with
'extra_args[@]: unbound variable'. Use the ${arr[@]+"${arr[@]}"}
guard so the empty-array expansion is safe; CI behaviour (with
PYTEST_EXTRA_ARGS set) is unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* chore: release v0.16.1

Roll the [Unreleased] changelog into a dated 0.16.1 block and bump
pyproject.toml + uv.lock. Adds the previously-missing user-facing
entries for #1539 (apm doctor), #1566, #1569, #1567, #1553, #1552,
and #1538 surfaced by enumerating merged PRs since v0.16.0.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* ci: parallelise macOS release integration tests to fix 20min timeout

The v0.16.1 release pipeline failed on the macOS x86_64 (Intel) build:
the consolidated job's "Run integration tests" step hit its 20-minute
timeout at ~61% progress. The tests were passing -- the slower Intel
runner simply could not finish the full suite serially in time, and the
arm64 runner was also near the edge.

Unlike ci-integration.yml, which shards the suite across four runners,
the release workflow runs the whole integration suite on a single
scarce macOS runner. Parallelise it in-process with xdist (-n 2,
matching ci-integration's per-shard width to bound shared-PAT API
concurrency) using --dist loadgroup so the home_env xdist_group markers
keep HOME-mutating tests serialized on one worker. Also raise the step
timeout to 30 minutes for headroom on the slow Intel runner.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: danielmeppiel <danielmeppiel@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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] apm install --update writes duplicate deployed_files entries and churns unrelated lockfile deps

2 participants