Skip to content

fix(stacks): detectPackageManagerSync is JS-only — a uv/poetry repo without a declared packageManager resolves to npm and skips its install #1231

Closed

Description

@admarble

Epic: field-2026-09-28 follow-up (downstream non-Node adoption) Tier: mechanical Graph: tracker #1203 (not in the DAG)

Problem. There are two package-manager detectors, and they disagree on Python repos:

  • detectPackageManager() (async, src/lib/stacks.ts:209) checks JS lockfiles, then package.json → npm, then Python lockfiles (uv.lock → uv, poetry.lock → poetry), then pyproject.toml/requirements.txt → pip. sequant init and init --manifest-only use it, so their manifests record packageManager: "uv" correctly.
  • detectPackageManagerSync(root) (src/lib/stacks.ts:249) checks JS lockfiles only and otherwise returns "npm". It's the fallback in resolvePackageManager (:291-299) when the manifest declares no packageManager. Worktree provisioning (installWorktreeDeps), the dependency reinstall and merge-check's combined-branch test (combined-branch-test.ts:171) all rely on that fallback.

So a uv or poetry repo whose manifest has no packageManager resolves to npm. installWorktreeDeps then logs "Skipping dependency install — no manifest found for npm" and installs nothing. #1217's uv sync --frozen is never reached, and neither is poetry's or pip's install. It's the same two-producer drift as #833/#870.

Evidence (2026-09-30, main @ 4797ac8c, built dist/). A real project with pyproject.toml (depending on six) and uv lock:

  • installWorktreeDeps(dir, undefined) resolved pm=npm, ciInstall="npm ci", printed "Skipping dependency install — no manifest found for npm", and created no .venv.
  • The same directory after sequant init --manifest-only (manifest packageManager: "uv"): installWorktreeDeps(dir, "uv") ran uv sync --frozen, and six imported from the project's .venv.

Who's affected: manifests written by hand (a minimal {version, stack, installedAt, files: {}} was the documented workaround before #1209), and manifests created before the repo gained a Python lockfile.

AC

  • AC-1: detectPackageManagerSync(root) follows detectPackageManager's order. JS lockfiles come first, then package.json → npm, then uv.lock → uv, poetry.lock → poetry, then pyproject.toml or a requirements*.txt → pip, and npm last when none of these exist. Evidence: npx vitest run src/lib/stacks.test.ts
  • AC-2: A parity test runs both detectors over the same fixture directories (JS lockfiles, package.json only, uv.lock, poetry.lock, pyproject.toml only, requirements.txt only, a JS+Python mix, empty). Wherever the async detector returns non-null, the sync detector returns the same value. Evidence: npx vitest run src/lib/stacks.test.ts
  • AC-3: installWorktreeDeps(dir, undefined) on a directory with pyproject.toml and uv.lock (no declared package manager) resolves uv and spawns uv with ["sync", "--frozen"], not the npm "no manifest found" skip. Evidence: npx vitest run src/lib/workflow/worktree-manager.frozen-install.test.ts

Non-goals.

  • templates/scripts/new-feature.sh's detect_package_manager is JS-only too, but its install is gated on package.json, so Python repos never reach it. Leave it alone.
  • version-check.ts:413 also calls the sync detector. It only runs for a local node_modules install, and JS-first ordering keeps its answer unchanged for any repo with a package.json.

Graph metadata

May touch

  • src/lib/stacks.ts
  • src/lib/stacks.test.ts
  • src/lib/workflow/worktree-manager.frozen-install.test.ts (it mocks spawnSync; worktree-manager.test.ts deliberately leaves child_process real)

Activity

  1. added
    bug
    graph-2026-09-field
    on Sep 30, 2026
  2. admarble commented on Sep 30, 2026

    @admarble
    ContributorAuthor

    Context for the run (re-checked against main @ 2aec2459, 2026-09-30)

    Line refs (all still hold):

    • src/lib/stacks.ts:196: PYTHON_LOCKFILE_PRIORITY.
    • src/lib/stacks.ts:209: the async detectPackageManager(). It reads the cwd, has no root parameter, and uses fileExists from ./fs.js.
    • src/lib/stacks.ts:249: detectPackageManagerSync(root). It's JS-only, with "npm" as the fallback.
    • src/lib/stacks.ts:291: resolvePackageManager.
    • src/lib/stacks.ts:322: the private findRequirementsFile(root). Reuse it for the pip fallback so requirements-dev.txt and similar files count, the same way hasManifestForPackageManager counts them.

    Shape of the fix

    • Mirror the async order exactly inside detectPackageManagerSync:
      1. LOCKFILE_PRIORITY (JS)
      2. package.json → npm
      3. PYTHON_LOCKFILE_PRIORITY
      4. pyproject.toml or findRequirementsFile(root) → pip
      5. "npm"
    • Keep the return type PackageManager, not nullable. That final "npm" is what the callers rely on.
    • Only touch the sync detector. Don't change the async one's behaviour.

    Tests

    • AC-1 / AC-2 (src/lib/stacks.test.ts). That file vi.mocks ./fs.js (so fileExists is mocked for the async detector), while the sync detector uses real existsSync. For the parity test, build real temp directories for the sync side and drive the async side's mockFileExists from the same file list for each fixture. Don't chdir, and don't spy on process.cwd.
    • AC-3 (src/lib/workflow/worktree-manager.frozen-install.test.ts). That file already hoists a spawnSync mock. Assert that installWorktreeDeps(dir, undefined, false) on pyproject.toml + uv.lock calls spawnSync("uv", ["sync", "--frozen"], …). Don't add it to worktree-manager.test.ts, which deliberately leaves child_process real.
    • The existing worktree-manager.test.ts "skips … no package.json, no lockfile" case must still pass. An empty directory still resolves to npm and gets skipped.

    Standard block

    • No full npm test in exec or in qa. This applies to the qa phase as well as exec. Run targeted suites in the foreground with a timeout: timeout 600 npx vitest run src/lib/stacks.test.ts src/lib/workflow/worktree-manager.frozen-install.test.ts src/lib/workflow/worktree-manager.test.ts. Global setup runs npm run build first.
    • Commit WIP early, and always before any mutation.
    • A mutation marker's failedTest starts with the test file path.
    • PR body: Closes #1231. Use Refs only for the tracker, tracker(graph): field report 2026-09-28 — downstream non-Node adoption gaps (10 nodes) #1203.
    • Skill snippets that read .sequant/settings.json must handle JSONC (not expected to apply here).
    • Add a CHANGELOG ### Fixed entry under [Unreleased].
  3. admarble commented on Sep 30, 2026

    @admarble
    ContributorAuthor

    @/tmp/existing_comment.md

  4. added
    planned
    on Sep 30, 2026
  5. admarble commented on Sep 30, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 3/3 met

    Gaps:

  6. added a commit that references this issue on Sep 30, 2026
  7. admarble commented on Sep 30, 2026

    @admarble
    ContributorAuthor

    QA Verdict: NEEDS_VERIFICATION

    AC coverage: 3/3 met

    Gaps:

    • Required CI test check had not completed at QA time
    • Misplaced test comment block
  8. added a commit that references this issue on Sep 30, 2026
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

    buggraph-2026-09-fieldplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions