Skip to content

fix(bundle): keep a directory source package out of the bundle path - #3604

Merged
Daniel Meppiel (danielmeppiel) merged 10 commits into
mainfrom
danielmeppiel-fix-3443-dir-plugin-json-bundle
Nov 12, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 10 commits into
mainfrom
danielmeppiel-fix-3443-dir-plugin-json-bundle

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

TL;DR

apm install DIR routed any directory with a root plugin.json to the local-bundle path, so an APM source package that also ships a plugin manifest was copied verbatim, warned about an "older APM version", and never recorded as a dependency. Bundle detection for directories now requires real apm pack output: a directory with apm.yml and no pack: manifest in apm.lock.yaml falls through to the local-dependency resolver, exactly like apm install DIR DIR.

Note

Credit: approach from #3447 by JohnnyXu (@xubenqiang) (closed for CLA). This PR carries the same _has_pack_manifest check and adapts its installed-CLI regression file; JohnnyXu (@xubenqiang) is credited via Co-authored-by.

Problem (WHY)

  • apm install --target copilot ../demo-pkg on HEAD (3b1ab4d) printed Installing local bundle, wrote .github/.apm/skills/demo/SKILL.md and .github/apm.yml, and left dependencies: [] in apm.lock.yaml.
  • The same path passed twice resolved as a local dependency (.agents/skills/demo/SKILL.md, source: local), so the outcome depended on argument count.
  • [!] The misleading "produced by an older APM version" warning fired for a directory that was never pack output.

Why these matter: the local_bundle.py module docstring defines a local bundle as a directory "produced by apm pack", and the package-types reference says "When plugin signals coexist with an eligible apm.yml, the APM layout wins.".

Approach (WHAT)

# Fix
1 detect_local_bundle returns None for a directory that has apm.yml but whose apm.lock.yaml has no non-empty pack mapping (every apm pack writes one via lockfile_enrichment).
2 Archives (.zip, .tar.gz) and legacy manifestless directories (plugin.json, no apm.yml) keep current behavior, per the record's out-of-scope list.

