Skip to content

fix(self-update): isolate Windows installer from inherited PSModulePath - #3931

Merged
Daniel Meppiel (danielmeppiel) merged 9 commits into
mainfrom
danielmeppiel-fix-windows-self-update-psmodulepath
Nov 19, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 9 commits into
mainfrom
danielmeppiel-fix-windows-self-update-psmodulepath

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Description

On Windows, apm self-update could fail inside install.ps1 with Expand-Archive : Cannot find an overload for "ExtractToDirectory" and the argument count: "3", leaving the old version installed (scheduled run 44455839414, Test 5 of test_windows_installer_exposes_stable_executable).

Root cause: self_update prefers powershell (Windows PowerShell 5.1) and passed the parent environment through. Under a PowerShell 7 parent, the inherited PSModulePath lists PowerShell 7 module paths ahead of 5.1's own, so 5.1 loads PowerShell 7's Microsoft.PowerShell.Archive, whose Expand-Archive calls a ZipFile.ExtractToDirectory overload .NET Framework lacks. PowerShell 7 strips its own paths only when it starts 5.1 directly, not through an intermediate process such as apm.exe (about_PSModulePath, 5.1 note). That explains why the failure depends on the environment.

Changes:

  • src/apm_cli/commands/self_update.py: _build_self_update_installer_env (the existing installer env builder, on top of external_process_env) drops PSModulePath (matched case-insensitively) on Windows. With the variable absent, Windows PowerShell and pwsh both rebuild their default module path (CurrentUser + AllUsers + $PSHOME), per the docs above. install.ps1 needs only in-box modules.
  • install.ps1: new Expand-ReleaseArchive helper. It runs Expand-Archive -ErrorAction Stop. If that throws, it warns and falls back to Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory($ZipPath, $fallbackDir) (the 2-argument overload) in a fresh extract-<guid> dir under $tempDir, so partial output from Expand-Archive cannot collide. The install flow reads apm-windows-x86_64 from the returned root. Staging, binary test, promotion, and cleanup are unchanged: $tempDir is still removed recursively.

Issue and approved scope

Issue: Fixes #3926

Human scope-approval comment: #3926 (comment)

Does this PR complete the issue, or what remains? It covers the whole approved scope: the child env no longer depends on the parent host's module path, install.ps1 has the ZipFile fallback, and unit tests cover both. The full Windows installer integration test (Test install.ps1 end-to-end (Windows) in build-release.yml) runs only on full plans (schedule / repository_dispatch on main), not on PRs. build-release.yml has no workflow_dispatch trigger, and repository_dispatch runs only on the default branch, so it cannot run on this branch. The next scheduled run after merge gives that evidence. PR-time functional evidence comes from the windows_compat Windows Compatibility Gate, which runs the new behavioral test under real powershell (5.1) and pwsh on windows-latest.

Type of change

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

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

New tests:

  • tests/unit/test_self_update_config.py::test_windows_installer_env_drops_inherited_psmodulepath: the regression trap, which fails on main (AssertionError: assert not ['PSMODULEPATH', 'PSModulePath']). Plus a Unix counterpart that keeps PSModulePath.
  • tests/unit/test_windows_installer_archive_fallback.py (windows_compat): extracts Expand-ReleaseArchive from install.ps1 and runs it under each available host (powershell, pwsh). It covers the happy path, plus a simulated Expand-Archive failure with the exact MethodException text that must fall back to ZipFile. It also includes a static check that the install flow stages from the helper's root. All 3 runnable cases fail on main.

Validation evidence (macOS, pwsh 7 available; powershell 5.1 cases skip locally and run on the Windows gate):

  • .venv/bin/python -m pytest -p no:xdist -q tests/unit/test_windows_installer_archive_fallback.py tests/unit/test_self_update_config.py: 11 passed, 2 skipped (5.1 host not present).
  • Same command with install.ps1 reverted to main: 3 failed (fallback, happy-path helper lookup, static check). The env trap on unfixed self_update.py: 1 failed, 7 passed.
  • Lint mirror on HEAD merged with main: uvx [email protected] check and format --check (src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py): passed. pylint R0801 10.00/10. bash scripts/lint-auth-signals.sh: clean. bash scripts/lint-architecture-boundaries.sh: exit 0.
  • Related suites: .venv/bin/python -m pytest -p no:xdist -q tests/unit/test_windows_installer_archive_fallback.py tests/unit/test_self_update_config.py tests/unit/test_windows_installer_binary_test.py tests/unit/test_windows_installer_launchers.py tests/unit/install/test_windows_shim_template.py tests/unit/test_update_command.py tests/unit/commands/test_self_update_air_gapped.py tests/unit/test_enterprise_bootstrap_installers.py tests/unit/test_windows_compat_gate_workflow.py: 141 passed, 5 skipped, 2 failed. Both failures are local-only and unrelated: test_update_uses_powershell_installer_on_windows fails the same way with main's self_update.py/install.ps1 (an os.chmod on config.json), and test_windows_compat_gate_marker_selects_nonempty_subset hit a 300s collection timeout on the loaded shared host. Both pass in CI.

