Skip to content

fix(install): replay locked marketplace dependencies from the lockfile - #3915

Merged
Daniel Meppiel (danielmeppiel) merged 6 commits into
mainfrom
danielmeppiel-fix-3911-marketplace-lockfile-replay
Nov 19, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 6 commits into
mainfrom
danielmeppiel-fix-3911-marketplace-lockfile-replay

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

TL;DR

apm install re-resolved every object-form marketplace dependency ({name, marketplace, version}) through the registered catalog, even when apm.lock.yaml already pinned it. Catalog edits therefore moved what a plain install deployed, and a cold apm install --frozen failed without the alias registration. Locked entries now replay from the lockfile with no catalog, alias or registration I/O. Only new or changed entries and apm update read the catalog.

Important

Known 0.37 limitation (approved by the delivery scheduler): catalog entries can define MCP/LSP servers inline (Claude-style strict: false plugins). The lockfile does not record those definitions, so a package whose servers the lock records, and which has no apm_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, the install reference and apm-usage.

Problem (WHY)

  • deps/apm_resolver.py _resolve_marketplace_dep called resolve_marketplace_plugin for every root, dev and transitive object-form dep, before any lock lookup. A changed catalog ref then registered as drift and was re-locked.
  • Reproduced on main with the real CLI: lock replay-skill@acme, block the catalog origin, then run apm install. It fails with [x] Failed to resolve marketplace dependency 'replay-skill' from marketplace 'acme': Failed to fetch marketplace 'acme': git fetch failed.
  • Cold apm install --frozen with no registration failed with MarketplaceNotFoundError, although the git: form replays cold.
  • [!] Supply-chain exposure: a catalog takeover or edit changed installed bytes on an ordinary install (design [FEATURE] Persist marketplace object-form deps; accept SHA catalog pins #2903 §8, "Catalog takeover").

Approach (WHAT)

# Fix
1 One owner for "replay vs re-resolve": drift.locked_marketplace_replay, built on the existing marketplace_ref_mismatch evidence check and the LockFile.marketplace_index association.
2 _resolve_marketplace_dep asks 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.
3 --frozen refuses 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.
4 apm update / --refresh (update_refs) always re-resolve, as today (#3279 unchanged).
5 Catalog-inline-server exception: re-resolve only when the copy is cold and the lock records MCP/LSP servers owned by that package. The decision uses lock evidence only.

Implementation (HOW)

  • src/apm_cli/drift.py: adds locked_marketplace_row (single matching, non-replacement row whose evidence satisfies marketplace_ref_mismatch), _owns_locked_servers (lock mcp_config_provenance / lsp_config_provenance owned by the row's name or key) and locked_marketplace_replay. All are placed next to marketplace_ref_mismatch, away from fix: derive install expected state from the lock #3900's should_force_ref_recheck hunk. The replayed ref keeps the edge's own alias and selection.
  • src/apm_cli/deps/apm_resolver.py: _resolve_marketplace_dep now 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 before resolve_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: the marketplace-integrations-locked-evidence guard now requires the new routes and an ordering check: locked_marketplace_replay must be called before resolve_marketplace_plugin in _resolve_marketplace_dep.
  • .apm/architecture/owners/marketplace-plugins.json: the marketplace-locked-selection record names the replay decision and its resolver consumer. Selectors are unchanged because apm_resolver.py already belongs to another owner.
  • Docs: consumer/installing-from-marketplaces.md, reference/cli/install.md (frozen bullet), reference/lockfile-spec.md and apm-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"]
Loading

Trade-offs

  • Cold catalog-only server packages keep reading the catalog. Rejected alternative: pure replay. It fails closed with a misleading "Content hash mismatch ... supply-chain attack", because the lock content_hash covers the catalog-synthesized apm.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).
  • Over-approximation of that exception. A package that declares MCP/LSP servers in its own apm.yml also matches the lock evidence. It also reads the catalog when cold, which matches today's behavior. Warm installs replay.
  • Replacement-bound rows (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.
  • No spec change. OpenAPM v0.1 treats marketplace deps as non-normative (7.1 kind 5), so the commit carries an apm-spec-waiver rather than a req-* citation.

Benefits

  1. A plain apm install of a locked marketplace entry makes zero catalog requests. Proven with the catalog origin moved away.
  2. Cold CI apm install --frozen needs no apm marketplace add. Only package bytes are fetched, at the locked commit.
  3. A catalog edit changes installed bytes only through apm update, which is reviewable as a lock diff.
  4. A static guard fails if any future edit moves catalog I/O ahead of the replay decision.

Validation

CI-mirror lint chain, run on this branch after rebasing onto main (29ed7f1), all green:

$ uvx [email protected] check src/ tests/ scripts/... && uvx [email protected] format --check ...
All checks passed!
2421 files already formatted
$ python -m pylint --disable=all --enable=R0801 --min-similarity-lines=10 --fail-on=R0801 src/apm_cli/ scripts/...
Your code has been rated at 10.00/10
$ bash scripts/lint-auth-signals.sh   -> exit 0
$ python scripts/lint_architecture_boundaries.py --root .   -> exit 0
$ BASE_REF=<main> bash tests/spec_conformance/mode_b_detector.sh
[!] mode_b: WAIVED (22 substantive added lines) -- marketplace dependencies are non-normative in OpenAPM v0.1 ...
Tests
$ APM_E2E_TESTS=1 APM_BINARY_PATH=.venv/bin/apm pytest tests/integration/test_marketplace_lock_replay_lifecycle.py -p no:xdist
2 passed            (both fail on main: the catalog is contacted with the origin blocked)
$ pytest tests/unit/marketplace/test_locked_selection_evidence.py tests/integration/test_architecture_marketplace_locked_evidence.py
58 passed
$ pytest tests/unit/{deps,marketplace,install,scripts,policy,commands} tests/unit/test_drift_detection.py \
    tests/integration/test_architecture_owner_rule_mutations.py tests/integration/test_deps_resolver_resolution.py -n 8
11791 passed, 28 failed: all 28 are tests/unit/install/test_unix_install_ownership.py
subprocess.TimeoutExpired (host load average ~45; the shell installer is untouched by this diff)
$ APM_E2E_TESTS=1 pytest tests/integration/test_marketplace_lock_replay_lifecycle.py tests/integration/test_marketplace_object_audit_lifecycle.py -p no:xdist   (after rebase)
23 passed in 851.85s

Scenario Evidence

# Scenario (user promise) Principle(s) Test(s) proving it Type
1 "After I lock a marketplace package, apm install restores it even with the catalog unreachable, and catalog edits don't move it." Secure by default, Portability tests/integration/test_marketplace_lock_replay_lifecycle.py::test_locked_marketplace_entry_replays_without_catalog_until_update e2e
2 "Cold CI apm install --frozen works with no marketplace registration." Portability, DevX same test (frozen step after marketplace remove + wiping apm_modules/ and deployed files) e2e
3 "apm update still follows the catalog's new selection." Governed by policy same test (update step asserts v2 commit) e2e
4 "Catalog-inline MCP servers replay from a warm copy; a cold copy re-resolves through the catalog." Secure by default tests/integration/test_marketplace_lock_replay_lifecycle.py::test_catalog_defined_servers_replay_warm_and_reresolve_cold e2e
5 "Only new, changed or updated declarations reach the catalog; --frozen refuses unlocked ones." Secure by default 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_copy unit
6 "A future refactor cannot move catalog I/O ahead of replay." OSS (maintainability) tests/integration/test_architecture_marketplace_locked_evidence.py::test_marketplace_locked_evidence_guard_rejects_bypasses integration

How to test

  • Register a git catalog, declare {name: X, marketplace: acme}, run apm install, and note resolved_commit.
  • Change the catalog's ref for X, run apm marketplace update acme, make the catalog unreachable, then run apm install. Expect exit 0 and an unchanged apm.lock.yaml.
  • Run apm marketplace remove acme --yes, delete apm_modules/, then run apm install --frozen. Expect exit 0 and the locked content restored.
  • Re-register and run 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

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

Testing

  • Tested locally
  • All existing tests pass (except 28 load-induced TimeoutExpired failures in the untouched shell-installer tests; see Validation)
  • Added tests for new functionality (if applicable)

Changelog

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

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 -- marketplace dependencies are non-normative in OpenAPM v0.1 (7.1 kind 5). The scope record excludes a spec amendment, and the commit carries an apm-spec-waiver.

Co-authored-by: Copilot [email protected]

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.

🟡 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

Comment thread src/apm_cli/drift.py Resolved
Comment thread src/apm_cli/drift.py Resolved
Comment thread src/apm_cli/drift.py Resolved
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]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) force-pushed the danielmeppiel-fix-3911-marketplace-lockfile-replay branch from bfd6853 to c0a498f Compare November 19, 2026 11:22
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 19, 2026
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
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_with_followups

apm install now restores locked marketplace dependencies from apm.lock.yaml without contacting the marketplace, so a catalog outage or change no longer breaks reproducible installs, and --frozen never consults a catalog.

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

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

This is a lockfile correctness fix, and it supports APM's main claim as a package manager: when apm.yml and apm.lock.yaml agree, install replays the lock. On main, every object-form marketplace dependency went to the catalog before any lock lookup. As a result, an unreachable or changed catalog broke apm install even when the lock already pinned the exact commit. The fix sends a dependency to the catalog only when it is new or changed, or when the user runs apm update or --refresh. --frozen either replays the lock row or refuses with an actionable message.

All seven recommended findings from the three panelists were folded at head da86b24aea:

  • Supply chain: enterprise/security.md now says marketplace lock rows are reviewed source identity. The policy gate consumes the flattened resolved graph, which includes replayed refs. A new test shows that a catalog-inline server mutated under the same selection fails closed on a cold frozen install.
  • Test coverage: real-CLI traps now cover transitive replay, the transitive --frozen refusal, and the versioned, subdir and plugin layouts, each with the catalog removed.
  • Architecture: the frozen decision is a single MarketplaceReplay object, and drift owns the refusal. MCP and LSP owner decoding go through the writers' own encoders. The two lock-to-edge projections are unified. The architecture linter pins each route, including the rule that replay and refusal happen before resolve_marketplace_plugin.

Both deferred boundaries are scoped honestly, and neither is a regression:

  1. Registry-routed catalog rows. The lock has no registry binding, so a replayed ref cannot be routed without the catalog. These rows were already rejected by marketplace_ref_mismatch and refused by frozen on main.
  2. Catalog-inline servers with no lock provenance (--only=apm, or a root mcp: entry that shadows the server). A cold replay fails closed on content_hash, and the docs say to run apm update.

Both fixes need new lock fields, which the #3911 scope record excludes, so they move to 0.38 (#2903).

One trade-off from supply-chain S1 remains. Replay makes the lock row the only identity binding for {name, marketplace} dependencies. A cached-catalog cross-check is correctly declined here, because it would bring back the catalog reads this PR removes. Lockfile diffs are reviewed like source and the policy gate checks replayed refs; this is the npm/cargo trust model, now documented.

Aligned with: Portable by manifest: a matching apm.yml and lock reproduce the same packages with no marketplace contact, warm or cold, frozen or not. Secure by default: --frozen never consults a catalog and refuses unlocked entries; changed catalog-inline servers fail closed on content_hash. Governed by policy: the policy gate runs on replayed refs, and marketplace lock rows are documented as reviewed identity. Pragmatic as npm: the lock wins until an explicit update, with no new fields and no migration.

Panel summary

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

  1. [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.
  2. [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, root mcp: shadowing). -- Today a cold replay fails closed and needs apm update; a lock field turns that into a correct replay or a clear re-resolve.
  3. [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 on ctx.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 --frozen exits 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_offline now runs install after marketplace 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.MarketplaceReplay plus drift.frozen_marketplace_refusal. The guard requires the refusal before resolve_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_owner is 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_reference is 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.

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 0e19cce into main Nov 19, 2026
34 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-fix-3911-marketplace-lockfile-replay branch November 19, 2026 13:06
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 19, 2026
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]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 19, 2026
…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]>
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 re-resolves marketplace dependencies on every run instead of replaying the lockfile

2 participants