Skip to content

fix(cli): tunnel moc exit code so compiler crashes are distinguishable#605

Merged
Kamirus merged 1 commit into
mainfrom
cli/tunnel-moc-exit-code
Jun 30, 2026
Merged

fix(cli): tunnel moc exit code so compiler crashes are distinguishable#605
Kamirus merged 1 commit into
mainfrom
cli/tunnel-moc-exit-code

Conversation

@Kamirus

@Kamirus Kamirus commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

mops build, mops check, mops generate, mops check-stable, and mops test now exit with moc's process exit code instead of always 1. CLI output is unchanged — use $? to tell a compiler crash (2) from a normal user error (1).

Why

moc exits 1 for user errors (type/compile errors, stable-compat mismatch, bad args) and 2 for compiler crashes (uncaught internal error). mops routed every moc failure through cliError, which hard-codes process.exit(1), so a crash looked like any other failure in CI or retry loops.

Before / After

# moc compiler crash
$ mops check; echo "exit=$?"
exit=1    # before
exit=2    # after — stderr unchanged

# normal compile error
$ mops check; echo "exit=$?"
exit=1    # before and after

# moc crash while running tests
$ mops test; echo "exit=$?"
exit=1    # before
exit=2    # after — test output unchanged

What is unchanged

  • All CLI output text and test snapshots.
  • cliError (exit 1) for config/validation/IO errors; only final moc failure sites use cliExit(code, …).
  • Autofix inner loop (--fix), mops watch, mops bench.

@ggreif ggreif changed the title fix(cli): tunnel moc exit code so compiler crashes are distinguishable fix(cli): tunnel moc exit code so compiler crashes are distinguishable Jun 30, 2026
@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Cursor AI review

👍 APPROVE — looks safe to merge

Category Assessment Details
Summary Adds cliExit to propagate moc's process exit code (notably 2 for compiler crashes vs 1 for user errors) through build, check, generate, check-stable, and test; changelog updated.
Code Quality Minimal cliExit helper mirrors cliError; call sites consistently use result.exitCode ?? 1; test tracking via optional onClose callback is clean.
Consistency Config/validation/IO failures still use cliError(1); only final moc failure sites switched, matching stated scope and sibling-command patterns.
Security No auth, signing, or package-integrity changes; exit-code propagation only.
Tests ⚠️ PR description mentions a cliExit unit test, but no test file is in the diff; existing integration/snapshot coverage is unchanged per PR notes.
Maintainability Clear separation between CLI validation errors and compiler exit semantics; changelog documents the behavior change.

Verdict

Decision: APPROVE
Risk: Low
Reason: The change is narrowly scoped, correctly tunnels moc exit codes at all intended failure sites, preserves existing output text, and documents the behavior in the changelog. No correctness regressions or production-risk issues were found relative to the base SHA.


Generated for commit 06526ba

@ggreif ggreif left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks solid to me and an important feature to have!

moc exits 2 on a compiler crash vs 1 for user errors. Route final moc
failures through cliExit(code) instead of cliError (always 1). mops test
tracks moc crash codes via pipeMMF's onClose callback and exits 2 when
any moc process crashed during the run.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Kamirus Kamirus force-pushed the cli/tunnel-moc-exit-code branch from 39a44da to 06526ba Compare June 30, 2026 14:16
@Kamirus Kamirus merged commit 9ee2d1e into main Jun 30, 2026
30 checks passed
@Kamirus Kamirus deleted the cli/tunnel-moc-exit-code branch June 30, 2026 14:26
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.

2 participants