S31 Step 17: tarball handler

Part of #290 (closed), S31 npm virtual. This slice composes code that is already merged: S11's hosted npm reads, S15's remote legs, and S13's resolution engine in internal/virtual, which has had no caller until now. The three npm_virtual_* tables land in internal/datastore/migrations/, the resolution reads in internal/datastore/, and the loading slice, the serve surface, and the three read handlers in internal/format/npm/.

References: S31 spec · S31 plan (see "Step 17").

Type: feat | Depends on: Step 14 (composition root) (tracked as blocked-by links below).

Scope

GET and HEAD on the tarball route, streaming the winner's bytes with no re-point. Sibling of Steps 15 and 16.

Files

  • internal/format/npm/virtual_tarball.go (Create): the version derived from {file_name} before resolution, because a version-targeted rule matches against it. This file keeps its own serve path rather than extending Step 13's, which is metadata-only. The spec's Tarball serving section carries the Cache-Control directive set, the Last-Modified and If-Modified-Since rules, and the file-name grammar.
  • cmd/artifact-registry/wire_npm_virtual.go (Modify): npmVirtualDownloadSlot only.
  • .claude/skills/run-artifact-registry/SKILL.md, driver.sh (Modify): this route's section and this route's smoke check only. The check already exists from Step 14 and this step flips its expected status from 501; the hard-coded smoke-check count is not touched here.
  • the paired test files (Create).

Acceptance

Spec AC, Resolution #3 (closed) (a tarball held by both is fetched from the priority winner) and the tarball slice of #5.

Spec AC, Conditional requests #5 (a streamed tarball carries no ETag, the next read carries the cached blob's digest), #6 (closed) (If-Modified-Since follows the winner's kind, and If-None-Match decides when both are sent), and #7 (closed) re-asserted on the tarball path (visibility from the virtual repository), whose primary assertion on the two metadata routes is Step 13's.

Spec AC, Packument re-point #11 (closed) (a winner change between the packument and tarball reads is visible, not masked).

Plus Spec AC, Validation and reads #1's tarball third, #2 (traversal in the file name returns 400 before any resolution), and #3 (closed) (an unparseable file name returns 404 with no rule evaluation and no resolution).

Tests

Handler tables across winner kinds; the file-name rejections proving no rule evaluation and no resolution ran; the winner-change case, which pins the accepted MVP behavior so a later change to it is deliberate; HEAD parity.

A tarball larger than the metadata body cap, asserted to stream rather than fail ErrResponseSizeTooLarge: this is the case that fails if Step 12's options leave BodyKind at its BodyKindMetadata zero value, and nothing else in the plan would catch it.

As with Step 16, this suite mirrors Step 15's and is diffed against it for dropped subtests, not only added ones.

Size

Source ~420 · Test ~1,120 · Total ~1,540