Skip to content

Fix marketplace --ref not propagated to relative plugin sources (#1811) - #1824

Merged
Daniel Meppiel (danielmeppiel) merged 1 commit into
mainfrom
sergio-sisternes-epam/fix-marketplace-ref-propagation
Jun 19, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 1 commit into
mainfrom
sergio-sisternes-epam/fix-marketplace-ref-propagation

Conversation

@sergio-sisternes-epam

Copy link
Copy Markdown
Collaborator

TL;DR

Propagate the marketplace's registered --ref to relative string plugin sources so apm install plugin@marketplace resolves against the registered branch, not the default branch.

Problem (WHY)

When a marketplace is registered with apm marketplace add owner/repo --ref feat/xxx, and its marketplace.json uses relative string sources (e.g. "./plugins/my-plugin"), apm install my-plugin@my-marketplace downloads the plugin from the default branch instead of the registered --ref.

The ref is correctly persisted and used to fetch marketplace.json, but resolve_marketplace_plugin calls resolve_plugin_source without passing source.ref. The canonical string has no #ref suffix, so the downloader resolves against the default branch. The same gap exists in the GitLab structured-ref path where _gitlab_in_marketplace_dependency_reference receives None for string sources.

Approach (WHAT)

Two surgical changes in resolve_marketplace_plugin:

  1. GitHub-family path: After computing the canonical, append #source.ref when the plugin is a relative string source, no #ref is already present, no explicit version_spec overrides it, and source.ref is not "main" or "HEAD".

  2. GitLab/non-GitHub structured path: Fall back to source.ref in the ref argument to _gitlab_in_marketplace_dependency_reference when path_ref is None and no version_spec.

Validation

  • 5 new regression tests covering both GitHub and GitLab hosts (ref propagation, main exclusion, version_spec override)
  • All 111 existing + new tests pass
  • Lint (ruff check, ruff format, pylint R0801) clean

Fixes #1811

When a marketplace is registered with --ref <branch>, relative string
sources (e.g. ./plugins/my-plugin) resolved against the default branch
instead of the registered ref. The canonical built by
resolve_plugin_source carried no #ref suffix.

Propagate source.ref into the canonical for GitHub-family hosts and
into the DependencyReference for GitLab/non-GitHub hosts when:
- No explicit version_spec overrides it
- The plugin source is a relative string (in-marketplace)
- source.ref is not "main" or "HEAD" (default-branch no-ops)

Add regression tests for both GitHub and GitLab marketplace hosts.

Fixes #1811

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.

✅ Ready to approve

The change is narrowly scoped to the documented root cause and is defended by targeted regression tests for the affected GitHub and GitLab resolution paths.

Note: this review does not count toward required approvals for merging.

Pull request overview

This PR fixes a marketplace resolution gap where a marketplace’s registered --ref was not being applied when resolving relative string plugin sources from marketplace.json, causing installs to unexpectedly resolve against the default branch instead of the pinned ref.

Changes:

  • Propagates the registered marketplace ref into GitLab structured dependency references for in-repo plugins when the plugin source does not specify its own ref and no version_spec override is provided.
  • Appends #<marketplace-ref> to GitHub-family relative string source canonicals (when no ref/version override is present) so downstream resolution uses the pinned branch/tag.
  • Adds regression tests covering GitHub and GitLab ref propagation, main exclusion behavior, and version_spec override precedence.
File summaries
File Description
src/apm_cli/marketplace/resolver.py Ensures registered marketplace refs are applied to in-marketplace relative string plugin sources (GitHub canonical suffix + GitLab dep_ref fallback).
tests/unit/marketplace/test_marketplace_resolver.py Adds unit regression tests validating ref propagation and override precedence across GitHub and GitLab hosts.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.

@sergio-sisternes-epam Sergio Sisternes (sergio-sisternes-epam) added the panel-review Request an advisory PR review; consumed after review. Not human approval or a merge gate. label Jun 17, 2026
@github-actions

Copy link
Copy Markdown

APM Review Panel: ship_with_followups

Correct two-site fix for silent --ref loss in marketplace plugin installs; ship after CHANGELOG entry; HEAD exclusion regression trap and missing debug logs are the priority follow-ups.

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

All nine panelists agree this is a correct, minimal, and safe fix. Auth-expert and performance-expert are appropriately inactive -- neither credential resolution paths nor install throughput are touched. The two changed lines restore the user promise that apm install plugin@marketplace with a registered --ref governs plugin installation for relative string sources, not just marketplace.json fetching. The five new unit tests are tight regression traps on both the GitHub canonical-append path and the GitLab effective_ref path; they are the strongest positive signal in this PR.

Three themes converge across five active panelists and constitute the complete actionable gap set. First, the CHANGELOG omission: oss-growth-hacker and doc-writer independently converge on the missing [Unreleased] > ### Fixed entry -- this is the one pre-merge ask, since contributor attribution and user self-triage both depend on it. Second, two silent canonical mutations carry no logger.debug() calls; the adjacent host-backfill block (lines 843-854) establishes the mandatory pattern -- every silent canonical mutation gets a debug trace -- and cli-logging-expert flags both absences as recommended; devx-ux-expert independently confirms the --verbose user-promise impact. Third, and highest-signal per test-evidence weighting rules: test-coverage-expert returns outcome: missing for the HEAD exclusion test on both new code blocks. A single tuple edit removing 'HEAD' from either exclusion causes zero existing tests to fail yet #HEAD begins appearing in canonicals. This missing-test finding on a behavioral guard ranks above all opinion-only recommended findings and must be addressed in the same release cycle as the fix.

Supply-chain's _validate_ref recommendation is defense-in-depth: downstream subprocess arg-lists and URL encoding already neutralize crafted ref characters, and the threat vector requires direct edit of a local marketplaces.json file. The integration-floor gap (install canonical through lockfile round-trip) is real but appropriate as a follow-up issue given the tight resolver-boundary unit coverage already present. Doc updates to the --ref CLI reference and the main/HEAD silent-drop caveat are a genuine omission that devx-ux-expert and doc-writer agree on; they belong in the same or an adjacent PR but do not hold up the behavior fix itself.

Dissent. No material disagreements among panelists. Supply-chain-security (lockfile non-determinism angle) and devx-ux-expert (broken user promise angle) frame the main/HEAD silent-drop edge case through complementary lenses on the same pre-existing behavior -- both rate it nit-tier for this PR since the fix does not introduce or worsen the edge case.

Aligned with: Portable by manifest -- The fix directly advances portability: marketplace-registered --ref is now correctly propagated to relative plugin source canonicals, making installs reproducible across machines regardless of default-branch assumptions on the plugin repository. A lockfile written after this fix encodes the canonical with the explicit ref fragment, eliminating the silent drift that issue #1811 reported. Secure by default -- Downstream ref consumers (git subprocess arg-list, URL-encoded API calls) are safe by construction. Supply-chain-security correctly notes that _validate_ref -- the project's explicit ref-injection control, already called in _fetch_git and _fetch_local -- is absent at the new canonical assembly point; adding it is a low-effort defense-in-depth follow-up.

Growth signal. oss-growth-hacker flags this as the second non-trivial contribution from sergio-sisternes-epam; two substantive PRs from the same employer is a leading org-level adoption signal. Recommended actions: (1) ensure CHANGELOG entry carries a contributor attribution for sergio-sisternes-epam, (2) include in the next release post with story angle "APM now correctly honors --ref across all plugin source types -- including relative string sources registered in a marketplace", (3) track EPAM as a potential org-level adopter given the cadence of contributions.

Panel summary

Persona B R N Takeaway
Python Architect 0 1 3 Correct, surgical two-site fix; guards complete for stated scope. One untested GHE+string interaction and duplicated magic exclusion set are the only rough edges.
CLI Logging Expert 0 2 1 Two silent canonical mutations lack logger.debug() calls; the host-backfill block directly above sets the exact pattern both new blocks must follow.
DevX UX Expert 0 3 1 Bug fix correctly restores --ref user promise for string sources; three UX gaps remain around silent ref exclusion, uncontextualized downstream errors, and missing doc update.
Supply Chain Security Expert 0 1 2 No urgent issues; source.ref is safe via subprocess arg-list and URL encoding, but _validate_ref is absent at the canonical assembly point -- recommend adding as defense-in-depth.
OSS Growth Hacker 0 1 2 Solid community fix for a silent, adoption-affecting bug in --ref marketplace installs; missing CHANGELOG entry is the only gap before merge.
Doc Writer 0 2 1 No CHANGELOG entry for bug fix #1811; --ref propagation-to-relative-sources behavior and its main/HEAD silent-drop caveat are undocumented.
Test Coverage Expert 0 2 0 5 unit tests are tight regression traps for both new code blocks; HEAD exclusion (both blocks) has no test -- one tuple edit away from silent regression; integration floor for install-with-ref is absent.

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

Top 5 follow-ups

  1. [OSS Growth Hacker + Doc Writer] Add [Unreleased] > ### Fixed CHANGELOG entry with contributor attribution and issue/PR refs before merge -- Pre-merge ask: affected users cannot self-triage the upgrade; contributor receives no visible credit. Both panelists converge independently. Suggested text: "apm install plugin@marketplace now correctly propagates the marketplace-registered --ref to relative string plugin sources instead of silently falling back to the default branch. (by Sergio Sisternes (@sergio-sisternes-epam); closes [BUG] marketplace add --ref: registered ref not propagated to relative plugin source resolution #1811) (Fix marketplace --ref not propagated to relative plugin sources (#1811) #1824)"
  2. [Test Coverage Expert] Add HEAD exclusion tests for both GitHub canonical-append and GitLab effective_ref new code blocks -- outcome: missing on a behavioral guard: removing 'HEAD' from either exclusion tuple causes zero test failures yet silently appends #HEAD to canonicals. One parametrized test covering both 'main' and 'HEAD' for both paths closes the regression trap entirely.
  3. [CLI Logging Expert] Add logger.debug() calls inside both new ref-propagation blocks to match the host-backfill pattern at lines 843-854 -- Without it, --verbose mode cannot distinguish whether the ref fragment came from plugin registration, a version_spec override, or the marketplace fallback -- breaking both agent diagnostics and developer debugging.
  4. [Supply Chain Security Expert] Call _validate_ref(source.ref) before appending to canonical (GitHub block) and before GitLab effective_ref assignment -- Defense-in-depth following the project's own ref-injection control pattern; _validate_ref is already called in _fetch_git and _fetch_local; extending it here closes the gap at the assembly point.
  5. [DevX UX Expert + Doc Writer] Update the --ref CLI reference doc to document propagation to relative plugin sources and the main/HEAD silent-drop caveat -- Post-fix, --ref semantics expanded silently beyond what the CLI reference documents. The main/HEAD exclusion edge case -- explicit --ref main silently dropped when the plugin repo's actual default branch differs -- needs a callout to avoid user confusion.

Architecture

classDiagram
    direction LR
    class MarketplaceSource {
        <<ValueObject>>
        +name str
        +ref str
        +owner str
        +repo str
        +host str
        +kind str
    }
    class MarketplacePlugin {
        <<ValueObject>>
        +name str
        +source any
        +version str
    }
    class MarketplaceManifest {
        <<ValueObject>>
        +plugins tuple
        +plugin_root str
        +find_plugin(name) MarketplacePlugin
    }
    class MarketplacePluginResolution {
        <<OutputAggregate>>
        +canonical str
        +dependency_reference DependencyReference
        +cross_repo_misconfig_risk CrossRepoMisconfigRisk
    }
    class DependencyReference {
        <<ValueObject>>
        +repo_url str
        +reference str
        +to_canonical() str
    }
    class resolve_marketplace_plugin {
        <<IOBoundary>>
        +plugin_name str
        +marketplace_name str
        +version_spec str
    }
    class resolve_plugin_source {
        <<Pure>>
        +plugin MarketplacePlugin
        +returns str
    }
    class gitlab_dep_ref_builder {
        <<Pure>>
        +source MarketplaceSource
        +in_repo_path str
        +ref str
        +returns DependencyReference
    }
    MarketplaceManifest *-- MarketplacePlugin : contains
    resolve_marketplace_plugin ..> MarketplaceSource : reads ref
    resolve_marketplace_plugin ..> MarketplaceManifest : fetches
    resolve_marketplace_plugin ..> MarketplacePluginResolution : returns
    resolve_marketplace_plugin ..> resolve_plugin_source : delegates str source
    resolve_marketplace_plugin ..> gitlab_dep_ref_builder : calls for gitlab path
    resolve_plugin_source ..> MarketplacePlugin : reads source
    gitlab_dep_ref_builder ..> DependencyReference : builds
    MarketplacePluginResolution o-- DependencyReference : optional dep_ref
    class resolve_marketplace_plugin:::touched
    classDef touched fill:#fff3b0,stroke:#d47600
Loading
flowchart TD
    A["resolve_marketplace_plugin"] --> B["get_marketplace_by_name: load MarketplaceSource.ref"]
    B --> C["fetch_or_cache: download marketplace.json"]
    C --> D["manifest.find_plugin"]
    D --> E{"local kind + str source?"}
    E -->|Yes| F["_resolve_local_relative_source: early return"]
    E -->|No| G["resolve_plugin_source: str src yields owner/repo/subpath, no ref"]
    G --> H{"_source_needs_explicit_git_path? (gitlab or non-GitHub)"}
    H -->|"Yes + in-marketplace"| I["_extract_in_repo_path_and_ref: rel_path + ref=None"]
    I --> J["[NEW] effective_ref = version_spec or path_ref or source.ref if not in exclusions"]
    J --> K["_gitlab_in_marketplace_dep_reference: builds DependencyReference with effective_ref"]
    K --> L["dep_ref.to_canonical()"]
    H -->|"No or cross-repo"| M["dep_ref = None"]
    L --> N{"dep_ref is None + _needs_canonical_host_prefix?"}
    M --> N
    N -->|"Yes GHE"| O["canonical = source.host/canonical"]
    N -->|No| P["canonical unchanged"]
    O --> Q["_compute_cross_repo_misconfig_risk"]
    P --> Q
    Q --> R{"dep_ref is None + not version_spec + str plugin.source + no hash + source.ref not in exclusions?"}
    R -->|Yes| S["[NEW] canonical = canonical + '#' + source.ref"]
    R -->|No| T["skip ref propagation"]
    S --> U{"version_spec set + dep_ref is None?"}
    T --> U
    U -->|Yes| V["resolve_version_constraint or raw ref override"]
    U -->|No| W["canonical final"]
    V --> W
    W --> X["check_ref_pin / record_ref_pin"]
    X --> Y["detect_shadows advisory"]
    Y --> Z["return MarketplacePluginResolution"]
Loading

Recommendation

Merge after the CHANGELOG entry is added (followup #1 -- the single pre-merge ask). The fix is correct, minimal, and safe; all panelists agree and the unit regression tests are strong. The HEAD exclusion regression trap (followup #2) and missing debug logs (followup #3) are the highest-signal post-merge items and should land in the same release cycle. _validate_ref defense-in-depth (followup #4) and the doc update (followup #5) can follow in adjacent PRs. The behavior fix is ready to ship once the CHANGELOG is in place.


Full per-persona findings

Python Architect

  • [recommended] *.ghe.com marketplace + relative string source + registered ref combination is untested at tests/unit/marketplace/test_marketplace_resolver.py:1437
    The GHE host-backfill block and new ref-propagation block execute sequentially for GHE in-marketplace string sources. This interaction is architecturally correct but all five new tests only exercise github.com and gitlab.com hosts.
    Suggested: Add a sixth test: MarketplaceSource(host='corp.ghe.com', ref='feat/xxx', ...), plugin source='./plugins/p' -> expect result.canonical == 'corp.ghe.com/acme/catalog/plugins/p#feat/xxx' and result.dependency_reference is None.
  • [nit] Magic exclusion tuple ('main', 'HEAD') duplicated at resolver.py:829 and resolver.py:886 at src/apm_cli/marketplace/resolver.py:829
    The same two-element literal appears independently in both the GitLab effective_ref block and the GitHub ref-propagation block. If the exclusion policy is extended, both sites must be updated in sync.
    Suggested: Add _DEFAULT_REF_EXCLUSIONS: frozenset[str] = frozenset({'main', 'HEAD'}) module-level constant.
  • [nit] Silent skip when '#' already in canonical produces no debug trace at src/apm_cli/marketplace/resolver.py:884
    Suggested: logger.debug('Ref propagation skipped for %s@%s: canonical already carries fragment %r', plugin_name, marketplace_name, canonical)
  • [nit] Procedural pipeline, no new patterns introduced -- appropriate for two-site bug fix scope; no abstraction changes warranted.

CLI Logging Expert

  • [recommended] GitHub ref-propagation block mutates canonical with no logger.debug() -- breaks established pattern set by adjacent host-backfill block at src/apm_cli/marketplace/resolver.py:888
    Lines 843-854 establish the pattern: every silent canonical mutation gets a logger.debug() call. In --verbose mode, a developer cannot determine whether the ref fragment came from the plugin source, version_spec, or the marketplace-registration fallback.
    Suggested: After line 888: logger.debug("Propagated marketplace ref '%s' to canonical for %s@%s (#1811)", source.ref, plugin_name, marketplace_name)
  • [recommended] GitLab effective_ref fallback (line 830) has no logger.debug() call -- resolution decision is untraced at src/apm_cli/marketplace/resolver.py:830
    Suggested: Inside the if not effective_ref... branch: logger.debug("Propagated marketplace ref '%s' to GitLab in-repo dep for %s@%s (#1811)", source.ref, plugin_name, marketplace_name)
  • [nit] Silent exclusion of 'main'/'HEAD' refs emits nothing at src/apm_cli/marketplace/resolver.py:886 -- a debug trace when exclusion fires would help agents diagnose the known edge case.

DevX UX Expert

  • [recommended] Silent exclusion of --ref main/HEAD with no observable signal is invisible in a narrow but real scenario at src/apm_cli/marketplace/resolver.py:886
    A user who explicitly types apm marketplace add acme/catalog --ref main on a repo whose actual default branch is NOT main expects main to be pinned; instead the fix silently drops it with no debug log, no warning.
    Suggested: logger.debug("ref '%s' for %s@%s matches default-branch exclusion list; not propagating to canonical", source.ref, plugin_name, marketplace_name) when exclusion fires.
  • [recommended] When propagated source.ref does not exist on the plugin repo, the downstream error has no marketplace context at src/apm_cli/marketplace/resolver.py:888
    User sees generic git "Reference not found" error with no mention of the marketplace or the recovery action (apm marketplace add <SOURCE> --ref <valid-ref>).
  • [recommended] --ref docs say it governs marketplace.json fetching only; after this PR it also governs plugin installation -- the doc is now incomplete at docs/src/content/docs/reference/cli/marketplace.md
    Suggested: Extend the --ref row to document: "governs both the marketplace.json fetch and, for relative string plugin sources, the ref used when installing plugins. main/HEAD are treated as the default branch and not propagated."
  • [nit] HEAD exclusion asserted in code at two sites but has zero test coverage at tests/unit/marketplace/test_marketplace_resolver.py:1465 -- parametrize 'main'/'HEAD' in the main-exclusion tests.

Supply Chain Security Expert

  • [recommended] _validate_ref is not called before source.ref is appended to the canonical string at src/apm_cli/marketplace/resolver.py:888
    _validate_ref (enforces ^[A-Za-z0-9][A-Za-z0-9._/-]*$) is called in _fetch_git and _fetch_local but not in _fetch_github or _fetch_gitlab. A crafted local marketplaces.json entry could embed characters that flow silently into the canonical. Downstream subprocess arg-lists and URL encoding mitigate in practice, but the explicit guard the project relies on is absent at the assembly point.
    Suggested: Call _validate_ref(source.ref, marketplace_name) before line 888 and before the GitLab effective_ref assignment at line 830.
  • [nit] The 'main'/'HEAD' exclusion silently drops explicitly user-pinned refs at src/apm_cli/marketplace/resolver.py:886 -- two machines with different repo defaults install different commits from the same lockfile entry.
  • [nit] GitLab effective_ref block lacks the explanatory comment present in the GitHub-family block at src/apm_cli/marketplace/resolver.py:829 -- copy rationale + known-limitation disclosure from lines 875-879.

OSS Growth Hacker

Auth Expert -- inactive

Both changed hunks only touch the ref/fragment portion of canonical URLs and the DependencyReference.reference field. AuthResolver dispatches exclusively on host, port, and host_type -- none of which are modified. The existing *.ghe.com host-backfill auth block (#1285, lines 843-854) is unaffected and runs before the new ref-propagation block.

Doc Writer

Test Coverage Expert

  • [recommended] HEAD exclusion from ref propagation is untested in both new code blocks at tests/unit/marketplace/test_marketplace_resolver.py
    Both new blocks gate on source.ref not in ('main', 'HEAD') but the new test class only covers ref='main'. Removing 'HEAD' from either exclusion tuple causes zero test failures. Confirmed absence via grep.
    Proof (missing): tests/unit/marketplace/test_marketplace_resolver.py::test_github_relative_source_head_ref_not_appended -- proves: A marketplace registered with --ref HEAD does not append #HEAD to the canonical [devx, portability-by-manifest]
    assert result.canonical == "acme/catalog/plugins/my-plugin" # no #HEAD suffix
    Suggested: Add tests for HEAD exclusion for both GitHub and GitLab paths (or parametrize existing main-exclusion tests with ('main', 'HEAD')).
  • [recommended] No integration-with-fixtures test walks apm install plugin@marketplace through the lockfile when marketplace carries a non-default --ref at tests/integration/test_install_marketplace_phase4w3.py
    The headline user promise is "install resolves against the registered branch." 5 unit tests defend the resolver in isolation, but no integration test traces the corrected canonical through install pipeline, lockfile write, and round-trip. Confirmed absence via grep on tests/integration/.
    Proof (missing): tests/integration/test_install_marketplace_phase4w3.py::test_marketplace_install_propagates_registered_ref_to_lockfile -- proves: apm install plugin@marketplace with registered --ref feat/xxx locks canonical as owner/repo/path#feat/xxx [portability-by-manifest, devx]
    assert locked_entry["canonical"].endswith("#feat/my-feature")
    Suggested: Add hermetic integration test driving install with fixture marketplace at --ref feat/xxx and asserting lockfile canonical ends with #feat/xxx.

Performance Expert -- inactive

The two changed files (src/apm_cli/marketplace/resolver.py and its unit-test companion) are not in the perf fast-path (cache/deps/install phases/pipeline/resolve); all 30 added lines are pre-download metadata computation -- boolean guards and f-string concatenation -- with zero impact on resolve round-trips, fetch bytes, materialization syscalls, or install wall-time.

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.

Generated by PR Review Panel for issue #1824 · sonnet46 16.5M · ◷

@github-actions github-actions Bot removed the panel-review Request an advisory PR review; consumed after review. Not human approval or a merge gate. label Jun 17, 2026
Merged via the queue into main with commit 42f05f3 Jun 19, 2026
39 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the sergio-sisternes-epam/fix-marketplace-ref-propagation branch June 19, 2026 07:12
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Jun 25, 2026
…GitLab slash-ref proxy filenames (#1880)

* fix(artifactory): deterministic boundary probe for nested GitLab paths

Mirrors the native GitLab resolver pattern -- but uses HEAD on Artifactory
archive URLs as the existence signal, so no separate metadata API is
needed.  Covers both routing modes:

  Mode 1 -- explicit FQDN deps (host/artifactory/key/owner/repo/...).
  Mode 2 -- bare shorthand under PROXY_REGISTRY_URL+PROXY_REGISTRY_ONLY.

The resolver walks candidate (owner, repo, virtual_path) splits
shallow-first and locks in the first one whose archive responds 2xx-3xx.
For unambiguous paths it returns the parse-time ref unchanged.  When
every candidate is rejected it raises -- distinguishing "missing repo"
from auth (401/403) errors so users get an actionable hint instead of
silently anchoring on a wrong guess.  ``allow_redirects=False`` on the
HEAD call keeps the Bearer token from leaking cross-host.

Removes the parse-time marker-segment heuristic
(_VIRTUAL_PATH_ROOT_SEGMENTS / _ARTIFACTORY_VIRTUAL_MARKERS /
_ARTIFACTORY_VIRTUAL_FILE_EXTENSIONS) that previously decided the
boundary based on hard-coded directory names like ``skills/`` or
``prompts/``.  Parse-time now defaults to all-as-repo with a structural
file-extension rule on the last segment; the install-time resolver is
the authoritative source of the boundary.

Also fixes a pre-existing URL-roundtrip bug where ``to_github_url`` ->
``parse`` folded the ``artifactory/<key>`` prefix into ``repo_url``,
causing the downloader to build double-prefixed archive URLs and 404.
``_validate_url_repo_path`` now strips the prefix before returning the
bare ``owner/repo`` slug.

* fix(artifactory): address Copilot review feedback on PR #1472

- parse_artifactory_path: reject ``owner//virtual`` (empty segment before
  the explicit boundary) instead of falling through and returning an empty
  ``repo`` slug.
- _proxy_routing_target: thread the proxy ``scheme`` (https/http) through
  the resolver into ``build_artifactory_archive_url`` so installs that
  intentionally route through an ``http://`` proxy (under
  ``PROXY_REGISTRY_ALLOW_HTTP=1``) probe over the same transport.
- _CandidateStatus.EXISTS: update inline comment to say ``2xx or 3xx``
  (redirect-inclusive), matching the actual classification in
  ``_candidate_archive_status``.
- CHANGELOG: split the parse-time-behavior note into explicit-FQDN vs
  bare-shorthand modes (the all-as-repo default applies only under
  ``PROXY_REGISTRY_ONLY``; Mode 1 stays shallow).
- package_resolution: clarify the ``direct_virtual_resolved`` docstring --
  GitLab path gates on ``is_virtual``, Artifactory path gates on probe
  rebuild; both signal "persist as structured ``git:`` + ``path:`` entry".
- Add two regression tests for the empty-segment edge case (parser +
  iterator).

* test(artifactory): add regression traps for boundary resolver

Adds focused regression-trap tests for the new install-pipeline
boundary resolver (#1472) covering the contracts a future refactor
could silently break:

- allow_redirects=False on every HEAD probe (token-leak guard against
  proxy-issued cross-host redirects)
- Mode 2 Authorization header is sourced from RegistryConfig
  (proxy bearer), never from AuthResolver (which returns the
  github.com PAT and would leak it to the proxy host)
- 403 (like 401) classifies as AUTH; mixed 401/non-auth-4xx demotes
  the candidate set to MISSING so the user-facing error stays
  accurate (avoids misreporting a missing repo as auth failure)
- 429 and other non-{401,403} 4xx are MISSING, not AUTH (guards
  against accidental broadening of the AUTH set)
- _split_owner_repo subgroup folding for 3+ segment GitLab boundaries
  (group/sub1/sub2/repo correctly folds to owner=group,
  repo=sub1/sub2/repo)

Both mutation-break gates were exercised: flipping allow_redirects
to True and rewiring Mode 2 to AuthResolver each made the
corresponding test fail; restoring the source code made them pass.

Also applies ruff format pass to bring three files in line with
the canonical formatter (pre-existing drift on the PR branch that
would have failed CI lint check).

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

* fix(marketplace): propagate marketplace --ref to string sources; fix GitLab slash-ref proxy filenames

Two related fixes for marketplace ref handling:

1. `apm install plugin@marketplace` now fetches from the registered --ref
   branch instead of silently falling back to the repo default branch.
   `resolve_marketplace_plugin` was not propagating `source.ref` downstream.
   Covers GitHub-family hosts (ref appended to canonical) and GitLab hosts
   (ref injected into DependencyReference). Guards skip main/HEAD and respect
   explicit version_spec overrides. Mirrors #1824.

2. GitLab archive URLs with slash-containing branch names (e.g. feat/my-feature)
   now produce Artifactory-proxyable filenames: slash preserved in the path
   segment, replaced with '-' in the filename. Previously PROXY_REGISTRY_ONLY=1
   installs returned HTTP 404 because the filename contained a literal slash.
   This is the proxy scenario absent from #1824.

9 regression tests added; 0 pre-existing failures introduced.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* style: replace non-ASCII em-dashes, arrows, and box-drawing chars with ASCII

Addresses Copilot review comments on PR #1880.  Repo encoding rules
require source files to stay within printable ASCII to avoid
Windows cp1252 UnicodeEncodeError in some environments.

- github_host.py: U+2192 arrow (->)
- resolver.py: two U+2014 em-dashes (--)
- test_marketplace_resolver.py: U+2014 em-dash and two U+2500 separators
- test_artifactory_support.py: U+2014 em-dash and three U+2500 separators

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(artifactory): demote mixed 401+404 candidate to MISSING not AUTH

_candidate_archive_status() was returning AUTH whenever any URL shape
returned 401/403, even if other shapes returned non-auth 4xx (e.g. 404).
This misreported a boundary-resolution failure as an authentication
failure, giving users a misleading error message.

Per the module spec: AUTH is returned only when *every* observed response
was 401/403 with no non-auth 4xx seen.  A mix means at least one URL shape
was definitively absent -- the candidate is MISSING and the unresolved-
boundary error path is triggered instead.

Added saw_non_auth_4xx flag; AUTH gate now requires
`saw_auth and not saw_non_auth_4xx`.

Addresses Copilot review comment on PR #1880.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix: restore CHANGELOG from main; format test files; fold panel items

- Restore CHANGELOG.md from current main (refs #1902, #1873, #1897, etc.)
- Add two PR-specific Fixed entries: marketplace --ref propagation and
  GitLab slash-ref proxy filename normalization
- Apply ruff format to test_marketplace_resolver.py and
  test_artifactory_support.py (CI Lint gate fix)
- All four lint checks pass: ruff check, ruff format, pylint R0801,
  auth-signals

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

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: chkp-roniz <[email protected]>
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Co-authored-by: danielmeppiel <[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] marketplace add --ref: registered ref not propagated to relative plugin source resolution

3 participants