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 inspect the repository structure and search for pnpm/catalog/package-source resolution code and relevant tests. Then I’ll reproduce the name mismatch, trace where the declared alias is lost, implement the narrowest general fix, and run the affected and broader test suites.

  3. Assistant

    ripgrep is unavailable, so I’ll use grep/find. The project is a Rust workspace; I’ll identify resolver and lockfile crates plus fixtures before running a targeted baseline.

  4. Assistant

    The catalog parser itself only tracks catalog usage; the symptom points to module resolution returning a package’s physical pnpm store identity. I’ll inspect dependency-analysis data flow—especially extraction of external imports, resolved paths, and package-name derivation—then inspect the existing JSR edge-case test for intended semantics.

  5. Assistant

    I found graph.package_usage is the canonical input to both findings. Next I’ll trace how each ResolvedImport contributes to that map and inspect the resolver’s NpmPackage result construction; that is likely where the physical package.json name overrides the import specifier.

  6. Assistant

    I’ll inspect specifier.rs around normal package resolution and physical package.json handling, along with result types and graph construction. I’ll also check dependency versions to understand whether the underlying resolver exposes the original module request separately.

  7. Assistant

    The fallback correctly uses extract_package_name(specifier), so the bug must be in the successful-resolution branch. I’ll open the complete resolver function and path classification helpers, focusing on symlink/canonical pnpm paths and package manifest name lookup.

  8. Assistant

    The successful branch has several early and canonicalized paths. I’ll view it without truncation and inspect extract_package_name_from_node_modules_path, since pnpm aliases likely produce node_modules/<declared-name> pre-canonicalization but .pnpm/<source-name>/node_modules/<source-name> after canonicalization.

  9. Assistant

    The defect is now clear: the resolver intentionally skips the pre-canonical package-name extraction for .pnpm, canonicalizes the path, then extracts the source package name from the inner virtual-store node_modules. For package-source aliases, that differs from the bare request name.

    Before editing, I’ll reproduce with a temporary workspace and realistic pnpm-style symlinks for both unscoped npm alias and scoped JSR-translated source. I’ll build/run the CLI and capture JSON findings.

  10. Assistant

    The fixture was created, but Cargo requires selecting the fallow binary; no code has run yet. I’ll invoke that binary, checking help only if the root option placement is rejected, and then summarize dependency findings from the JSON envelope.

  11. Assistant

    The command produced JSON but my filter found no nonempty keys containing “depend”, suggesting either the fixture symlinks were malformed or output categories use different names. I’ll inspect the report and verify symlink targets/resolution directly.

  12. Assistant

    The symlink targets were one directory too high, so resolution fell back to the import request name and did not reproduce. I’ll correct both links and mark source files as entry points to ensure dependency analysis includes them, then rerun the baseline.

  13. Assistant

    The reproduction exactly matches the report. I’ll implement a resolver helper that, only for resolved paths inside pnpm’s virtual store and valid bare package requests, returns the package name from the original specifier rather than the canonical inner path. This keeps current behavior for relative imports, tsconfig/plugin aliases, and non-pnpm layouts, while covering JS and style resolution paths consistently. First I’ll inspect package-name validation semantics to avoid treating path aliases as package requests.

  14. Assistant

    Validation is permissive, but is_path_alias reliably excludes the framework aliases most at risk. I’ll add two small private helpers in specifier.rs: virtual-store detection by path component (cross-platform), and extraction that substitutes the original bare request name only in that case. Then I’ll use it at all node_modules classifications in the central JS/style resolver, leaving lower-level SCSS and explicit plugin fallback behavior untouched.

  15. Assistant

    The patch is localized and also replaces the previous byte-window path check with component-aware detection. I’ll rerun the exact reproduction and verify all four false positives disappear while imports remain resolved.

  16. Assistant

    The reproduction is fixed: both declared aliases receive usage credit, neither physical source name is unlisted, and no imports are unresolved. I’ll now run the graph crate’s full tests (the directly affected layer), then core dependency-analysis tests/integration tests. I’ll identify exact Cargo package names first.

  17. Assistant

    All 520 graph tests pass. Since the behavioral effect is consumed by core’s dependency analysis, I’ll run the full fallow-core library/unit and integration test suite rather than only a name-filtered subset.

  18. Assistant

    The full core run passed (2,477 library tests and 545 integration tests), including catalog and style-package coverage. I’ll run Clippy on the changed crate with all targets, inspect the final diff/status for accidental files, and remove the temporary reproduction (outside the repository) before submission.

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