Skip to content

Generic workspace mode (npm/yarn/pnpm/bun) always returns an empty affected set when run from an absolute cwd #73

Description

@gbleu

Context

Evaluated domino 1.4.0 against nx affected on a production monorepo (250 pnpm workspace packages, Nx 22 on top). While testing the generic workspace path (no nx.json), discovery and the semantic trace both work — but the affected set is always empty.

Reproduction

Any npm/yarn/pnpm/bun workspace, run from an absolute cwd (i.e. normal CLI usage):

  1. pnpm workspace with packages/*, two packages where b imports an exported function from a
  2. Modify the body of the consumed function in a
  3. domino affected --base HEADNo affected projects

With --debug the contradiction is visible: Found N workspace projects, the changed symbol is found, the cross-package reference chain is fully traced... and then Affected projects: []. On our 250-package repo the trace correctly walked from the changed lib through a barrel wildcard re-export into a deep consumer call chain — and still attributed nothing.

Root cause

  • parse_package_json (src/workspace/workspaces.rs) keeps source_root/root absolute whenever cwd is absolute (test_source_root_with_absolute_cwd asserts this behavior).
  • Changed files parsed from the git diff headers (src/git.rs::parse_diff) are repo-relative.
  • ProjectIndex::resolve_packages (src/utils.rs) decides ownership via file_path.starts_with(root) — a relative path never starts with an absolute root, so every lookup returns empty.

The Nx loader doesn't have this bug: it strips the cwd prefix (src/workspace/nx.rs), which is why Nx-mode attribution works. Since the CLI always canonicalizes to an absolute cwd, generic mode currently returns an empty affected set on, as far as I can tell, every real-world invocation — a silent false-green if used for CI gating.

Fix

Strip the cwd prefix unconditionally in parse_package_json, matching the Nx loader (one-line change + the unit test update): gbleu/domino@65f0de3

All 207 unit tests pass. Verified end-to-end on the 250-package monorepo: 251 projects discovered via pnpm-workspace.yaml, and correct affected sets across a 14-scenario matrix (comment-only edit → source package only; body change in a shared lib → exact consumer set including transitive chains; type-shape change → 3 precise projects vs 16 from nx's file-graph).

Happy to open a PR. (Related but distinct: #70 covers Nx-mode discovery missing inferred projects — commented there separately.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions