Skip to content

fix(#848): pre-flight rejections exit non-zero across run/update/state/status/init - #852

Merged
admarble merged 3 commits into
mainfrom
feature/848-sequant-run-exits-0-on-pre-flight-rejections-not-i
Jul 29, 2026
Merged

admarble merged 3 commits into
mainfrom
feature/848-sequant-run-exits-0-on-pre-flight-rejections-not-i

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

sequant run printed a red error but returned exit code 0 on two pre-flight rejection paths (not-initialized, --stacked + --no-chain), so any CI wrapper or shell script gating on $? read the failure as success. Both bare-returned instead of setting process.exitCode = 1.

Following AC-3, an audit of every console.log(chalk.red(…)) + bare-return pair across src/commands/ found the defect was wider than the two named sites — and turned up three sites the issue's own audit table missed (status.ts).

Pre-PR AC Verification

AC Source Description Status Evidence
AC-1 Original not-initialized path sets non-zero exit ✅ run.ts:55; test run-preflight-exit.test.ts + e2e (exit 1)
AC-2 Original --stacked+--no-chain sets non-zero exit ✅ run.ts:64; test + e2e (exit 1)
AC-3 Original audit confirms no other error path exits 0 ✅ full audit below; all sites fixed + tested

AC-3 audit — every command-level rejection now sets process.exitCode = 1

Site Path In issue? Fixed
run.ts not-initialized AC-1 yes ✅
run.ts --stacked+--no-chain AC-2 yes ✅
run.ts --chain+--batch no (same class) ✅
run.ts invalid --concurrency no (same class) ✅
update.ts not-initialized no — issue wrongly cited as correct ✅
state.ts init / rebuild / clean failures no ✅ (+ --json branches)
status.ts --rebuild / --cleanup / state-read no — missed by the issue's audit table ✅ (+ --json branches)
init.ts --upgrade-skills no-skills-dir no (site 9) ✅
locks.ts (×3), dashboard.ts already set exit codes — no change

Design notes

  • Uses process.exitCode = 1, not process.exit(1), matching the sync.ts:274 reference so pending output/cleanup drains naturally.
  • --json failure branches in state/status also set the code so scripted consumers reading structured output can still gate on $?.
  • Issue premise correction: update.ts was not a correct reference — its not-initialized branch had the identical bug. Only sync.ts set the code on that branch.

Test plan

  • npm run build — passes
  • npm run lint — passes (0 warnings)
  • Unit tests per fixed site + a negative test (a passing pre-flight leaves the exit code unset)
  • Mutation-verified: reverting the run.ts AC-1 fix fails exactly the AC-1 test, nothing else
  • E2E: the issue's repro (run 999999 --dry-run in an uninitialized dir) now exits 1 (was 0); update and the --stacked+--no-chain conflict likewise

Closes #848

…exit non-zero

Two sequant run pre-flight paths (not-initialized, --stacked/--no-chain)
printed a red error but bare-returned at exit 0, so CI/shell gating on $?
read the failure as success. The AC-3 audit found the same defect across
run.ts (+2 sites), update.ts, state.ts, status.ts (3 sites the issue's own
table missed), and init.ts --upgrade-skills.

Each rejection now sets process.exitCode = 1 (not process.exit(1), matching
the sync.ts reference so output/cleanup drains). --json failure branches in
state/status also set the code so scripted consumers can gate on $?.

Adds unit tests per fixed site plus a negative test pinning that a passing
pre-flight leaves the exit code unset.

Entire-Checkpoint: 687aaddd9868
admarble added 2 commits July 29, 2026 00:59
…ialized dir

The #848 exit-code fix makes run.ts's not-initialized guard exit 1 (was 0).
The four run flag-parsing tests in cli.integration.test.ts used exit-0 as a
"Commander parsed OK" proxy, so they broke on the corrected behavior.

Replace the runDryRun helper with expectFlagAccepted: spawnSync the command and
assert it reached the not-initialized guard (which only prints after all flags
parse successfully) and was not rejected as an unknown option. This asserts the
actual intent — the flag is accepted by Commander — independent of the exit code.
Mutation-verified: an unknown flag fails the assertion.

Entire-Checkpoint: 55ace59dac43
…-code fix

The four process.exitCode=1 inserts pushed run.ts from 199 to 203 lines, over
the #503 AC-2 thin-adapter cap enforced by run-orchestrator.integration.test.ts.

Consolidate the four pre-flight rejections into a rejectPreflight() helper that
prints the red message and sets process.exitCode. This satisfies both the exit-
code requirement (#848) and the LOC cap, and reads better than four repeated
console.log + exitCode + return triples. Behavior is unchanged — verified by
run-preflight-exit.test.ts (all sites still set exit 1) and the LOC test.

Entire-Checkpoint: 2897c1e3fa4f
@admarble
admarble merged commit c17d27a into main Jul 29, 2026
5 checks passed
@admarble
admarble deleted the feature/848-sequant-run-exits-0-on-pre-flight-rejections-not-i branch July 29, 2026 06:33
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.

sequant run exits 0 on pre-flight rejections (not-initialized, --stacked/--no-chain conflict)

1 participant