Repository navigation
feat(availability): check many package versions at once, also through a group - #473
Conversation
M0Rf30
left a comment
There was a problem hiding this comment.
Thanks, this follows the design agreed in #471. No blockers. #472 is merged, so this needs a rebase (tools_gate.go, drift_test.go, mcp.md and upgrading.md overlap).
Your questions
-
Curation hold on an uncached package: do it in a follow-up.
unknownis honest and safe for now. -
Formats that filter their metadata: I checked the serving path. The merged npm packument and the composer p2 document can offer a version from a later member when an earlier member's gate hid it. The download then goes through
firstHit, andprobeWriteronly skips a member on a 404 or 5xx, so a 403 from the earlier member ends the install.- npm: the tarball path is the same for every member, and the npm proxy answers a held tarball with
checkGate's 403. The rule "first member that has the version decides, held or not" holds. - composer, curation:
serveComposerDistrunscheckGatefrom the path, before the reference is compared, so it is a 403 and the rule holds. - composer, minimum age: this hold is only checked in
locateComposerDist, afterdist.ProxyRef() != p.Ref. A dist relinked from a later member whose reference differs gets a 404 from the earlier proxy, and the later member serves it. So under a minimum-age hold, the version passes to the next member when the dist references differ (for example two proxies of different upstreams). It stays held when they match.
I'd rather fix serving than special-case
advance: haveserveComposerDistcheck the minimum age before the reference too (or 403 any gated version of the package regardless of reference). That's the safer behavior anyway, and then your rule holds as written. A separate PR is fine; until then, mention the gap inhosted-proxy-group.md. - npm: the tarball path is the same for every member, and the npm proxy answers a held tarball with
Small points
- Hosted-wins definition:
HostedNamesHeldtreats a name as held when the member has a live version with a live file. Serving decides it by whether the member answers a package document with 200 (internal/group/hostedwins.go). Please add a comment saying the two are meant to match, so a later change to either side gets noticed. - Unchecked read result:
readCachedthrows away the result ofg.Wait(). That's correct today, but a read that later returns an error would be silently dropped. Async.WaitGroupwith a semaphore, or checking the error, makes that explicit. check_availabilitydescription: after the rebase, its group sentence should also point atcheck_dependencies, which now answers for a group.
… a group
POST /api/v1/repositories/{name}/availability answers up to 1000
package versions (duplicates once, results in request order) with the
GET's fields plus status (available, held, not_found, unknown) and the
repository that decided. The MCP tool check_dependencies calls the same
function, api.ExplainAvailabilityBatch.
A hosted repository answers not_found for a version it does not store,
a proxy not_found when its cached metadata does not list the version
and unknown when the metadata is not cached or the format lists no
versions. A group follows the serving path: a blocked group refuses
everything; nested groups, members of another format, blocked members
and members the caller cannot read are skipped; unless
merge_proxy_versions is set a name a remaining hosted member holds is
decided by the hosted members only; otherwise the first member that has
the version decides, held or not; a proxy that cannot tell makes the
answer unknown.
Cost: the members once, the curation rules once per proxy member, the
hosted data in two queries (HostedNamesHeld, HostedVersionsStored, which
match like PackageVersionHolds), and one cached-metadata read per proxy
member and distinct package (proxy.Service.CachedVersions, never
fetching), at most 8 at a time and only for entries no earlier member
decided.
The POST only reads: isRepoAvailabilityBatchRoute gives it read like the
GET, and the rbac_hardening_test case flips from manage to read.
Refs openartifact#471.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The batch answer gives reasons with source not_found and unknown; the AvailabilityReason enum only listed the GET's five, so api-fuzz flagged the 200 response of POST /availability as violating the schema. With the enum widened, the web client's sourceLabel needs labels for both: added in every locale, and the "labels every source" test covers them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…_dependencies - HostedNamesHeld and hostedwins.go each say the other must stay equal (database predicate vs the package document serving probes). - readCached runs under a WaitGroup and semaphore: the reads have no error to return, so nothing is discarded. - check_availability's description and its group error point at check_dependencies, which answers for a group. - hosted-proxy-group.md states the composer minimum-age case where serving passes a version on and the batch reports it held. Co-Authored-By: Claude Fable 5.2 <[email protected]>
e0e8883 to
6e42e8d
Compare
|
Rebased on main and addressed the three points:
The composer minimum-age gap is documented in Follow-ups I'll send as separate PRs:
|
Version 0.2.0: the `check-lockfile` skill, using the `check_dependencies` tool that landed in openartifact/openartifact#473. ## What the skill tells the agent 1. **Find the repository** the project installs from, the `/repos/<name>` in its package manager config. A group is fine, since `check_dependencies` answers for one. 2. **Extract the pinned versions with `jq`**, not by reading the lockfile into context. The filters apply the rules of `oa check` (openartifact/openartifact#476): path packages, links, bundled packages, workspace folders, and git or file dependencies are left out. There are instructions for when `jq` is missing, and for lockfileVersion 1. 3. **Call `check_dependencies`** with at most 1000 entries per call. 4. **Report by status:** - `held`, with the reason, rule id or `until` time, and the deciding repository; - `not_found`; - `unknown`, explained as "the proxy hasn't cached this package yet", not as a block. 5. **Suggest fixes that respect the registry**, with no public-registry fallback, handing off to `check-dependency` for an available version. Servers without the tool (any release before #473) get a check of the direct dependencies through `check_availability`, and the agent says the whole lockfile couldn't be checked. ## Checked - I ran both `jq` commands exactly as written in the skill against the parser fixtures of #476. They return the same lists as the Go parser (4 and 5 dependencies). - End to end against a server built from current `main`: the extracted list from a `composer.lock` went to `check_dependencies` on a Composer group. Guzzle 6.5.8 came back held ("EOL, use 7.x"), 7.8.1 available, and two uncached packages unknown. - `scripts/check-plugin.py` passes and `reuse lint` reports compliance. CI's Agent Skills job validates the new skill. Not tested: a full agent session using the skill. The tool is on `main` but not in a server release yet. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Areef <[email protected]> Co-authored-by: Claude Fable 5.2 <[email protected]>
First PR of #471: batch availability, without vulnerabilities and without
oa check. It follows the design agreed in this comment.API
POST /api/v1/repositories/{name}/availabilitywith{"packages": [{"package", "version"}, ...]}:status(available/held/not_found/unknown) andrepository, the repository that decided.The MCP tool
check_dependencies(repository, packages)calls the sameapi.ExplainAvailabilityBatch, the waycheck_availabilitysharesExplainAvailability, and marks the result untrusted.Decisions
One repository
not_foundunless a live version with a live file is stored. Matching works as inPackageVersionHolds(name/name_key,version/version_key). Otherwise the quarantine and license holds apply.unknownwhen the cached metadata can't say,not_foundwhen it doesn't list the version. Otherwise the gate decides, with the publish time from the same metadata.held(repository_blocked).Group
group.Handler.members, minus members the caller can'tread(any type, asDispatcher.authorizedoes).merge_proxy_versionsis set, a name a remaining hosted member holds is decided by the hosted members only. If none of them has the version, the answer isnot_found.unknown, and later members aren't consulted.Cost
HostedNamesHeldandHostedVersionsStored, bothunnestover the entries.proxy.Service.CachedVersions, which wrapsHooks.Versionsand never fetches. At most 8 reads run at a time, and only for entries no earlier member decided.TestAvailabilityBatchCostpins this with 900 entries: one call each for members, rules, held names and stored versions, and one read per (proxy, package) actually reached.TestAvailabilityBatchReadConcurrencychecks that reads peak at exactly 8.RBAC
isRepoAvailabilityBatchRoutegives the POSTread, outside the safe-method set, so nothing else widens. Therbac_hardening_test.gocase flips toread. New cases pinPUT,DELETEand deeper POST paths ofavailabilitytomanage. The existing POST cases forheld-back-versionsandproxy-versionsstill expectmanage.Tests
Engine (
availability_batch_test.go, fakes that count calls): hosted, proxy and blocked single repositories, then one case per group rule:merge_proxy_versions;unknown;Also a blocked group (no member or cache is touched), cost, concurrency, and docker refused. I checked the tests catch mistakes by breaking hosted wins and the blocked-member skip on purpose: both failed.
SQL (
tests/integration, real Postgres):TestHostedBatchMatchesPackageVersionHoldschecks that the batch holds equalPackageVersionHoldsfor every stored version (vulnerability, license, clean, identity-key match, other repository), that deleted and unknown versions aren't stored, and the names held.HTTP: the endpoint through a group, plus validation (bad JSON, no or empty
packages, a missing or oversized field, 1001 entries).MCP:
check_dependenciesthrough the authenticated stack. For an admin, a hosted member owns the name; for the read-only token that member is invisible and the proxy decides. Also refusals: bounds, docker, an unreadable repository.Checked against a real server
A Composer group (
php-hosted, thenphp-proxy, a Packagist proxy with a block rule onguzzlehttp/guzzle 6.*), with Guzzle's metadata fetched once:check_dependenciesover MCP gave the same answers.Two questions for review
evil/backdoor 1.0.0against a proxy with a block rule onevil/*currently answersunknown, because nothing is cached. For the formats whose downloadscurationRefusalgates before any fetch (those withHooks.Coordinates: apk, conan, ivy, pacman, mirrored), the 403 doesn't depend on the cache. Those could answerheldwithout reading it. Worth doing here, or as a follow-up?Serveby leaving held versions out of the metadata. In a group, the merged metadata could then offer that version from a later member. Does "the first member that has the version decides, held or not" hold for those formats as well, or does a version hidden by one member's gate pass to the next member there? I followed your rule as written. If merged formats behave differently, the change is local toadvance.Checks
golangci-lint run ./...passes, also with-tags integrationfortests/integrationandinternal/database.go test -short -racepasses forinternal/{api,mcp,middleware,proxy,database}andcmd/server.make docs-checkandmake deadcodepass, and the-tags noai,nomcpbuild passes.vue-tsc --noEmitpasses with the regenerated client.Next:
oa checkwithcomposer.lockandpackage-lock.json, then vulnerabilities from the OSV mirror.🤖 Generated with Claude Code