Skip to content

release: lockfile age check and the analytics beacon in the architecture map - #104

Merged
0xferit merged 13 commits into
mainfrom
develop
Nov 20, 2026
Merged

0xferit merged 13 commits into
mainfrom
develop

Conversation

@0xferit

@0xferit 0xferit commented Nov 20, 2026

Copy link
Copy Markdown
Member

Nothing that proveuswrong.io serves changes. #102 corrects ARCHITECTURE.md, which said a page contacts no other site, though the zone adds Cloudflare Web Analytics at the edge. #103 makes pull requests into main and develop fail when they newly lock a version younger than Yarn's age gate. This release is itself the first pull request into main to run that check, and it newly locks nothing.

0xferit and others added 13 commits November 21, 2026 00:35
ARCHITECTURE.md said a page runs one script and contacts no other site.
Both hold for the build, and the checks hold the build to them, but the
proveuswrong.io zone adds Cloudflare Web Analytics to every HTML
response on the custom domains: a script from
static.cloudflareinsights.com that reports each visit to Cloudflare.
It is absent on pages.dev and for clients that do not look like
browsers, which is why curl and the checks never saw it.

Ferit chose on 2026-11-20 to keep the analytics, so the map now scopes
both statements to the build and names the beacon, where it comes from
and the one party it reaches. Turning Web Analytics off in the zone was
the alternative: the guarantee would have held as served, at the cost
of the visit and speed numbers.
Yarn applies npmMinimalAgeGate only while it picks a version for a range
or tag from registry metadata; a version already pinned in yarn.lock
installs without the check, so a pull request whose lockfile pins a
fresh version passes CI's immutable install untouched.

test/lockfile-age.js compares yarn.lock with a base revision and judges
each npm version the head newly locks as Yarn would: younger than the
gate, or without a publish time, is too young unless
npmPreapprovedPackages names that exact version. It reads the gate, the
preapprovals and the registry through `yarn config get`, so .yarnrc.yml
stays the one source, and it imports only Node's built-ins: it is meant
to run before anything is installed, where an installed young package
could otherwise change its verdict.

Preapprovals broader than one exact name@version are refused rather
than matched. Yarn's own matching needs a semver range parser and glob
matching, which would mean a dependency or a reimplementation, and an
exemption is meant to cover one version anyway.

Each test failed when the rule it pins was broken: the boundary at
exactly the gate's age, the base lockfile, preapprovals, unknown publish
times and broad preapprovals. Against develop before PR #100 the check
fails on astro@7.4.8, which clears the gate at 2026-11-21T14:51:52Z, and
passes with that version preapproved.
The output checks now fetch two levels of history and run
test/lockfile-age.js against HEAD^1 before `yarn install --immutable`.
For a pull_request run the checked-out commit is GitHub's merge commit,
whose first parent is the commit the pull request merges into, so the
check judges exactly what merging would add, and a version younger than
the age gate fails the run before any of its code is installed or run.

Ferit chose this on 2026-11-20, after Astro 7.4.8 had been adopted a
day early by resolving it once with an exemption that was never
committed: CI could not tell. An early adoption now keeps its exact
name@version under npmPreapprovedPackages in .yarnrc.yml until it
clears the gate, where reviewers see it. README.md says so where it
describes .yarnrc.yml, and ARCHITECTURE.md gives the reason.
The check found the versions a lockfile pins with a pattern for the
resolution lines Yarn 4 writes. If a later Yarn wrote them differently,
the head lockfile would yield no versions, nothing would count as newly
locked, and every pull request would pass. A head lockfile without a
single npm version now fails the check instead; the new test failed
until the check refused it.
The check turned whatever the registry listed as a version's publish
time into a Date and compared its age with the gate. A listed value
that is not a date string slipped through: "not-a-date" gives an
invalid date whose age is NaN, and `NaN < gate` is false, so the
version passed; null gives 1970, so it passed as very old. Yarn's own
gate compares the same way and shares the first gap, but this check
promises to fail closed whenever a version's age cannot be established.

The judgement now takes the listed value as the registry gives it and
reads a publish time only from a string that parses to a valid date;
anything else counts as unknown, which is too young. The test failed
for "not-a-date" and null until then, and fails again when either half
of the parse is loosened.

Found by an independent review of PR #103.
The check fetched each package's metadata itself, from npmRegistryServer
with a path it built by hand. Yarn picks the registry per scope:
npmScopes can send a scope elsewhere, and Yarn 4.10.3 sends the jsr
scope to npm.jsr.io by default. A scoped package served from its own
registry was therefore judged by another registry's publish time, or
by none. CodeQL also flagged the hand-built path, which escaped only
the first "/" of a name.

`yarn npm info <packages> --fields name,time --json` now supplies the
publish times, so Yarn's own routing, path encoding, authentication and
proxy settings apply, and the check builds no URL. The judgement takes
a batch: one Yarn call per run, for the unique packages among the
versions it judges, and none when nothing new needs judging.

Rejected: copying Yarn's routing into the check, which would duplicate
Yarn internals such as the built-in jsr registry and still leave out
authentication; and asking Yarn for name@version, because
`yarn npm info astro@99.0.0` exits 0 and reports 7.4.13. Only each
package's full time map is requested, and the check looks the locked
version up in it.

