Repository navigation
fix(marketplace): explicit refresh revalidates catalogs or fails (#3279) - #3910
Daniel Meppiel (danielmeppiel) merged 11 commits into
Conversation
apm install --refresh, apm update and apm marketplace update now revalidate each needed marketplace catalog once per invocation and fail closed instead of serving a still-in-TTL or stale cached catalog. Invalid responses never replace the last valid cache; marketplace update reports partial failures and exits nonzero. Selected 'apm update plugin@marketplace' now re-checks the package the declaration resolves to. Co-authored-by: Copilot App <[email protected]>
…nielmeppiel-marketplace-refresh-cli-version-gate
Co-authored-by: Copilot App <[email protected]>
apm-spec-waiver: CLI-local marketplace catalog cache freshness and update selection; no OpenAPM manifest, lockfile or wire contract change (#3279) Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Required-refresh handling still allows partial installs to succeed during catalog outages and malformed catalog data to overwrite valid caches.
3 open issues
What changed in this PR
This PR addresses #3279 by connecting explicit install and update intent to marketplace catalog revalidation, while retaining cached reads for ordinary installs. Durable marketplace identity remains outside scope under #2903.
Changes:
- Adds invocation-scoped catalog freshness handling and cache-preserving refresh failures.
- Carries selected marketplace dependencies through to resolved Git coordinates and reports partial marketplace-update failures.
- Adds lifecycle tests, architecture guards, and documentation for the refresh behavior.
| File | Description |
|---|---|
tests/unit/scripts/test_architecture_runner.py |
Registers the freshness guard in the expected inventory. |
tests/unit/marketplace/test_marketplace_commands_surface.py |
Expects nonzero exit on partial refresh failure. |
tests/unit/marketplace/test_marketplace_commands_phase3.py |
Checks partial-failure output and exit status. |
tests/unit/marketplace/test_marketplace_client.py |
Tests strict refresh, retained caches, and shared answers. |
tests/integration/test_marketplace_explicit_refresh_lifecycle.py |
Adds installed-CLI catalog refresh scenarios. |
tests/integration/test_architecture_owner_rule_mutations.py |
Adds a freshness-guard mutation case. |
src/apm_cli/marketplace/shadow_detector.py |
Marks shadow lookups as advisory. |
src/apm_cli/marketplace/errors.py |
Introduces a catalog freshness error. |
src/apm_cli/marketplace/client.py |
Implements strict refresh and invocation-scoped results. |
src/apm_cli/install/service.py |
Maps install intent to catalog freshness policy. |
src/apm_cli/install/phases/resolve.py |
Transfers resolved marketplace selection keys. |
src/apm_cli/deps/apm_resolver.py |
Tracks Git coordinates selected through catalogs. |
src/apm_cli/commands/update.py |
Wraps dependency updates in a freshness scope. |
src/apm_cli/commands/marketplace/__init__.py |
Revalidates without clearing caches and reports failures. |
src/apm_cli/commands/install.py |
Opens the install catalog freshness scope. |
scripts/architecture_linter/checks/marketplace_integration_analyzers.py |
Includes the new freshness rule. |
scripts/architecture_linter/checks/marketplace_catalog_freshness.py |
Guards canonical freshness routing. |
packages/apm-guide/.apm/skills/apm-usage/commands.md |
Updates command guidance for catalog refresh. |
docs/src/content/docs/reference/cli/update.md |
Documents catalog revalidation and selection syntax. |
docs/src/content/docs/reference/cli/marketplace.md |
Describes cache retention and partial failures. |
docs/src/content/docs/reference/cli/install.md |
Expands the documented --refresh behavior. |
docs/src/content/docs/consumer/update-and-refresh.mdx |
Explains explicit marketplace refresh behavior. |
docs/src/content/docs/consumer/manage-dependencies.md |
Updates the catalog dependency refresh workflow. |
CHANGELOG.md |
Records the user-visible freshness change. |
.apm/architecture/owners/marketplace-plugins.json |
Registers catalog freshness ownership and its guard. |
Review effort: Balanced
…lugins Co-authored-by: Copilot App <[email protected]>
…nrelated catalogs Addresses the three Copilot inline threads on #3910: - install.py: an unverifiable catalog in a mixed positional batch now fails the whole command instead of installing the healthy packages. - client.py: an explicit refresh rejects catalogs with structural errors so a malformed response cannot replace the last valid cache; ordinary and add parsing stay tolerant; local catalogs stay ordinary reads. - client.py: during a required-freshness scope, advisory (shadow-detection) reads use only cached data, keeping one request per needed source. Co-authored-by: Copilot <[email protected]>
…pinned advisory contract Addresses lean-panel follow-ups on #3910: - python-architect: MarketplaceFreshnessError routes through the base __init__ with a command-neutral retry hint; one _manifest_from_cache helper owns cache-to-manifest projection for fresh, stale and advisory reads; an explicit MarketplaceNotCachedError pins the advisory contract under required scopes (unit-tested per mode). - test-coverage-expert: lifecycle now exercises install --frozen --refresh during an outage (mutation-proven against the frozen guard) and proves a local catalog stays a local read under --refresh. Co-authored-by: Copilot <[email protected]>
…nielmeppiel-marketplace-refresh-cli-version-gate # Conflicts: # scripts/architecture_linter/checks/marketplace_integration_analyzers.py
Co-authored-by: Copilot <[email protected]>
Addresses the apm-ceo follow-up on #3910: when an explicit refresh leaves uncached (for example generic-git) catalogs out of shadow detection, the resolver now warns which catalogs were not checked instead of narrowing the supply-chain signal silently. Co-authored-by: Copilot <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 3 | 0 | Freshness ownership is correctly centralized in client.py, scoped once per command, and reuses RefFreshnessPolicy; three cohesion and fidelity gaps worth folding. |
| Test Coverage Expert | 0 | 2 | 0 | Real-binary scenario tests cover most of #3279; frozen+refresh and local catalogs needed regression-catching tests. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 1 follow-ups
- [Python Architect] Track the shadow-detection coverage trade-off during explicit refresh. -- Shadowing between catalogs is a supply-chain signal, so narrowing it must be visible. Folded in a663b1d: the resolver now warns which uncached catalogs were not checked, and
test_uncached_catalogs_skipped_during_explicit_refresh_are_reportedpins this.
Recommendation
Ready for maintainer merge once CI is green on a663b1d. All panel and Copilot findings are folded with mutation-proven or installed-CLI regression tests. The CI-mirror lint chain and the architecture lint are clean after merging current main, and CHANGELOG has the user-visible line.
Full per-persona findings
Python Architect
- [recommended] MarketplaceFreshnessError hardcodes install-only remediation and skips the base init at
src/apm_cli/marketplace/errors.py
The remediation namedapm install --refresheven when raised fromapm updateorapm marketplace update, and the class bypassedMarketplaceFetchError.__init__. Folded: base init plus a command-neutral hint. - [recommended] Cache-to-manifest decision written out three times at
src/apm_cli/marketplace/client.py
Split-authority risk for digest/provenance handling. Folded:_manifest_from_cacheowns it. - [recommended] Advisory shadow detection silently goes blind for git-kind and uncached catalogs during explicit refresh at
src/apm_cli/marketplace/client.py
The advisory contract changed by mode without a written contract. Folded:MarketplaceNotCachedError, a per-mode unit test, and a user-visible skipped-catalog warning.
Test Coverage Expert
- [recommended] Frozen-replay lifecycle test could not catch removal of the
and not frozenguard attests/integration/test_marketplace_explicit_refresh_lifecycle.py
Folded: object-form seed plusinstall --frozen --refreshduring an outage; mutation-proven.
Proof (passed):tests/integration/test_marketplace_explicit_refresh_lifecycle.py::test_frozen_replay_needs_no_live_catalog-- proves: a locked CI replay never needs a live marketplace, even with --refresh. - [recommended] No explicit-refresh test against a local catalog at
src/apm_cli/marketplace/client.py
Folded: installed-CLI test asserting a local read, zero HTTP requests, and a not-found result for a removed entry.
Proof (passed):tests/integration/test_marketplace_explicit_refresh_lifecycle.py::test_local_catalog_stays_a_local_read_under_refresh-- proves: --refresh against a local catalog still installs from the local file.
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.
Skip the version-range tag lookup for a resolution admission will refuse, so no request reaches the ambiguous package remote. Move DependencyConfusionError into marketplace/errors.py and name it in the resolver's except tuple. Harden the static guard against nested defs, getattr reads, aliased imports and direct resolve_plugin_source calls. Serve the enterprise catalog from an SSH-registered Git fixture so apm update revalidates offline (#3910) and reaches admission; add a version-range case, a host-qualified positive control and unit traps. Narrow docs to type: github sources and fix the producer example. Addresses panel follow-ups (python-architect, test-coverage-expert, supply-chain-security-expert, doc-writer) on #3923. Co-authored-by: Copilot App <[email protected]>
… install path (#3923) * fix(marketplace): apply the #1326 dependency-confusion check on every install path Route apm install NAME@MARKETPLACE, apm.yml marketplace entries, transitive marketplace dependencies and apm update through one admission owner, marketplace/dependency_confusion.py admit_marketplace_resolution, before any fetch or write. A new architecture guard rejects resolver calls that skip it. Closes #3913 Co-authored-by: Copilot App <[email protected]> * docs(changelog): record #3913 dependency-confusion fix Co-authored-by: Copilot App <[email protected]> * fix(marketplace): fold panel review into the #1326 admission Skip the version-range tag lookup for a resolution admission will refuse, so no request reaches the ambiguous package remote. Move DependencyConfusionError into marketplace/errors.py and name it in the resolver's except tuple. Harden the static guard against nested defs, getattr reads, aliased imports and direct resolve_plugin_source calls. Serve the enterprise catalog from an SSH-registered Git fixture so apm update revalidates offline (#3910) and reaches admission; add a version-range case, a host-qualified positive control and unit traps. Narrow docs to type: github sources and fix the producer example. Addresses panel follow-ups (python-architect, test-coverage-expert, supply-chain-security-expert, doc-writer) on #3923. Co-authored-by: Copilot App <[email protected]> * test(marketplace): prove apm update re-admits ambiguous locked entries Plain installs replay lock rows without the catalog (#3911), so apm update is the remediation for entries an older APM locked; a lifecycle case locks a host-qualified entry, flips the catalog to the bare form, and asserts apm update refuses without touching the lock. Document the remediation. Addresses CEO follow-up on #3923. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>
- default client is copilot; vscode is its deprecated alias (#3875) - non-default port is part of the lock identity key (#3932); the roundtrip still writes and reads port: 7990 - a partial `apm marketplace update` fails closed with exit 1 and names the failed catalog (#3910) - Claude's skill-command rewrite is an instance method that needs the project's .claude/skills copy (#3875) Co-authored-by: Copilot App <[email protected]>


Description
apm install --refreshandapm updateresolved marketplace plugins from a catalog cache up to 1 h old, andapm marketplace updatecleared the last valid cache before fetching and printed success even when catalogs failed. A publisher's fix was not visible when a consumer explicitly asked for it.Now:
apm install --refresh,apm install --updateandapm updaterevalidate each catalog they actually resolve. They send a conditional request (If-None-Match/If-Modified-Since, so304is cheap) and make one request per source per invocation, however many plugins come from that source. If a catalog is unreachable or invalid, the command fails withCould not verify that marketplace '<name>' is current ... nothing was changed. It does not fall back to stale data, and it does not report the plugin as removed.apm installstill uses the TTL cache, and browse/view keep their stale fallback. Frozen replay gets no live-catalog requirement. Local catalogs are still read locally.apm marketplace update [NAME]revalidates through the same owner instead of clearing the cache first. On a partial batch it names every failed catalog and exits 1. Catalogs that did refresh stay refreshed.apm update foo@acmequietly said everything was current even afterfoowas re-pinned. The resolver now carries the selection through to the Git coordinate the declaration resolves to.Canonical owners:
marketplace/client.pyowns revalidation (fetch_marketplace(require_fresh=True)) and the per-invocation answer (catalog_freshness_scope/fetch_or_cache). Shadow detection reads catalogs in advisory mode, so a refresh never revalidates unrelated catalogs.InstallService.catalog_freshnessmaps command intent through the existingRefFreshnessPolicy.for_install_intent. Theinstallandupdatecommands enter it once.Static guard:
marketplace-integrations-catalog-freshness, with an owner record and a mutation case.Positional
apm install plugin@marketplacesaves a Git dependency, so laterapm updateruns do not follow the catalog. That matches the boundary in the scope; durable catalog-following is #2903.izidormaklary offered to implement this in October and no PR followed. Daniel Meppiel (@danielmeppiel) asked for it to land in 0.37, so it is delivered here. Thanks for the precise report.
Issue and approved scope
Issue: Fixes #3279
Human scope-approval comment: #3279 (comment) (apm-scope:v1 by Daniel Meppiel (@danielmeppiel), 2026-10-20). Delivery for 0.37 was re-confirmed by Daniel Meppiel (@danielmeppiel) via the issue-triage coordinator.
This PR completes the bounded scope. Out-of-scope items (configurable TTL, new flags, always-online default install, #2903) are not touched.
Type of change
Testing
I reproduced the bug first with the real CLI on main (0.36.1 fec774d). I removed
foofrom a hosted catalog, andapm install --refresh foo@acmestill succeeded with 0 catalog requests.tests/integration/test_marketplace_explicit_refresh_lifecycle.py(installed CLI, loopback HTTPS with a private CA,urlcatalogs, plugins in a local Git repo) covers:apm updatethrough the object-form route, selectedapm update foo@acmechanges onlyfoo, and a304follows--refresh(positional and object routes) andapm update, leaving the manifest, lockfile, deployed files and cache byte-identical, while ordinary install still worksmarketplace update, including304, partial failure with exit 1, retained cache, and browse fallbackWith
src/reverted, 4 of the 6 lifecycle cases fail; the frozen-preservation case passes by design, and the selection case had been dropped when that check ran. It was then re-added and failed until the resolver fix.APM_E2E_TESTS=1 APM_BINARY_PATH=.venv/bin/apm pytest tests/integration/test_marketplace_explicit_refresh_lifecycle.py tests/unit/marketplace/{test_marketplace_client,test_marketplace_commands_phase3,test_marketplace_commands_surface,test_marketplace_resolver}.py tests/integration/test_marketplace_{catalog_path,update_provenance}_lifecycle.py(after merging main)pytest tests/unit/marketplace tests/unit/install tests/unit/commands tests/unit/deps tests/unit/test_outdated_marketplace*.pytest_unix_install_ownership.py/test_install_safety.pyhappened under host load average 68 and pass in isolationpytest tests/unit/scripts/test_architecture_runner.pyandtests/integration/test_architecture_{owner,semantic}_rule_mutations.py(new guard cases)pytest tests/quality;check_test_assertions.py;check_exact_test_duplicates.pyuvx [email protected] checkandformat --checkon the CI pathsbash scripts/lint-auth-signals.sh,bash scripts/lint-architecture-boundaries.shChangelog
## [Unreleased]inCHANGELOG.md: user-visibleeffect first, 25 words or fewer, ending with
(#PR); see.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regenerated