Skip to content

fix(#883): spawn the CLI flag-surface tests in a manifest-less temp dir - #884

Merged
admarble merged 1 commit into
mainfrom
feature/883-fix-test-cli-integration-flag-surface-tests-as
Jul 30, 2026
Merged

admarble merged 1 commit into
mainfrom
feature/883-fix-test-cli-integration-flag-surface-tests-as

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

Four run command flag surface (#705) tests failed on any locally sequant init'd clone while passing in CI.

They assert on run.ts's not-initialized pre-flight guard as a proxy for "Commander parsed this flag", and spawned the CLI with cwd: projectRoot. The comment claimed the repo root "is not itself an initialized Sequant project" — true only on a fresh checkout. The guard fires on getManifest() returning null, and MANIFEST_PATH is cwd-relative with no upward walk, so whether it fires depends entirely on the spawn cwd. .sequant-manifest.json is gitignored:

Environment manifest guard fires result
CI (fresh checkout) absent yes 4 pass
locally init'd clone present no 4 fail

So npm test could not go green on a dev machine that had ever run sequant init. Same family as #842 and #880 — a test coupled to ambient environment rather than to what it means to assert.

Fix

Spawn in a directory the test creates itself — manifest-less by construction in both environments. Added a positive control (AC-3) asserting an unknown option is rejected and never reaches the guard, so the proxy can't pass vacuously. Corrected the stale comment (AC-4).

The temp-dir cleanup guards its own recursive delete against any path outside tmpdir(). Not hypothetical: while mutation-testing this, pointing cwd at projectRoot with the cleanup in place deleted the worktree. The guard turns that class of edit into a loud failure.

Verification

Run with a manifest copied in, reproducing an init'd clone:

State Result
Fixed code 17/17 pass
Pre-fix code 4 failed / 16
Mutation: spawn back in projectRoot 4 fail (reproduces #883)
Mutation: positive control given a real flag control fails (not vacuous)

Known: pre-existing tautology-detector false positive

npm test on this branch also fails 3 tautology-detector-cli tests. Not caused by this change — the detector scans only files in git diff main...HEAD, and this file scores 100% tautological at origin/main too (16/16 there, 17/17 here). Its heuristic can't see assertions made on subprocess stdout/stderr, which is exactly how this integration file works by design. Any PR touching this file trips it. Tracked separately rather than silenced here.

Closes #883

Generated with Claude Code

The four `expectFlagAccepted` tests assert on run.ts's not-initialized
pre-flight guard as a proxy for "Commander parsed this flag". They spawned the
CLI with `cwd: projectRoot` and the comment claimed the repo root "is not itself
an initialized Sequant project" -- true only on a fresh checkout.

The guard fires on `getManifest()` returning null, and MANIFEST_PATH is
cwd-relative with no upward walk, so whether it fires depends entirely on the
spawn cwd. `.sequant-manifest.json` is gitignored (.gitignore:35), so:

  CI (fresh checkout)      -> no manifest -> guard fires -> 4 tests pass
  any locally init'd clone -> manifest    -> guard silent -> 4 tests FAIL

meaning `npm test` could not go green on a dev machine that had ever run
`sequant init`, while CI stayed green. Same family as #842 and #880: a test
coupled to ambient environment rather than to what it means to assert.

Fixed by spawning in a directory the test creates itself, which is manifest-less
by construction in both environments. Added a positive control asserting an
unknown option IS rejected and never reaches the guard, so the proxy cannot pass
vacuously (AC-3). Corrected the stale comment (AC-4).

The temp-dir cleanup guards its own recursive delete against a path outside
`tmpdir()`. That is not hypothetical: while mutation-testing this change I
pointed `cwd` at `projectRoot` with the cleanup still in place and it deleted
the worktree. The guard turns that class of edit into a loud failure.

Verified in both environments: with a manifest copied into the worktree
(reproducing an init'd clone) the suite is 17/17; the pre-fix code is 4/16 there.
@admarble
admarble merged commit 11a90c8 into main Jul 30, 2026
5 checks passed
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(test): cli.integration flag-surface tests assert on the not-initialized guard, so they fail on any locally init'd clone

1 participant