Yarn fetches one package at a time, about half a second each. Past
lockfile changes newly locked 4, 39 and 262 packages: a few seconds
for an upgrade, about two minutes for a migration of the whole tree.

Checked: against develop before PR #100 the check still fails on
astro@7.4.8 and passes with it preapproved. With the astrojs scope
routed to https://registry.invalid in a throwaway worktree, Yarn
reports ENOTFOUND for that host and the check fails; without the route
it passes.

Found by an independent review of PR #103 and by CodeQL.
Yarn writes `name@npm:1.0.0::__archiveUrl=<encoded url>` as the
resolution when a registry serves a version's tarball from an address
other than the conventional one. The check took everything after
`npm:` as the version, so it looked up a publish time for
"1.0.0::__archiveUrl=..." and found none, and a preapproval of
name@1.0.0 could never match: an old, approved version failed for good.

The version is now the reference up to its first `::`, as Yarn's own
range parser reads it. Anything else left in the reference still counts
as part of the version, so an odd reference still fails closed. The
test failed until the parameters were dropped; the current yarn.lock
carries none.

Found by an independent review of PR #103.
The check compares a version's age in minutes with npmMinimalAgeGate as
`yarn config get` prints it. Yarn 4.10.3 types the setting as a number
of minutes, but Yarn's main branch has made it a duration (unit
minutes, default "1d"), and 4.18.1 is already out. If an upgrade made
the printed value a string such as "12d", `age < "12d"` would be false
for every version and the check would pass everything without a word,
from the upgrade's own pull request onwards.

The judgement now refuses a gate that is not a finite number, so a
change in Yarn's output fails the pull request that brings it. The
test failed until then.
`yarn npm info` was the wrong source. Its output is
`{...packument, ...selectedVersionManifest, version, versions}`
(plugin-npm-cli/sources/commands/npm/info.ts#L131-L144 at
@yarnpkg/cli/4.10.3), so a field in the selected version's own
package.json replaces the registry's. A young version published with
`"time": {"1.0.0": "2020-01-01T00:00:00Z"}` in its manifest would have
looked six years old and passed: the very release the age gate exists
to hold back.

The check now fetches each package's metadata document itself and
reads only its top-level `time`, which the registry writes at publish.
It fetches from the address Yarn's resolver uses, and so the times
Yarn's own gate judges: the registry `npmScopes` gives the scope, else
Yarn's built-in registry for `jsr`, else `npmRegistryServer`, with one
trailing slash dropped, at the path `@scope%2fname`. `metadataUrlOf`
mirrors Yarn's getScopeRegistry, getScopeConfiguration and getIdentUrl
and links them; a test pins each rule.

Given up with Yarn: its authentication and proxy settings. A registry
that needs credentials answers 401 or 403 and fails the check, which
then passes only for preapproved versions. No registry here needs them.

Rejected: resolving the new versions with Yarn itself in a scratch
project, which applies Yarn's exact gate but resolves the whole
transitive tree around them. Fetching in parallel brings back speed:
the 262 packages of the Astro migration took 4.7 s against about two
minutes through Yarn. A failed fetch now names the address it tried.

Checked: each routing rule broken in turn fails the new test. Against
develop before PR #100 the check fails on astro@7.4.8 and passes with
it preapproved. With the astrojs scope routed to
https://registry.invalid in a throwaway worktree it fails with "Could
not read https://registry.invalid/@astrojs%2finternal-helpers"; without
the route it passes.

Found by the second independent review of PR #103.
CI failed on 4b7e6c8 with `Unexpected token 'u', "undefined" is not
valid JSON`. `yarn config get <name> --json` prints a setting without a
value as the bare word `undefined`, and npmScopes has none when no
scope is configured: on CI there is no home .yarnrc.yml. Local runs had
passed only because Yarn reads every .yarnrc.yml above the project too,
and the one in the home directory configures a scope.

yarnSetting now returns undefined for that output, and no npmScopes
means no scope configurations. `yarn config --json` was no way out: it
leaves `effective` out for an empty map and prints `{}` for a
non-empty one, since a Map serializes to `{}`.

Checked in a worktree outside the home directory, with HOME empty and
Yarn 4.10.3 run from its bundle as corepack runs it: against HEAD^1 the
check passes with nothing newly locked; against develop before PR #100
it fails on astro@7.4.8 and passes with it preapproved through
YARN_NPM_PREAPPROVED_PACKAGES; with the astrojs scope routed to
https://registry.invalid it fails reading that address.
The check accepts a preapproval only as an exact name@version and is
meant to refuse anything broader, but its name pattern took any
character except `@`, so `*@7.4.8` and `@*/telemetry@3.3.1` passed the
validation. Such a glob matched no locked version, so it granted
nothing; it was silently ignored where the rule says to refuse it.

The scope and the name now admit only letters, digits, `.`, `_` and
`-`, the characters an npm package name may use. A legacy name with
one of `~'!()*`, which npm no longer accepts for new packages, cannot
be preapproved and keeps failing the check until it clears the gate.
The test failed for both globs until then, and fails again when either
part of the pattern is loosened.

Found by the third independent review of PR #103.
docs: name the analytics beacon Cloudflare adds to every page
ci: check newly locked versions against the age gate before installing
@0xferit
0xferit merged commit cbe050a into main Nov 20, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant