Skip to content

feat(#932): fix(run): manifest fallback ?? "npm" bypasses resolvePackageManager — pnpm worktrees get npm ci (surviving #870 site) - #1000

Merged
admarble merged 14 commits into
mainfrom
feature/932-fix-run-manifest-fallback-npm-bypasses-resolvepack
Sep 8, 2026
Merged

admarble merged 14 commits into
mainfrom
feature/932-fix-run-manifest-fallback-npm-bypasses-resolvepack

Conversation

@admarble

@admarble admarble commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Automated PR for issue #932.

Fixes #932

QA verdict: AC_MET_BUT_NOT_A_PLUS — acceptance criteria met, but not A+. The run broke to this PR for review rather than entering the quality loop; see the QA review comment for improvement notes.


🤖 Generated by sequant run

Mutation verification (runner, 2026-09-07)

Mutation-verified: AC-3 — re-added ?? "npm" at src/commands/run.ts:102; src/lib/stacks.no-npm-fallback-gate.test.ts (932: no source file falls back to a literal "npm") failed with expected 'src/commands/run.ts:102: …' to be ''; restored (git checkout -- src/commands/run.ts), gate green again (2/2).

A+ pass (runner, 2026-09-07, commit 153ccbb)

Addresses the QA round-1 notes so this PR can reach READY_FOR_MERGE:

Mutation-verified: AC-3 (widened gate) — re-added || "npm" at src/commands/run.ts:102; src/lib/stacks.no-npm-fallback-gate.test.ts failed (932: no source file falls back to a literal "npm"); restored, gate green 2/2.

The ?? DEFAULT_PM spelling cannot be exercised through vitest (an undefined identifier fails the global-setup build before the gate runs); the gate's regex was proven against it directly: grep -rnE <pattern> src bin → 1 hit at run.ts:102 under the mutation, 0 after restore.

Acceptance criteria (verbatim from #932)

  • AC-1: manifest without packageManager + pnpm-lock.yaml resolves to pnpm install --frozen-lockfile through the run path — Verify: npx vitest run src/lib/stacks.resolve-package-manager.test.ts -t "932" → passes; the test builds the orchestrator init the way run.ts does (no literal fallback) and asserts the resolved install command.
  • AC-2: same for yarn.lock and bun.lockb per LOCKFILE_PRIORITY — Verify: same test, two more cases.
  • AC-3: gate — no producer reintroduces the literal — Verify: grep -rn 'packageManager ?? "npm"' src bin | wc -l → 0, asserted by a scoped gate test; PR body carries Mutation-verified: AC-3 — re-added ?? "npm" at run.ts:102; <test> failed; restored.
  • AC-4: the setup skill writes packageManager next to pmRun in the manifest template — Verify: grep -c 'packageManager' templates/skills/setup/SKILL.md ≥ 1 inside the manifest template block, and md5 -q templates/skills/setup/SKILL.md .claude/skills/setup/SKILL.md skills/setup/SKILL.md | uniq | wc -l → 1.

A+ round 2 (runner, 2026-09-07, commit 6b61a7f)

Addresses the QA round-2 adversarial findings:

  • Setup skill no longer records a guessed "npm" (the same short-circuit one layer up): the package-manager block starts with PM="", the no-lockfile branch leaves it empty, and the manifest template says to include packageManager only when a lockfile identified it — so an undetected manager stays undeclared and resolvePackageManager decides live, exactly as run.ts now does. All three skill mirrors updated; check-skill-sync.ts → 44 synced, 0 diverged.
  • CHANGELOG restored from origin/main and only the [Unreleased] entry re-added by hand — the earlier formatter pass had garbled released entries (the feat(spec/qa): explicit Evidence: clause on ACs — declared verification replaces keyword inference #938 line). No formatter is run on CHANGELOG.md any more in this PR.
  • AC-4 gate scoped to the .sequant-manifest.json fenced block (regex over the template, asserting "packageManager" follows "pmRun"), per CLAUDE.md's scoping rule.

Mutation-verified: AC-4 — deleted the "packageManager" line from the manifest template block in all three setup/SKILL.md mirrors; src/lib/stacks.no-npm-fallback-gate.test.ts (932: setup skill's manifest template writes packageManager next to pmRun) failed; restored.

Note on AC-1/AC-2: their tests mirror run.ts's init shape (no literal fallback) and assert the resolved install command; AC-3's grep gate is the production-line regression guard.

A+ round 3 (runner, 2026-09-07, commit d7f4468)

  • Gate-test failure messages name the failing mirror again (${SETUP_SKILL_MIRRORS[i]} …); the loop index is used.
  • The grep gate now also catches a direct packageManager: "npm" assignment (alternation ?? | || | :). Test files (*.test.ts, __tests__/) are excluded from the scan because fixtures legitimately declare packageManager: "npm" as data (six such fixtures exist today); production sources under src/ and bin/ are still scanned in full.

Mutation-verified: AC-3 (direct literal) — replaced run.ts:102 with packageManager: "npm",; src/lib/stacks.no-npm-fallback-gate.test.ts failed; restored (git checkout on that one clean file), gate green 2/2, resolve suite 15/15.

A+ round 4 (runner, 2026-09-07, commit 581d95a)

  • Unused PM_CONFIG import removed from stacks.resolve-package-manager.test.ts.
  • Setup skill's lockfile precedence now mirrors LOCKFILE_PRIORITY in stacks.ts — bun.lockb/bun.lock > yarn.lock > pnpm-lock.yaml > package-lock.json — with a comment naming the source of truth, so a declared value can never outrank what live detection would pick on a multi-lockfile repo. All three mirrors; check-skill-sync.ts 44 synced.
  • Manifest template placeholder is plain "<detected PM>" again; the omit-when-empty instruction lives in the prose above the block.
  • Known, documented, not closed: the grep gate cannot see a two-step alias (const pm = manifest.packageManager; … pm ?? "npm"); AC-1/AC-2 tests mirror run.ts's init shape rather than invoking runCommand. Both are noted here as the gate's stated limits.

A+ round 5 (runner, 2026-09-07, commit b21c68a)

  • The real init path is now tested. run.ts's manifest subset is built by a new manifestForRun helper (src/commands/run-manifest.ts) and run.ts calls it; src/commands/run.manifest-init.test.ts asserts an undeclared packageManager reaches the orchestrator init as undefined (key present, no default of any spelling), a declared one passes verbatim, and — through that real init — a pnpm worktree resolves to pnpm. A non-literal regression inside the helper now fails this test even though the grep gate cannot see it. (Correction, round 7: the helper is tested but its call site was not — a future edit could bypass manifestForRun with an inline literal. Round 7 pins the call site by source inspection; see below.)
  • Off-list files, disclosed: src/commands/run-manifest.ts (new) and src/commands/run.manifest-init.test.ts (new) are not in the node's may-touch list. The helper lives in its own module because run.ts carries a stated 200-LOC cap (arch: extract RunOrchestrator — decouple execution engine from CLI wiring #503 AC-2; it is at 197 lines) — folding the helper in would have pushed it to 218.
  • CHANGELOG entry now opens with an action verb (Fix pnpm/yarn/bun worktrees installing with npm ci).

A+ round 6 (runner, 2026-09-07, commit 0b85c15)

  • The include-conditional now sits inside the manifest template block (jsonc fence, comment line directly above "packageManager"), with the prose kept; the template gate accepts the jsonc fence. All three mirrors; check-skill-sync.ts 44 synced.
  • Drift guard added (PM_CONFIG.yarn.ciInstall uses Yarn 2+ --immutable, which Yarn 1 rejects — no berry detection exists #871 class): stacks.no-npm-fallback-gate.test.ts reads the skill's -f "<lockfile>" chain and LOCKFILE_PRIORITY's file: entries from src/lib/stacks.ts as text and asserts identical order, per mirror. Neither side is imported, so a reorder on either side fails the test.
  • Documented, not closed: the grep gate cannot see non-literal re-defaulting; run.manifest-init.test.ts closes it at the one RunInit producer that exists today.

Mutation-verified: AC-4 (drift guard) — swapped the yarn.lock and pnpm-lock.yaml branches in skills/setup/SKILL.md only; src/lib/stacks.no-npm-fallback-gate.test.ts (skills/setup/SKILL.md checks lockfiles in exactly the resolver's order) failed; restored from a backup copy (not git checkout), mirrors byte-identical again, 5/5 green.

A+ round 7 (runner, 2026-09-07, commit c23c96c)

  • Call site pinned: run.manifest-init.test.ts now also reads run.ts as text and asserts manifest: manifestForRun(manifest) is present and no inline manifest: { stack: … literal is — the same read-as-text technique as the lockfile drift guard. With the helper tested and its only call site pinned, a two-step alias at the init site is caught by one of the two.
  • Round-5 wording corrected above (the helper was tested; the call site was not until now).
  • CHANGELOG notes that a recorded packageManager is a setup-time snapshot (like pmRun) that outranks live detection, so a project migrating package managers should update or remove the key.

Mutation-verified: AC-3 (call site) — replaced manifest: manifestForRun(manifest) in run.ts with an inline { stack: manifest.stack, packageManager: manifest.packageManager } literal; src/commands/run.manifest-init.test.ts (run.ts builds init.manifest via manifestForRun(manifest)) failed; restored (perl reverse edit, git diff empty), 4/4 green.

A+ round 8 (runner, 2026-09-07, commit 85de5aa)

  • Round 6 moved the include-conditional inside the template as a jsonc comment; round 8 correctly pointed out that an agent copying the block verbatim to .sequant-manifest.json would write unparseable JSON. Reverted to a plain json fence with the conditional in the prose directly above it ("plain JSON, exactly the shape below … omit that line entirely"). All three mirrors; check-skill-sync.ts 44 synced; the AC-4 template gate stays green (5/5).
  • Round 8's follow-up question — whether the setup skill should record packageManager at all, given a declared value outranks live detection — is AC-4's explicit requirement in this node; the CHANGELOG discloses the snapshot semantics. Not filed as an issue here (PLAN §5 I-7); recorded for the plan owner.

A+ round 9 (runner, 2026-09-07, commit c376760)

  • Off-list, disclosed: docs/features/run-orchestrator.md:45 — the public programmatic-API example still taught packageManager: manifest.packageManager ?? 'npm'; amended to forward the value verbatim. This was the last copy of the anti-pattern in the repo (docs/ and README now have zero). Runner decision under the owner's A+ instruction: a one-line doc fix beats a follow-up issue for a copy-paste example that reintroduces the bug.
  • The gate's test-file exclusion also covers *.spec.ts.

A+ round 10 (runner, 2026-09-07, commit a9d96b0)

  • CHANGELOG now states that the setup skill's lockfile precedence mirrors LOCKFILE_PRIORITY (bun > yarn > pnpm > npm; it was pnpm > yarn > bun), which changes the recorded pmRun/packageManager for multi-lockfile projects.
  • The snapshot-staleness follow-up now has a home that outlives this PR without filing an issue (PLAN §5 I-7): PLAN §9 OQ-20 on the plan branch (PR docs(plan): 2026-09 backlog graph (16 nodes, /graph-run ready) #998, commit 67050f7) — "should the setup skill record packageManager at all, given a declared value outranks live detection after a migration?" with the recommendation to decide before node 12 adds another manifest consumer.
  • Noted, out of scope: withActivityHook reading process.env.SEQUANT_ORCHESTRATOR makes batch-executor.test.ts fail when the suite runs under sequant run (the three pre-existing local failures every round settled against main).

…tion-verify)

Entire-Checkpoint: 5af4df97391f
…irrors

Closes remaining #932 scope: the setup skill's manifest template only
wrote pmRun, so every plugin-installed project still hit the run.ts
fallback path indirectly. Extends the AC-3 gate test to also assert
AC-4 (packageManager present + mirrors byte-identical).

Entire-Checkpoint: ec929992e989
… add CHANGELOG entry

Entire-Checkpoint: a4b924ffe21b
…AC-4 gate to the manifest template; restore released CHANGELOG entries (#932)

Entire-Checkpoint: 6f74ea3c2bd8
… packageManager literal too

Entire-Checkpoint: db4669d6d951
…fest placeholder; drop unused import (#932)

Entire-Checkpoint: 46e61cc7042b
…orRun; action-verb CHANGELOG

Entire-Checkpoint: de5af4ef28cd
…FILE_PRIORITY; conditional inside the template block

Entire-Checkpoint: e65d6a2e8815
…n; CHANGELOG snapshot caveat

Entire-Checkpoint: 5cc15ee94055
…le; gate excludes *.spec.ts

Entire-Checkpoint: 6e269a2ae05a
…anifest-fallback-npm-bypasses-resolvepack

# Conflicts:
#	CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(run): manifest fallback ?? "npm" bypasses resolvePackageManager — pnpm worktrees get npm ci (surviving #870 site)

1 participant