Implementation (HOW)

  • src/apm_cli/bundle/local_bundle.py -- new _has_pack_manifest() reuses _read_bundle_lockfile (so unsupported lockfile versions still fail closed); the directory branch of detect_local_bundle skips source packages. Docstring updated.
  • tests/unit/bundle/test_local_bundle.py -- regression trap for source packages with and without their own install lockfile, plus pins for packed directories with apm.yml and legacy manifestless directories.
  • tests/integration/test_install_dir_source_package_lifecycle.py -- installed-CLI contract (adapted from fix(bundle): keep a directory source package out of the bundle path #3447): install DIR equals install DIR DIR (manifest, lock, deployed tree); real apm pack directory and archive output still install as bundles; legacy manifestless bundle unchanged.
  • Docs -- consumer/deploy-a-bundle.md and apm-guide commands.md describe the new detection rule.

Diagrams

Legend: single-argument apm install PATH routing after this change; the boxed decision is new.

flowchart LR
    A["apm install PATH (one arg)"] --> B{"directory with plugin.json?"}
    B -- no --> R["local dependency resolver"]
    B -- yes --> C["NEW: apm.yml present AND no pack manifest in apm.lock.yaml?"]
    C -- yes --> R
    C -- no --> D["local bundle install"]
    R --> E["apm.yml + apm.lock.yaml record source: local"]
    D --> F["files deployed, apm.yml untouched"]
    style C fill:#fff3cd,stroke:#b58900
Loading

Trade-offs

  • Any apm.yml vs "eligible" apm.yml. Chose "any apm.yml without a pack manifest" (the record's wording); apm pack never emits a root apm.yml, so the narrower eligibility check would only add complexity.
  • Warning wording untouched. The "older APM version" warning no longer fires for source packages; rewording it is not in the approved scope.
  • E2E file not in lifecycle_smoke. It runs in the merge-group full integration path; promoting it to the PR-time budget is a separate call.

Benefits

  1. apm install DIR and apm install DIR DIR produce identical apm.yml, apm.lock.yaml dependencies and deployed tree for a source package with plugin.json.
  2. Wrappers no longer need the duplicate-argument workaround to get dependency semantics.
  3. Real pack output (directory and archive) and legacy bundles keep the bundle path, proven by e2e tests.

Validation

Local preflight skipped by maintainer instruction (2026-11-12); CI is the gate.

$ .venv/bin/python -m pytest tests/unit/bundle/test_local_bundle.py -q -p no:xdist
57 passed, 1 skipped in 2.18s

$ APM_E2E_TESTS=1 APM_BINARY_PATH=.venv/bin/apm .venv/bin/python -m pytest \
    tests/integration/test_install_dir_source_package_lifecycle.py -q -p no:xdist
4 passed in 8.34s

$ ruff check / ruff format --check (changed .py files)
All checks passed! / 3 files already formatted
Mutation-break: guard replaced with if False:
FAILED tests/unit/bundle/test_local_bundle.py::TestDetectLocalBundle::test_detect_skips_source_package_with_apm_yml[no-lockfile]
FAILED tests/unit/bundle/test_local_bundle.py::TestDetectLocalBundle::test_detect_skips_source_package_with_apm_yml[install-lock]
FAILED tests/integration/test_install_dir_source_package_lifecycle.py::test_single_argument_dir_install_matches_two_argument_dependency_install
3 failed, 58 passed, 1 skipped in 12.40s

Scenario Evidence

# Scenario (user promise) Principle(s) Test(s) proving it Type
1 apm install DIR on a source package with apm.yml + root plugin.json records it as a local dependency, same as apm install DIR DIR DevX, Portability by manifest tests/integration/test_install_dir_source_package_lifecycle.py::test_single_argument_dir_install_matches_two_argument_dependency_install (regression-trap for #3443)
tests/unit/bundle/test_local_bundle.py::TestDetectLocalBundle::test_detect_skips_source_package_with_apm_yml
e2e, unit
2 Real apm pack output (directory or archive) still installs as a local bundle Governed by policy, DevX tests/integration/test_install_dir_source_package_lifecycle.py::test_apm_pack_output_still_installs_as_local_bundle
tests/unit/bundle/test_local_bundle.py::TestDetectLocalBundle::test_detect_keeps_packed_directory_with_apm_yml
e2e, unit
3 A legacy manifestless bundle directory keeps installing as a bundle DevX tests/integration/test_install_dir_source_package_lifecycle.py::test_legacy_manifestless_bundle_keeps_bundle_install
tests/unit/bundle/test_local_bundle.py::TestDetectLocalBundle::test_detect_keeps_legacy_manifestless_directory
e2e, unit

How to test

  • Build the issue's demo-pkg (apm.yml, .apm/skills/demo/SKILL.md, root plugin.json).
  • In an empty dir run apm install --target copilot ../demo-pkg -> no "local bundle" line; apm.yml lists ../demo-pkg; lock records source: local; skill at .agents/skills/demo/SKILL.md.
  • apm pack -o dist a package, then apm install dist/<bundle> -> still "Installing local bundle".

Issue and approved scope

Issue: Fixes #3443

Human scope-approval comment: #3443 (comment) (apm-scope:v1, approver and review contact Daniel Meppiel (@danielmeppiel))

Does this PR complete the issue, or what remains? Completes the approved scope. Out of scope per the record: archive bundle detection, new flags to force bundle or dependency mode, plugin-only directories without apm.yml.

Type of change

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

Testing

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

Targeted local runs only (see Validation); full suites are left to CI per maintainer instruction.

Spec conformance (OpenAPM v0.1)

If this PR changes behaviour that an OpenAPM v0.1 req-XXX covers,
confirm the three-step ritual in the
development guide:

  • Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

Co-authored-by: Copilot [email protected]

…3443)

A directory with apm.yml and a root plugin.json but no pack manifest in
apm.lock.yaml is an APM source package, so 'apm install DIR' now resolves
it as a local dependency, matching 'apm install DIR DIR'. Real apm pack
output, archives and legacy manifestless bundles keep the bundle path.

Credit: approach from #3447 by @xubenqiang.

Co-authored-by: xubenqiang <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 12:21

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.

🟢 Approval recommended

No active review issues were identified for the change distinguishing source directories from packed bundles.

No open issues 🎉

What changed in this PR

Fixes #3443 by keeping APM source directories with a root plugin.json on the local-dependency path instead of incorrectly installing them as bundles.

Changes:

  • Requires a non-empty pack mapping in apm.lock.yaml before treating a directory with apm.yml as a bundle.
  • Adds regression coverage for single-argument dependency installs, packed bundles, and legacy manifestless bundles.
  • Documents the detection rule while preserving archive handling.
File Description
tests/​unit/​bundle/​test_local_bundle.py Tests source-package detection and packed/legacy bundle compatibility.
tests/​integration/​test_install_dir_source_package_lifecycle.py Verifies installed-CLI routing, dependency records, and deployed files.
src/​apm_cli/​bundle/​local_bundle.py Adds the pack-manifest check to directory bundle detection.
packages/​apm-guide/​.apm/​skills/​apm-usage/​commands.md Updates command guidance for source-directory routing.
docs/​src/​content/​docs/​consumer/​deploy-a-bundle.md Explains when directories use bundle or dependency installation.

Review effort: Balanced

@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_now

Routing fix aligns apm install DIR with the npm/pip mental model: source packages now fall through to the dependency resolver instead of bundle mode. Clean panel, all evidence green.

panel-mode=lean; personas=devx-ux-expert,test-coverage-expert,apm-ceo

cc Daniel Meppiel (@danielmeppiel) -- a fresh advisory pass is ready for your review.

Both panelists converge without dissent. The devx-ux-expert confirms the fix restores the install-a-directory-as-dependency behavior users expect from npm and pip, with no CLI surface change and docs updated in the same PR. The test-coverage-expert noted the e2e tests had not been run at panel time; orchestrator evidence closes that: all four e2e tests pass at the exact head, the unit file passes, and mutation-break proves the new guard is load-bearing.

The PR stays inside the approved apm-scope:v1 record on #3443. Warning rewording, archive bundle detection, mode-forcing flags and plugin-only directories without apm.yml are all out of the record's scope and untouched. The CHANGELOG entry credits #3447 by JohnnyXu (@xubenqiang).

Aligned with: Pragmatic as npm -- apm install DIR on a source package now behaves like npm install DIR. Portable by manifest -- detection keys on apm.yml plus the pack: manifest in apm.lock.yaml, no path heuristics. OSS community driven -- credits the community approach from #3447.

Panel summary

Persona B R N Takeaway
Devx Ux Expert 0 0 0 Routing fix restores npm/pip mental model; docs synced, no CLI surface change.
Test Coverage Expert 0 2 0 Unit and e2e tests cover all three Done-when arms at the correct tier.

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

Recommendation

Both panelists returned clean or informational-only findings, all test evidence is green (unit, e2e, mutation-break), and the PR stays within the approved scope record. Recommend the maintainer merge. No follow-ups to track.

Folded in this run

  • (merge-worker) Merged current main into the branch (PR was CONFLICTING); no code folds were needed -- resolved in 66a4602.

Copilot signals reviewed

  • (overview review) -- NOT-LEGIT: approval recommended, no open issues, zero inline comments; nothing to fold.

Regression-trap evidence (mutation-break gate)

  • tests/unit/bundle/test_local_bundle.py::TestDetectLocalBundle::test_detect_skips_source_package_with_apm_yml -- replaced the apm.yml/_has_pack_manifest guard with if False:; both params FAILED as expected; guard restored.

Lint contract

ruff check and ruff format --check (ruff 0.15.12, the uv.lock pin) silent on src/, tests/ and the architecture linter scripts; pylint R0801 10.00/10; lint-auth-signals.sh and lint-architecture-boundaries.sh clean.

CI

All checks green at 66a4602d (23 success, 2 neutral, 1 skipped; includes CI, Merge Gate, CodeQL, Spec conformance), after 0 CI fix iteration(s). Exact-head local runs: tests/integration/test_install_dir_source_package_lifecycle.py 4 passed; tests/unit/bundle/test_local_bundle.py 57 passed, 1 skipped.

Mergeability status

PR head SHA CEO stance iters folds defers Copilot rounds CI mergeable mergeStateStatus notes
#3604 66a4602 ship_now 1 0 0 1 green MERGEABLE BLOCKED pending required review

Convergence

1 outer iteration; 1 Copilot round. Final panel stance: ship_now. Ready for maintainer review.

Full per-persona findings

Devx Ux Expert

No findings.

Test Coverage Expert

  • [recommended] E2e regression-trap tests were not run at panel time; rely on CI green. Resolved: the orchestrator ran them at the exact head (4 passed) and CI is green.
  • [recommended] Unit tests are sub-floor for the install-pipeline surface; the e2e file supplies floor-tier coverage. Correct two-tier shape; no action needed.

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.

Resolve merge state DIRTY for #3604 by merging current main (432eb5b).
Git merged cleanly; CHANGELOG keeps both main's entries (#1994, #3601) and
this PR's #3604 entry.

Co-authored-by: Copilot App <[email protected]>
Pick up 5b8f92f (#3637). CHANGELOG.md conflicted textually under
### Fixed; resolved by keeping main's #3637 entry and this PR's #3604
entry (no entry dropped).

Co-authored-by: Copilot App <[email protected]>
Pick up e194a7d (#3642) and 1a37071 (#3600). CHANGELOG.md
conflicted textually under ### Fixed; resolved by keeping main's #3600
entry and this PR's #3604 entry (no entry dropped).

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

Copy link
Copy Markdown
Collaborator Author

Merged current main into the branch (merge-of-main fallback; this branch already carries merge commits) at base 1a37071 -> 68ee8b2 (pre-resolution head 66a4602). Main moved twice during resolution, so three merge commits were needed (dd800cf, 5f8d824, 68ee8b2).

Conflicting paths resolved (faithful merge of both intents):

No regression-trap test was touched by the merge; the PR's own tests were re-run at the new head: tests/integration/test_install_dir_source_package_lifecycle.py 4 passed, tests/unit/bundle/test_local_bundle.py 57 passed, 1 skipped.

Lint contract: uv run --extra dev ruff check and ruff format --check (src/ tests/ and the architecture-linter scripts), pylint R0801, scripts/lint-auth-signals.sh and scripts/lint-architecture-boundaries.sh all exit 0 post-merge; no src file over 2100 lines.

CI at 68ee8b2: 23 pass, 3 skipping.

Post-push mergeability: gh pr view --json mergeStateStatus,mergeable reports BLOCKED / MERGEABLE (BLOCKED is the repo ruleset: code-owner review + merge queue). Push used git push https://github.com/microsoft/apm.git HEAD:refs/heads/danielmeppiel-fix-3443-dir-plugin-json-bundle (plain fast-forward push of merge commits, no force).

Ready for maintainer review.


This comment was generated by an AI agent (GitHub Copilot) on behalf of the maintainer. Please verify before acting on it.

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 5bc5721 into main Nov 12, 2026
26 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-fix-3443-dir-plugin-json-bundle branch November 12, 2026 18:00
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
…kage (#3649)

apm install DIR (routed by #3604) and manifest-declared local deps classify
a directory with apm.yml and a root plugin.json as apm_package and deploy
only its .apm/ primitives. The audit --ci replay normalized any local dir
with a plugin.json as a legacy plugin, integrating root agents/ and failing
drift on a fresh install. Route the replay through detect_package_type,
the same classifier install uses.

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
…kage (#3649)

apm install DIR (routed by #3604) and manifest-declared local deps classify
a directory with apm.yml and a root plugin.json as apm_package and deploy
only its .apm/ primitives. The audit --ci replay normalized any local dir
with a plugin.json as a legacy plugin, integrating root agents/ and failing
drift on a fresh install. Route the replay through detect_package_type,
the same classifier install uses.

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 13, 2026
…kfile symlink, audit replay, targeted install, MCP cleanup) (#3672)

* fix(export-patch): make subdirectory package patches apply from the repo root (#3649)

A git: + path: (or marketplace git-subdir) dependency is cached as just
its subdirectory, so exported diff paths were relative to that
subdirectory while the patch header says to apply from the package
repository root; git apply failed with 'No such file or directory'.
Prefix the locked virtual_path for subdirectory packages.

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

* fix(export-patch): export edits to Claude plugin packages (#3649)

Install normalizes a Claude plugin (no apm.yml) by mirroring skills/,
agents/ and commands/ into .apm/ inside the cache. export-patch indexed
both copies, so every skill or agent edit in a marketplace plugin was
skipped as 'ambiguous source'. When the cache carries the parser-owned
normalization receipt, prefer the upstream candidate over the .apm/
mirror.

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

* fix(view): accept logical absolute paths in view --file (#3649)

apm view --file "$PWD/<file>" exited 2 ('outside the project deploy
root') whenever the working directory was reached through a symlink
(macOS /tmp and /var, symlinked workspaces): the deploy root comes from
the physical getcwd() while the query kept its logical parents. When
the lexical query is not under the deploy root, resolve only its parent
directory so the queried leaf stays exact.

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

* test(redteam): C5 marketplace, pack, export-patch and view --file chains (#3649)

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

* fix(lockfile): refuse a symlinked lockfile before update or uninstall writes (#3649)

apm update, apm install --update and apm uninstall detected a symlinked
apm.lock.yaml (#3532) only when writing the lockfile, after deploying new
files, cleaning stale ones and editing apm.yml. The command then exited 1
with the lockfile still describing the old state, and update reported that
no transaction changes were committed. ensure_lockfile_writable() is now
the single owner of the rule; LockFile.write uses it, and update (when the
plan changes the graph) and uninstall (when it removes a locked package)
call it before any other write, so the transaction rolls back cleanly.

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

* fix(audit): replay local apm.yml packages with plugin.json as apm_package (#3649)

apm install DIR (routed by #3604) and manifest-declared local deps classify
a directory with apm.yml and a root plugin.json as apm_package and deploy
only its .apm/ primitives. The audit --ci replay normalized any local dir
with a plugin.json as a legacy plugin, integrating root agents/ and failing
drift on a fresh install. Route the replay through detect_package_type,
the same classifier install uses.

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

* fix(install): keep a targeted package's dropped deps an unreached entry may need (#3649)

apm install PKG drops the selected package's former descendants that this
run's graph no longer contains (#3528). With #3571 the graph is rebuilt from
the current apm.yml of every local package, so an unselected sibling edited
since it was locked makes the graph omit retained entries it still locks.
A shared dependency of such an entry was then removed while the entry stayed
locked, leaving apm.lock.yaml without that entry's dependency while audit
and prune passed. When the graph omits any retained entry it cannot prove the
candidate unneeded, so drop nothing; the next full install reconciles.

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

* fix(mcp): keep user short-name entries when a slashed server is removed (#3649)

Stale MCP cleanup expanded every stale name to its last path segment, so
removing self-defined com.example/server deleted a user-authored or
still-declared 'server' entry from VS Code, Cursor, Copilot and OpenCode.
Self-defined servers keep their declared key (#3493) and older truncated
keys are reconciled only under ownership proof at install time, so derive
the alias from the adapter key owner with self-defined context.

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

* test(lifecycle): guard 0.36.0 release flows with lifecycle chains (#3649)

Permanent APMLifecycle scenarios from the 0.36.0 pre-release sweep.
They drive the real apm binary over hermetic local Git fixtures across
install, install --frozen, update, audit --ci, prune, uninstall, pack,
marketplace, export-patch, view --file, policy and user scope. They
assert disk, lockfile, receipts and exit code after every step.

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

* docs(changelog): record 0.36.0 red-team regression fixes (#3649)

apm-spec-waiver: restores promised behavior of features merged since v0.35.0; no OpenAPM requirement changes

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

* refactor(owners): route export-patch mirror, lockfile preflight, and MCP config-key through canonical owners (#3649)

Fix 2: export_patch now routes .apm/ mirror classification through
plugin_parser.is_install_generated_mirror() instead of hard-coding
.apm/ prefix knowledge. The normalization owner decides what is a
mirror.

Fix 4: lockfile symlink write-guard consolidated into
refuse_lockfile_before_mutation() in deps/lockfile.py (single owner).
Both pipeline.py and uninstall/cli.py now call this owner API.
Added owner registry guard contracts-tooling-lockfile-symlink-write-guard
with a MutationCase proving its teeth.

Fix 7: MCPClientAdapter._determine_config_key promoted to public
determine_config_key(). All 17 call sites (adapters, integrators,
ownership, cleanup) updated. No cross-module private access.

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

* docs(changelog): cite #3672 for the red-team regression fixes (#3649)

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

* fix(compile): never overwrite hand-authored nested context files (#3655)

Distributed compile replaced a hand-authored subdirectory AGENTS.md or
CLAUDE.md that carries no APM marker, then treated the replaced file as
generated output and reported it as orphaned. The canonical owner
hand_authored_root_context_blocks_write now applies its marker rule to
catalog context filenames at any depth, the AGENTS.md and CLAUDE.md call
sites route every placement through it, and nested Git repository skips
are decided before protection so their accounting is unchanged. The
static guard pins the any-depth rule, with mutation cases.

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

* fix(uninstall): keep apm.lock.yaml truthful when uninstall refuses (#3656)

When apm uninstall stopped because a tracked target file was edited or a
user file sat in a managed skill directory, it had already removed the
package's other target files but left apm.lock.yaml claiming all of them.
The target-contraction owner (reconcile_target_deployed_files) now reports
what each selected dependency still owns through SelectedCleanupOutcome,
and the refusal applies it via DeploymentLedgerCodec.replace_legacy_owners
and writes the lockfile, so it claims only files still on disk while
apm.yml keeps the package for the retry. Preserved profile rows stay
claimed. The retained-edit warning now carries its [!] symbol.

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

* fix(uninstall): keep the other runtime's default root on selected-profile uninstall (#3661)

A global uninstall retained for another Claude/Hermes profile removed rows
under every USER_ROOT_ENV_VARS target's selected root, so a HERMES_HOME
profile uninstall also deleted ~/.claude files (and vice versa).
profile_scope now shares one other-profile record walk and removes only the
selected roots of the runtimes whose profiles split the package.

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

* fix(deps): replay proxy-routed lock rows under --frozen (#3657)

A transparent registry proxy records the proxy host and registry_prefix
instead of the upstream host, so drift classified every such row as a
provider change and --frozen refused the lock the proxy had just written.
ArtifactoryRouter now owns the proxy routing target (promoted from the
resolver's private copy) and answers whether a dep routes to a locked proxy
row; drift, download-ref replay and the cached-commit owner reuse it.

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

* fix(audit): honor --no-cache for auto-discovered policy (#3659)

The explicit --policy and auto-discovery branches now share one discovery
call that always forwards no_cache, so 'apm audit --ci --no-cache' fetches
the org policy fresh as documented.

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

* test(policy): guard audit --ci agreeing with install on denied transitives (#3658)

main's source-dependency owner (#3606) already runs the allow and deny
checks over effective direct deps plus locked transitives. This keeps
the installed-CLI guard that install and audit --ci agree.

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

* fix(marketplace): real recovery hint, verified package refs, packed relative hook scripts (#3670)

- apm pack on a branch-ref marketplace package no longer suggests the
  nonexistent --allow-head flag; it names the real recovery command
  (apm marketplace package set <pkg> --ref <tag-or-sha>).
- marketplace package add/set --ref verify the ref on the entry's own host
  through the explicit-ref owner shared with marketplace check
  (ref_resolver.explicit_ref_error, package_entry_coordinates): a missing
  tag or unreachable remote exits 2 without changing apm.yml; --no-verify
  keeps the opt-out. Previously a non-default host looked 'network
  unavailable' and any missing tag was stored with exit 0.
- apm pack carries hook scripts referenced as ./scripts/x from .apm/hooks
  the way install resolves them (resolve_relative_hook_script, promoted to
  public) and repoints the packed command.
- Owner record marketplace-entry-ref-verification + AC10 guard + MutationCase.

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

* fix(bundle): name skipped source symlinks in pack; skip plugin hooks in bundle installs (#3670)

- apm pack keeps not following own-source symlinks (matching own-project
  install), but now names each dropped link in a pack warning instead of
  dropping it silently. The existing exporter walkers record the skipped
  links; both bundle exporters warn through _emit_pack_warning.
- apm install <bundle> no longer copies a Claude plugin bundle's hooks.json
  raw into the target root or lowers hooks/ scripts through the hook
  descriptor extension (fmt.sh -> fmt.sh.json). The local-bundle routing
  owner (install/local_bundle_paths.py) skips plugin-native hook paths and
  reports one bundle_deploy_skip_warning per file; deployed-layout bundles
  keep routing their target hook files. Merging bundle hooks through the
  hook integrator is a follow-up.

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

* fix(mcp): clean recorded servers after their runtime opt-in dir is pruned (#3664)

Removing a dependency prunes an emptied .claude/ or .opencode/ before MCP
stale cleanup runs, and remove_stale reused those write opt-in directories
as cleanup gates, so the recorded server stayed in .mcp.json or
opencode.json while its ledger ownership was dropped (apm uninstall and
apm install after removing the dependency).

install/mcp/ownership.py, the safe-removal owner, gains
project_mcp_cleanup_reachable: ledger-scoped cleanup (an explicit runtime
from the ownership ledger) stays reachable, otherwise the opt-in dir still
gates. remove_stale routes both gates through it; Claude removal stays
content-verified by require_removable_mcp_connections. The
install-deployment-mcp-ownership-migration guard requires that route and
rejects a raw .claude/.opencode is_dir gate in mcp_integrator.py, with a
mutation case.

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

* fix(hooks): retire merged events a hook source no longer declares (#3665)

Merged hook targets cleared a source's earlier entries only for the
events its current hook files declare. Deleting one hook file from a
package or the root .apm/hooks while another remained left the old event
entry in .claude/settings.json and apm-hooks.json, pointing at a deleted
script, and apm audit --ci then reported drift.

hook_ownership.py gains drop_source_entries, extracted from Cursor's
inline whole-source clear. HookIntegrator now uses it for that clear and,
after merging, to drop the source's entries from every event it did not
re-declare, so hook_integrator.py shrinks. The neutral-hook-contract
guard requires both calls and forbids a second definition, with a
mutation case.

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

* fix(mcp): exit apm mcp install through the install outcome (#3666)

apm mcp install forwarded to apm install --mcp with
cli.main(standalone_mode=False), which returns ctx.exit codes instead of
raising them, so a failed forwarded install (for example an org policy
block) exited 0. Run the forwarded command in standalone mode so its exit
comes from install/outcome.py and Click's error handling exactly as for
apm install. The install-deployment-outcome guard rejects
standalone_mode=False under commands/, with a mutation case.

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

* fix(deps): list the dependency key apm uninstall accepts (#3671)

apm deps list showed a self-hosted GitLab dependency (type: gitlab) by its
host-blind org/repo key with Source github, while apm deps tree showed
the host-qualified key and apm uninstall only accepts that identity.
deps list now shows the key deps tree derives (_dep_display_key, extracted
from _dep_display_name) for remote locked dependencies, keeping
host-blind keys for orphan detection, and labels Source through the
canonical classify_host_provider with the declared or locked host_type.

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

* fix(cleanup): never delete a deployed file without a matching recorded hash (#3663)

Stale, orphan, contraction, prune and uninstall cleanup all route through
integration/cleanup.py::remove_stale_deployed_files. Its provenance gate
deleted any lockfile-claimed file without a recorded hash (legacy
fall-through), so a hand-edited lockfile could make a receipt-less install
delete user files. Gate 3 now keeps such files with a warning and reports
them as retained, matching the documented rule that stale files are removed
only when recorded hashes match. cowork:// rows stay exempt because install
records no hashes for them yet. enterprise/security.md now states that a
committed apm.lock.yaml is reviewed input with cleanup authority.

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

* fix(audit): replay local packages through the install package image (#3667)

apm install copies a local package with materialize_local_package, which
dereferences in-package links and materializes single files. The audit
--ci replay integrated straight from the source tree, where integrators
skip links, so a clean install of a package with a contained link reported
its deployed file as orphaned drift.

materialize_local_package is now the one raising owner of the local
package image: install (_copy_local_package), the uninstall survivor
refresh and audit replay (materialize_local_package_for_replay) all copy
through it. path_anchoring.resolve_local_dep_base owns the admission
anchor for a locked local dep. The replay's raw-directory branch, the
file-only replay materializer and the legacy-plugin normalizer's extra
copy are gone. The single-file owner guard, registry record and mutation
cases now pin the shared routes.

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

* fix(prune): keep a hand-removed direct dependency another package still needs (#3668)

prune and deps list retained lock entries recorded with depth > 1 only, so
a dependency hand-removed from apm.yml that another installed package
still declares looked orphaned and prune deleted its checkout, deployed
files and lock entry.

deps/reachability.py, the forward-reachability owner uninstall already
uses, now answers which lock entries are retained (retained_lock_keys):
recorded transitives plus stale direct entries still reachable from a
declared package's manifest, failing closed when the walk is incomplete.
_build_expected_install_paths (prune, deps list, orphan warning) and
prune's lock-key selection route through it instead of re-deriving
depth > 1. The walk treats a manifestless skill, skill bundle or hook
package as a leaf (classified by detect_package_type) instead of an
unverifiable node. The reachability guard rejects a parallel depth rule
in prune or the selector; docs describe the kept package.

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

* fix(uninstall): keep is_dev as install writes it and never report a withheld lock write (#3669)

The forward-reachability walk that rescues a shared dependency after
uninstall treated every survivor as production, so a dependency left
reachable only through devDependencies was rewritten without is_dev and
the next install rewrote apm.lock.yaml.

compute_forward_reachable_keys now takes the surviving devDependencies
separately and drains production paths first, reporting dev_only keys
with the install resolver's rule (a production path wins); uninstall
persists it with the resolved_by repair. LockFile.write/save return
whether the file was persisted, so install --frozen no longer prints
'Updated apm.lock.yaml' for a write it withheld.

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

* refactor(install): gate update plans through one plan_inputs owner (#3649)

The update-plan confirmation and the symlinked-lockfile refusal now
live in install/helpers/plan_inputs.confirm_update_plan, next to
build_resolved_update_plan. The pipeline makes one call and drops its
local helper, so pipeline.py stays under the install LOC budget. The
plan is still built lazily, only when an unwritable lockfile needs it.

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

* refactor(install): keep install modules within their LOC budgets (#3649)

Moves SelectedCleanupOutcome (#3656) into install/selected_cleanup.py;
the target-contraction owner re-exports it for its callers. Compacts
the cached-commit tail in sources.py (#3657) with no behavior change.
The dependency-replacement guard and its mutation case now pin the plan
through plan_inputs.confirm_update_plan.

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

* docs(changelog): record the #3649 fix wave (#3672)

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

* docs(policy): state that org policy does not govern user-scope installs (#3660)

Org policy discovery starts from the project's git remote, so apm install -g
(user scope) is not governed by org policy today. Docs only; no behavior
change. A user-scope policy source is tracked separately.

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

* test(architecture): keep one matrix case per guard for sweep sub-rules (#3649)

The #3664, #3665 and #3666 guard extensions now prove their teeth in a
parametrized standalone test, so the owner-rule matrix keeps exactly one
mutation case per registry guard.

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

* fix(install): keep packages apm.yml no longer declares during --frozen (#3662)

apm install --frozen tolerated lockfile entries that apm.yml no longer
declares but still ran orphan cleanup, deleting their deployed files while
the never-rewritten lockfile kept claiming them. The cleanup phase now
retains every orphan under --frozen through the existing
orphan_cleanup_retained map, so files, the apm_modules checkout and the
lock rows stay in place, and prints one info line naming the kept packages
with the remedy to run apm install. Retained orphans now carry their
source rows' concrete targets, so the frozen build stays equivalent to the
committed lockfile and no rewrite is withheld.

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

* docs(changelog): record frozen orphan retention (#3662)

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

* test(lifecycle): install vs audit --ci replay matrix across package shapes (#3649)

Sixteen package shapes (APM package via Git/local/alias/target subset,
monorepo subdirectory, contained links in Git and local packages, hooks via
Git alias/local alias/symlinked path, Claude skill local alias and Git,
skill bundle subset, Claude plugin Git and local alias, MCP-only, single
file) driven through install, re-install, install --frozen, compile, cold
clone without receipts or cache, and uninstall, asserting audit --ci agrees
at every step. Guards the #3667 local package image replay for aliased and
symlinked local paths.

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

* fix(audit): keep local replay images out of the live apm_modules (#3667)

The #3667 replay wrote each local package image at
apm_modules_dir/<slot>. A cache-only replay (bare 'apm audit') passes the
live project apm_modules there, so auditing silently rewrote the installed
copy with unaudited source bytes and normalized legacy plugins in place;
in --ci mode the image landed on the native plugin replay path and
verify_native_plugin_cache then copied the source onto itself
(SameFileError). Materialize local images under the scratch deployment
root and let native verification hash that image instead of re-copying.

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

* fix(deps): find case-equivalent installs in the reachability walk; keep sweep guards green (#3649)

- models/dependency/materialization.installed_package_path is the one
  read-only lookup for where a dependency is materialized. It recognizes a
  case-equivalent directory. Prune's expected-path builder and the forward
  reachability walk both use it, so prune and uninstall no longer treat a
  casing-equivalent install as unverifiable on case-sensitive file systems
  (#3668).
- integration/cleanup.py: a managed final symlink needs no content hash
  to be unlinked, because unlinking removes no file content (#3663).
- Hook sync tests pass the recorded hashes that uninstall passes. The
  Claude MCP broadcast test pins the opt-in gate (#3664). The frozen rule
  inventory lists the lockfile symlink guard.

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

* docs(changelog): drop the #3658 entry delivered by #3606 (#3649)

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

* docs(changelog): remove stale placeholder bullets left by the rebase (#3649)

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

* style(tests): format owner-rule mutations after rebase (#3649)

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

* fix(install)!: fail --frozen when deployed bytes differ from locked hashes (#3654)

BREAKING CHANGE: apm install --frozen now exits 1 when a deployed file's
on-disk bytes differ from its deployed_file_hashes entry (OpenAPM
req-lk-017), naming each path with its expected and observed envelope.
Before, frozen exited 0 on a dirty tree and the next apm audit --ci
failed with hash drift. This covers a kept local edit (e.g. a user-edited
skill) and an APM upgrade that renders an already-locked file
differently. Repair: run apm install without --frozen and commit.

The per-record hash loop of audit content-integrity is extracted into
policy/ci_checks.py verify_deployed_file_hashes, and audit scope/target
resolution into resolve_audit_scope; audit and the existing post-deploy
frozen owner (InstallService._enforce_frozen_no_rewrite) both call them.
The install success line now reads 'Deployed files verified against
apm.lock.yaml.'. Audit drift text no longer offers export-patch for a
modified file whose bytes still match the lock; local_edits owns the new
rendering-change hint. check_frozen pins both verifier call sites; docs,
apm-usage skill, a req-lk-017 CLI conformance test and lifecycle guards
are updated.

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

* docs(changelog): record the frozen hash verification break (#3654)

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

* test(spec): give the cleanup conformance context its frozen default (#3662)

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

* fix(audit): keep user-scope local replay images out of the governed tree (#3667)

At user scope the scratch modules root sits under the governed .apm
directory, so local package images read as deployed drift. Replay now
materializes local images in an ungoverned scratch apm_modules. At project
scope that is the same directory as before.

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

* test(lifecycle): parse git URLs in the SSH transport guard (#3640)

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

* test(deps): guard the case-equivalent install lookup directly (#3668)

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

* refactor(architecture): register MCP config-key derivation owner (#3649)

Add guard hooks-integrations-mcp-config-key-derivation to the existing
mcp-package-launcher owner in hooks-integrations.json, with a static
check in mutation_mcp_target_and_scope.py that verifies:
  - determine_config_key exists as a definition in MCPClientAdapter
  - MCP consumers (mcp_integrator, mcp_integrator_install, mcp/ownership)
    route through determine_config_key() and do not re-derive config keys
    by splitting on "/"

MutationCase proves the guard fires when the definition is renamed.
Frozen rule inventory updated in test_architecture_runner.py.

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

* test(install): guard frozen hash verification at user scope (#3654)

Parametrize the warm kept-edit frozen guard over project and user scope:
apm install -g, tamper with a deployed skill under the isolated HOME,
then apm install --frozen -g must exit 1 naming the path with expected
and observed hashes and leave $APM_HOME/apm.lock.yaml byte-identical;
after the user resolves the edit and runs apm install -g, --frozen -g
exits 0.

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

* fix(uninstall): scope selected-profile removal per package in batched uninstalls (#3649)

selected_profile_survivors combined the split runtimes of every requested
package, so uninstalling two packages at once could delete files that two
separate uninstalls keep (one package split across Hermes homes, the other
across Claude profiles). The removable selected-profile prefixes are now
computed per package before survivor rows are combined.

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

* fix(install): refuse a symlinked lockfile before any update side effect (#3649)

confirm_update_plan only refused a symlinked apm.lock.yaml when the
resolved dependency plan had changes. A target-only change under
apm install --update leaves the plan unchanged but still rewrites the
deployment ledger, so files were deployed before the lockfile write
failed. An update exists to rewrite the lockfile, so it now refuses
unconditionally through refuse_lockfile_before_mutation(would_mutate=True),
after the apm update plan callback and before any download, deploy or
cleanup. Plain install, --frozen, apm lock and dry runs are unchanged.

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

* fix(export-patch): classify plugin mirrors from path-specific receipt evidence (#3649)

A normalization receipt does not prove every .apm/ file was generated:
plugins can declare authored .apm/skills or .apm/agents sources. When such
a source shared bytes with an unrelated repository file, export-patch
dropped the real source and patched the unrelated file. The normalization
owner now maps only .apm/skills/<name>/<tail> to the source directory its
receipt records (install_generated_mirror_source), and export-patch drops a
candidate only when that proven source is itself another candidate;
otherwise the ambiguity skip is kept.

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

* fix(pack): reject symlinked relative hook scripts before packing (#3649)

resolve_relative_hook_script() resolved symlinks before pack validated the
resource, so a contained ./scripts/alias.sh -> fmt.sh (or a linked scripts/
directory) was packed instead of rejected. The owner gains a lexical mode,
like resolve_plugin_root_hook_script, so pack validates the unresolved path
and its ancestors through the existing hook-resource symlink rule; install
keeps resolving as before.

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

* fix(pack): anchor packed relative hook scripts on the plugin root (#3649)

A packed ./scripts/fmt.sh reference became ./hooks/scripts/fmt.sh, which
resolves from the consumer's working directory rather than the installed
plugin, so it could not find the bundled file. The plugin-root vocabulary
owner gains plugin_root_script_reference, which anchors the packed path on
${CLAUDE_PLUGIN_ROOT} while keeping the authored quoting (unquoted,
double- or single-quoted); pack uses it for relative script references.

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

* fix(hooks): retire dropped events under safe legacy source markers (#3649)

The #3665 retirement pass dropped a source's entries from events it no
longer declares only under the canonical marker. An upgraded install
whose sidecar still carries a leaf marker such as 'hooks' kept the
dropped event pointing at a deleted script. HookIntegrator now computes
the owned marker set once from _get_hook_source_markers (keeping its
ambiguity rules) and passes it to both drop_source_entries passes. The
neutral-hook-contract guard requires both passes to use it, with a
mutation case.

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

* docs(changelog): match export-patch and pack entries to the review folds (#3672)

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] apm install <dir> installs a source package as a local bundle when the directory has a root plugin.json

2 participants