Skip to content

[0.38] fix(marketplace): registry-routed marketplace entries install and replay (#4009) - #4017

Merged
Daniel Meppiel (danielmeppiel) merged 12 commits into
mainfrom
danielmeppiel-4009-registry-marketplace
Nov 22, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 12 commits into
mainfrom
danielmeppiel-4009-registry-marketplace

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

TL;DR

A catalog entry routed to a package registry (registry: in marketplace.json) can now be installed by name and replayed with --frozen.
Positional apm install plugin@catalog writes the registry form to apm.yml, never a git: entry, and validates it without probing Git or GitHub.
An object-form {name, marketplace} declaration replays its registry lock row (exact version, resolved_url, resolved_hash, no commit) without reading the catalog.
The lockfile format, lockfile_version and the OpenAPM spec are unchanged.

Closes #4009

Note

The lifecycle test reuses main's scripted Registry HTTP API gateway from tests/integration/test_registry_redirect_origin_lifecycle.py as it is. #4015 moves that fixture into tests/utils, so this import may need to follow it on rebase.

Problem (WHY)

  • apm install plugin@catalog serialized the registry reference through a Git-only helper (install/package_resolution.py::dependency_reference_to_yaml_entry), so it wrote git: <url> with a semver ref: and failed at git ls-remote.
  • The same registry reference reached the Git/GitHub existence probe in commands/install.py, because the probe-skip predicate only covers default-registry shorthands.
  • drift.py::marketplace_ref_mismatch demanded a full commit for every marketplace row ("missing locked commit evidence"), so a registry row was always unlocked and --frozen refused it.
  • A replayed row names no registry, so a required-registry policy judged it as sourced from registry 'None' and blocked it.
  • [!] When no configured registry served a replayed row, the error said "parser bug or unconfigured default registry", with no remedy.

These break the existing registry lock contract, which already defines registry identity without a commit: req-lk-003 ("For every registry-sourced dependency entry the consumer MUST instead record resolved_url and resolved_hash") and req-lk-019 ("the registry-resolved version MAY remain the exact registry selection used for reinstall, but the integrity anchor is the recorded resolved_hash").

Approach (WHAT)

# Fix
1 dependency_reference_to_yaml_entry delegates registry references to DependencyReference.to_apm_yml_entry() (id, registry, version).
2 commands/install.py validates a source == "registry" reference as a registry selector instead of probing Git.
3 marketplace_ref_mismatch accepts a registry row when has_complete_registry_pin holds and any declared selector passes registry_selector_mismatch. Both rules now have one owner in drift.py, shared with existing registry drift detection and the --frozen pin check.
4 _check_registry_source restores a missing registry name from the lockfile URL through the existing dependency_ref_with_registry_name_from_lockfile, as the download path already does.
5 _resolve_registry_url gives a configuration remedy when no configured registry serves a locked row.
6 validate_registry_ref tells a registry-routed reference with no version that the catalog or apm.yml entry must name a version, instead of suggesting the git: URL form.

Implementation (HOW)

  • src/apm_cli/install/package_resolution.py, src/apm_cli/commands/install.py: write and validation routing only. The shared should_skip_github_probe_for_dep predicate is unchanged, because package_resolution also uses it for comparisons.
  • src/apm_cli/drift.py: adds a registry branch in the single replay-evidence owner, which install, frozen preflight (install/plan.py) and audit (policy/ci_checks.py) already route through. detect_ref_change and build_download_ref (the --frozen pin check) now call the extracted helpers. Git and semver marketplace evidence is unchanged.
  • src/apm_cli/policy/policy_checks.py: _check_registry_source takes the lockfile it already receives. The name is restored only for registry deps that carry none, using the existing longest-prefix URL match.
  • src/apm_cli/install/registry_wiring.py: changes only the message for a registry-routed reference with no version. The default-registry shorthand message and its git: hint are unchanged.
  • src/apm_cli/deps/registry/resolver.py: changes only the _resolve_registry_url message, which now names the configuration remedy (add the registry to the registries: block in apm.yml). The download_from_lockfile URL check is untouched (mirror tolerance is Registry replay rejects a moved or mirrored endpoint before checking the hash (req-rs-009) #4013).

Architecture impact: owner-extension of drift.marketplace_ref_mismatch, the existing single owner, which tests/integration/test_architecture_marketplace_locked_evidence.py already guards. No new owner or second routing path, so the existing static guard covers the change.

Trade-offs

Benefits

  1. A registry-backed catalog entry installs by name and replays cold under --frozen with zero catalog, Git or GitHub connections (asserted on every proxy observation after setup).
  2. Lockfile bytes stay identical across warm install, cold --frozen and cold install.
  3. Required-registry org policy applies to replayed rows by their real registry.
  4. A lock row with no configured registry gets a concrete registries: remedy.

Docs re-home after #3996

Page (path on main) #3996 status Re-home
consumer/installing-from-marketplaces.md, "Locked entries replay the lockfile" Rewritten into bullets (the "apm install and apm install --frozen replay the locked commit" bullet) Add the registry sentence as a bullet after that one.
reference/lockfile-spec.md Unchanged None
reference/manifest-schema.md Unchanged None
packages/apm-guide/.apm/skills/apm-usage/dependencies.md Edited elsewhere (around line 781) The registry paragraph is unchanged. The "Exceptions until 0.38 (#2903)" sentence also said registry-routed catalog entries still resolve through the catalog; this PR makes that false, so that clause is dropped and the MCP/LSP exception stays.
CHANGELOG.md Released as [0.37.0] The line sits at the bottom of ### Fixed in the new [Unreleased] above [0.37.0]

Rebase onto v0.37.0 (decisions taken under rule S15)

  • commands/install.py: 0.37 added the identity_policy_refuses gate before the Git probe. The registry-source condition sits inside that gate (not denied and (dep_ref.source == "registry" or ...)), so a denied registry entry still refuses before any contact. The file is 2084 lines (cap 2100).
  • deps/registry/resolver.py: the 0.37 rule contracts-tooling-remediation-advice rejects free-text advice to run a state-changing apm command. The message keeps the configuration remedy the scope record asks for (the registries: block) and drops the apm config set ... / re-run apm install advice. The alternative, a new core/remediation.py catalog entry with its own installed-CLI proof, was out of scope.
  • test_registry_marketplace_frozen_replay_fails_closed: 0.37 prints the cause line before the --frozen header, so the test asserts the header and the cause as separate substrings. The refusal and its cause are unchanged.
  • CONFORMANCE.md and CONFORMANCE.json: regenerated on the rebased tree (req-lk-003 11/12, req-lk-019 13/14).
  • #4015 moved the scripted Registry HTTP API to tests/utils/local_package_registry.py, which serves only seeded packages. The lifecycle scenario now seeds acme/widget 1.0.0 and simulates changed bytes with the registry's wrong-bytes download fault (its own test commit).
  • Ratchets new in 0.37: the two new test modules carry tm006 markers (e2e + promise("P-OWN-marketplace-locked-selection", "req-lk-003", "req-lk-019") and unit + promise("req-lk-003", "req-lk-019")). The spec module tests a pure function, so it is unit, not component (assertion-quality AQ003). drift.marketplace_ref_mismatch keeps 8 returns (PLR0911) by extracting _registry_marketplace_mismatch.
  • Rebased over [0.38] fix(registry): lockfile replay tolerates a mirror URL when the hash matches (#4013) #4022 (registry mirrors, Registry replay rejects a moved or mirrored endpoint before checking the hash (req-rs-009) #4013): the CHANGELOG keeps both ### Fixed lines. The marketplace guide and dependencies.md now say a registry-routed catalog entry replays "through a registry declared in apm.yml, like any registry dependency", not "from the configured registry that owns the locked URL". That wording would have contradicted [0.38] fix(registry): lockfile replay tolerates a mirror URL when the hash matches (#4013) #4022's mirror and moved-endpoint fallback.

Issue and approved scope

Issue: Closes #4009

Human scope-approval comment: #4009 (comment) (scripts/governance/eligibility.cjs reports record-present; review contact Daniel Meppiel (@danielmeppiel)).

Does this PR complete the issue, or what remains? It completes the record's Done when. Mirror tolerance (#4013) and URL-named catalog registries are out of scope.

Type of change

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

Testing

Scenario Evidence

# Scenario (user promise) Principle(s) Test(s) proving it Type
1 apm install widget@corp for a registry-routed entry writes {id, registry, version} and a registry lock row with marketplace association and no commit, contacting only the registry Portability, Vendor-neutral tests/integration/test_marketplace_registry_entry_lifecycle.py::test_positional_registry_marketplace_install_replays_frozen e2e (installed CLI)
2 The positional manifest and an object-form declaration replay cold with --frozen and plain install: identical bytes, unchanged lock, no catalog Portability, DevX ...::test_positional_registry_marketplace_install_replays_frozen, ...::test_object_form_registry_marketplace_declaration_replays_frozen e2e
3 Incompatible selector, incomplete pin, changed bytes (hash checked before extraction) and missing registry config all fail closed Secure by default ...::test_registry_marketplace_frozen_replay_fails_closed e2e
4 A required-registry org policy passes the replayed row for its real registry and blocks it for another Governed by policy ...::test_required_registry_policy_applies_to_registry_marketplace_replay e2e
5 Install, drift and audit share one registry replay-evidence decision, and a refusal names its reason Secure by default tests/unit/marketplace/test_locked_selection_evidence.py::test_registry_row_is_locked_evidence_without_a_commit, ::test_registry_row_refusal_names_its_reason unit
7 A registry-routed marketplace row replays on resolved_url + resolved_hash without a commit, and its registry version is the replayed selection Portability, Secure by default tests/spec_conformance/test_marketplace_registry_replay_reqs.py (req-lk-003, req-lk-019) spec conformance
6 A registry-routed entry with no version gets an accurate remedy, not a Git hint DevX tests/unit/install/test_registry_wiring.py::TestValidateRegistryRef::test_registry_routed_ref_without_version_names_the_entry_not_git unit

Mutation-break checks:

  • Removing the registry branch in marketplace_ref_mismatch fails 4 unit cases.
  • Removing the registry serializer delegation fails the positional lifecycle test.
  • Removing the probe skip fails it on an api.github.com connection.
  • Removing the policy name restoration fails the policy lifecycle test.
Validation output
uv run --extra dev ruff check src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/      -> clean
uv run --extra dev ruff format --check src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ -> clean
uv run --extra dev python -m pylint --disable=all --enable=R0801 --min-similarity-lines=10 --fail-on=R0801 src/apm_cli/ ... -> 10.00/10
bash scripts/lint-architecture-boundaries.sh -> rc 0
bash scripts/lint-auth-signals.sh -> rc 0
pytest tests/unit/policy tests/unit/marketplace tests/unit/test_drift_detection.py tests/unit/test_drift_registry.py \
  tests/unit/test_drift_registry_proxy_route.py tests/integration/test_marketplace_registry_entry_lifecycle.py \
  tests/integration/test_architecture_marketplace_locked_evidence.py -n 8
  -> 3612 passed, 1 xfailed
pytest tests/integration/test_deps_registry_coverage.py -> passed
cd docs && npm run build -> Complete; 1264 relative links, none broken

Changelog

  • One line in one section under ## [Unreleased] (above [0.37.0]) in CHANGELOG.md (bottom of ### Fixed)
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • Test edit: tests/spec_conformance/test_marketplace_registry_replay_reqs.py adds @pytest.mark.req("req-lk-003") and @pytest.mark.req("req-lk-019") tests; CONFORMANCE.{md,json} regenerated from the full spec suite (645 collected).
  • N/A for spec/manifest edits -- this PR does not change OpenAPM-observable behaviour. It brings marketplace replay in line with existing req-lk-003 and req-lk-019 registry evidence. OpenAPM does not specify consumer-side marketplace declarations. There is no spec edit and no new requirement.

How to test

  • uv run --extra dev pytest tests/integration/test_marketplace_registry_entry_lifecycle.py -q passes 4 tests.
  • uv run --extra dev pytest tests/unit/marketplace/test_locked_selection_evidence.py -q passes.
  • Manually: apm experimental enable registries, add a local catalog whose entry has registry:, run apm install plugin@catalog. apm.yml shows id/registry/version, and after deleting apm_modules/ and the catalog, apm install --frozen reinstalls the same files.

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

Registry drift checks incorrectly reject matching SHA-shaped version labels and accept prereleases excluded by stable selectors, causing frozen replay and audit to disagree with registry resolution.

2 open issues
What changed in this PR

This PR addresses #4009 by enabling registry-backed marketplace entries to install by name and replay from the lockfile, including with --frozen, without requiring a Git commit.

Changes:

  • Preserve registry-form dependencies and bypass Git validation for registry-routed entries.
  • Share registry replay checks and recover registry identity for policy evaluation.
  • Add lifecycle and conformance coverage, update documentation, and clarify configuration errors.
File Description
tests/​unit/​marketplace/​test_locked_selection_evidence.py Tests registry replay evidence and selector mismatches.
tests/​unit/​install/​test_registry_wiring.py Tests missing-version guidance.
tests/​spec_conformance/​test_marketplace_registry_replay_reqs.py Adds registry lockfile conformance cases.
tests/​integration/​test_marketplace_registry_entry_lifecycle.py Covers install, cold replay, failures, and registry policy.
src/​apm_cli/​policy/​policy_checks.py Recovers registry names for replay policy checks.
src/​apm_cli/​install/​registry_wiring.py Clarifies missing registry-version errors.
src/​apm_cli/​install/​package_resolution.py Preserves registry-form manifest entries.
src/​apm_cli/​drift.py Adds shared registry pin and replay checks.
src/​apm_cli/​deps/​registry/​resolver.py Adds a registry configuration remedy.
src/​apm_cli/​commands/​install.py Routes registry entries away from Git probes.
packages/​apm-guide/​.apm/​skills/​apm-usage/​dependencies.md Documents registry-backed marketplace replay.
docs/​src/​content/​docs/​reference/​manifest-schema.md Explains registry serialization and lock evidence.
docs/​src/​content/​docs/​reference/​lockfile-spec.md Documents registry marketplace lock rows.
docs/​src/​content/​docs/​consumer/​installing-from-marketplaces.md Explains registry install and replay behavior.
CONFORMANCE.md Updates requirement coverage counts.
CONFORMANCE.json Records added conformance test references.
CHANGELOG.md Announces the marketplace registry fix.

Review effort: Balanced

Comment thread src/apm_cli/drift.py Resolved
Comment thread src/apm_cli/drift.py Resolved
… form

A positional `apm install <plugin>@<catalog>` whose catalog entry routes to
a registry was serialized as a `git:` entry and probed on Git, so it could
not install. Keep the registry form (id, registry, version selector) and
validate it as a registry selector instead of probing Git.

Adds the installed-CLI lifecycle test for #4009.

Refs #4009

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
An object-form marketplace declaration whose lock row came from a registry
was always treated as unlocked, because replay evidence required a commit,
so `--frozen` refused it. A registry row is locked evidence when it records
its exact version, resolved URL and resolved hash, and any declared selector
still accepts the locked version under the existing registry selector rules
(req-lk-003, req-lk-019). The selector and complete-pin rules now each have
one owner in drift.py.

The registry-source policy check judges a replayed row (which names no
registry) by the configured registry that owns its locked URL, as its
download does, so a required-registry policy keeps applying. A registry row
that no configured registry serves now gets an actionable remedy.

Refs #4009

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
The fail-closed lifecycle steps for an incompatible selector and an
incomplete registry pin now assert the --frozen out-of-sync refusal for the
declaration, and a unit test pins the distinct replay-evidence reasons.

A registry-routed reference with no version (an id:/registry: entry or a
catalog entry with registry:) no longer suggests the git: URL form; it says
the catalog entry or apm.yml entry must name a version selector.

Refs #4009

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…eplay

Spec-conformance tests pin that a registry-routed marketplace row replays
on resolved_url and resolved_hash without a commit (req-lk-003), that its
registry-resolved version is the replayed selection (req-lk-019), and the
named refusal reasons. CONFORMANCE.* regenerated from the full spec suite.

Refs #4009

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…log replay

The scripted Registry HTTP API gateway now serves only seeded packages
(#4015 extracted it into tests/utils/local_package_registry.py), so the
scenario seeds acme/widget 1.0.0 and simulates changed bytes with the
registry's wrong-bytes download fault instead of swapping a served archive.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
… replay

The marketplace consumption guide no longer says registry-routed entries
always re-resolve through the catalog. The guide, lockfile reference,
manifest schema and apm-usage dependencies resource describe the registry
form written by `apm install plugin@catalog` and the registry lock evidence
(exact version, resolved URL, resolved hash, no commit) that replays under
--frozen. One CHANGELOG line.

Refs #4009

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
… rule (#4009)

Range coverage used match_version, so a stable range such as ^1.0.0
accepted a locked 1.1.0-rc.1 that the resolver's pick_best would never
select. Coverage now asks pick_best, so replay and audit apply the same
pre-release eligibility rule. The registry marketplace check also drops
its Git-SHA special case: a 40-hex registry version label that equals
the locked version is an unchanged selection, not drift.

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 21, 2026
test_metrics_json_counts re-walked the repository minutes after the
linter run, while tests on other xdist workers kept writing files, so
its count drifted by one on #4017 integration shard 8 (4959 != 4960,
twice). The fixture now snapshots the inventory just before and just
after the run; the count must match one of them, and a mismatch names
the paths that changed.

Co-authored-by: Copilot App <[email protected]>
chessMan (mohitmishra786) pushed a commit to mohitmishra786/apm that referenced this pull request Nov 22, 2026
With coverage parallel = true, an xdist worker that finishes early writes
.coverage.<host>.<pid>.<random> at the repository root while the others
still run. A linter walk and a later re-walk could then disagree by one
file, flaking test_metrics_json_counts_reflect_a_read_once_parse_once_clean_run
(4959 != 4960 on microsoft#4017 integration shard 8). Root-level .coverage and
.coverage.* files are generated (gitignored), so the inventory skips them
like apm_modules. .coveragerc and nested names are still inventoried.

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

Both sides added a branch to marketplace_ref_mismatch and a bullet to the
marketplace docs: registry-routed entries (#4009) and local catalogs (#4639).
They are disjoint (source registry vs local), so keep both.

Co-authored-by: Copilot App <[email protected]>
The main merge left marketplace_ref_mismatch with 9 returns (PLR0911,
limit 8). Fold the registry (#4009) and local-catalog (#4639) dispatch into
_non_git_marketplace_mismatch; the Git evidence checks stay in place so the
marketplace-locked-evidence owner routes still hold.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 899d17b into main Nov 22, 2026
72 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-4009-registry-marketplace branch November 22, 2026 09:27
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.

Registry-backed marketplace entries cannot install by name or replay with --frozen

2 participants