Repository navigation
test(marketplace): cover registered ref install flow - #1994
Daniel Meppiel (danielmeppiel) merged 10 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new integration-tier test that exercises the end-to-end apm install <plugin>@<marketplace> flow to ensure a registered marketplace --ref is propagated all the way through resolution, persistence (apm.yml / lockfile), and into the downloader boundary for both GitHub-family and GitLab marketplaces.
Changes:
- Introduces a hermetic integration test that stubs only external I/O seams (marketplace fetch/cache, existence probe, downloader) while running the rest of the install pipeline on production code.
- Verifies
--refpropagation for both dependency persistence formats:- GitHub-family string dependency form
- GitLab structured
{git, path, ref}dependency form
- Asserts clone URL components via
urllib.parse.urlparse(component-level checks rather than substring assertions).
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 0 | 2 | Well-structured integration test with correct seam selection at the downloader boundary; one minor coupling risk, no blockers. |
| CLI Logging Expert | 0 | 0 | 1 | Test-only PR; ref propagation is well-covered but CLI output assertions are entirely absent -- acceptable scope for this issue. |
| DevX UX Expert | 0 | 2 | 1 | Good integration coverage of the happy-path ref propagation; missing user-facing error and idempotency contracts. |
| Supply Chain Security Expert | 0 | 0 | 2 | Test-only PR; stubs are at correct I/O boundaries and assertions verify ref provenance from trusted source. No blocking issues. |
| OSS Growth Hacker | 0 | 0 | 2 | Community contributor PR is exemplary: rich docstring, clear test naming, and hermetic pattern lower the bar for future contributors. |
| Test Coverage Expert | 0 | 1 | 0 | PR fills a real integration-tier gap for marketplace ref propagation (GitHub+GitLab); one recommended gap: ref=None fallback path. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 5 follow-ups
- [Test Coverage Expert] Add integration test for marketplace source with ref=None (default branch fallback) -- Missing-evidence finding on a portability-by-manifest surface; the full pipeline with an unset ref is untested at integration tier, leaving a regression trap for future refactors of the fallback logic.
- [Supply Chain Security Expert] Add negative test asserting user-supplied ref cannot override marketplace-registered ref -- Strengthens the security promise that refs come exclusively from the trusted registry; currently only the happy path is exercised.
- [DevX UX Expert] Add assertion on user-facing install confirmation output -- Guards the UX contract that apm install prints what was installed and from where; a future refactor could silently break the summary message.
- [DevX UX Expert] Add idempotency test (re-install same plugin does not duplicate dep entry) -- Guards the "install adds, never silently mutates" UX promise at integration tier.
- [Python Architect] Decouple _DownloadRecorder from private _build_repo_url method -- Reduces test fragility; a rename of the private method would break the test for non-behavioral reasons.
Architecture
classDiagram
direction LR
class CliRunner {
+invoke(cli, args) Result
}
class _DownloadRecorder {
<<TestDouble>>
+calls list~_DownloadCall~
+install(monkeypatch) None
}
class _DownloadCall {
<<ValueObject>>
+dep_ref DependencyReference
+clone_url str
}
class GitHubPackageDownloader {
+download_package(repo_ref, target_path) PackageInfo
-_build_repo_url(url, dep_ref, token) str
}
class DependencyReference {
<<ValueObject>>
+host str
+repo_url str
+virtual_path str
+reference str
}
class MarketplaceSource {
<<ValueObject>>
+name str
+owner str
+repo str
+host str
+ref str
}
class MarketplaceManifest {
<<ValueObject>>
+name str
+plugins tuple
}
_DownloadRecorder *-- _DownloadCall : collects
_DownloadRecorder ..> GitHubPackageDownloader : monkeypatches
_DownloadCall ..> DependencyReference : captures
flowchart TD
A["runner.invoke(cli, install reviewer@acme-market)"] --> B["PRODUCTION: apm_cli.commands.install"]
B --> C{"resolve_marketplace_plugin\nSTUBBED via patch"}
C --> D["PRODUCTION: build DependencyReference\nwith host + ref from MarketplaceSource"]
D --> E["PRODUCTION: manifest persistence\napm.yml dependencies list"]
E --> F["PRODUCTION: lockfile writer\napm.lock.yaml"]
F --> G["GitHubPackageDownloader.download_package\nSTUBBED by _DownloadRecorder"]
G --> H["_DownloadRecorder.calls captures\nDependencyReference + clone_url"]
H --> I["Assertions: ref, host, repo_url,\nvirtual_path, manifest shape, lockfile fields"]
sequenceDiagram
participant Test
participant CLI as apm install
participant Resolver as marketplace.resolver (stubbed)
participant Pipeline as install pipeline (production)
participant Downloader as GitHubPackageDownloader (stubbed)
participant FS as Filesystem
Test->>CLI: invoke install reviewer@acme-market
CLI->>Resolver: get_marketplace_by_name
Resolver-->>CLI: MarketplaceSource(ref=release/feature-ref)
CLI->>Resolver: fetch_or_cache
Resolver-->>CLI: MarketplaceManifest
CLI->>Pipeline: build DependencyReference
Pipeline->>FS: write apm.yml dependencies
Pipeline->>Downloader: download_package(dep_ref, target)
Downloader-->>Pipeline: PackageInfo (fixture)
Pipeline->>FS: write apm.lock.yaml
Pipeline-->>CLI: exit 0
CLI-->>Test: Result(exit_code=0)
Test->>FS: assert apm.yml deps shape
Test->>FS: assert lockfile fields
Recommendation
Ship now. This PR delivers exactly what #1918 asked for: integration-tier proof that marketplace-registered refs propagate correctly through the full install path. Zero blocking findings across nine panelists. The ref=None fallback gap is the only finding with structural weight (missing evidence on a portability surface) and is best addressed as a fast follow-up issue rather than gating a community contributor's clean, focused PR. Merge, file a follow-up for ref=None coverage, and consider highlighting the contributor's pattern in CONTRIBUTING.md.
Full per-persona findings
Python Architect
-
[nit] _DownloadRecorder reaches into private _build_repo_url method at
tests/integration/test_marketplace_ref_install_e2e.py:72
Couples the test to a private method signature; if _build_repo_url is renamed the test breaks for non-behavioral reasons.
Suggested: Build clone_url asf'https://{dep_ref.host}/{dep_ref.repo_url}'instead of calling the private helper. -
[nit] Recorder install() uses 'self' as inner param name, shadowing outer class at
tests/integration/test_marketplace_ref_install_e2e.py:64
Naming the inner param 'self' in _fake_download while the enclosing method also lives on _DownloadRecorder is slightly confusing.
Suggested:def _fake_download(dl_self, repo_ref, target_path, *args, **kwargs):
CLI Logging Expert
- [nit] No assertions on CLI output messages at
tests/integration/test_marketplace_ref_install_e2e.py:232
The tests assert exit_code==0 and use result.output only as a diagnostic on failure, but never verify the user-visible success message.
Suggested: Consider addingassert '[*]' in result.output or 'Installed' in result.outputto guard the happy-path summary message.
DevX UX Expert
-
[recommended] No test for user-facing output on successful install at
tests/integration/test_marketplace_ref_install_e2e.py:192
The test asserts exit_code==0 but never checks stdout for the human-readable confirmation. From the UX contract, apm install plugin@marketplace should print what was installed and from where. -
[recommended] Missing idempotency test (re-install same plugin) at
tests/integration/test_marketplace_ref_install_e2e.py:221
A core UX promise is 'install adds, never silently mutates'. Running apm install reviewer@acme-market twice should not duplicate the dep entry or error cryptically. -
[nit] Module-level constants could use a brief grouping comment at
tests/integration/test_marketplace_ref_install_e2e.py:47
Seven underscore-prefixed constants in a row with no grouping hint make it harder for a new contributor to grok which are fixture data vs patch targets.
Supply Chain Security Expert
-
[nit] Consider a negative test asserting user-supplied ref cannot override marketplace-registered ref at
tests/integration/test_marketplace_ref_install_e2e.py:54
The tests verify the happy path (registered ref reaches downloader), but no test asserts that a user attempting to inject an alternative ref is rejected or ignored. -
[nit] Fake resolved_commit is a hardcoded placeholder; consider asserting lockfile integrity hash field at
tests/integration/test_marketplace_ref_install_e2e.py:108
The stub returns 'a'*40 as resolved_commit. _validate_package_exists is patched to True, skipping content-hash/integrity verification. A comment or TODO noting integrity verification is covered separately would help future contributors.
OSS Growth Hacker
-
[nit] Add a CONTRIBUTING breadcrumb in the module docstring at
tests/integration/test_marketplace_ref_install_e2e.py:1
The docstring already explains the stub strategy well. Adding 'See CONTRIBUTING.md for integration test conventions' would turn this file into a discoverable on-ramp for the next contributor. -
[nit] Test function names are story-shaped -- consider a brief inline comment explaining the user journey at
tests/integration/test_marketplace_ref_install_e2e.py:181
A short comment like '# Simulates: user runs apm install reviewer@acme-market with a pinned ref' at the top of the test body would help newcomers map test logic to the CLI surface.
Auth Expert -- inactive
PR adds only tests/integration/test_marketplace_ref_install_e2e.py; no production auth code touched. The empty-token in _build_repo_url lives inside a recording stub that never performs real downloads, so it cannot mask auth regressions.
Doc Writer -- inactive
PR adds only a test file with no user-facing documentation, README claims, instruction prose, or CHANGELOG entry required -- test coverage additions are internal quality work and do not warrant an [Unreleased] CHANGELOG entry by APM convention.
Test Coverage Expert
- [recommended] No integration test for marketplace source with ref=None (default branch fallback) at
tests/integration/test_marketplace_ref_install_e2e.py:286
The PR tests only the happy path where _REGISTERED_REF is set. When a marketplace source has ref=None, the install pipeline should fall back to the default branch. Unit tests in test_marketplace_resolver.py cover ref=None at parse level but no integration test exercises the full pipeline with an unset ref. Grep confirmed no 'ref=None' or 'without.*ref' match in the new test file.
Suggested: Addtest_marketplace_no_registered_ref_falls_back_to_default_branchusing_sourcewithref=Noneand assertdep_ref.reference is None.
Proof (missing at integration-with-fixtures):tests/integration/test_marketplace_ref_install_e2e.py::test_marketplace_no_registered_ref_falls_back_to_default_branch-- proves: When a marketplace source omits ref, install uses the repo default branch rather than erroring or injecting a stale ref [portability-by-manifest, devx]
Performance Expert -- inactive
PR adds an integration test only; no source changes to cache, transport, resolution, materialization, or any hot path.
This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.
|
Thanks for the detailed review. I have updated the branch and addressed the applicable follow-ups:
I did not add a test asserting that a user-supplied ref cannot override the registered marketplace ref because this is intentional, documented behavior: Validation completed:
|
PR triage recommendationneeds-issue Recommendation only, not merge or scope approval. A responsible Linked issue#1918 (open). Labels: Proposed classification
PR had no labels. Suggested next actionWait for a maintainer to accept #1918 ( Suggested PR commentThank you for contributing this pull request and for following up on the panel notes.
APM starts with an issue, not an implementation
(https://github.com/microsoft/apm/blob/main/CONTRIBUTING.md).
This PR already links #1918, but that issue is not labelled status/accepted.
Please keep the user problem on that issue so a maintainer can review and
accept the scope first.
This PR is labelled status/deferred until that happens. CODEOWNERS review
requests (@danielmeppiel, @sergio-sisternes-epam) are unchanged. |
The microsoft#1918 scope record requires artifact-selection proof: distinct plugin bytes on main and release/pilot, normal registration and install through the installed CLI, and assertions on deployed bytes, selected ref, resolved commit, source identity and manifest/lock state. The existing downloader-boundary tests fabricate package output, so they cannot detect a default-branch download. Add installed-CLI lifecycle tests for the GitHub-family canonical route (loopback GitHub fixture) and the GitLab structured git+path route (local Git URL rewrite), with explicit plugin pin and plugin@marketplace#ref override controls. Teach the GitHub raw fixture to resolve slash-containing refs, as raw.githubusercontent.com does. Mutation-break: dropping the inherited registered ref in marketplace/resolver.py makes both tests fail on default-branch bytes. Co-authored-by: abhinavgautam01 <[email protected]> Co-authored-by: Copilot App <[email protected]>
Add the microsoft#1994 CHANGELOG entry crediting the contributor and point the downloader-boundary test module at the artifact-selection lifecycle tests. Co-authored-by: abhinavgautam01 <[email protected]> Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Test Coverage Expert | 0 | 1 | 0 | Both routes have lifecycle-tier regression traps validated by mutation break; pin/override precedence tested. Absent-ref tier gap is the only advisory. |
| Doc Writer | 0 | 1 | 0 | CHANGELOG entry and both module docstrings match the tests and the scope. One wording fix: the GitHub route is canonical shorthand, not git + path. Ship. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 2 follow-ups
- [Test Coverage Expert] Add a lifecycle-tier test for absent-ref (no
--ref) registration that asserts default-branch bytes are deployed. -- The scope names absent-ref/main/HEAD handling as a preservation target; current proof is mocked-downloader only. - [Doc Writer] Fix CHANGELOG wording to "GitHub canonical (
owner/repo/path#ref) and GitLabgit+pathroutes". -- The CHANGELOG is the durable public record; the current line conflates two dependency forms.
Recommendation
Both follow-ups are in scope and proportionate for the driving worker to fold before maintainer review. After the absent-ref lifecycle test and the CHANGELOG wording fix land, every preservation target in the #1918 scope has a byte-level regression trap.
Full per-persona findings
Test Coverage Expert
- [recommended] Absent registered ref (default-branch) handling is proven only at a mocked-downloader tier, not with real deployed bytes. at
tests/integration/test_marketplace_ref_install_e2e.py
The scope lists absent-ref/main/HEAD handling as a preservation target.test_marketplace_without_registered_ref_uses_default_branchprovesreference=Nonereaches the downloader but mocksdownload_package, so it does not prove deployed bytes come from the default branch.
Suggested: Add a lifecycle consumer that registers the marketplace without--ref, installs, and asserts main-branch bytes are deployed.
Proof (missing at):tests/integration/test_marketplace_registered_ref_lifecycle.py-- proves: Registering a marketplace without --ref still installs the default branch's real plugin bytes. [portability-by-manifest]
Doc Writer
- [recommended] CHANGELOG line says "GitHub and GitLab
git+pathroutes", but the GitHub test uses the canonicalowner/repo/path#refstring atCHANGELOG.md:13
Readers may think the GitHub structured-dict route was tested when only the canonical string was.
Suggested: Replace with "GitHub canonical (owner/repo/path#ref) and GitLabgit+pathroutes".
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.
Panel follow-ups (test-coverage-expert, doc-writer). The microsoft#1918 scope lists absent-ref handling as a preservation target, but only the mocked-downloader test covered it. Register the GitLab catalog without --ref and assert real default-branch bytes, the default commit, no injected manifest ref and no lock resolved_ref. Mutation-break: dropping the main/HEAD exclusion in the resolver makes this control fail. Also correct the CHANGELOG wording: the GitHub route is the canonical owner/repo/path#ref string, not git + path. Co-authored-by: abhinavgautam01 <[email protected]> Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Test Coverage Expert | 0 | 0 | 0 | Prior absent-ref lifecycle gap resolved by delta; no new coverage gaps introduced. |
| Doc Writer | 0 | 0 | 0 | Prior CHANGELOG route-conflation finding resolved: line now names GitHub canonical and GitLab git+path routes, matches docstring, one Added line with credit. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Recommendation
All earlier follow-ups are resolved with mutation-break evidence, and no findings remain open. Daniel Meppiel (@danielmeppiel) and Sergio Sisternes (@sergio-sisternes-epam) remain the CODEOWNERS reviewers and land this at their discretion.
Folded in this run
- (scope gap, test(marketplace): add integration-tier coverage for marketplace --ref end-to-end flow #1918 apm-scope:v1) Installed-CLI lifecycle tests with distinct
mainvsrelease/pilotplugin bytes on the GitHub canonical and GitLabgit+pathroutes, asserting deployed bytes, selected ref, resolved commit, source identity and manifest/lock; explicit plugin pin andplugin@marketplace#refoverride controls; GitHub raw fixture resolves slash-containing refs -- resolved in d38d67a. - (scope gap) CHANGELOG entry crediting the contributor; contributor test docstring points at the artifact-selection tests -- resolved in 373b619.
- (panel: test-coverage-expert) Absent registered ref covered at lifecycle tier (default-branch bytes, no injected ref, no lock
resolved_ref) -- resolved in 5db40a8. - (panel: doc-writer) CHANGELOG names GitHub canonical and GitLab
git+pathroutes separately -- resolved in 5db40a8.
Copilot signals reviewed
- Two Copilot reviews (2026-07-02, 2026-08-18) produced overview text only and zero inline comments; nothing to classify.
Regression-trap evidence (mutation-break gate)
test_github_registered_branch_installs_pilot_artifactsandtest_gitlab_registered_branch_installs_pilot_artifacts-- deleted the inherited registered-ref propagation insrc/apm_cli/marketplace/resolver.py(canonical#refsuffix and GitLabeffective_reffallback); both tests FAILED on default-branch bytes; guard restored.test_gitlab_registered_branch_installs_pilot_artifacts(absent-ref control) -- deleted themain/HEADexclusion in the GitLabeffective_reffallback; test FAILED ({'git','path','ref'} != {'git','path'}); guard restored.
Lint contract
The full CI lint mirror (ruff check and format on src/ tests/ plus the architecture scripts, pylint R0801, lint-auth-signals.sh, lint-architecture-boundaries.sh) is silent on the merged head.
CI
All checks green on a4edeed (CI https://github.com/microsoft/apm/actions/runs/43249457259, Merge Gate https://github.com/microsoft/apm/actions/runs/43249457429; Lint, Build & Test shards, Lifecycle Smoke shards, Windows gates, CodeQL and license/cla pass), after 0 CI fix iterations (one transient GitHub 503 in the advisory PR-eligibility job on f84a673 passed on re-run). Since the panel head e03ab20, the only changes are merges of main, including #1992 (ref propagation helper); the lifecycle tests pass on that merged code.
Mergeability status
| PR | head SHA | CEO stance | iters | folds | defers | Copilot rounds | CI | mergeable | mergeStateStatus | notes |
|---|---|---|---|---|---|---|---|---|---|---|
| #1994 | a4edeed |
ship_now | 2 | 4 | 0 | 1 | green | MERGEABLE | BLOCKED | pending required review; main advanced 2 unrelated commits after the last merge (trial merge clean) |
Convergence
2 outer iterations; 1 Copilot round. Final panel stance: ship_now. Ready for maintainer review.
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.
0230957
into
microsoft:main
Description
Adds integration-tier coverage for marketplace registered
--refpropagation through the full install path.This covers the follow-up from #1918 by exercising
apm install plugin@marketplacethrough marketplace resolution, dependency parsing, manifest persistence, lockfile writing and the downloader boundary. The test verifies both GitHub-family and GitLab marketplace flows, including the structured GitLabgit+pathdependency shape.Fixes #1918
Type of change
Testing
Validation run:
Results:
Spec conformance (OpenAPM v0.1)
If this PR changes behaviour that an OpenAPM v0.1 req-XXX covers,
confirm the three-step ritual (see CONTRIBUTING.md "Adding or
changing a normative requirement"):
Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
(new/changed 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 -- this PR does not change OpenAPM-observable behaviour.