Skip to content

fix(merge-check): combined-branch-test runs npm test/build without reinstalling deps after a lockfile change → false BLOCKED #803

Closed

Description

@admarble

Summary

sequant merge --check's combined-branch test runs npm test and npm run build on the merged combined state without reinstalling dependencies first. When any merged branch changed the lockfile / added a dependency, the repo-root node_modules is stale, so both commands fail — producing a false BLOCKED verdict that can scare a user away from a perfectly healthy merge.

Real-world evidence

A length-4 chain (sequant run 109 111 112 113 --chain -Q, ad-motion M6 audio) produced 4 stacked PRs. sequant merge --check reported:

## Combined Branch Test
**Status:** ❌ Issues found (14s)
- ❌ npm test failed on combined state: 
- ❌ npm run build failed on combined state: 
Batch Verdict: ❌ BLOCKED

Note the empty error strings. But the actual combined state was fine:

  • The full-stack tip worktree (feature/113…, which contains all 4 issues' commits) built clean (npm run build — all 4 workspaces) and passed the whole suite (npm test — 929 passed, 1 skipped, 0 failed).
  • Both PRs' GitHub CI (which does a clean npm ci first) were fully green.

The chain's own run log had printed Reinstalling dependencies (lockfile changed)… before creating the PRs — i.e. the branches genuinely changed the lockfile, and the merge-check never re-ran install, so it tested against stale node_modules.

Root cause

src/lib/merge-check/combined-branch-test.ts (lines ~177-207): after merging the branches into the combined state, it goes straight to:

const testResult = npm(["test"], repoRoot);      // ~178
// ...
const buildResult2 = npm(["run", "build"], repoRoot);  // ~194

There is no npm install (or pnpm/yarn equivalent) between the merge and the test/build. A combined state that changed package.json/lockfile therefore runs against outdated dependencies.

Secondary defect: the failure message is ${testResult.stderr.slice(0, 500)} — when the failure writes to stdout (or exits without stderr, as here), the report shows an empty reason, making the false-BLOCKED impossible to diagnose from the report alone.

Acceptance Criteria

  • AC-1: After assembling the combined state and before running test/build, combined-branch-test.ts reinstalls dependencies when the lockfile changed (compare lockfile vs the base, or install unconditionally). Use the detected package manager (this repo is pnpm; don't hardcode npm install).
  • AC-2: With deps reinstalled, a combined state whose branches only changed the lockfile (added a dep) reports npm test/npm run build passed — reproduce the fix: /qa should detect templates/scripts changes for verification #109-113-class scenario in a test/fixture and assert no false BLOCKED.
  • AC-3: When test/build genuinely fails, the finding message includes a non-empty reason: fall back to a stdout tail when stderr is empty (both truncated). No more failed on combined state: with nothing after it.
  • AC-4: Install failures themselves are surfaced distinctly (a bad merged lockfile → clear "dependency install failed" finding, not a downstream mystery test failure).
  • AC-5: Regression test covering: (a) lockfile-changed combined state passes after reinstall, (b) empty-stderr failure still yields a diagnosable message.

Notes

  • Mirrors what GitHub CI already does correctly (npm ci before test), which is why every individual PR was green while the local merge-check was red.
  • Impact: a false BLOCKED on a good stack is high-friction — it directly contradicts green PR CI and a clean worktree, and (empty errors) gives the user nothing to act on. Found while merging a real chain; had to override the verdict by hand after verifying build+test in the worktree.

Activity

  1. admarble commented on Jul 25, 2026

    @admarble
    ContributorAuthor

    Plan (/spec) — #803

    Complexity: Standard (5 ACs, 3 directories)


    AC Quality Check

    All 5 ACs pass the linter (no vague/unmeasurable/open-ended patterns). Two notes:

    1. AC markers were not parseable — issue body normalized. The ACs were written as - [ ] **AC-1** After … (bold ID, no colon). src/lib/ac-parser.ts requires the colon inside or immediately after the bold marker, so all four parser patterns missed and 0 ACs were extracted — state tracking and /qa would have had nothing to check against. I edited the issue body to - [ ] **AC-1:** … (formatting only, AC text untouched); all 5 now parse. Flagged as a follow-up candidate under Open Questions.

    2. AC-1's parenthetical is factually wrong for this repo. It says "(this repo is pnpm; don't hardcode npm install)". Sequant has package-lock.json and no pnpm-lock.yaml — it is an npm repo. The requirement (use the detected package manager rather than a hardcoded one) is still correct and worth implementing, because sequant merge --check runs in consumer projects that may be pnpm/yarn/bun. Implementing the requirement, ignoring the incorrect premise.


    Scope Assessment

    Non-Goals: ⚠️ Non-Goals section not found. Consider adding scope boundaries.

    Metric Value Status
    Feature count 3 ❌
    AC items 5 ✅
    Directory spread 1 ✅

    Verdict: ❌ SCOPE_SPLIT_RECOMMENDED — overridden, do not split.

    Reasoning: The red comes solely from the feature-count heuristic scoring three nouns (reinstall / error message / install-failure surfacing). All three are facets of one defect in one ~230-line file, and splitting would mean shipping the reinstall without the diagnostics that made the original failure unreadable. Directory spread is 1, AC count is green. Proceeding as a single change; quality loop left disabled.


    Acceptance Criteria

    AC-1: Reinstall deps after assembling the combined state, using the detected package manager

    Verification: Unit Test
    Scenario: Given a combined state whose merge changed a lockfile → When runCombinedBranchTest runs → Then a frozen install for the detected package manager is spawned before the first test/build spawn.
    Assumptions: detectPackageManagerSync() currently resolves lockfiles relative to process.cwd(), not to repoRoot — needs an optional root param (backward compatible). PM_CONFIG has no CI/frozen-install command yet — needs a ciInstall field.

    AC-2: Lockfile-only combined state no longer reports a false BLOCKED

    Verification: Unit Test
    Scenario: Given branches that only added a dependency (lockfile + package.json changed), and test/build that succeed once deps are installed → When merge-check runs → Then both findings are info ("passed") and result.passed === true.
    Assumptions: The #109–113 scenario is reproduced at the spawn-sequence level (mocked spawnSync), which is the layer the defect lives at — the missing install call. A live npm-install fixture would add minutes of wall-clock for no extra signal.

    AC-3: Failure findings always carry a non-empty reason

    Verification: Unit Test
    Scenario: Given a test/build failure with empty stderr and diagnostics on stdout → When the finding is built → Then the message contains a stdout tail, not a trailing empty string. Given both streams empty (e.g. timeout / signal kill) → Then the message states the exit code or signal.
    Assumptions: spawnSync timeouts produce status: null + empty stderr — the exact empty-message symptom — so the fallback chain must terminate in an exit-code/signal string, never "".

    AC-4: Install failures are surfaced distinctly

    Verification: Unit Test
    Scenario: Given the merged lockfile is inconsistent with package.json (frozen install fails) → When merge-check runs → Then a single error finding names dependency installation as the cause, and test/build are skipped (no downstream mystery failure).

    AC-5: Regression tests

    Verification: Unit Test
    Scenario: New src/lib/merge-check/combined-branch-test.test.ts covering (a) lockfile-changed state passes after reinstall, (b) empty-stderr failure yields a diagnosable message. Today runCombinedBranchTest has zero direct test coverage — only buildResult is tested.


    Implementation Plan

    Phase 1: Shared package-manager plumbing (src/lib/stacks.ts)

    1. Add ciInstall to PackageManagerConfig and to all 7 PM_CONFIG entries — npm ci, pnpm install --frozen-lockfile, yarn install --immutable, bun install --frozen-lockfile; Python entries reuse their existing quiet install. Frozen install is chosen deliberately: it mirrors what green PR CI does (the issue's own diagnosis), it does not rewrite the lockfile (a mutating npm install would dirty the temp branch and make the git checkout <original> in the finally block fail), and a bad merged lockfile fails it loudly — which is exactly AC-4's signal.
    2. Give detectPackageManagerSync(root = process.cwd()) an optional root so merge-check can detect against repoRoot rather than the process cwd. Existing caller (version-check.ts:371) is unaffected.

    Phase 2: Fix combined-branch-test.ts

    1. Generalize the npm() helper into runPm(command, cwd, timeoutMs) that takes a resolved command string from PM_CONFIG and a per-step timeout (install gets a longer budget than test/build).
    2. Add resolveFailureReason(result) — first non-empty of: stderr head-500 → stdout tail-500 → spawn error.message → killed by signal X / exited with code N. Guaranteed non-empty. (AC-3)
    3. Add lockfileChanged(repoRoot, baseRef) — git diff --name-only <base> HEAD -- <lockfiles>, reusing the same lockfile list worktree-manager.ts already uses.
    4. After the merge loop and before test/build: if the lockfile changed, run ciInstall. On failure → push one error finding naming dependency installation, include resolveFailureReason, and return early without running test/build. (AC-1, AC-4)
    5. Route test and build through the detected manager's run command instead of hardcoded npm, and embed the actual command in every finding message. (Consistency with AC-1; keeps AC-3's failed on combined state: phrasing.)
    6. Restructure the try/finally so cleanup findings can be appended: today return buildResult(...) inside try freezes passed before finally runs, so anything pushed during cleanup would silently not affect the verdict. Compute findings in the try, build the result after the finally.
    7. Restore the caller's node_modules (derived — see below): if we installed, re-run the non-frozen install after the original branch is restored, so the user isn't left with the combined state's dependency tree. Best-effort; emits a warning finding with a manual-fix hint if it fails.

    Phase 3: Tests + docs

    1. New src/lib/merge-check/combined-branch-test.test.ts with a mocked spawnSync (the pattern merge-check-extended.test.ts already uses): AC-2 happy path asserting install-before-test ordering, AC-3 empty-stderr and empty-both cases, AC-4 install-failure short-circuit, plus a no-lockfile-change case asserting install is skipped.
    2. Update docs/reference/merge-command.md:159-160 sample output for the new finding wording, and extend stacks.test.ts for ciInstall.

    Design Review

    1. Where does this logic belong? Package-manager command strings belong in src/lib/stacks.ts (already the single source of truth — worktree-manager.ts, update.ts both consume PM_CONFIG). The merge/install/test sequencing belongs in combined-branch-test.ts. No new module.
    2. What's the simplest correct approach? A conditional frozen install between the merge loop and the test run, plus a shared failure-reason resolver. Rejected: installing unconditionally (adds ~30–60s to every merge-check, including the common no-dep-change case); rejected: a full temp-git-repo integration fixture (minutes of wall-clock to prove a fact about spawn ordering that a mocked sequence proves exactly).
    3. What existing pattern does this follow? reinstallIfLockfileChanged() in worktree-manager.ts:1127 — same "diff the lockfile against a ref, reinstall if changed" shape, same LOCKFILES list, same PM_CONFIG lookup. Deliberately not extracted into a shared util yet: that function is rebase-specific (ORIG_HEAD, chalk console output, boolean return) while this one must emit CheckFindings and short-circuit. Noted as a future consolidation, not done here.
    4. What would a senior reviewer challenge?
      • "Why npm ci instead of npm install?" — because npm install rewrites the lockfile, dirtying the temp branch and breaking the finally checkout. Answered inline in the code comment.
      • "You're mutating the user's node_modules." — yes; step 9 restores it. Called out as a derived AC so it can be argued down.
      • "Mocked spawnSync isn't a real reproduction of fix: /qa should detect templates/scripts changes for verification #109–113." — the defect is a missing call in a command sequence; the mock asserts on that sequence. Stated in AC-2's assumptions.

    Feature Quality Planning

    Notable items:

    • Test/build timeout is 120s and produces an empty error message on expiry. spawnSync(..., {timeout: 120_000}) returns status: null with empty stderr when it fires — a second, independent path to the same "empty reason, false BLOCKED" symptom this issue reports. A 929-test suite plus a 4-workspace build can plausibly exceed 2 minutes on a cold cache. AC-3's fallback chain makes it diagnosable; raising the budget makes it not happen.
    • node_modules side effect (Phase 2 step 9) — without it, this fix leaves the user's repo installed against the combined lockfile after the check restores their original branch. Ironic failure mode given the issue.
    • Sibling-site scan: the "report stderr only" pattern has exactly one other instance in merge-check/ (report.ts:320, a gh pr comment failure) — gh reliably writes to stderr there, so no value in changing it. Below the ≥3-instance bar; no scope expansion recommended.

    Derived ACs

    Source Derived AC Priority
    Error handling AC-6: Test/build/install timeouts get budgets that don't fire on a healthy repo, and an expired timeout produces a message naming the timeout — not an empty reason Medium
    Side effects AC-7: After the check restores the original branch, node_modules is restored to that branch's state (or the user is explicitly told it wasn't) Medium

    Open Questions

    1. Should the AC parser accept - [ ] **AC-1** Desc (bold ID, no colon)? — Recommendation: file a separate follow-up against src/lib/ac-parser.ts; it's a different module and out of scope here. Impact if not fixed: every issue written in that (very common) style silently yields zero ACs, and /qa has nothing to verify — a silent failure, not a loud one. Normalized fix(merge-check): combined-branch-test runs npm test/build without reinstalling deps after a lockfile change → false BLOCKED #803's body in the meantime.
    2. Restore node_modules after the check, or just warn? — Recommendation: restore (AC-7), best-effort with a warning finding on failure. Impact if wrong: one extra incremental install per merge-check that hit a lockfile change; harmless but slower.
    3. Route test/build through the detected package manager too, or only the install? — Recommendation: route both. AC-1 only mandates the install, but installing with pnpm and then testing with npm test is incoherent. Impact: finding-message wording changes, so docs/reference/merge-command.md needs a matching update (included in the plan).

    Rule Touchpoints

    None — the behavior-rule detector short-circuits on all 5 ACs (0 keyword hits). Section omitted.


    Conflict Risk Analysis

    Two other worktrees exist (feature/782-*, feature/795-*), both sitting at origin/main with zero commits — no file overlap, no conflict risk. No Depends on / Blocked by markers in the issue body.


    Recommended Workflow

    Phases: spec → exec → qa
    Quality Loop: disabled
    Reasoning: Single-file bugfix with precise, mostly unit-testable ACs. No UI surface → no /test phase. Skipping testgen: AC-5 already specifies the exact test cases, so generating stubs first adds a round-trip without adding information.


    Label Review

    Current: (none)
    Recommended: bug, no-browser-test
    Reason: It's a defect fix, not an enhancement; no-browser-test is the explicit opt-out that keeps /fullsolve from probing for a UI surface that doesn't exist.
    Quality Loop: Won't auto-enable — the SCOPE_SPLIT_RECOMMENDED verdict is an overridden false positive (single file, 1 directory), so the yellow/red auto-enable is not honored here.

  2. added
    planned
    bug
    no-browser-test
    on Jul 25, 2026
  3. added 2 commits that reference this issue on Jul 25, 2026
  4. admarble commented on Jul 25, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #803

    PR: #806 · Branch: feature/803-fix-merge-check-combined-branch-test-runs-npm- · HEAD: 7d4a54e

    Size Gate

    Check Value
    Diff size 827 lines (threshold: 100)
    package.json changed No
    Security-sensitive paths No
    Decision Sub-agents (standard pipeline)

    Deviation, stated: the review below was done inline, not via sequant-qa-checker sub-agents. Reason: the substantive change is one 430-line file plus its new test file, and QA sub-agents have a track record of hallucinating about worktree contents. The mechanical checks the agents would have run (type-safety, deleted-tests, scope, security grep) were executed directly and are reported verbatim below.


    AC Coverage

    AC Source Description Status Notes
    AC-1 Original Reinstall deps after assembling the combined state, before test/build, using the detected package manager MET combined-branch-test.ts:355-380. lockfileChanged(repoRoot, "origin/main") gates it; detectPackageManagerSync(repoRoot) picks the manager; pmConfig.ciInstall is the command. Literal check on "before running test/build": the test asserts spawn-index ordering, not just presence — installIdx < testIdx and installIdx < buildIdx. Not hardcoded npm install anywhere.
    AC-2 Original Lockfile-only combined state reports test/build passed — no false BLOCKED MET Test "does not report a false BLOCKED for a lockfile-only combined state" asserts result.passed === true, zero error findings, and the three expected info messages. The #109-113 shape (branches touched package.json + package-lock.json) is the fixture's filesModified.
    AC-3 Original Failure message includes a non-empty reason; stdout tail when stderr empty; both truncated MET resolveFailureReason() at :119-141. Literal check on each clause: stdout tail (truncateTail, :150-154) ✅; stderr truncated (truncateHead, :144-148) ✅; never empty — terminal branch returns exited with code N ✅. Two end-to-end tests assert not.toMatch(/failed on combined state:\s*$/), which is the exact symptom string from the issue.
    AC-4 Original Install failures surfaced distinctly, not as a downstream mystery test failure MET :365-372 pushes one error finding naming dependency installation and returns early. The test asserts both halves: the finding text, and that npm run test / npm run build were never spawned and no test-related finding exists. The "not a downstream mystery" clause is what the early return buys.
    AC-5 Original Regression test covering (a) lockfile-changed passes after reinstall, (b) empty-stderr failure is diagnosable MET New combined-branch-test.test.ts, 17 cases. (a) and (b) both present. Regression value measured, not assumed — see Adversarial Re-Read.
    Derived ACs
    AC-6 Derived (Error Handling) Timeouts don't fire on a healthy repo; an expired timeout is named, not empty MET INSTALL_TIMEOUT_MS = 300_000, TEST_BUILD_TIMEOUT_MS = 600_000 (was a flat 120_000). resolveFailureReason has a dedicated signal branch; test "names the signal when the command was killed (timeout)".
    AC-7 Derived (Side effects) node_modules restored after the check, or the user is told MET :214-238. Restores with a frozen install after the branch checkout; on failure emits a warning finding with the exact remediation command. Two tests: ordering (one install either side of git checkout main) and the warning path.

    Coverage: 7/7 AC items fully met
    Original ACs: 5/5 met · Derived ACs: 2/2 met

    Note on AC-1's premise: AC-1 parenthesizes "(this repo is pnpm; don't hardcode npm install)". Sequant has package-lock.json and no pnpm-lock.yaml — it is an npm repo. The requirement is implemented as written (detect, don't hardcode), because merge --check runs in consumer projects that may be pnpm/yarn/bun; only the parenthetical is factually wrong. Flagged rather than silently followed.


    Quality Plan Verification

    Dimension Items Planned Items Addressed Status
    Completeness 5 AC 5 ✅ Complete
    Error Handling 2 (timeout diagnosability, install-failure surfacing) 2 ✅ Complete
    Code Quality 2 (frozen-install rationale documented, try/finally restructure) 2 ✅ Complete
    Test Coverage 2 (AC-5 a/b) 2 (plus 15 more) ✅ Complete
    Best Practices 1 (reuse PM_CONFIG / LOCKFILES rather than new detection) 1 ✅ Complete
    Polish N/A N/A – (not a UI feature)

    Derived ACs: 2/2 addressed
    Quality Plan Status: Complete


    CI Status

    Check State Bucket Impact
    typecheck SUCCESS pass ✅ MET
    build (22.x) SUCCESS pass ✅ MET
    node-floor-guard SUCCESS pass ✅ MET
    validate-skills SUCCESS pass ✅ MET
    validate-plugin SUCCESS pass ✅ MET

    CI Summary: 5 passed, 0 pending, 0 failed (run 30145981343, on final commit 7d4a54e)
    CI-related AC items: none — no AC references CI.


    Quality Metrics

    Metric Value Status
    Type issues (any / as any on added lines) 0 OK
    Deleted tests 0 OK
    Files changed 6 OK
    Lines added +746 OK (455 of them the new test file)
    Lines deleted −135 OK
    Security patterns on added lines 0 OK

    Build Verification

    N/A — npm run build passes on the feature branch (tsc, clean).


    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    src/lib/merge-check/combined-branch-test.ts Standard ✅ Yes (new) src/lib/merge-check/combined-branch-test.test.ts
    src/lib/stacks.ts Standard ✅ Yes src/lib/stacks.test.ts (extended for ciInstall)

    Coverage: 2/2 changed source files have corresponding tests
    Critical paths without tests: None. Before this PR runCombinedBranchTest had zero direct coverage — only buildResult was tested.

    Local results: npx vitest run src/lib/merge-check/ → 68 passed. Full npm test → 4056 passed, 2 failed; both failures (lock-manager.integration, phase-registry.integration) are pre-existing worktree-environment flakes — they pass on main, and running them in this worktree with the changes stashed produced 3 failures, i.e. more without the PR than with it. Both are subprocess-spawn tests hitting a 5s timeout under worktree cold-start. CI (which runs on a clean checkout) is fully green.


    Code Review

    Strengths:

    • The frozen-install choice is load-bearing and documented at the call site, not just in the commit. A plain npm install would rewrite the lockfile, dirty the temp branch, and break the git checkout <original> during cleanup — a failure mode that would have been maddening to diagnose.
    • Reuses PM_CONFIG and mirrors worktree-manager.ts's existing LOCKFILES list rather than inventing a second detection path.
    • The try/finally restructure is a real correctness fix, not cosmetics: the original return buildResult(...) inside try evaluated passed before finally ran, so any finding pushed during cleanup would have appeared in the array but silently failed to affect the verdict. Findings are now collected in the try and the result is built after cleanup.
    • detectPackageManagerSync(root = process.cwd()) is genuinely backward compatible — all three existing callers (version-check.ts:371, bin/cli.ts:145, bin/cli.ts:538) call it with no arguments.

    Issues found and fixed during this review (both committed, both re-verified):

    1. The restore install was mutating. Cleanup originally used pmConfig.installSilent (npm install --silent), which normalizes and rewrites package-lock.json — so the restore step could leave the user's own branch with a dirty tree, the exact hazard the forward install was made frozen to avoid. Not theoretical: this worktree's own new-feature.sh npm install stripped libc fields from package-lock.json earlier in this session. Fixed in af0494a; two tests now assert the mutating variant is never spawned.
    2. runCommand name collision. src/commands/run.ts already exports runCommand (the CLI run entry point). A second unrelated runCommand made grepping for either ambiguous — it cost time during this very review. Renamed to runPackageManagerCommand in 7d4a54e.

    Suggestions (non-blocking, not filed):

    • reinstallIfLockfileChanged() in worktree-manager.ts:1127 now shares the "diff lockfiles against a ref, reinstall" shape with lockfileChanged() here. Deliberately not extracted: that one is rebase-specific (ORIG_HEAD, chalk output, boolean return) while this one emits CheckFindings and short-circuits. Worth revisiting if a third caller appears.
    • spawnSync("npm", …) without shell: true does not resolve npm.cmd on Windows. Pre-existing — the original npm() helper had the identical problem — so not a regression from this PR, and the whole merge-check path is Unix-oriented today.

    Test Quality Review

    Category Status Notes
    Behavior vs Implementation ✅ OK Assertions are on the observable spawn sequence and on returned findings — which is precisely where the defect lived (a missing call between merge and test). Not on internals.
    Coverage Depth ✅ OK Both success and failure paths for install, test, and build; skip-install path; empty-stderr, empty-both, spawn-error, and signal cases; restore ordering and restore failure.
    Mock Hygiene ✅ OK Exactly one module mocked (child_process), the established pattern in merge-check-extended.test.ts.
    Test Reliability ✅ OK No timers, no real I/O, no network. mockSpawnSync.mockReset() in beforeEach. detectPackageManagerSync("/repo") finds no lockfile and deterministically falls back to npm.

    Issues Found: None.


    Anti-Pattern Detection

    Dependency Audit: N/A — package.json unchanged.

    Code Patterns: No await in loop, no empty catch, no hardcoded secrets, no SQL concatenation, no 0.0.0.0 bind, no uncleared timer. spawnSync timeouts are bounded and now diagnosable.

    Critical Issues: 0 · Warnings: 0


    Call-Site Review

    New exported symbols: 4 (CommandResult, runPackageManagerCommand, resolveFailureReason, lockfileChanged) + 1 signature change (detectPackageManagerSync)

    Symbol Call Sites Loop? Conditions AC Match
    runPackageManagerCommand :223 (restore), :356 (install), :383 (test), :400 (build) No Restore gated on installedCombinedDeps; install gated on lockfileChanged ✅ Matches AC-1, AC-7
    resolveFailureReason :232, :369, :394, :415 No Called on every failure branch — all four ✅ Matches AC-3 (no failure path bypasses it)
    lockfileChanged :355 No if (lockfileChanged(repoRoot, BASE_REF)) ✅ Matches AC-1 ("when the lockfile changed")
    detectPackageManagerSync(root?) :189 (new, passes repoRoot); pre-existing: version-check.ts:371, bin/cli.ts:145, bin/cli.ts:538 No Pre-existing callers pass no arg → default process.cwd() ✅ Backward compatible, no behavior change
    CommandResult Type-only, used by the two exported functions and the test – – ✅

    Findings: No mismatches. Every new export is reachable; no dead exports. installedCombinedDeps is deliberately set to true before the install's success is checked, because a failed npm ci may already have wiped node_modules — so restore must still run. Confirmed correct by reading :358-373.


    Execution Evidence

    Test Type Command Exit Code Result
    Smoke test npx tsx bin/cli.ts merge --help 0 ✅ Command intact, all flags render
    Build npm run build 0 ✅
    Lint npm run lint (--max-warnings 0) 0 ✅
    Unit npx vitest run src/lib/merge-check/ 0 ✅ 68 passed

    Evidence status: Complete

    Note on scope: scripts/ was not modified — the change is in src/lib/, reached via sequant merge --check. A live end-to-end merge --check run against a real multi-branch lockfile-changing batch was not executed; it requires a purpose-built 2+ branch stack and would run a real npm ci plus the full suite. The spawn-sequence tests cover the defect exactly (the missing call), and the smoke test confirms the command surface is intact. Recorded here as the honest boundary of what was executed.


    Skill Command Verification

    N/A — no .claude/skills/**/*.md files changed.

    Detection Pattern Verification

    N/A — no skill markdown changed, so the §6c hard precondition is false.

    CLI Registration Verification

    N/A — no RunOptions or other CLI option-interface fields added. bin/cli.ts unchanged.

    Behavior-Rule Survival Check

    N/A — the behavior-rule detector was run against all 5 ACs during /spec; zero triggered (0 keyword hits each).

    Manual Test ACs

    N/A — the spec plan assigns Unit Test verification to all 5 original ACs and both derived ACs. No Manual Test ACs detected.

    Smoke Test

    Test Command Result Notes
    Happy path npx tsx bin/cli.ts merge --help ✅ Exit 0, full flag list renders
    Edge case git diff --name-only origin/main HEAD -- <5 lockfile paths> with 4 of 5 absent ✅ Exit 0, empty output — confirms lockfileChanged doesn't error on pathspecs matching nothing

    Smoke Test Status: Complete


    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅ Found
    User-facing changes ✅ Yes (fix(#803): commits)
    [Unreleased] entry ✅ Present, under ### Fixed
    Entry format ✅ Valid — action verb, issue number (#803), correct section

    Result: CHANGELOG requirements met


    Risk Assessment

    • Likely failure mode: A npm ci that fails for an environmental reason unrelated to the merge (registry outage, disk full, corrupted cache) now produces an error finding and skips test/build — turning a transient infra problem into a BLOCKED verdict. This trades one false BLOCKED for a narrower one, but the new message names dependency installation and quotes the real reason, so it's diagnosable in seconds rather than being an empty string. Second-order: npm ci deletes and rebuilds node_modules, so a merge-check on a lockfile-changing batch is now materially slower (two full frozen installs) — correctness bought with wall-clock.
    • Not tested: No live end-to-end merge --check against a real multi-branch stack that actually changes a lockfile (see Execution Evidence). The mocked spawn sequence proves the ordering; it does not prove npm ci behaves as expected inside a temp-branch checkout on every platform. Windows npm.cmd resolution remains untested (pre-existing).
    • Sibling sites considered: Cross-file scan of src/lib/merge-check/ for the same "report stderr only" root cause found exactly one other instance — report.ts:320, a gh pr comment failure, where gh reliably writes to stderr. Below the ≥3-instance bar and low value; no scope expansion, no follow-up filed. The related "reinstall on lockfile change" logic in worktree-manager.ts:1127 was checked and is correct there (it already reinstalls).
    • Sibling-line audit: Intra-file — all four failure-reporting sites in combined-branch-test.ts (:232 restore, :369 install, :394 test, :415 build) share the root-cause pattern and all four route through resolveFailureReason. Verified by grep, not assumed: the only other stderr interpolation left in the file is :250 (Failed to create temp branch), where git checkout -b reliably populates stderr.

    Adversarial Re-Read

    Findings:

    1. Regression value was measured, not asserted. I re-ran the new suite against a simulated pre-fix implementation (install branch disabled, resolveFailureReason reduced to stderr.slice(0, 500)): 13 of 16 failed. The 3 that passed are the ones that should be behavior-independent (skip-install-when-unchanged, prefer-stderr, truncate-stderr-head). This rules out the tautological-test class.
    2. Two real defects surfaced and were fixed mid-review — the mutating restore install and the runCommand collision (both detailed under Code Review). Neither was caught by the structured pipeline; both came from re-reading the diff against its own stated rationale ("we chose frozen so we don't dirty the tree" — then the cleanup path used a mutating install).
    3. Evidence claims audited. The "13/16 fail" figure is a post-fix measurement against a simulated old implementation, not a pre-fix bug repro dressed up as validation. The 2 full-suite failures are backed by a differential: stashing the changes in the same worktree yields more failures (3), which is what makes "pre-existing" a measurement rather than an assumption.
    4. Process state inspected. git status clean; branch 0 commits behind origin/main; 3 commits ahead, all pushed; no stashes left (the two diagnostic stashes were popped and verified). One trap caught: new-feature.sh's npm install had silently modified package-lock.json (stripping libc fields) — reverted before the first commit, so no unrelated lockfile churn is in the PR.
    5. Non-Goals check. The issue body has no Non-Goals section (flagged in /spec). Two things went beyond AC-1's literal text and are called out rather than smuggled: routing test/build through the detected manager (AC-1 mandates only the install), and raising the timeouts. Both are stated in the PR body and the CHANGELOG.
    6. A near-miss worth recording: a sed -i '' 's/\brunCommand\b/…/' rename silently did nothing (BSD sed has no \b). It was caught because the follow-up grep -c returned 0 and git diff --stat was empty — not because anything failed loudly. Had I trusted the exit code, the rename commit would have been empty.

    Status: Gaps Found — two defects were surfaced and fixed within this PR; no AC is left unmet, and no fixture went unrun.


    Verdict: AC_MET_BUT_NOT_A_PLUS

    All 7 ACs (5 original + 2 derived) are MET, CI is fully green on the final commit, and the new tests demonstrably fail against the old behavior. The verdict is one notch below READY_FOR_MERGE for one reason, per the §7 algorithm: the adversarial re-read reached Gaps Found, having surfaced two genuine defects (a mutating restore install that could dirty the user's tree, and an export-name collision) that the structured checks did not catch. Both are fixed and verified in this PR — but the honest record is that a second pass was required to reach this state, and "no live end-to-end merge --check run" remains a stated coverage boundary.

    This is merge-ready. The distinction from A+ is that the first pass shipped a defect of the same family as the bug being fixed.

    Documentation

    • docs/reference/merge-command.md updated — both the check-description table row and the sample report output
    • CHANGELOG [Unreleased] entry added under ### Fixed
    • README — N/A (no new command, flag, or user-facing surface)

    Next Steps

    1. Merge PR fix(#803): reinstall deps in merge-check's combined-branch test #806 (gh pr merge 806 --squash), then clean up the worktree.
    2. Optional follow-up, not filed: src/lib/ac-parser.ts does not match - [ ] **AC-1** Desc (bold ID, no colon) — all four patterns require the colon. This issue's ACs originally parsed as zero items; the body was normalized during /spec to unblock state tracking. It is a silent failure mode (/qa would have had nothing to verify) affecting a very common authoring style, and is worth its own issue against the parser.
  5. added
    needs-improvement
    on Jul 25, 2026
  6. admarble commented on Jul 25, 2026

    @admarble
    ContributorAuthor

    /fullsolve Complete

    Issue: #803 · PR: #806 · Verdict: AC_MET_BUT_NOT_A_PLUS

    Summary

    Phase Iterations Status
    Spec 1/1 Complete
    Exec 1/1 Complete
    Test — Skipped (no-browser-test, no UI surface)
    QA 1/2 Complete
    • AC: 7/7 met (5 original + 2 derived)
    • CI: 5/5 green on final commit 7d4a54e
    • Tests: 68 passed in src/lib/merge-check/; new suite has 17 cases, 13 of which fail against the pre-fix behavior
    • Build / Lint: clean

    Key changes

    • src/lib/merge-check/combined-branch-test.ts — diff lockfiles vs origin/main, run a frozen install for the detected package manager before test/build; install failures become their own finding and skip test/build; resolveFailureReason() guarantees a non-empty reason; timeouts raised and named; node_modules restored after the branch restore
    • src/lib/stacks.ts — added ciInstall to PM_CONFIG; detectPackageManagerSync(root?) now targets a given repo root
    • src/lib/merge-check/combined-branch-test.test.ts — new (previously zero direct coverage for runCombinedBranchTest)
    • CHANGELOG.md, docs/reference/merge-command.md updated

    Why not READY_FOR_MERGE

    The adversarial re-read reached Gaps Found: it surfaced two real defects that the structured checks missed — a mutating restore install that could dirty the user's own branch (the same hazard the forward install was made frozen to avoid), and a runCommand export-name collision with src/commands/run.ts. Both are fixed and verified in this PR. The verdict reflects that a second pass was needed, not an outstanding gap.

    Stated coverage boundary: no live end-to-end merge --check was run against a real multi-branch lockfile-changing stack; the defect is covered at the spawn-sequence level.

    Next steps

    1. Review and merge fix(#803): reinstall deps in merge-check's combined-branch test #806 — not auto-merged, per policy.
    2. Optional follow-up, not filed: src/lib/ac-parser.ts silently returns zero ACs for - [ ] **AC-1** Desc (bold ID, no colon). This issue's ACs hit exactly that; the body was normalized during /spec to unblock state tracking.
  7. added a commit that references this issue on Jul 25, 2026
  8. admarble commented on Jul 25, 2026

    @admarble
    ContributorAuthor

    QA gaps closed

    Every gap the QA review recorded as a stated limitation is now fixed. Verdict moves to READY_FOR_MERGE.

    # Gap (from QA) Resolution Commit
    1 No live end-to-end run against a real multi-branch lockfile-changing stack combined-branch-test.integration.test.ts — 8 cases on real git; 5 fail against pre-fix behavior 1356c24
    2 Windows npm.cmd unresolvable (pre-existing) shell: true on win32 only 1356c24
    3 node_modules restore lost if runChecks throws Mutable InstallState; flag set before the install runs 1356c24
    4 report.ts:320 reports stderr only — sibling of this bug Extracted command-result.ts; both call sites routed through it 1356c24
    5 ac-parser.ts silently returns zero ACs for bold-no-colon Filed as #808, fixed in #809 (separate module) —

    On gap 1

    The integration test uses a real bare origin, a real clone, real feature branches, a real git merge into a real temp branch, and the real git diff that decides whether the lockfile moved. Only the package manager is stubbed — a shell script named npm, first on PATH, logging its argv and exiting with a configurable code.

    Building it surfaced a fixture bug worth recording: my first attempt had both branches write the same package-lock.json object, so real git conflicted and the check early-returned before ever reaching the install. The fixture now reserves one padded, non-adjacent lockfile slot per branch so git auto-merges — which is what actually reproduces the #109-113 shape. A mocked test could not have caught that; the merge was fake there.

    Verification

    Revised verdict: READY_FOR_MERGE

    The earlier AC_MET_BUT_NOT_A_PLUS was driven by the adversarial re-read reaching Gaps Found. Those gaps are closed, the sibling site is fixed rather than argued down, and the coverage boundary that justified the downgrade no longer exists.

    Merge order: #809 (parser, independent) and #806 (merge-check) touch disjoint files — either order works.

  9. added
    ready-for-review
    and removed
    needs-improvement
    on Jul 25, 2026
  10. added a commit that references this issue on Jul 25, 2026
  11. added 5 commits that reference this issue on Jul 25, 2026
  12. added 4 commits that reference this issue on Sep 9, 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

    bugno-browser-testplannedready-for-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions