Skip to content

yarn.lock (Berry v2+): report which dependencies changed #66

Closed

Description

@adityankale190895

Context: on a replay of one production app's history, DiffCI fell back to the full suite on 58% of commits, mostly because config, package.json, workflow or lockfile changes forced it to. Narrowing those safely is the main open problem.

Follow-up to #50. Yarn Classic v1 lockfiles are handled since #63; Yarn Berry (v2+) yarn.lock files still force a full run.

Berry lockfiles differ from v1:

  • YAML-style syntax with a __metadata header (version, cacheKey)
  • descriptor keys carry a protocol, e.g. "lodash@npm:^4.17.0", plus workspace:, patch:, portal:, link:
  • each entry has resolution, checksum, languageName and linkType fields

Scope: parse supported Berry lockfiles in src/repo/yarn-lockfile.ts (or alongside it), report which dependencies changed, and reuse the selection path from #63. Keep the full-run fallback for anything we cannot analyze safely, e.g. Plug'n'Play installs without node_modules, patch: / portal: protocols, workspaces, or malformed input. If that's too much for one PR, start with nodeLinker: node-modules repos using plain npm: descriptors.

Narrowing must first prove the install linker from .yarnrc.yml; the lockfile alone can't establish it, and Yarn Modern defaults to Plug'n'Play. Treat only an explicit nodeLinker: node-modules as eligible for further checks. A missing or empty .yarnrc.yml, pnp / pnpm, malformed or non-object YAML, or a YARN_NODE_LINKER override we can't rule out must force a full run.

Please include synthetic regression fixtures for direct and transitive changes, an unsupported protocol, and a malformed lockfile, plus a valid npm:-only Berry lockfile that still falls back to the full suite when the linker is absent or unproven. Also include a grouped key ("shared@npm:^1.0.0, shared@npm:~1.0.0") where a dependency edge resolves through a descriptor other than the first, and an edge whose descriptor is missing from every key, which must fall back to the full suite.


New to DiffCI? See CONTRIBUTING.md: add a synthetic fixture, run npm test, and sign off commits with git commit -s. Comment here to claim the issue.

Activity

  1. added
    enhancement
    help wanted
    on Oct 30, 2026
  2. robertwmccarty-caelum commented on Oct 30, 2026

    @robertwmccarty-caelum
    Contributor

    Read-only contribution to #66 (AI-assisted analysis for a human BuddyLists/Linked AIs operator; not an autonomous-agent account).

    One fail-closed prerequisite for the proposed Berry npm: / node_modules subset: a Berry yarn.lock cannot establish the install linker. Yarn Modern defaults to Plug'n'Play, and nodeLinker is configured separately in .yarnrc.yml (and may be overridden by environment settings). A parser that accepts plain npm: descriptors without proving nodeLinker: node-modules could return a narrowed test plan for a PnP installation that DiffCI cannot model.

    Evidence: Yarn's first-party install-mode guide (https://yarnpkg.com/features/linkers) and settings documentation (https://yarnpkg.com/configuration/yarnrc/); current DiffCI parser explicitly rejects Berry (https://github.com/DiffCI/core/blob/main/src/repo/yarn-lockfile.ts), and this issue already calls for PnP fallback.

    Suggested regression matrix (eligibility for selective Berry analysis, before inspecting the lockfile):

    • explicit nodeLinker: node-modules → eligible for further checks, not automatically safe;
    • no .yarnrc.yml, empty file, pnp, pnpm, malformed YAML, non-object YAML → blocker/full run;
    • unmodeled YARN_NODE_LINKER / CI runtime override → blocker/full run unless the effective setting can be established.

    I implemented a small isolated PyYAML predicate for this matrix and ran eight unittest cases: 8/8 passed. This validates the proposed guard's behavior only; it does not test DiffCI's code, parse real Berry fixtures, or prove a full integration path. If helpful, a focused regression in tests/repo/yarn-lockfile.test.ts should assert that a syntactically valid npm:-only Berry lockfile still causes full-suite fallback when linker mode is absent or unproven.

    No registration, product pitch, or production change is involved.

  3. adityankale190895 commented on Oct 30, 2026

    @adityankale190895
    MemberAuthor

    Thanks, this is a real gap. The scope said to start with nodeLinker: node-modules repos but didn't say the linker has to be proven from .yarnrc.yml rather than inferred from npm: descriptors. Today DiffCI only forces a full run when .yarnrc.yml itself changes; it never reads it to decide whether a lockfile change can be narrowed.

    I've updated the issue body: Berry narrowing now requires an explicit nodeLinker: node-modules, everything else in your matrix (missing/empty/malformed file, pnp/pnpm, unmodeled YARN_NODE_LINKER) falls back to the full suite, and the requested fixtures include a valid npm:-only lockfile that must still fall back when the linker is unproven.

  4. robertwmccarty-caelum commented on Oct 30, 2026

    @robertwmccarty-caelum
    Contributor

    Thanks for incorporating the linker gate. I tested one additional Berry parsing edge case that may be worth including in the synthetic fixtures: one YAML mapping key can contain multiple comma-separated descriptors for the same resolution. A dependency edge may use the second descriptor, so indexing only the first can silently lose a transitive dependency.

    Minimal synthetic YAML-shaped case:

    __metadata:
      version: 8
    "app@npm:^1.0.0":
      version: 1.0.0
      resolution: "app@npm:1.0.0"
      dependencies:
        shared: "~1.0.0"
    "shared@npm:^1.0.0, shared@npm:~1.0.0":
      version: 1.0.1
      resolution: "shared@npm:1.0.1"

    The app's edge resolves through shared@npm:~1.0.0, not the first selector in that grouped key. A change from shared@npm:1.0.0 to 1.0.1 must be attributable to app; if the second descriptor is absent/unresolved, fail closed instead of treating the graph as unaffected.

    I ran five isolated Python 3 / PyYAML 6.0.3 unittest checks (5/5 passed): both grouped descriptors map to one record; a transitive resolution bump reaches the direct root; an unchanged resolution is a no-op; indexing only the first descriptor fails closed; an unsupported workspace: selector fails closed. These exercise a small reconstructed parser, not DiffCI, Yarn's own parser, or the repository test suite. The YAML above is an illustrative reduced fixture, not an installable lockfile.

    For #66's TypeScript tests, the useful regression assertion is that every descriptor in a supported grouped key resolves to the same entry and no missing/unsupported descriptor can produce a narrowed plan. The existing tests/repo/yarn-lockfile.test.ts is the natural fixture location.

    Format reference: https://docs.rs/openvet-lockfile/latest/openvet_lockfile/yarn/index.html ; repository source: https://github.com/DiffCI/core/blob/main/src/repo/yarn-lockfile.ts .

    — AI-assisted analysis on behalf of the human BuddyLists / Linked AIs operator; not an independently operated agent identity. No registration or product request.

  5. adityankale190895 commented on Nov 8, 2026

    @adityankale190895
    MemberAuthor

    Thanks, this is a good catch. Classic v1 headers already work this way (selectorHeader in yarn-lockfile.ts reads every selector in a header and requires them all to name the same package). Berry is different: the whole list is one quoted YAML key, so the Berry parser has to split that string itself. It can't reuse the v1 tokenizer as-is.

    I've added it to the fixture list in the issue body:

    • every descriptor in a grouped key must map to the same entry
    • a transitive bump reached through a later descriptor must be attributed to the direct dependency
    • an edge whose descriptor isn't in any key, or a key with an unsupported protocol (workspace:, patch:, etc.), must fall back to the full suite
  6. KingEmma7 commented on Nov 17, 2026

    @KingEmma7
    Contributor

    I’d like to work on this. I’ll start with the Yarn Berry node-modules case and keep the full-suite fallback whenever the linker or dependency graph can’t be verified safely.

  7. adityankale190895 commented on Nov 17, 2026

    @adityankale190895
    MemberAuthor

    @KingEmma7 sure you may take it up

  8. added a commit that references this issue on Nov 18, 2026
    881c4a4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions