Skip to content

CI rules: a lockfile change reaches only the workspaces and crates whose resolved dependencies changed - #134

Open
agorischek wants to merge 2 commits into
agorischek/ci-rules-narrowerfrom
agorischek/ci-rules-lockfiles
Open

agorischek wants to merge 2 commits into
agorischek/ci-rules-narrowerfrom
agorischek/ci-rules-lockfiles

Conversation

@agorischek

Copy link
Copy Markdown
Collaborator

Stacked on #133. This is step (c): a lockfile change reaches only the workspaces and crates whose resolved dependencies changed.

package-lock.json and Cargo.lock no longer run everything. They match a new lockfile file rule:

{"description": "A lockfile: a change to the workspaces and crates whose resolved dependencies changed, and everything when the root's own tooling (TypeScript, ESLint, oxfmt) did",
 "paths": ["package-lock.json", "Cargo.lock"], "effect": "lockfile", "root": "full"}
  • How it decides: tools/cli/src/lib/ci-lockfiles.ts compares each lockfile with its version at the merge base, using the lockfiles alone, with no install, registry or network.
    • npm: the packages entries, with each dependency resolved as Node resolves it (nested node_modules first), and workspace links standing for their workspace.
    • Cargo: the [[package]] blocks, with name, name version or name version (source) dependencies.
  • What it reaches: a workspace or crate is reached when its resolved closure contains a changed package. The traversal stops at other workspaces and crates, because the unit graph already carries changes to their dependants.
  • When everything still runs:
    • "root": "full": when the root package's own dependencies change. Only its dependency fields are compared, not its workspaces list.
    • When there's no earlier lockfile to compare.
  • Wiring: ci-plan.mjs passes each file's contents before (git show <merge-base>:path) and after.
  • Tests:
    • tools/cli/test/ci-lockfiles.test.ts covers npm nested and hoisted resolution, removed packages, the root's tooling, a new workspace, and Cargo blocks and dependencies.
    • A planner test runs on a mutated copy of the real package-lock.json.
  • Docs: CONTRIBUTING.md#what-ci-runs.

Replayed on main's recent lockfile commits (lockfile alone, then the whole commit):

Commit Lockfile reaches Jobs, lockfile alone
6d3953d, VS Code webview packages/integrations/vscode 6, was 42
e5df8a8, Agent viewer packages/host/inspector 14, was 42
8e029ed, 62a975f, db51462, 5e678d3: new extractors the extractor, its support crate and the catalog 12, was 42
9a2aeee, a new packages/machine packages/machine 16, was 42; the whole commit still runs everything because the root package.json changed

…ose resolved dependencies changed

package-lock.json and Cargo.lock no longer run everything. A new `lockfile`
file effect compares each with its version at the merge base, by the
lockfiles alone (ci-lockfiles.ts: npm's `packages` entries resolved as Node
resolves them, Cargo.lock's `[[package]]` blocks), and counts the change as
one to the workspaces and crates whose resolved dependencies changed; the unit
graph carries it to their dependants. The rule's `root: "full"` still runs
everything when the root package's own tooling (TypeScript, ESLint, oxfmt)
changed, and so does a lockfile with no earlier version to compare.

Replayed on main's recent lockfile commits: a VS Code extension dependency
reaches only that extension (6 jobs), and a new extractor only its crate and
the catalog (12), instead of 42 each.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Dependency resolution ignores Cargo source qualifiers, so same-name/version packages from different sources can be confused and transitive dependency changes may not trigger the consuming crate’s CI jobs.

1 open issue
What changed in this PR

This PR narrows CI runs for lockfile changes to the workspaces and crates whose resolved dependencies changed, building on the earlier CI rule refinements. Root tooling changes and missing baseline lockfiles still trigger full runs.

Changes:

  • Compare npm and Cargo dependency graphs before and after lockfile changes.
  • Wire merge-base and current file contents into the CI planner.
  • Extend rule schemas, tests, and contributor documentation.
File Description
tools/​scripts/​ci-plan.mjs Supplies baseline and current lockfile contents.
tools/​cli/​test/​ci-plan.test.ts Tests selective planning with the real npm lockfile.
tools/​cli/​test/​ci-lockfiles.test.ts Tests npm resolution and Cargo dependency reach.
tools/​cli/​src/​lib/​ci-rules.schema.ts Defines lockfile effects and root handling.
tools/​cli/​src/​lib/​ci-plan.ts Passes file contents into change classification.
tools/​cli/​src/​lib/​ci-lockfiles.ts Computes affected units from lockfile dependency graphs.
tools/​cli/​src/​lib/​ci-files.ts Applies lockfile rules and full-run fallbacks.
CONTRIBUTING.md Documents lockfile-driven CI selection.
.github/​ci-rules.schema.json Updates the generated rule schema.
.github/​ci-rules.json Replaces blanket lockfile runs with selective rules.

Review effort: Balanced

Comment thread tools/cli/src/lib/ci-lockfiles.ts Resolved
@agorischek
agorischek force-pushed the agorischek/ci-rules-lockfiles branch from 972cbb2 to dc0b37f Compare November 21, 2026 04:21
…name and version

Copilot review on #134.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
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