Windows CI evidence (live reproduction of #3926):

  • At e7cde07, Windows Compatibility Gate (2/3) ran test_release_archive_extracts_with_expand_archive[powershell] under the pwsh CI shell, with the inherited environment. Windows PowerShell 5.1 inherited PowerShell 7's PSModulePath, Expand-Archive failed, and the new ZipFile fallback extracted the archive. The test failed only because it expected the no-fallback path (job 135612764363). This reproduces the root cause on windows-latest and proves the fallback works there.
  • At 6b955e5 the tests are split: (a) test_self_update_child_env_extracts_with_expand_archive[powershell|pwsh] runs the helper under the env _build_self_update_installer_env produces, and asserts Expand-Archive succeeds without fallback. (b) test_release_archive_extracts_under_inherited_host_env[powershell|pwsh] runs under the inherited pwsh env and asserts extraction still succeeds. (c) The forced-failure fallback case. All 7 PASSED on the Windows Compatibility Gate, and all 31 PR checks are green.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md:
    user-visible effect first, 25 words or fewer, ending with (#PR);
    breaking changes only under upgrade notes; no Highlights; see
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour. (Commit carries apm-spec-waiver.)

apm self-update on Windows launched Windows PowerShell with the parent
environment. Under a PowerShell 7 parent, the inherited PSModulePath
loaded PowerShell 7's Archive module into 5.1, whose Expand-Archive calls
a ZipFile.ExtractToDirectory overload .NET Framework lacks (#3926).

- Drop PSModulePath from the installer child env so each host rebuilds
  its default module path.
- install.ps1 falls back to the 2-argument ZipFile.ExtractToDirectory
  overload in a fresh directory when Expand-Archive fails.

Refs #3926

apm-spec-waiver: Windows installer host hardening, no OpenAPM contract change

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 14:00
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 19, 2026

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.

🔵 Needs a closer look

Human review is needed because the required Windows installer integration upgrade lacks end-to-end PowerShell 5.1 runtime evidence, which the PR says can be obtained only after merge.

No open issues 🎉

What changed in this PR

Fixes #3926 by isolating the Windows self-update installer from inherited PowerShell module paths and adding a compatible archive-extraction fallback.

Changes:

  • Removes PSModulePath case-insensitively from the Windows installer environment while preserving it on Unix.
  • Falls back from Expand-Archive to the two-argument .NET extraction method in a fresh directory.
  • Adds environment-isolation and PowerShell extraction regression tests, plus a changelog entry.
File Description
tests/​unit/​test_windows_installer_archive_fallback.py Tests normal extraction, fallback behavior, and use of the returned extraction root.
tests/​unit/​test_self_update_config.py Tests Windows module-path removal and Unix preservation.
src/​apm_cli/​commands/​self_update.py Clears inherited PowerShell module paths for the Windows installer.
install.ps1 Adds archive-extraction fallback and stages from the returned root.
CHANGELOG.md Records the Windows self-update fix.

Review effort: Balanced

…al hosts

The Windows gate runs pytest under pwsh, so powershell 5.1 inherits the
PowerShell 7 PSModulePath there and reproduces #3926. Run the happy path
under the env _build_self_update_installer_env produces, and assert the
inherited-env run still extracts through the fallback.

Co-authored-by: Copilot App <[email protected]>
Test 5 drives the historical v0.28.0 binary, whose self-update predates
the #3926 fix and leaks the pwsh host's PSModulePath into Windows
PowerShell 5.1, so it flaked in Expand-Archive. Clear PSModulePath around
the call, mirroring the env current self-update builds, so the installer
integration gate stays green.

Refs #3926

Co-authored-by: Copilot App <[email protected]>
Addresses test-coverage-expert F1/F2 from the lean advisory panel:
- Test 5 clears PSModulePath only for pinned binaries older than the
  first fixed release (0.37.0), so a fixed OlderVersion still proves
  self-update from an inherited PowerShell 7 environment.
- A CLI-level test asserts apm self-update never forwards the parent
  PSModulePath to the Windows installer subprocess.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_with_followups

Windows self-update from PowerShell 7 works again. The child powershell.exe 5.1 no longer inherits PS7's PSModulePath, and install.ps1 falls back to .NET ZipFile extraction if Expand-Archive fails. Checksum verification still runs first.

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

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

This is a narrow fix for a broken user path. Running apm self-update from PowerShell 7 on Windows failed during archive extraction because the child powershell.exe 5.1 picked up PS7's PSModulePath and loaded the wrong Archive module. The fix has two parts. First, _build_self_update_installer_env drops PSModulePath (matched case-insensitively) so 5.1 rebuilds its own module path. Second, install.ps1 gets an Expand-ReleaseArchive helper that falls back to the two-argument .NET ZipFile extraction into a fresh extract-<guid> folder. The evidence is strong. The Windows CI gate reproduced the bug live and the fallback recovered. The new Windows cases pass under both real powershell 5.1 and pwsh. The child-env trap fails on main. The change stays inside the accepted scope for #3926: download sources, signing and junction logic are untouched.

The panelists agree. Supply-chain found no integrity regression: the checksum still runs before extraction, the fallback writes into a fresh temp subfolder, and removing PSModulePath for the child shrinks the module-hijack surface. Test coverage raised no objection to the fix itself, only two places where the tests could stay green if the fix regressed later. Both are in scope, because the accepted brief names unit tests of the child env and the Windows installer integration test. Both are recommended, not blocking-severity.

Aligned with: secure by default (checksum first, fallback confined to a fresh temp subfolder, smaller module-hijack surface); multi-host (self-update works again under both PowerShell 7 and Windows PowerShell 5.1, and CI covers both hosts); pragmatic as npm (self-update works from whatever shell you use, with no flags and no migration).

Panel summary

Persona B R N Takeaway
Supply Chain Security Expert 0 0 0 No integrity regression: checksum still runs before extraction, the ZipFile fallback extracts into a fresh subdirectory of tempDir, and removing PSModulePath for the child narrows module-hijack risk.
Test Coverage Expert 0 2 0 Both halves of the fix have regression traps that fail on main. Follow-ups: the e2e harness clear would hide the pwsh7 self-update scenario permanently, and the CLI-level env was never checked for PSModulePath.

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] Assert at the CLI level that no PSMODULEPATH key reaches the env passed to subprocess.run. -- This is a cheap, in-scope trap: today only the env builder is tested. Folded in dcbe1a6 as tests/unit/test_update_command.py::TestUpdateCommand::test_windows_update_does_not_forward_parent_psmodulepath, which fails with main's self_update.py.
  2. [Test Coverage Expert] Have Test 5 clear PSModulePath only when the pinned OlderVersion predates the fix, and assert that guard statically. -- Otherwise the scheduled e2e would hide a regression once OlderVersion moves past the fix. Folded in dcbe1a6: the clear is gated on OlderVersion < 0.37.0. The static test asserts the guard, and fails when the guard is removed.

Recommendation

Merge this fix. It is in scope, the bug was reproduced live, the fix is verified on both PowerShell hosts, and supply-chain found no integrity regression. Since this panel ran, both test-coverage follow-ups have been folded into the PR at dcbe1a6. At 1af71f1 all 31 checks are green, including the Windows Compatibility Gate under real powershell 5.1. The scheduled Test install.ps1 end-to-end (Windows) step runs only on main/schedule, so its first green run will come after merge. Test 5 now isolates the pre-fix v0.28.0 binary, so that run should stay green.


Full per-persona findings

Supply Chain Security Expert

No findings.

Test Coverage Expert

  • [recommended] Test 5 cleared PSModulePath unconditionally, and a static test locked that in, so the e2e could never catch a regression of the self-update fix. At scripts/windows/test-install-script.ps1:649
    Test 5 is the only test that runs a real apm.exe self-update under a pwsh parent. Once OlderVersion moves past the fix, an unconditional clear keeps the e2e green even if _build_self_update_installer_env regresses.
    Suggested: Gate the clear on the pinned binary predating the fix, and assert the version guard statically.
    Proof (missing at): scripts/windows/test-install-script.ps1::Test-SelfUpdateCommand -- proves: Running apm self-update from a PowerShell 7 terminal on Windows upgrades successfully without the user touching PSModulePath. [devx,portability-by-manifest]
  • [recommended] The Windows self-update CLI test checked env['VERSION'] but not that PSModulePath is missing from the installer subprocess env. At tests/unit/test_update_command.py
    The drop was only checked on the builder directly. A later command-body change could bring PSModulePath back without any assertion failing.
    Suggested: Patch os.environ with PSModulePath and assert no PSMODULEPATH key reaches mock_run.call_args.kwargs['env'].
    Proof (missing at): tests/unit/test_update_command.py::TestUpdateCommand::test_update_uses_powershell_installer_on_windows -- proves: apm self-update on Windows never forwards the parent shell's PowerShell module path to the installer it launches. [devx,portability-by-manifest]

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.

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit a98ac42 into main Nov 19, 2026
34 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-fix-windows-self-update-psmodulepath branch November 19, 2026 15:11
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 19, 2026
A Claude plugin silently lost the MCP servers apm install renders from
apm.yml. Pack now names them and the remedy; the CHANGELOG moves the
#3966 line to upgrade notes with that migration, pack.md and apm-usage
say the same, and the unrelated #3931 line this PR dropped is restored.

Addresses panel follow-ups (supply-chain, doc-writer) on #3988.

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 19, 2026
* fix(lockfile): stamp the running APM on every substantive lock write (#3962)

Harvested from #3977.

Co-authored-by: Copilot App <[email protected]>

* fix(bundle): warn when a bundle's lockfile was written by a newer APM (#3963)

Harvested from #3978.

Co-authored-by: Copilot App <[email protected]>

* fix(marketplace): origin-check every marketplace resolution entry point (#3959)

Harvested from #3976; the positional install reads the lock lazily.

Co-authored-by: Copilot App <[email protected]>

* fix(install): preview object-form marketplace dependencies in --dry-run (#3960)

Harvested from #3973.

Co-authored-by: Copilot App <[email protected]>

* fix(prune): keep object-form marketplace dependencies (#3960)

Harvested from #3974.

Co-authored-by: Copilot App <[email protected]>

* fix(install): retire a local bundle's MCP servers when a reinstall drops them (#3956)

Harvested from #3975.

Co-authored-by: Copilot App <[email protected]>

* fix(update,audit): honour the current executables decision after apm deny (#3958)

Harvested from #3981.

Co-authored-by: Copilot App <[email protected]>

* fix(approve): correct the remediation after apm deny; approve clears a same-store deny (#3957)

Harvested from #3979.

Co-authored-by: Copilot App <[email protected]>

* fix(approve): match package names exactly and refuse ambiguous names

A partial name could grant or deny execution for another package.

Co-authored-by: Copilot App <[email protected]>

* fix(pack): never ship APM-managed root .mcp.json servers (#3966)

Harvested from #3971.

Co-authored-by: Copilot App <[email protected]>

* fix(install): the trust owner reads the scope manifest, so -g honours executables: (#3954)

exec_trust_context_for_project takes the manifest file instead of deriving
apm.yml from a caller-chosen root; -g resolves APM_HOME/apm.yml through
core.scope.get_manifest_path. A closed-world guard registers every caller.
Supersedes #3969 and keeps its lifecycle test.

Co-authored-by: Copilot App <[email protected]>

* fix(deps): deps update and lock --update revalidate marketplaces (#3961)

Every caller of the shared install entry now runs inside a registered
catalog-freshness envelope; the guard is closed-world.

Co-authored-by: Copilot App <[email protected]>

* fix(lifecycle): lifecycle test --execute fires through the script gate

APM_NO_SCRIPTS, org executables.deny_all and project script trust now apply;
LifecycleScriptRunner is built only by build_runner_from_context, guarded
closed-world by the new lifecycle-script-firing-gate owner.

Co-authored-by: Copilot App <[email protected]>

* test(approve): exact and unambiguous approve/deny matching

Co-authored-by: Copilot App <[email protected]>

* fix(pack): root .mcp.json reads exclude APM-managed servers by default (#3966)

The only opt-out is a dependency's own authored .mcp.json; a closed-world
guard refuses any other.

Co-authored-by: Copilot App <[email protected]>

* test(architecture): a bundle reinstall must reconcile its owned MCP servers (#3956)

Co-authored-by: Copilot App <[email protected]>

* test(architecture): guard object-form lock-row mapping and exact approve matching

Co-authored-by: Copilot App <[email protected]>

* fix(update): read packages as replay does; skip the policy fetch when the gate was never on (#3958)

Harvested from #3981 (b4cface, cb015e6); the trust read uses the scope manifest.

Co-authored-by: Copilot App <[email protected]>

* fix(install): -g MCP admission reads trust from APM_HOME/apm.yml (#3954)

Harvested from #3969 (5c2cab2).

Co-authored-by: Copilot App <[email protected]>

* fix(targets): apm targets honours targets: in apm.yml (#3792)

Reads the manifest restriction through the same owner install uses.

Co-authored-by: Copilot App <[email protected]>

* fix(cli): user-facing text names current keys, targets and marketplaces

- compile's no-output hint names targets:, not the deprecated target:
- pack's mismatch hint no longer suggests the deprecated pack --target
- skip messages name executables.allow instead of allowExecutables
- origin and freshness errors say marketplace, not catalog
- generated apm.yml headers and unknown-target errors stop listing vscode
- config docs show default_client: copilot

Co-authored-by: Copilot App <[email protected]>

* docs(changelog): 0.37 owner hardening entries; ruff fixes

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

* docs(changelog): reference #3988

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

* fix(update): converge the mixed-type reconcile; pin probe boundaries

Harvested from #3981 (6cd7b3a, delta panel fold). Only a denied row
with mixed per-type verdicts reconciles, so common partial approvals keep
the no-change short-circuit; the probe catches only unreadable-package
errors instead of every exception. Tests pin when the probe fetches
policy, mixed detection on a two-type package, and every unavailable
policy outcome. Test calls pass the scope manifest path, per #3988's
trust-owner signature.

Refs #3958

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: danielmeppiel <[email protected]>
Co-authored-by: Copilot App <[email protected]>

* test: align tests with the 0.37 contracts this PR introduces

CI on 913336a was red on tests that encoded the pre-#3983 contracts:
- lifecycle test --execute now fires through the script gate, so the
  firing test trusts the project first and the old bypass trap now
  asserts untrusted scripts are withheld (mutation-break: restoring an
  ungated LifecycleScriptRunner fails it);
- codex native admission names executables.allow, not allowExecutables;
- a real LockFile.write stamps the running CLI (#3962), so the heal
  eligibility fixture pins the stamp it means to write;
- pack no longer ships servers apm install renders from apm.yml (#3966),
  so the bundle MCP retire test authors its server in .mcp.json.

Addresses merge-worker CI triage on #3988.

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

* fix(uninstall): origin-check marketplace rows from the batch index

require_locked_catalog_origin rescanned lockfile.dependencies for every
package, breaking the uninstall single-traversal guarantee. The batch
index now also keys rows case-insensitively, and the registry fallback
checks each matched row through require_locked_row_origin before any
catalog I/O. Adds a rebound-alias regression test (mutation-break:
dropping the check lets the catalog be reached) and moves the origin
entry-point guard and its mutation case to the new call.

Refs #3959

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

* fix(pack): warn when root .mcp.json servers APM manages are left out

A Claude plugin silently lost the MCP servers apm install renders from
apm.yml. Pack now names them and the remedy; the CHANGELOG moves the
#3966 line to upgrade notes with that migration, pack.md and apm-usage
say the same, and the unrelated #3931 line this PR dropped is restored.

Addresses panel follow-ups (supply-chain, doc-writer) on #3988.

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

* fix: fold Copilot review on trust and origin owners

- install x@alias reads a legacy apm.lock for the origin check, through
  the read-only lockfile resolver, so a rebound alias fails closed before
  migration (Copilot on commands/install.py:220);
- the update probe reuses POLICY_RESOLUTION_FAILURE_OUTCOMES, so an
  incomplete policy chain also forces the guarded install path
  (Copilot on commands/update.py:148);
- apm approve clears a same-store deny stored under any spelling the
  deny ladder matches (URL, host, case), via canonical_exec_identity
  (Copilot on commands/approve.py:817).

Each fix has a regression test proven by mutation-break.

Refs #3957, #3958, #3959

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

* fix(targets): singular target: all lists the install set as active

restriction() folds singular `target: all` to None (auto-detect), but
install expands it to the stable install set, so apm targets showed every
target inactive. Expand it through target_catalog.expand_all("install").
Regression test proven by mutation-break.

Addresses Copilot on commands/targets.py:32.

Refs #3792

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

* perf: share one marketplace index across dry-run and prune lookups

locked_marketplace_row and locked_marketplace_form were called per
declaration without an index, so LockFile.get_dependency rebuilt the
marketplace index each time (O(M*N)). Both callers now build it once,
as the reachability walk already does.

Addresses Copilot on install/dry_run_plan.py:33 and install/orphans.py:46.

Refs #3960

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

* test(architecture): track the shared marketplace index in mutation cases

The object-form mutation cases match the exact call text, which now
passes the shared marketplace index.

Co-authored-by: Copilot App <[email protected]>

* fix(pack): ship apm.yml MCP declarations; only root claims hide root entries

Red team qa-prA-5 and qa-prA-6 on #3988, both regressions against main:

- A Claude bundle and plugin.json dropped the producer's own apm.yml MCP
  servers: they were read only from the rendered root .mcp.json, which pack
  now withholds. collect_mcp_servers projects the root manifest's
  self-defined declarations from apm.yml values (never the rendered copy),
  through the existing credential stripping, so output is byte-identical
  before and after apm install. The pack warning remains only for
  APM-managed servers apm.yml does not define (a dependency's).
- apm_managed_mcp_names unioned lock claims from every runtime, so a
  Cursor-only claim on `docs` hid an authored root `docs` from Claude and
  Codex. Only claims whose runtime writes root .mcp.json count, read
  through the factory (ClientFactory.project_destination_is_root_mcp_json,
  side-effect free); unknown runtimes and unplaced aggregate names stay
  managed (conservative).

The new unit tests fail on e9d6c9d and pass here; the bundle-retire
lifecycle test is back to its apm.yml declaration; test_pack_mcp_ownership
asserts byte identity, no header or secret values and no reference to the
rendered file; the pack guard requires both owner rules, with a standalone
mutation test. CHANGELOG, pack.md and apm-usage updated.

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

---------

Co-authored-by: danielmeppiel <[email protected]>
Co-authored-by: Copilot App <[email protected]>
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] Windows apm self-update fails in Expand-Archive (ExtractToDirectory overload) when launched from PowerShell 7

2 participants