Skip to content
TheChatArchiveThe Chat Archive
gpt-5.6-sol· openaiHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION False positives for pnpm package source aliases What happened? fallow…

  1. User

    ISSUE DESCRIPTION

    False positives for pnpm package source aliases

    What happened?

    fallow dead-code reports incorrect unused/unlisted dependency findings when pnpm package sources are used through catalogs.

    Example pnpm-workspace.yaml:

    packages:
      - apps/*
    
    catalog:
      '@std/csv': jsr:1.0.6
      unstorage: npm:unstorage-nightly@2.0.0-alpha.5
    

    The package manifests depend on the declared names:

    {
      "dependencies": {
        "@std/csv": "catalog:"
      }
    }
    
    {
      "dependencies": {
        "unstorage": "catalog:"
      }
    }
    

    Source imports also use the declared names:

    import { stringify } from '@std/csv/stringify';
    
    import { createStorage } from 'unstorage';
    

    But Fallow can report the declared package names as unused:

    {
      "package_name": "@std/csv",
      "location": "dependencies",
      "path": "apps/cli/package.json"
    }
    
    {
      "package_name": "unstorage",
      "location": "dependencies",
      "path": "apps/native/package.json"
    }
    

    And report the resolved package-source names as unlisted:

    {
      "package_name": "@jsr/std__csv",
      "imported_from": [
        {
          "path": "apps/cli/src/output.ts"
        }
      ]
    }
    
    {
      "package_name": "unstorage-nightly",
      "imported_from": [
        {
          "path": "apps/native/src/storage.ts"
        }
      ]
    }
    

    This seems to conflate the manifest/import package name with pnpm’s resolved package-source name.

    pnpm documents that packages can be installed from alternate sources:

    • jsr: installs from the JSR registry
    • npm:<name>@<version> can resolve a declared dependency through a different npm package name
    • package sources are part of pnpm’s supported dependency model, not separate source imports

    So if @std/csv is declared and imported, Fallow should credit @std/csv, even if pnpm resolves it to @jsr/std__csv internally. Same for unstorage resolving to unstorage-nightly.

    Reproduction

    Create pnpm-workspace.yaml:

    packages:
      - apps/*
    
    catalog:
      '@std/csv': jsr:1.0.6
      unstorage: npm:unstorage-nightly@2.0.0-alpha.5
    

    Create apps/cli/package.json:

    {
      "name": "@example/cli",
      "type": "module",
      "dependencies": {
        "@std/csv": "catalog:"
      }
    }
    

    Create apps/cli/src/output.ts:

    import { stringify } from '@std/csv/stringify';
    
    console.log(stringify);
    

    Create apps/native/package.json:

    {
      "name": "@example/native",
      "type": "module",
      "dependencies": {
        "unstorage": "catalog:"
      }
    }
    

    Create apps/native/src/storage.ts:

    import { createStorage } from 'unstorage';
    
    console.log(createStorage);
    

    Run:

    fallow dead-code --format json
    

    Expected behavior

    Fallow should treat the package name used in package.json/imports as canonical for dependency analysis.

    Expected:

    • @std/csv should not be reported as unused
    • @jsr/std__csv should not be reported as unlisted
    • unstorage should not be reported as unused
    • unstorage-nightly should not be reported as unlisted

    The resolver may need to preserve both names for pnpm package-source entries:

    • declared/import name: @std/csv, unstorage
    • resolved source name: @jsr/std__csv, unstorage-nightly

    Dependency usage should match against the declared/import name, not only the resolved source package name.

    Fallow version

    2.85.0

    Operating system

    macOS

    Configuration

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /fallow, current file: none) bash-$

  2. Assistant

    I’ll first map the repository and locate the pnpm lockfile/catalog resolution and dependency-usage logic. Then I’ll reproduce the alias behavior with the project’s existing test or fixture conventions, patch the resolver so declared names remain canonical, and run focused plus broader tests.

  3. Assistant

    ripgrep is unavailable, so I’ll use grep/find. The repository is a Rust workspace; I’m narrowing the search to source and test files and reading the workspace crate layout before attempting a reproduction.

  4. Assistant

    The first search was noisy. I’ll now identify files whose names or contents specifically implement lockfile/package resolution, then inspect the dependency analyzer’s data flow from parsed imports to package names.

  5. Assistant

    The catalog parser itself may only track catalog usage; the incorrect @jsr/std__csv/unstorage-nightly names likely originate when the graph resolver reads the installed target package’s package.json. I’ll inspect resolver result types and the unused/unlisted dependency analyzer to see where the package name gets selected.

  6. Assistant

    ResolveResult::NpmPackage currently stores one name, documented as the name receiving usage credit. The likely bug is the path-based branches deriving that name from the canonical pnpm store path rather than the original bare specifier. I’ll inspect those branches and graph population code to make the smallest consistent correction.

  7. Assistant

    The central resolver confirms the failure: after pnpm symlink canonicalization it extracts the source package name from the store path. For bare imports, dependency accounting should instead use extract_package_name(specifier), while path extraction remains useful for determining whether the target is external/workspace. I’ll review all resolver branches and upgrade logic to ensure aliases are corrected everywhere without changing relative imports inside node_modules or CSS file-preservation behavior.

  8. Assistant

    The fix should preserve two concepts locally: use the path-derived package name only to classify the resolved target and detect workspace packages, but use the original bare specifier’s package segment for NpmPackage accounting. This applies to normal and style package resolution, including scoped subpaths. Before editing, I’ll reproduce with an actual pnpm layout if pnpm/corepack is available; otherwise I’ll synthesize the exact symlink structure in a temporary project and run the CLI.

  9. Assistant

    No Node/pnpm or prebuilt binary is present, so I’ll synthesize pnpm’s filesystem semantics: declared-name symlinks under each workspace point to virtual-store packages whose manifests/source names differ. This directly exercises the failing canonicalization branch. I’ll build/run the CLI against that temporary reproduction and capture the pre-fix JSON findings.

  10. Assistant

    The reproduction filesystem is ready; Cargo only required selecting the fallow binary. I’ll rerun it and inspect the reported package names.

  11. Assistant

    The reproduction confirms the npm alternate-name half exactly (unstorage unused, unstorage-nightly unlisted). The scoped JSR symlink appears not to canonicalize to its target, so it took a fallback path rather than reproducing the source-name mismatch. I’ll verify/fix that temporary symlink, then patch all path-based NpmPackage returns to credit the declared bare name. A helper will keep the behavior explicit and avoid repeated conditional logic.

  12. Assistant

    There are six returns: three in normal resolved-path handling, two in style resolution, and one unresolved bare fallback. The unresolved fallback already derives the original specifier and must remain unchanged. I’ll introduce a small function that returns the import’s declared package name when the specifier is bare, otherwise retains the resolved path name (needed for relative imports originating within external style files), and use it in the five path-derived accounting returns.

  13. Assistant

    With the corrected symlink, the pre-fix run now reproduces all four reported false positives (@std/csv and unstorage unused; resolved names unlisted). I’ll implement the declared-name helper and update only the five path-derived package-accounting branches, leaving workspace detection and unresolved-import behavior intact.

  14. Assistant

    Formatting adjusted two calls; the code is now formatted. I’ll rerun the exact reproduction to verify both aliases are credited under declared names, then run the graph crate’s resolver tests and the focused core integration tests for pnpm catalogs/dependencies.

  15. Assistant

    The post-fix reproduction has zero unused and zero unlisted dependencies for both aliases. Resolver-focused tests passed (235), and 29 dependency/style/workspace integration tests passed. One attempted catalog test filter used --exact with an incomplete module path and selected zero tests, so I’ll rerun the catalog tests with the correct substring filter, run the full graph suite, and run Clippy for the changed crate. I’ll also inspect the final diff for accidental changes.

  16. Assistant

    Final review found one additional style-resolution fallback that maps a path-derived name directly when canonicalization fails. It would exhibit the same alias bug on inaccessible/broken-canonicalization filesystems, so I’ll update it for completeness. I’ll also inspect other path-derived NpmPackage constructors in fallback code to distinguish original-specifier accounting from relative imports before final verification.

  17. Assistant

    The other fallback constructors are intentionally different: configured path aliases and SCSS relative node-module fallbacks do not carry a declared bare package name, while package-import maps already use their declared external target. I’ll change only the canonicalization-failure branch in the central style resolver, then rerun formatting, the reproduction, and focused resolver tests.

  18. Assistant

    The complete fix now handles both successful and failed canonicalization paths. Verification is clean: the exact synthetic pnpm reproduction went from four alias-related dependency findings to none; all 472 graph tests, 29 dependency integration tests, 8 catalog-reference/catalog-usage tests, formatting, diff checks, and graph Clippy passed. After the final small fallback adjustment, 15 specifier tests and the reproduction also passed.

    Checklist:

    • Successfully reproduced the reported error. A temporary pnpm-style virtual store with declared-name symlinks produced unused @std/csv/unstorage and unlisted @jsr/std__csv/unstorage-nightly findings before the change.
    • Confirmed the fix resolves the error. The same project now reports unused_dependencies: 0 and unlisted_dependencies: 0.
    • Considered edge cases. The implementation covers scoped names, package subpaths, npm alternate sources, JSR-translated names, style resolution, and canonicalization failure, while preserving path-derived names for non-bare relative/style fallbacks.
    • Ran affected existing tests. Full graph tests passed (472/472), dependency integrations passed (29/29), pnpm catalog suites passed (8/8), focused post-adjustment resolver tests passed (15/15), and Clippy/format/diff checks passed.

    I’ll submit the single-file resolver change.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.