GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — perf(deps): sweep raw CDN across marker probes before any anonymous Contents API call by ShaoLOWu · Pull Request #3348 · microsoft/apm

Conversation

@ShaoLOWu

@ShaoLOWu ShaoLOWu commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the maintainer-approved scope from #3283 (apm-scope:v1): stop spending anonymous Contents API calls during virtual-package validation and marketplace registration on public github.com sources.

1. Virtual-package validation: raw CDN first sweep

validate_virtual_package_exists previously probed marker files one at a time, and each miss on a public github.com repo escalated to an anonymous Contents API call. A Claude-plugin-layout repo (plugin.json deep in the marker list) could burn 4+ calls before the layout was found — a large share of the 60 req/h anonymous budget.

  • Before the per-marker loop, every marker path is now swept through the raw CDN (raw.githubusercontent.com, no rate limit) via a new raw_only pass-through on download_raw_file / download_github_file. A single hit validates the package with zero API calls.
  • If the sweep finds nothing, the existing per-marker probes and both fallbacks run unchanged — API-only, private, GHES/ADO/GitLab hosts keep their previous behavior.
  • GitHubThrottleError still propagates untouched.

2. Marketplace add: reuse the discovery response

_auto_detect_path probes candidate locations, then fetch_marketplace(force_refresh=True) immediately re-fetched the same catalog it had just downloaded.

  • New _auto_detect_path_with_payload returns (path, data); the command layer passes the captured payload to fetch_marketplace(discovery_payload=...), which skips the redundant network round-trip.
  • The sidecar cache is still written, so subsequent force_refresh/freshness semantics are identical.

Testing

New unit tests (12):

  • tests/unit/deps/test_virtual_package_cdn_first_sweep.py (6): sweep hits every marker raw-only; first-hit success spends zero Contents API calls; full-miss path escalates to API and keeps fallback behavior; non-public hosts skip the sweep; single-file virtual packages unaffected.
  • tests/unit/marketplace/test_catalog_discovery_reuse.py (6): discovery payload is reused (no second fetch); explicit force_refresh still fetches; cache file still written.

Local run (Python 3.13, Windows): all new tests pass; the pre-existing failure set (tests/unit/deps/, test_github_downloader.py, test_virtual_package_multi_install.py) is byte-identical before and after this change (13 Windows/Unix-environment failures: symlinks, GitLab/Gitea routing, /dev/null — none touched by this PR). ruff check clean on all modified files.

AI-Generated PR disclosure

This PR was authored with AI assistance (Claude-based coding agent working under human direction): issue analysis, fix design, implementation, and test authoring were agent-assisted; scope was user-approved against the maintainer's approved-scope comment on #3283 before implementation. All changes were validated locally as described above, and the human reviewed and confirmed the final diff before submission.

Fixes #3283

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ShaoLOWu
perf(deps): sweep raw CDN across marker probes before any anonymous C…
3d391e9
…ontents API call

Virtual-package validation on public github.com repos spent anonymous
Contents API calls per marker file before discovering the layout, and
`apm marketplace add` re-fetched the catalog immediately after the
discovery probe had just downloaded it. On the default 60 req/h
anonymous budget a single Claude-plugin-layout install could burn 4+
calls (validation + registration combined).

- validate_virtual_package_exists: probe every marker path through the
  raw CDN first (zero API calls) before falling back to the existing
  per-marker Contents API probes; fallbacks and non-public hosts are
  unchanged
- download_raw_file: new raw_only pass-through for CDN-only probes
- marketplace add: reuse the catalog response captured during path
  discovery instead of re-fetching it (sidecar cache semantics kept)
- tests: 12 new unit tests covering sweep ordering, API-spend
  assertions, fallback retention, and catalog reuse

Fixes microsoft#3283
@ShaoLOWu
ShaoLOWu requested review from Daniel Meppiel (danielmeppiel) and Sergio Sisternes (sergio-sisternes-epam) as code owners October 22, 2026 12:09
Copilot AI balanced review requested due to automatic review settings October 22, 2026 12:09
Copilot started reviewing on behalf of ShaoLOWu October 22, 2026 12:10
View session
Copilot AI reviewed Oct 22, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Incorrect and incomplete test mocks cause assertion failures and unintended network requests.

3 open issues
  • High severity Update tests to patch _auto_detect_path_with_payload · New
  • High severity Test uses public GitHub dependency and accepts unconfigured CDN mock · New
  • Medium severity Unmocked Contents API probe can make unit test perform real requests · New
What changed in this PR

This PR addresses #3283 by reducing redundant GitHub API requests during virtual-package validation and marketplace registration.

Changes:

  • Sweep package markers through the raw CDN before allowing Contents API fallback.
  • Reuse the discovered marketplace catalog while preserving cache writes.
  • Add regression tests and update existing discovery mocks.
File Description
tests/​unit/​marketplace/​test_marketplace_commands.py Updates discovery mocks to return path/payload tuples.
tests/​unit/​marketplace/​test_catalog_discovery_reuse.py Tests payload reuse, refresh behavior, and cache writes.
tests/​unit/​deps/​test_virtual_package_cdn_first_sweep.py Tests CDN-first validation and fallback behavior.
tests/​unit/​deps/​test_github_downloader_validation.py Allows keyword arguments in an existing download mock.
src/​apm_cli/​marketplace/​client.py Returns discovery payloads and supports reusing them.
src/​apm_cli/​deps/​github_downloader.py Passes the raw_only option through downloader methods.
src/​apm_cli/​deps/​github_downloader_validation.py Adds the CDN-only marker sweep before legacy probes.
src/​apm_cli/​deps/​download_strategies.py Prevents API fallback for raw-only requests.
src/​apm_cli/​commands/​marketplace/​__init__.py Passes discovered catalog data into marketplace fetching.

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/apm_cli/commands/marketplace/__init__.py
discovered_manifest = None
else:
detected_path = _auto_detect_path(probe_source)
detected_path, discovered_manifest = _auto_detect_path_with_payload(probe_source)
Comment thread tests/unit/deps/test_virtual_package_cdn_first_sweep.py
"uses_public_github_anonymous_first",
return_value=False,
),
patch.object(downloader._strategies, "try_raw_download") as cdn_mock,
Comment thread tests/unit/deps/test_virtual_package_cdn_first_sweep.py

with (
patch.object(downloader, "download_raw_file", side_effect=wrapper),
patch.object(downloader._strategies, "try_raw_download", return_value=None),
@ShaoLOWu

ShaoLOWu commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

1 similar comment
@ShaoLOWu

ShaoLOWu commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ShaoLOWu
test: retarget discovery mocks to _auto_detect_path_with_payload and …
3bfc1f4
…de-network sweep tests

Addresses Copilot review feedback on microsoft#3348:

- Retarget the traceback tests (phase3/surface) and the five wave7
  patch sites from _auto_detect_path to _auto_detect_path_with_payload,
  returning (path, payload) tuples so discovery stays mocked instead of
  executing the real fetch path.
- test_non_public_host_skips_sweep: use an actual non-public-host
  dependency and simulate legacy per-marker misses on the download
  strategy seam (a bare MagicMock return was accepted as file content),
  stubbing the directory and ls-remote fallbacks at the validation
  module boundary so the host boundary is checked fully offline.
- test_virtual_file_probe_keeps_legacy_semantics: mock the auth
  callback and return controlled API 404s (matching the full-miss
  test) so the single-file probe never attempts real GitHub requests.

Sweep test suite runtime drops from ~57s (network-dependent) to ~3s.
Verified: 6/6 sweep tests green; 332 tests across the touched
marketplace/deps suites pass; tests/unit/deps failure set identical
to the pre-change Windows baseline (7 pre-existing symlink/routing
failures); ruff clean.
@sergio-sisternes-epam

Sergio Sisternes (sergio-sisternes-epam) commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Thank you for implementing the scoped fix. Maintainer approval for the bounded scope is recorded in #3283, but neither the PR nor linked issue currently carries status/accepted. Under the triage rule, this PR is labelled status/deferred until the maintainer reconciles that status. This recommendation is advisory only, not merge approval.


Generated by autopilot-pr-triage-worker. This comment is AI-generated and may contain errors.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sergio-sisternes-epam Sergio Sisternes (sergio-sisternes-epam) added area/cli CLI command surface, flags, help text (cross-cutting). status/deferred Not invited for implementation now; no release commitment. triage/recommended Automated advice completed; not human scope approval. type/performance Latency, throughput, memory, install time. labels Nov 3, 2026
@danielmeppiel Daniel Meppiel (danielmeppiel) mentioned this pull request Nov 10, 2026
[BUG] Validating a public in-repo plugin spends one anonymous API call per marker the CDN misses (four for a .claude-plugin plugin) #3283
Closed
Daniel Meppiel (danielmeppiel) and others added 7 commits November 10, 2026 18:30
@danielmeppiel
Merge remote-tracking branch 'origin/main' into pr-3348
833b3a6
@danielmeppiel
test: exercise a real non-public host in the sweep boundary test
0818391
The host-boundary unit test forced uses_public_github_anonymous_first to
False on a github.com dependency, so it never exercised a non-public host
and its CDN mock could be reached through the legacy fast path. Use an
acme.ghe.com dependency through the real auth resolver, assert the CDN is
never contacted and every probe is legacy, and apply ruff format to the
PR's new unit tests. Addresses Copilot inline r4348166827 on
tests/unit/deps/test_virtual_package_cdn_first_sweep.py.

Co-authored-by: Copilot <[email protected]>
@danielmeppiel
test: installed-CLI request budget for public marker validation
f75184a
The microsoft#3283 scope requires installed-CLI request-count and state evidence,
not only unit mocks. Add a loopback HTTPS proxy fixture that terminates
CONNECT for raw.githubusercontent.com and api.github.com with a private CA
and answers from owned bare repositories, so the uv console script and the
frozen binary are both counted hermetically. Lifecycle cases cover
multi-plugin, repeat and --update installs with zero Contents API calls,
truthful missing-marker failure with one bounded API pass, private
authenticated recovery, marketplace add catalog reuse plus marketplace
installs, and no registration on a failed discovery. Mutation-break:
disabling the raw sweep or the discovery payload reuse fails these tests.

Co-authored-by: Copilot <[email protected]>
@danielmeppiel
docs: describe raw-first marker validation and catalog reuse
e7a840a
Document that public github.com subdirectory validation checks markers
through raw.githubusercontent.com before the Contents API, and that
marketplace add registers the catalog it discovered without downloading
it again. Required by the microsoft#3283 scope record (update directly related
documentation and usage guidance).

Co-authored-by: Copilot <[email protected]>
@danielmeppiel
docs(changelog): record raw-first marker validation (microsoft#3348)
595034e
Changelog entry for the microsoft#3283 request-budget repair, crediting the
contributor.

Co-authored-by: Copilot <[email protected]>
@danielmeppiel
docs: state raw-first marker validation once and accurately
ae1007a
Addresses panel doc-writer findings: remove the duplicate apm-guide
paragraph and update the Install validation chain to list all seven
markers with the raw-first sweep; describe the sweep in getting-started
without the misleading every-marker and fixed-ref wording; shorten the
changelog entry and the marketplace add note.

Co-authored-by: Copilot <[email protected]>
@danielmeppiel
chore: name _auto_detect_path_with_payload in probe comment
68de490
Addresses panel python-architect nit: the comment above the probe
source still named _auto_detect_path after the call site switched to
_auto_detect_path_with_payload.

apm-spec-waiver: request scheduling only -- raw-file marker probes run before Contents API probes and marketplace add reuses the catalog it discovered; admission results, markers, refs and lockfile contents are unchanged, so there is no OpenAPM-observable behaviour delta.

Co-authored-by: Copilot <[email protected]>
@danielmeppiel

Daniel Meppiel (danielmeppiel) commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

APM Review Panel: ship_now

Zero Contents API calls for public marker validation: a community-contributed raw-first sweep that removes the main rate-limit friction for anonymous installs of nested packages and Claude plugins.

panel-mode=full; personas=python-architect,auth-expert,performance-expert,test-coverage-expert,doc-writer,apm-ceo (terminal delta: doc-writer, no new findings)

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

All five panelists converge on ship. The architect confirms the raw_only seam threads cleanly through the existing shared download chain with no canonical-owner violation and no new downloader or cache. Auth finds no regressions: the raw path stays token-free, the sweep is gated to public github.com, and private recovery, throttle propagation and GHE/ADO/GitLab/SSH behavior are unchanged. Performance confirms the Done-when request budget, measured through the installed CLI. Test coverage confirms the scope's evidence list is met by new lifecycle tests plus existing throttle/SSH/other-host suites. All doc-writer findings were folded.

The one open item is a performance nit: on full-miss and private fallback paths, the per-marker loop repeats seven raw CDN 404s that the sweep already saw. This is bounded, un-metered, and explicitly accepted by the #3283 scope record; removing it needs a new inverse seam outside this PR.

Aligned with: pragmatic as npm (public nested installs validate markers with zero API calls); secure by default (anonymous-first and private recovery preserved); multi-harness/multi-host (sweep limited to github.com, other hosts untouched); OSS community driven (community contribution, CLA signed, maintainer folds for tests and docs).

Panel summary

Persona B R N Takeaway
Python Architect 0 0 2 raw_only seam is clean; discovery payload reuse is coordinate-safe (same url/ref/path).
Auth Expert 0 0 0 Anonymous-first, token-free CDN, host gating, private recovery and throttle propagation preserved.
Performance Expert 0 0 1 Zero Contents API for public markers; no duplicate catalog fetch; full-miss raw repeat is bounded noise.
Test Coverage Expert 0 0 0 Done-when surfaces covered: 5 installed-CLI lifecycle tests with real request counts plus existing suites.
Doc Writer 0 2 1 Docs accurate after folds; raw-first behavior now stated once in the validation chain.

Measured request counts (installed CLI, loopback HTTPS fixture)

Scenario Raw Contents API
Two nested Claude plugins at v1.0.0 (first, repeat, --update) 10 each 0
marketplace add 0 3 discovery probes, no second fetch (was 4)
install alpha@mkt beta@mkt 10 0
Missing marker 14 8 (one per marker + directory), exit 1, manifest unchanged
Private repo with GITHUB_APM_PAT 14 bounded, at most 2 per marker, one authenticated hit

Verified against both the uv console script and a locally built frozen binary.

Recommended follow-ups

  • (performance-expert) Avoid the repeated raw CDN pass after a missed sweep. Bounded today; would need an inverse api-only seam through the download chain.

Folded in this run

  • (copilot) Host-boundary unit test now uses a real acme.ghe.com dependency through the real resolver and asserts the CDN is never contacted -- resolved in 0818391.
  • (scope) Installed-CLI request-count and state lifecycle tests via a loopback MITM HTTPS fixture: multi-plugin, repeat, --update, missing marker, private recovery, marketplace add reuse plus marketplace installs, and no registration after failed discovery -- resolved in f75184a.
  • (scope) Docs for raw-first marker validation and catalog reuse (getting-started authentication, marketplace reference, apm-guide) -- resolved in e7a840a.
  • (scope) CHANGELOG entry crediting ShaoLOWu -- resolved in 595034e.
  • (doc-writer) Raw-first behavior stated once in the apm-guide Install validation chain with all seven markers; accurate getting-started wording; shorter changelog and marketplace note -- resolved in ae1007a.
  • (python-architect) Probe comment names _auto_detect_path_with_payload; commit carries the apm-spec-waiver line for the Mode B gate (request scheduling only, no OpenAPM-observable delta) -- resolved in 68de490.

Copilot signals reviewed

  • src/apm_cli/commands/marketplace/__init__.py:451 -- LEGIT: stale _auto_detect_path patches would hit the real fetch path (resolved in 3bfc1f4 by the author).
  • tests/unit/deps/test_virtual_package_cdn_first_sweep.py -- LEGIT: boundary test forced the resolver flag on a github.com dependency (resolved in 0818391).
  • tests/unit/deps/test_virtual_package_cdn_first_sweep.py:192 -- LEGIT: single-file probe left the Contents API unmocked (resolved in 3bfc1f4 by the author).

Deferred (out-of-scope follow-ups)

  • (panel) Skip the repeated raw CDN pass on full-miss/private fallback -- scope boundary: [BUG] Validating a public in-repo plugin spends one anonymous API call per marker the CDN misses (four for a .claude-plugin plugin) #3283 accepts extra bounded raw attempts on fallback-only paths; avoiding them needs a new inverse api-only seam; suggested follow-up: perf: avoid duplicate raw CDN probes after a missed marker sweep.

Regression-trap evidence (mutation-break gate)

  • test_public_nested_plugins_validate_without_contents_api -- deleted the raw-only marker sweep; test FAILED as expected; guard restored.
  • test_marketplace_add_reuses_discovered_catalog_and_installs_without_contents_api -- deleted discovery_payload reuse; test FAILED as expected; guard restored.
  • TestRawCdnFirstSweep::test_non_public_host_skips_sweep -- deleted the host gate in _raw_cdn_first_applies; test FAILED as expected; guard restored.

Lint contract

ruff check and ruff format --check on src/ tests/ silent; pylint R0801 10.00/10; lint-auth-signals.sh and lint-architecture-boundaries.sh clean. Canonical-owner gate: two existing owners touched (transport selection, single-file layout) as an owner extension; exact-head functional tests passed (242 and 24) and the semantic verifier passed.

CI

All checks green on 68de490: 28 pass, 3 skipping, 0 failing, including Lint, Build and Test shards, Lifecycle Smoke shards (which run the new lifecycle file), Windows gates, Spec conformance and the required-checks aggregator (after 1 CI fix iteration: Spec conformance Mode B waiver).

Mergeability status

PR head SHA CEO stance iters folds defers Copilot rounds CI mergeable mergeStateStatus notes
#3348 68de490 ship_now 1 6 1 2 green MERGEABLE BLOCKED pending required review

Labels were not changed. The approved apm-scope:v1 record on #3283 sets the scope for this PR.

Architecture diagrams (python-architect)
flowchart TD
    A["validate_virtual_package_exists"] --> C{"public github.com?"}
    C -- "yes" --> D["sweep markers raw_only=True"]
    D -- "raw hit" --> G["valid, zero Contents API"]
    D -- "all miss" --> J["unchanged per-marker loop: raw then Contents API with auth fallback"]
    C -- "no: GHE / ADO / other" --> J
    J -- "hit" --> G
    J -- "miss" --> N["directory Contents API, then ls-remote + ls-tree"]
    N -- "hit" --> G
    N -- "miss" --> P["invalid, diagnostic"]
    MA["marketplace add"] --> MB["_auto_detect_path_with_payload"]
    MB -- "path + catalog" --> MF["fetch_marketplace discovery_payload=catalog"]
    MF --> MJ["parse + write cache, no second fetch"]
    MB -- "none" --> ME["exit 1, nothing registered"]
Loading

Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Daniel Meppiel (danielmeppiel) and others added 5 commits November 10, 2026 19:43
@danielmeppiel
Merge main into perf/cdn-first-marker-sweep
bf7b0fd
Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Merge origin/main into PR microsoft#3348
3432029
Keep the PR changelog bullet under [Unreleased] after the 0.35.1 release cut.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Merge remote-tracking branch 'origin/main' into mw-3348
d5776dc
@danielmeppiel
Merge remote-tracking branch 'origin/main' into mw-3348
f2321d2
@danielmeppiel
Merge remote-tracking branch 'origin/main' into mw-3348
d6d136b
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 2ffc07c into microsoft:main Nov 12, 2026
31 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@danielmeppiel Daniel Meppiel (danielmeppiel) mentioned this pull request Nov 12, 2026
ci: Windows post-merge suite red since #3564 (test_comparison_uses_rendered_markdown CRLF fixture) #3590
Closed
@danielmeppiel Daniel Meppiel (danielmeppiel) mentioned this pull request Nov 12, 2026
fix(ci): restore Windows post-merge suite after #3564 #3592
Merged
4 of 15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@danielmeppiel Daniel Meppiel (danielmeppiel) Awaiting requested review from danielmeppiel danielmeppiel is a code owner
@sergio-sisternes-epam Sergio Sisternes (sergio-sisternes-epam) Awaiting requested review from sergio-sisternes-epam sergio-sisternes-epam is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

area/cli CLI command surface, flags, help text (cross-cutting). status/deferred Not invited for implementation now; no release commitment. triage/recommended Automated advice completed; not human scope approval. type/performance Latency, throughput, memory, install time.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[BUG] Validating a public in-repo plugin spends one anonymous API call per marker the CDN misses (four for a .claude-plugin plugin)

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@ShaoLOWu @sergio-sisternes-epam @danielmeppiel
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.