Skip to content

Check the release age and source of added dependencies in PR checks - #350048

Merged
Bryan Chen (bryanchen-d) merged 11 commits into
mainfrom
copilot/vscode/deps-cooldown-check
Nov 24, 2026
Merged

Bryan Chen (bryanchen-d) merged 11 commits into
mainfrom
copilot/vscode/deps-cooldown-check

Conversation

@bryanchen-d

@bryanchen-d Bryan Chen (bryanchen-d) commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Adds a Dependency Release Age job to the PR workflow, which PR Gate reports. It checks the package versions that a change adds to pnpm-lock.yaml, package-lock.json and Cargo.lock against the dependency policy, using only public registry data, so it works the same for pull requests from forks and in the merge queue.

For every package version that a lockfile adds, compared with the base branch (for a merge group, with the commit of main that the group forks from):

  1. Source: it must resolve from registry.npmjs.org or crates.io. Git repositories, tarball URLs and other registries fail. Local workspace packages are ignored. The one exception is the CLI's crates from github.com/microsoft/dev-tunnels and github.com/microsoft/vscode-russh, which are allowed at any revision.
  2. Release age: it must have been published at least minimumReleaseAge minutes ago, as set by the nearest pnpm-workspace.yaml (the root one for Cargo.lock). Versions that its minimumReleaseAgeExclude lists are exempt, matched the way pnpm matches them. Versions that a lockfile on the base branch already locks aren't checked again.
  3. Output: each failure is an annotation on the lockfile that names the package, the version, when it was published and when it becomes allowed. Lockfiles that can't be parsed, for example with merge conflict markers, fail too.

The packageManager pnpm version in package.json is checked the same way.

Wiring

  • Detect Changes gets a dependencies output. It's true when a change touches a lockfile, a pnpm-workspace.yaml or .pnpmfile.mjs, the root package.json, or the check itself. Otherwise the job is skipped, and it also runs when Detect Changes fails.
  • Rule paths in detect.ts can now be regular expressions, so lockfiles in any folder match.
  • No secrets, and contents: read only. The job checks out two commits, downloads js-yaml at a version and integrity pinned in the workflow (so a pull request can't change the parser that checks it), and runs node build/lib/dependencyReleaseAge.ts without installing dependencies.
  • Anything the check can't read fails it: unparseable lockfiles, unknown resolution fields, unreadable Cargo.lock entries, a policy that isn't a number and a list of strings, and a merge group whose fork point on main can't be found.

Validation

  • build/lib/test/dependencyReleaseAge.test.ts covers the three lockfile parsers (including pnpm's two-document lockfile), exclusion matching, source and age violations, registry retries and caching, and an end-to-end check over two commits of a temporary git repository.
  • build/lib/test/detectChanges.test.ts is updated for the new output and job.

Authored with Copilot

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved parser and merge-queue baseline flaws can bypass dependency source and release-age checks, omit queued dependency additions, and allow malformed lockfiles to pass.

6 open issues
What changed in this PR

Adds a dependency-policy check to VS Code’s PR workflow to verify the source and release age of newly added package versions, including the package manager.

Changes:

  • Adds lockfile parsing, public-registry lookups, policy exclusions, and failure annotations without installing dependencies.
  • Wires the check into Detect Changes and PR Gate, including merge-queue runs.
  • Adds tests for parsing, policy enforcement, registry requests, and workflow selection.
File Description
build/​lib/​test/​detectChanges.test.ts Tests dependency-check selection and the new output.
build/​lib/​test/​dependencyReleaseAge.test.ts Tests parsers, policy checks, registry handling, and revision comparisons.
build/​lib/​dependencyReleaseAge.ts Implements dependency source and release-age validation.
.github/​workflows/​pr.yml Adds the validation job and includes it in PR Gate.
.github/​actions/​detect-changes/​detect.ts Adds dependency-related path rules and regular-expression matching.
.github/​actions/​detect-changes/​action.yml Exposes the dependency-check selection output.

Review effort: Balanced

Comment thread .github/workflows/pr.yml Resolved
Comment thread build/lib/dependencyReleaseAge.ts Resolved
Comment thread build/lib/dependencyReleaseAge.ts Resolved
Comment thread build/lib/dependencyReleaseAge.ts Resolved
Comment thread build/lib/dependencyReleaseAge.ts Resolved
Comment thread build/lib/dependencyReleaseAge.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread build/lib/dependencyReleaseAge.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread build/lib/dependencyReleaseAge.ts Resolved
Comment thread build/lib/dependencyReleaseAge.ts Resolved
Comment thread build/lib/dependencyReleaseAge.ts Resolved
Comment thread build/lib/dependencyReleaseAge.ts Resolved
Comment thread build/lib/dependencyReleaseAge.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical lockfile parsing and Git filename handling defects allow dependencies to bypass source and release-age checks or malformed lockfiles to pass silently.

7 open issues

Review effort: Balanced

Comment thread build/lib/dependencyReleaseAge.ts Resolved
Comment thread build/lib/dependencyReleaseAge.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread build/lib/dependencyReleaseAge.ts Resolved
Comment thread build/lib/dependencyReleaseAge.ts Resolved
@bryanchen-d
Bryan Chen (bryanchen-d) requested a balanced review from Copilot November 24, 2026 02:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Registry parsing mishandles inline INI comments, and exclusion intersection drops overlapping exemptions, causing PR Gate to reject otherwise valid dependency changes.

2 open issues

Review effort: Balanced

Comment thread build/lib/dependencyReleaseAge.ts Resolved
Comment thread build/lib/dependencyReleaseAge.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the dependency-policy check and its PR workflow integration.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

Adds a Dependency Release Age job to the PR workflow. It checks the package
versions that a change adds to pnpm-lock.yaml, package-lock.json and
Cargo.lock: each must come from registry.npmjs.org or crates.io, and be at
least as old as the minimumReleaseAge of pnpm-workspace.yaml unless its
minimumReleaseAgeExclude lists it. It reads only public registry data, so it
also runs for pull requests from forks and in the merge queue, and PR Gate
reports it.

Co-authored-by: Copilot <[email protected]>
…nnot read

Parse pnpm-lock.yaml and pnpm-workspace.yaml with js-yaml, which the job downloads at a pinned version and integrity, so a pull request can't change the parser. Read Cargo.lock strictly, and fail on resolutions, sources and packages it cannot read. In the merge queue, find the commit of main that the group forks from, and fail when it can't, rather than comparing with the group ahead.

Co-authored-by: Copilot <[email protected]>
…eck cannot read

The check now applies the stricter of the base and head release-age policies, reads changed policies even when no lockfile changes, and grandfathers only registry versions that the base locks. It lists paths NUL-separated, rejects npm lockfiles without a known structure and non-registry version specifiers, reads only the layout that Cargo writes, and skips extraneous npm entries.

Co-authored-by: Copilot <[email protected]>
… rate-limit every crates.io attempt

Co-authored-by: Copilot <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The lockfile parser accepts duplicate TOML table definitions, allowing an invalid lockfile to pass the dependency job when no added versions need checking.

1 open issue

Review effort: Balanced

Comment thread build/lib/dependencyReleaseAge.ts Resolved
@bryanchen-d
Bryan Chen (bryanchen-d) added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit 500447b Nov 24, 2026
38 checks passed
@bryanchen-d
Bryan Chen (bryanchen-d) deleted the copilot/vscode/deps-cooldown-check branch November 24, 2026 19:21
Andy Jordan (andyleejordan) added a commit to Azure/bicep that referenced this pull request Nov 30, 2026
…FS hold (#20603)

<!-- copilot-assessment:v1 -->
### Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: `5bb9bda04755565ebebdd3f26037947d3a4e16c7`

| Dimension | Assessment | Rationale |
|---|---|---|
| Change confidence | 9.5/10 | ↑ All 36 required CI status checks on
`5bb9bda04` passed (including `Build Highlight Libraries`, all `Test CLI
(e2e)` platforms, all `Build CLI NuGet Packages` platforms, .NET,
Playground, VS Code Extension, and VS Code Bicep UI), and all eight npm
roots passed real `npm ci` locally against
`packagefeedproxy.microsoft.io/npm/`.<br>↑ Cross-family review by Claude
Sonnet 5.5 found no issues.<br>↓ No live Dependabot job has run yet; the
4 non-required `Test CLI (live)` jobs fail repo-wide on the disabled
Azure CLI identity. |
| Diagnosis confidence | 9.5/10 | ↑ Confirmed in `dependabot-core` that
`cooldown` uses `release_date + 7 * 86400s` and passes
`--min-release-age=7` during npm lockfile updates.<br>↑ Live CI on
`33927c7fc` proved that `omit-lockfile-registry-resolved=true` +
`min-release-age=7` also enforces the 7-day gate during real `npm ci`
reification, immediately catching `[email protected]`. |
| Evidence fit | 9.5/10 | ↑ Aligns future Dependabot and `.npmrc`
lockfile writes, enforces the 7-day floor at `npm ci` time in PR checks
(via `omit-lockfile-registry-resolved=true`), and repairs the two
remaining Nov 22 lockfile pins still missing from the proxy feed.<br>↓
`src/vscode-bicep-ui` still pins `[email protected]` under Corepack for
Dependabot runs. |
<!-- /copilot-assessment -->

## Description

Routine npm lockfile updates can land before newly published packages
clear the 7-day Central Feed Services
(`https://packagefeedproxy.microsoft.io/npm/`) release hold, leaving
Microsoft-managed developer machines failing `npm ci` with `ETARGET`
while GitHub-hosted CI passes against public npm (#20602). Rather than
wiring public GitHub Actions to an authenticated private feed
(`packagefeedproxy.microsoft.io` is for developer machines only), we
align both Dependabot and project-level `.npmrc` configs with the 7-day
release-age floor across all eight npm roots (`src/vscode-bicep`,
`src/vscode-bicep-ui`, `src/playground`, `src/Bicep.Cli.E2eTests`,
`src/Bicep.MSBuild.E2eTests`, `src/textmate`, `src/highlightjs`, and
`src/monarch`), and step back the two remaining `< 7d` packages still
breaking `main` today.

### Why `.github/dependabot.yml`, `.npmrc`, and the five lockfiles all
changed

- **Routine Dependabot version updates (`.github/dependabot.yml`):**
Sets `cooldown: { default-days: 7 }` on all eight `npm` entries while
leaving schedules, groups, `ignore` rules, and non-npm ecosystems
untouched. Checking
[`dependabot/dependabot-core`](https://github.com/dependabot/dependabot-core)
confirmed two details that weren't obvious from the docs alone:
[`cooldown_calculation.rb`](https://github.com/dependabot/dependabot-core/blob/main/common/lib/dependabot/update_checkers/cooldown_calculation.rb)
uses `(now - release_date) < 7 * 86400s` (168 hours from registry
publish, selecting the newest eligible release outside the window), and
when no `exclude` list is set,
[`npm_lockfile_updater.rb`](https://github.com/dependabot/dependabot-core/blob/main/npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater/npm_lockfile_updater.rb)
also passes `--min-release-age=7` to `npm install --package-lock-only`
(npm 11.10+) so transitive subdependencies like `tinybench` are held to
`>= 7` days old too.
- **Public-npm lockfile writers and a built-in `npm ci` PR gate
(`src/*/.npmrc`):** Surveying other public `microsoft` and `Azure` repos
showed teams choosing between or combining Dependabot `cooldown`
(`Azure/azure-dev`, `Azure/Azurite`, `Azure/azure-rest-api-specs`,
microsoft/PyRIT#4642) and `.npmrc`
`min-release-age=7` (microsoft/vscode-vsce#1346,
microsoft/hermes-windows#414). In `Azure/bicep`,
adding `min-release-age=7` to our existing `.npmrc` files does double
duty: it gates non-CFS lockfile writers hitting public npm
(`copilot-auto-fix.yml`, `update-dependencies.yml`,
`lockfiles-command.yml`, and external contributor or Codespace `npm
install`/`npm update` runs, plus avoiding the Dependabot transitive
resolver/writer `NpmNoChangeError` in
microsoft/hermes-windows#414), and because every
`.npmrc` here already sets `omit-lockfile-registry-resolved=true`, real
`npm ci` on Node 24 (`npm` 11.19+) resolves tarball metadata during
reification and **enforces `min-release-age=7` against
`package-lock.json` in PR CI** without needing a custom workflow script
like microsoft/vscode#350048 (`npm ci --dry-run`
skips reification, which initially masked that behavior locally).
- **Repairing the remaining Nov 22 lockfile pins
(`src/textmate/package.json` and five `package-lock.json` files):** That
new `npm ci` gate immediately failed CI on `33927c7fc` with `ETARGET`
for `[email protected]` (#20589, #20591, #20592, #20593, #20594), and
auditing all 65 recently bumped packages across all eight lockfiles
against `packagefeedproxy.microsoft.io/npm/` found `[email protected]`
(in `Bicep.Cli.E2eTests`, `Bicep.MSBuild.E2eTests`, `highlightjs`,
`monarch`, and `textmate`) and `[email protected]` (in `textmate` from #20592)
still inside the 7-day hold. Stepping only those two packages back to
`[email protected]` and `[email protected]` unbreaks `npm ci` today on both
managed developer machines and GitHub Actions.

### Tradeoffs and exclusions

- **Security updates:** Dependabot bypasses `cooldown` and passes
`--min-release-age=0` when writing security PRs, though `npm ci` in
GitHub Actions will now flag a `< 7d` locked package on PR validation
rather than letting it merge silently and break developer machines.
- **Older npm and `src/vscode-bicep-ui`'s `packageManager` pin:**
`min-release-age` requires npm `>= 11.10` (bundled with Node 24 in
`build.yml`). Older npm clients—confirmed on the Alpine `linux-musl-x64`
CLI e2e container in CI—only log an unknown-config warning and succeed.
`src/vscode-bicep-ui/package.json` still pins `"packageManager":
"[email protected]"` for Turborepo; CI doesn't enable Corepack so Node 24's npm
11 enforces `.npmrc`, while Dependabot runs `[email protected]` via Corepack
and therefore applies the 7-day direct `cooldown` without the
`--min-release-age=7` transitive flag until `packageManager` is bumped
separately.

Fixes #20602.

### Validation

- `.github/dependabot.yml` parsed cleanly and passed validation against
the [SchemaStore Dependabot v2
schema](https://www.schemastore.org/dependabot-2.0.json) and [GitHub's
`cooldown`
reference](https://docs.github.com/en/code-security/reference/supply-chain-security/dependabot-options-reference#cooldown).
- `npm --prefix <dir> config get min-release-age` returned `7` across
all eight npm roots, and real `npm ci --ignore-scripts` passed across
all eight npm roots against `packagefeedproxy.microsoft.io/npm/`.
- Full `npm ci && npm run build && npm test` passed in `src/highlightjs`
(31/31 tests), `src/monarch` (29/29 tests), and `src/textmate` (31/31
tests).
- `npm exec --yes --package=prettier -- prettier --check
src/textmate/package.json` passed; `.github/dependabot.yml` reported
only the pre-existing single-quoted wildcard in `dotnet-sdk`; `git diff
--check` passed across all 15 changed files.
- Cross-family full-diff review (Claude Sonnet 5.5) passed with no
findings, and all 36 required GitHub Actions status checks passed on
[Build run
45717706839](https://github.com/Azure/bicep/actions/runs/45717706839).

###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/20603)

_Drafted by Copilot with Gemini 4 Carbon._

---------

Co-authored-by: Copilot App <[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.

5 participants