Skip to content

Makes npmMinimalAgeGate: 1d the default - #7135

Merged
arcanis merged 1 commit into
masterfrom
mael/minimal-age-gate-default
May 18, 2026
Merged

arcanis merged 1 commit into
masterfrom
mael/minimal-age-gate-default

Conversation

@arcanis

@arcanis arcanis commented May 14, 2026

Copy link
Copy Markdown
Member

What's the problem this PR addresses?

The rate at which supply chain attacks occur is growing, and given that we can't rely on the npm registry for good practices it means we need to become stricter to protect our users.

How did you fix it?

The npmMinimalAgeGate settings will now default to 1d. Following the same pattern as in previous PRs (#7089, #7091) it will apply to all new projects, and the configuration of existing projects will be patched when upgrading their Yarn version to hardcode the previous defaults until users can ensure their projects are compatible with the new ones.

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@arcanis arcanis mentioned this pull request May 14, 2026
3 tasks done
@arcanis
arcanis force-pushed the mael/minimal-age-gate-default branch from 52dbe29 to 4c60340 Compare May 14, 2026 20:52
@arcanis
arcanis merged commit b11eb6d into master May 18, 2026
51 of 53 checks passed
@arcanis
arcanis deleted the mael/minimal-age-gate-default branch May 18, 2026 08:46
@andreialecu

Copy link
Copy Markdown
Contributor

@arcanis just a quick note, I think this new default could cause some issues unless this is also supported:

#6984

mischnic added a commit to vercel/next.js that referenced this pull request May 20, 2026
4.15 made [npmMinimalAgeGate: 1d the
default](yarnpkg/berry#7135)

1. Pin yarn version to prevent random breakages in the future
2. Add trusted packages to ignore npmMinimalAgeGate for them

https://github.com/yarnpkg/berry/releases/tag/%40yarnpkg%2Fcli%2F4.15.0
m-kawafuji pushed a commit to m-kawafuji/next.js that referenced this pull request Aug 8, 2026
4.15 made [npmMinimalAgeGate: 1d the
default](yarnpkg/berry#7135)

1. Pin yarn version to prevent random breakages in the future
2. Add trusted packages to ignore npmMinimalAgeGate for them

https://github.com/yarnpkg/berry/releases/tag/%40yarnpkg%2Fcli%2F4.15.0
muller39 added a commit to VirtoCommerce/vc-frontend that referenced this pull request Aug 31, 2026
Semgrep's yarn-missing-minimal-age-gate rule only recognizes the "Nd"
format; a bare minute count reads as an invalid value. Confirmed the
day-suffix parsing bug that motivated the minute count is fixed as of
Yarn 4.15.0 (yarnpkg/berry#7135), which we're already past at 4.18.0.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
lucasbraum added a commit to uptide-dev/uptide that referenced this pull request Oct 13, 2026
…nd plan

- uptide.yml's field is minReleaseAgeDays: camelCase like the rest of the
  file, with the unit in the name since pnpm counts minutes.
- When the repository sets no release-age policy, the default of the package
  manager version it pins applies, labelled in the reason: pnpm 11 and 12
  (minimumReleaseAge 1440, pnpm/pnpm#11158) and Yarn 4.15+ (npmMinimalAgeGate
  1d, yarnpkg/berry#7135). The version comes from packageManager,
  devEngines.packageManager or yarnPath; lockfiles cannot tell, and an unknown
  version gets no default. minReleaseAgeDays still applies next to a default.
- The HTML list report shows the release-age section; plan reads uptide.yml
  (--config) so its targets follow minReleaseAgeDays too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
lucasbraum added a commit to uptide-dev/uptide that referenced this pull request Oct 13, 2026
…e policy (#101)

Closes UPT-7.

## What

`list`, `check`, `fix`, `plan` and the Action never pick a target
version younger than the repository's release-age policy.

| Manager | Setting | Unit | Exempt |
| --- | --- | --- | --- |
| npm | `min-release-age` in `.npmrc` (env > project > user > global) |
days | — |
| pnpm | `minimumReleaseAge` in `pnpm-workspace.yaml` | minutes |
`minimumReleaseAgeExclude` (names, `@org/*`, `[email protected] \|\| 1.2.4`) |
| Yarn | `npmMinimalAgeGate` in `.yarnrc.yml` | duration (`3d`, `1w`),
bare number = minutes | `npmPreapprovedPackages` |

I checked the key names and units against the npm config docs, pnpm's
dependency-resolution settings and Yarn's `plugin-npm` source
(`DurationUnit.MINUTES`).

- **One place:** `loadRegistryConfig` attaches the policy, and both
fetchers (npm and discovery) apply it. `resolve(name, 'latest')` returns
the newest release old enough, never a prerelease in place of a stable
release. `versions` and `manifests` leave out younger releases, so
companions and re-resolved peers follow the policy too.
- **Network:** publish dates come from the full package document, once
per package. That document is fetched only when a policy is set and the
abbreviated document's `modified` falls inside the window. Packages with
no recent change cost no extra request. Nothing is fetched per version.
- **Output:** a package whose newest release is held back says why, e.g.
`4.6.7 is 2 days old; your policy is 7 days (min-release-age in .npmrc);
targeting 4.6.5`.
- `list` shows this under a RELEASE AGE section, in both the terminal
and the HTML report, and the JSON has a new `releaseAge` field.
- `check` prints the line under its table and labels the target
`release-age policy`.
- `fix` prints it in the summary and adds `targetSource: release-age
policy`.
- **Nothing qualifies:** the package is skipped with the reason. In
`check` this is `skipReason: RELEASE_AGE`, which is not a failure and
does not change the exit code. In `uptide.run/v1` it is `status:
skipped` with the reason.
- **Explicit targets:** `fix pkg@x` with a version the policy refuses
stops before any work and names the newest release old enough. When
nothing is old enough, `fix` never falls back to the pack's tested
target.
- **Built-in defaults:** when the repository sets nothing, the default
of the package manager version it pins applies, labelled in the reason
(`your policy is 1 day (pnpm 11 default)`). An explicit `0` turns it
off.
- **pnpm 11 and 12:** `minimumReleaseAge` 1440 minutes, together with
any `minimumReleaseAgeExclude`. Sources: the [v11.0.0 release
notes](https://github.com/pnpm/pnpm/releases/tag/v11.0.0)
([pnpm#11158](pnpm/pnpm#11158)),
[`config/reader/src/index.ts#L175` at
v11.0.0](https://github.com/pnpm/pnpm/blob/v11.0.0/config/reader/src/index.ts#L175)
(`'minimum-release-age': 24 * 60`), and the [v12.11.2 settings
reference](https://github.com/pnpm/pnpm/blob/v12.11.2/pnpm/docs/settings/dependency-resolution.md)
("Default: 1440 (since v11)").
- This default is not strict (`minimumReleaseAgeStrict: false`): pnpm
falls back to a younger release rather than fail. Here it keeps Uptide
on the release pnpm prefers; it doesn't prevent an install failure.
- **Yarn 4.15.0 and later 4.x:** `npmMinimalAgeGate` `1d`, together with
any `npmPreapprovedPackages`. Sources:
[yarnpkg/berry#7135](yarnpkg/berry#7135) (commit
`b11eb6d`,
[`plugin-npm/sources/index.ts`](https://github.com/yarnpkg/berry/blob/b11eb6d099/packages/plugin-npm/sources/index.ts)),
listed in the [4.15.0
release](https://github.com/yarnpkg/berry/releases/tag/%40yarnpkg%2Fcli%2F4.15.0)
and absent from 4.14.1. Upgrading Yarn writes the old value into
existing projects' `.yarnrc.yml`, and Uptide reads that as an explicit
setting.
- **Finding the version:** the version comes from `packageManager`, from
`devEngines.packageManager` when its range stays inside one of those
rows, or from Yarn's `yarnPath`.
- Lockfiles can't tell: pnpm 9 to 12 all write `lockfileVersion: '9.0'`,
and every Yarn 4 writes `__metadata.version: 8`.
- An unpinned version, a range that crosses a boundary (`>=10`), or a
version not verified (pnpm 13, Yarn 5) gets no default.
- **`uptide.yml`:** a new optional `minReleaseAgeDays` field. It's
camelCase like the other fields, and the unit is in the name because
pnpm counts minutes.
- It applies when the repository sets no policy itself. A package
manager's default doesn't count as one, so both apply then.
- The CLI passes it to the engine and its workers through
`UPTIDE_MIN_RELEASE_AGE_DAYS`, so `--config`, the Action and `plan`
(which now takes `--config`) are covered.
- **Docs:** `docs/config.md#release-age`, `SECURITY.md` (Release age)
and `docs/privacy.md` (the extra registry request). They include the
`npx uptide@latest` note from the issue.

## Decisions to review

- When several policies are set, a version must pass all of them. A
version with no publish date is allowed, matching pnpm's default.
- npm `before`, Yarn per-scope `npmScopes.*.npmMinimalAgeGate` and pnpm
settings in `.npmrc` are not read. pnpm 11 reads only auth and registry
settings from `.npmrc`.
- `check` and the fix workers now load the registry config from the
repository (`--cwd`) instead of the process cwd. This also fixes private
registries when `--cwd` points elsewhere.

## Tests

-
`fixtures/repos/release-age/{npm,pnpm,yarn,pnpm-11-default,yarn-default,none}`
are synthetic. `fetch/release-age.test.ts` (17 tests) covers each
manager's units, the built-in defaults (pinned through `packageManager`,
`devEngines` and `yarnPath`, with every no-default case including
explicit `0` and unknown versions), npm layer precedence, the fallback,
the exclude lists, the npm and discovery fetchers including the
no-full-document fast path, `list` end to end, `resolveTarget` and the
run report.
- `action/run.test.ts` has one more test for the skipped rows, and
`html/list.test.ts` one for the HTML and terminal sections.
- `pnpm test`, `pnpm lint`, `pnpm typecheck`, `pnpm docs:links` and
`pnpm public:check` all pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Lucas Braum <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

2 participants