Repository navigation
fix(install): replay locked marketplace dependencies from the lockfile - #3915
Conversation
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Lock-evidence checks reject valid registry-backed entries and overlook catalog-dependent MCP/LSP packages, causing frozen-install and cold-replay failures.
3 open issues
What changed in this PR
This PR makes object-form marketplace dependencies replay matching lockfile entries before catalog lookup, improving reproducibility for ordinary and frozen installs.
Changes:
- Adds a shared replay decision while preserving catalog resolution for new or changed entries and explicit updates.
- Adds resolver, lifecycle and architecture-guard coverage.
- Documents lock-first behavior and the cold MCP/LSP package exception.
| File | Description |
|---|---|
tests/unit/marketplace/test_locked_selection_evidence.py |
Tests replay, frozen refusal and cold-server fallback. |
tests/integration/test_marketplace_lock_replay_lifecycle.py |
Exercises installed-CLI replay and update behavior. |
tests/integration/test_architecture_marketplace_locked_evidence.py |
Adds mutations checking replay routing and ordering. |
src/apm_cli/drift.py |
Defines matching-row and marketplace replay decisions. |
src/apm_cli/deps/apm_resolver.py |
Attempts lock replay before catalog lookup. |
scripts/architecture_linter/checks/marketplace_locked_evidence.py |
Enforces canonical calls and replay-first ordering. |
packages/apm-guide/.apm/skills/apm-usage/dependencies.md |
Explains replay behavior and its exception. |
docs/src/content/docs/reference/lockfile-spec.md |
Describes marketplace coordinate replay. |
docs/src/content/docs/reference/cli/install.md |
Clarifies frozen marketplace restoration. |
docs/src/content/docs/consumer/installing-from-marketplaces.md |
Documents catalog-free replay and cold-server limitations. |
CHANGELOG.md |
Announces the marketplace replay fix. |
.apm/architecture/owners/marketplace-plugins.json |
Registers ownership of the replay decision. |
Review effort: Balanced
apm install and apm install --frozen replay an object-form marketplace declaration whose name, marketplace and version still match its lock row, without catalog, alias or registration I/O. New or changed entries and apm update resolve through the catalog; --frozen refuses an unlocked entry. A package whose locked MCP/LSP servers may come from catalog-inline metadata keeps reading the catalog while its apm_modules copy is cold. drift.locked_marketplace_replay owns the decision; the marketplace-integrations-locked-evidence guard pins the resolver route and its ordering before resolve_marketplace_plugin. Fixes #3911 apm-spec-waiver: marketplace dependencies are non-normative in OpenAPM v0.1 (7.1 kind 5); no spec requirement governs catalog replay, and the scope record excludes a spec amendment Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
bfd6853 to
c0a498f
Compare
Copilot review on #3915: lsp_config_provenance records package:<resolved_by>, so the cold catalog-inline-server exception missed LSP-only packages. Export the encoder from install/lsp/integration.py and match both the lock key and the first-install apm_modules-relative owner. Pin it with a real-CLI LSP lifecycle case and the locked-evidence guard. Document the registry-routed and unrecorded-server boundaries (0.38, #2903). Co-authored-by: Copilot App <[email protected]>
…to danielmeppiel-fix-3911-marketplace-lockfile-replay
…hared edge projection Lean panel on #3915: - locked_marketplace_replay returns a MarketplaceReplay decision; the owner also builds the --frozen refusal, so the resolver no longer re-derives 'no row' and the guard pins the refusal before catalog I/O. - MCP owner tokens come from mcp_config_view.mcp_package_owner, the same encoder the provenance writers use (LSP already shared package_lsp_owner). - LockedDependency.to_edge_reference is the one lock-row-to-edge projection, used by replay and by reachability._locked_marketplace_form. - Lifecycle traps: transitive replay plus the frozen refusal via the CLI; a changed catalog-inline server cannot reach a cold frozen install; catalog-free install and cold frozen across the object-form audit matrix. - enterprise/security.md: marketplace rows are reviewed source identity. Co-authored-by: Copilot App <[email protected]>
…to danielmeppiel-fix-3911-marketplace-lockfile-replay
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Supply Chain Security Expert | 0 | 2 | 0 | Lock-first replay is fail-closed. Lock-row identity is now documented, and the changed-inline-server case is tested (both folded). |
| Test Coverage Expert | 0 | 2 | 0 | Transitive replay plus frozen refusal, and catalog-free replay across the versioned/subdir/plugin matrix, now have real-CLI traps (folded). |
| Python Architect | 0 | 3 | 0 | Single replay decision, writer-owned MCP/LSP owner encoders, and one shared lock-to-edge projection, all statically guarded (folded). |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 3 follow-ups
- [Supply Chain Security Expert] 0.38 ([FEATURE] Persist marketplace object-form deps; accept SHA catalog pins #2903): add a lock field recording the registry binding of registry-routed catalog entries, so they replay without the catalog. -- These rows still need the catalog on every install. That is no regression from main, but it is the remaining gap in the lock-replay claim.
- [Supply Chain Security Expert] 0.38 ([FEATURE] Persist marketplace object-form deps; accept SHA catalog pins #2903): record lock provenance for catalog-inline MCP/LSP servers even when they are not materialized (
--only=apm, rootmcp:shadowing). -- Today a cold replay fails closed and needsapm update; a lock field turns that into a correct replay or a clear re-resolve. - [Supply Chain Security Expert] Consider an opt-in audit or policy rule that compares marketplace lock rows with the cached catalog. -- This would flag rows that retarget with no apm.yml change, while keeping the default install path catalog-free.
Recommendation
Merge into 0.37.0. The post-merge evidence at da86b24aea is green:
- CI: 31 pass, 3 skipping
- unit/architecture: 12868 passed
- lifecycle: 31 passed
Every panel finding was folded. Both deferred boundaries are scoped to new lock fields under #2903, with no regression from main. Track the 0.38 lock-field work, registry binding first.
Full per-persona findings
Supply Chain Security Expert
- [recommended] Replay makes the apm.lock.yaml row the only identity binding for {name, marketplace} deps; a forged row can retarget the package with no apm.yml diff. At
src/apm_cli/drift.py:155
Folded: enterprise/security.md documents marketplace lock rows as reviewed source identity. The policy gate runs onctx.deps_to_install(install/phases/policy_gate.py:112,phases/resolve.py:816), which includes replayed refs. A cached-catalog cross-check was declined because it would reintroduce catalog reads. - [recommended] No test showed that a changed catalog-inline server definition fails closed on cold frozen. At
src/apm_cli/drift.py:202
Folded:tests/integration/test_marketplace_lock_replay_lifecycle.py::test_catalog_defined_servers_replay_warm_and_reresolve_cold(MCP and LSP) now mutates the inline server under the same selection and asserts that cold--frozenexits 1 with the lock and server config bytes unchanged.
Test Coverage Expert
- [recommended] No real-CLI trap for transitive marketplace replay or the transitive --frozen refusal.
Folded:tests/integration/test_marketplace_lock_replay_lifecycle.py::test_transitive_marketplace_entry_replays_cold_and_frozen_refuses_unlocked. - [recommended] Versioned selectors and git-subdir/plugin rows had no catalog-free replay trap.
Folded:tests/integration/test_marketplace_object_audit_lifecycle.py::test_marketplace_object_install_audit_repeat_offlinenow runs install aftermarketplace remove, plus a cold--frozen, in every matrix case.
Python Architect
- [recommended] Frozen decision split between the owner and the resolver; the guard did not pin refusal ordering. At
src/apm_cli/deps/apm_resolver.py:685
Folded:drift.MarketplaceReplayplusdrift.frozen_marketplace_refusal. The guard requires the refusal beforeresolve_marketplace_plugin. - [recommended] MCP owner decoding was re-implemented in drift. At
src/apm_cli/drift.py:176
Folded:integration/mcp_config_view.mcp_package_owneris shared by both writers and by drift, and is guarded. - [recommended] A twin lock-to-edge projection existed in reachability. At
src/apm_cli/deps/reachability.py:129
Folded:LockedDependency.to_edge_referenceis used by replay and by_locked_marketplace_form, and is guarded.
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.
With #3915 on main, a plain `apm install` replays the locked catalog without consulting the rebound alias, so it succeeds and keeps the locked bytes; `apm update` still re-resolves and fails closed naming both origins. Docs and the CHANGELOG line now describe that split. Co-authored-by: Copilot App <[email protected]>
…ebound aliases (#3917) * fix(marketplace): record catalog origin in the lock; fail closed on rebound aliases A marketplace alias such as `company` is machine-local, but Git catalogs recorded only that alias in apm.lock.yaml. Rebinding the alias silently switched the catalog an object-form apm.yml entry resolved through. - Record the canonical catalog origin as `source_url` and a `source_digest` for every remote catalog kind, including Git (no new lockfile fields). - Re-resolving a locked entry fails closed when the alias's registered origin differs from the lock's `source_url`, naming both origins. - Warn when a second alias registers an already registered catalog. - Pre-0.37 rows without `source_url` keep working and gain it on the next lock write. Local file:// catalogs record no origin. Closes #3912 Co-authored-by: Copilot App <[email protected]> * docs(changelog): reference #3917 Co-authored-by: Copilot App <[email protected]> * fix(marketplace): close origin-check gaps from review Hosted catalog queries now take part in origin comparison, every locked row for an alias/plugin pair is checked so ambiguous associations cannot skip verification, the static guard requires `add` to call the duplicate warning, and guard mutation tests assert the mutated source still parses. Addresses Copilot inline review on source_identity.py:127, catalog_origin.py:40, marketplace_locked_evidence.py:45 and test_architecture_marketplace_locked_evidence.py:73. Co-authored-by: Copilot App <[email protected]> * fix(marketplace): fold lean-panel review of the catalog-origin guard - Match aliases case-insensitively via LockFile.marketplace_rows, so a recased alias cannot skip the fail-closed origin check. - Quote the restore command in MarketplaceOriginConflictError, suggest it only for a parseable origin, and give a switch path that works for object-form apm.yml entries (proved end-to-end in the lifecycle test). - Compute the Git catalog digest in client._parse_catalog so the digest scheme depends only on catalog kind; parse_marketplace_json is a pass-through again. - One catalog identity helper (same_marketplace_catalog) for the duplicate warning; document and pin the origin-only limit of the lock check. - Assert plain `apm install` also fails closed after a rebind, and cover the user-manifest reconcile duplicate warning. Addresses the lean panel advisory on #3917 (supply-chain F1/F2, test-coverage F1-F3, python-architect F1-F3). Co-authored-by: Copilot App <[email protected]> * test(marketplace): align rebound-alias assertions with lock-first replay With #3915 on main, a plain `apm install` replays the locked catalog without consulting the rebound alias, so it succeeds and keeps the locked bytes; `apm update` still re-resolves and fails closed naming both origins. Docs and the CHANGELOG line now describe that split. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>

Description
TL;DR
apm installre-resolved every object-form marketplace dependency ({name, marketplace, version}) through the registered catalog, even whenapm.lock.yamlalready pinned it. Catalog edits therefore moved what a plain install deployed, and a coldapm install --frozenfailed without the alias registration. Locked entries now replay from the lockfile with no catalog, alias or registration I/O. Only new or changed entries andapm updateread the catalog.Important
Known 0.37 limitation (approved by the delivery scheduler): catalog entries can define MCP/LSP servers inline (Claude-style
strict: falseplugins). The lockfile does not record those definitions, so a package whose servers the lock records, and which has noapm_modules/copy, still reads the catalog, including under--frozen. That is today's behavior for that narrow case. Warm copies replay. Lockfile-only replay for them is the 0.38 follow-up (#2903). The limitation is documented in the consumer guide, theinstallreference and apm-usage.Problem (WHY)
deps/apm_resolver.py_resolve_marketplace_depcalledresolve_marketplace_pluginfor every root, dev and transitive object-form dep, before any lock lookup. A changed catalog ref then registered as drift and was re-locked.mainwith the real CLI: lockreplay-skill@acme, block the catalog origin, then runapm install. It fails with[x] Failed to resolve marketplace dependency 'replay-skill' from marketplace 'acme': Failed to fetch marketplace 'acme': git fetch failed.apm install --frozenwith no registration failed withMarketplaceNotFoundError, although thegit:form replays cold.Approach (WHAT)
drift.locked_marketplace_replay, built on the existingmarketplace_ref_mismatchevidence check and theLockFile.marketplace_indexassociation._resolve_marketplace_depasks that owner before any catalog I/O and returns the locked coordinates. The commit and hashes then pin the download through the existing lock replay.--frozenrefuses a declaration with no matching lock row instead of asking the catalog. Root entries were already rejected by the frozen pre-check; this covers transitive ones.apm update/--refresh(update_refs) always re-resolve, as today (#3279 unchanged).Implementation (HOW)
src/apm_cli/drift.py: addslocked_marketplace_row(single matching, non-replacement row whose evidence satisfiesmarketplace_ref_mismatch),_owns_locked_servers(lockmcp_config_provenance/lsp_config_provenanceowned by the row's name or key) andlocked_marketplace_replay. All are placed next tomarketplace_ref_mismatch, away from fix: derive install expected state from the lock #3900'sshould_force_ref_recheckhunk. The replayed ref keeps the edge's own alias and selection.src/apm_cli/deps/apm_resolver.py:_resolve_marketplace_depnow runs replay, then the frozen refusal, then the read-only refusal, then the catalog. [BUG] Lockfile does not record a Git marketplace's origin, so a rebound alias can silently switch marketplaces #3912 places its fail-closed origin check directly beforeresolve_marketplace_plugin, so every path that contacts the catalog, including the cold-server path, goes through it. This was agreed with that worker; whoever lands second rebases.scripts/architecture_linter/checks/marketplace_locked_evidence.py: themarketplace-integrations-locked-evidenceguard now requires the new routes and an ordering check:locked_marketplace_replaymust be called beforeresolve_marketplace_pluginin_resolve_marketplace_dep..apm/architecture/owners/marketplace-plugins.json: themarketplace-locked-selectionrecord names the replay decision and its resolver consumer. Selectors are unchanged becauseapm_resolver.pyalready belongs to another owner.consumer/installing-from-marketplaces.md,reference/cli/install.md(frozen bullet),reference/lockfile-spec.mdandapm-usage/dependencies.md.Diagrams
Legend: the decision order inside
_resolve_marketplace_dep. Only the right-hand exits contact the catalog.flowchart LR A["_resolve_marketplace_dep(name@alias)"] --> B{"locked_marketplace_replay: matching lock row, not update?"} B -->|"yes, warm or no locked servers"| R["return locked coordinates - no catalog I/O"] B -->|"no row / changed / update / cold server package"| F{"--frozen and no matching row?"} F -->|"yes"| X["refuse: run apm install, commit lock"] F -->|"no"| O["origin check from issue 3912"] O --> C["resolve_marketplace_plugin - catalog fetch"]Trade-offs
content_hashcovers the catalog-synthesizedapm.yml. That would regress cases that work on main. The proper fix needs catalog evidence in the lock, which is a new field and out of scope (0.38, [FEATURE] Persist marketplace object-form deps; accept SHA catalog pins #2903).apm.ymlalso matches the lock evidence. It also reads the catalog when cold, which matches today's behavior. Warm installs replay.replace:) are not replayed. They re-resolve as today. A replacement row records the selected ref rather than the original, and reconstructing the original edge is out of scope. No existing coverage combines the two.apm-spec-waiverrather than areq-*citation.Benefits
apm installof a locked marketplace entry makes zero catalog requests. Proven with the catalog origin moved away.apm install --frozenneeds noapm marketplace add. Only package bytes are fetched, at the locked commit.apm update, which is reviewable as a lock diff.Validation
CI-mirror lint chain, run on this branch after rebasing onto
main(29ed7f1), all green:Tests
Scenario Evidence
apm installrestores it even with the catalog unreachable, and catalog edits don't move it."tests/integration/test_marketplace_lock_replay_lifecycle.py::test_locked_marketplace_entry_replays_without_catalog_until_updateapm install --frozenworks with no marketplace registration."marketplace remove+ wipingapm_modules/and deployed files)apm updatestill follows the catalog's new selection."tests/integration/test_marketplace_lock_replay_lifecycle.py::test_catalog_defined_servers_replay_warm_and_reresolve_cold--frozenrefuses unlocked ones."tests/unit/marketplace/test_locked_selection_evidence.py::test_resolver_replays_matching_lock_row_without_catalog,::test_frozen_refuses_unlocked_marketplace_declaration_without_catalog,::test_catalog_defined_servers_replay_only_from_a_materialized_copytests/integration/test_architecture_marketplace_locked_evidence.py::test_marketplace_locked_evidence_guard_rejects_bypassesHow to test
{name: X, marketplace: acme}, runapm install, and noteresolved_commit.apm marketplace update acme, make the catalog unreachable, then runapm install. Expect exit 0 and an unchangedapm.lock.yaml.apm marketplace remove acme --yes, deleteapm_modules/, then runapm install --frozen. Expect exit 0 and the locked content restored.apm update --yes. Expect the lock to move to the catalog's new selection.Issue and approved scope
Issue: Fixes #3911
Human scope-approval comment: #3911 (comment) (apm-scope:v1, Daniel Meppiel (@danielmeppiel))
Does this PR complete the issue, or what remains? It completes the scope record: lock-first replay for install and frozen, with only new or changed entries and update reading the catalog. Lockfile-only cold replay of catalog-inline MCP/LSP servers is the documented 0.38 follow-up under #2903, because it needs a lockfile field that the record excludes.
Type of change
Testing
TimeoutExpiredfailures in the untouched shell-installer tests; see Validation)Changelog
## [Unreleased]inCHANGELOG.md: user-visibleeffect first, 25 words or fewer, ending with
(#PR); see.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
If this PR changes behaviour that an OpenAPM v0.1
req-XXXcovers,confirm the three-step ritual in the
development guide:
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.
apm-spec-waiver.Co-authored-by: Copilot [email protected]