Repository navigation
fix(ci): read the npm version document, not the edge-cached packument (TASK-115) - #1848
Conversation
… (TASK-115) `npm view <pkg>@<version> version` fetches the whole packument — 130KB for @commonlyai/cli — and filters locally, and that endpoint is served through a CDN with `cache-control: public, max-age=300`. The poll's budget is also 300s, so a packument copy cached moments before the publish stays stale for essentially the whole run: the check can burn its entire budget without ever asking a question the cache has not already answered (Wren/Vera 71761-71763). Re-measured here: packument 130,515 bytes, `cf-cache-status: HIT`, `public, max-age=300`; version document 2,382 bytes, `cf-cache-status: DYNAMIC` — not edge-cached at all. So the poll now reads `https://registry.npmjs.org/<url-encoded-name>/<version>` with `curl -fsS` and asserts the document's own `version`. curl also sidesteps the runner's local npm cache, which `--prefer-online` only papers over, and a 404 there is genuinely "not published yet", so the retry loop still earns its place. The failure line names the endpoint it read, and the packument reads that follow it are labelled as the cached reads they are — with the old instrument a stale cache and a slow propagation were indistinguishable, which is what made the red run above unreadable. Live red this explains: the `Publish npm packages` run for #1838 (35843580433) went red after polling the full budget for cli 0.1.70 and being told `'@commonlyai/[email protected]' is not in this registry` — the publish had landed, and 0.1.71/0.1.72 published and read back fine afterwards. Witnesses: the poll's URL is asserted against a stub `curl` that refuses the packument outright (so the endpoint is a property under test, not an implementation detail), and the exhaustion banner must name the endpoint. Ledger 4/4 killed: the packument read restored, the version segment dropped from the URL, the parse reading `name` instead of `version`, and the banner losing the endpoint.
|
Structure read at Verified
Recut before press (comments only — the interdiff must show nothing else)
Not in this PR — Vera 71770's second half (read 🤖 Generated with Claude Code |
… banner word (TASK-115) Comment-only recut asked for by both gates on b6e250c (Vera 71777, Wren 71778): - the packument-vs-version-document measurement is Vera's: 71761 (cache headers), 71762 (the 300s/300s coincidence), 71763 (the endpoint). Both headers credited Wren for it, which would have landed permanently in a file that is read when the check goes red. The citation now says Vera. - the exhaustion banner's last fallback line still said `npm view` for a read that is now curl. - `node` on PATH is a new dependency (the old read needed only `npm`) and was named nowhere; it is now in the Env block, with why the job already guarantees it (actions/setup-node at npm-publish.yml:69). No behaviour change: the diff is four comment lines and one banner string.
|
Carry to Interdiff
No hunk touches the poll loop, the endpoint, or a test body. Test & Coverage is still running at this head; presses when it is green. 🤖 Generated with Claude Code |
What
scripts/verify-npm-publish-readback.shpollednpm view <pkg>@<version> version, which fetches the whole packument (130KB for@commonlyai/cli) and filters locally. That endpoint is served through a CDN withcache-control: public, max-age=300— and this poll's budget is also 300s. A packument copy cached moments before the publish therefore stays stale for essentially the whole run: the check can spend its entire budget asking a question the cache has already answered (Vera 71761-71763 — the cache headers, the 300s/300s coincidence, and the endpoint; corrected from an earlier draft that credited Wren).Re-measured at source for this PR:
cf-cache-status…/@commonlyai%2fcli(packument)HITpublic, max-age=300…/@commonlyai%2fcli/0.1.70(version document)DYNAMICFix
The poll reads the version document and asserts its own
version:curlalso sidesteps the runner's local npm cache, which--prefer-onlineonly papers over.-fkeeps a 404 body out of the parse — the registry answers a missing version with the plain textversion not found: 9.9.9, which is not JSON.The live red this explains
The
Publish npm packagesrun for #1838 (35843580433) went red after polling the full budget for cli0.1.70, ending withnpm error 404 '@commonlyai/[email protected]' is not in this registry— while the publish had in fact landed (0.1.71and0.1.72then published and read back fine).Honest scoping: whether that particular run was a stale cache copy or slow propagation is not recoverable from the old instrument — it printed only the value it was looking for. That indistinguishability is half the defect; the new banner names what it read.
Witnesses
curlanswers only<registry>/<name>/<version>and refuses the packument loudly, and the test asserts every poll call is the version-document URL — plus that nonpmcall is the oldview <name>@<version> versionshape.GET …/<name>/<version>) and label the packument lines as cached.nameinstead ofversion, and the banner losing the endpoint. Clean-tree baseline has zero failure lines; the harness restores the file per mutation.Also
nodeon PATH is now required for the JSON parse (it was not before — the old read needed onlynpm). It is guaranteed in that step:actions/setup-nodeatnpm-publish.yml:69runs before the read-back in the same job. The stub-driven tests never reach it. That dependency is now named in the script's Env block, because this is the one script that runs after a publish has already happened.Row: TASK-115.