[PR #122] [MERGED] fix(cli): return nonzero status for operation failures #1847

Closed
opened 2026-10-16 21:11:44 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/122
Author: @morluto
Created: 7/13/2026
Status: ✅ Merged
Merged: 7/13/2026
Merged by: @morluto

Base: main ← Head: fix/cli-operation-failure-status


📝 Commits (2)

  • 1a96199 fix(cli): return nonzero status for operation failures
  • b3b34bf Merge branch 'main' into fix/cli-operation-failure-status

📄 Description

Description

REA can serialize an expected operation failure as valid JSON, TOON, YAML, Markdown, or JSONL and still exit with status 0. Shell scripts and CI then treat failed analysis, policy checks, or setup as successful.

This change classifies the caller-visible result at the shared CLI logging boundary. Typed errors, unhealthy diagnostics, failed operations, unapplied setup plans, confirmation requirements, and human-remediation outcomes set exit status 1 without replacing their structured result. Successful unknown, bounded, and truncated evidence remains status 0.

Process-capture commands now return their existing typed error, category, and message fields instead of converting them to a less specific Incur error. Opt-in CLI logs write to stderr so structured stdout remains parseable.

The README documents the status contract, setup and doctor semantics, signal-derived status, and pipefail. Package verification now checks doctor and setup result statuses in the installed artifact.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Performance improvement
  • Refactoring (no functional change)
  • Tool contract change (MCP schema modification)

Testing Performed

  • Unit tests added or updated
  • TypeScript typecheck passes (npm run typecheck)
  • Linting passes (npm run lint)
  • Full test suite passes (npm run check): 68 files, 490 tests
  • Real Hopper verification performed (npm run verify:hopper): not run because this change affects the CLI result boundary, not Hopper analysis
  • Linux real Hopper verification performed (npm run verify:hopper:linux): not run for the same reason
  • Package verification performed (npm run verify:package)

Additional proof:

  • Regression tests fail on the base because operation failures return status 0 and process errors lose their typed category.
  • Packaged commands cover normal and full envelopes, JSON, TOON, YAML, Markdown, JSONL, filters, token limits, and token counting.
  • Structured logging proof parses stdout as JSON and observes the failure log on stderr.
  • Fresh structured autoreview reported no accepted or actionable findings.

Tool Contract Impact

MCP behavior and the 68-tool inventory are unchanged. CLI failure values keep their existing structured fields while the process status now reports failure. This completes the CLI-status portion of #100; it does not claim the broader per-code typed-error contract, permission details, or generated error schemas.

Suggested Review Order

  1. src/cliLogging.ts and tests/cliLogging.test.ts
  2. src/cliProcessCommands.ts and tests/processCli.test.ts
  3. tests/cliOutput.test.ts
  4. scripts/verify-package.mjs and README.md

Closes #113.
Partial progress on #100.
Follows the diagnostic projection merged in #119 for #111.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/122 **Author:** [@morluto](https://github.com/morluto) **Created:** 7/13/2026 **Status:** ✅ Merged **Merged:** 7/13/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/cli-operation-failure-status` --- ### 📝 Commits (2) - [`1a96199`](https://github.com/morluto/rea/commit/1a96199bed4901153607690303dc09a861cddbcc) fix(cli): return nonzero status for operation failures - [`b3b34bf`](https://github.com/morluto/rea/commit/b3b34bf5d4809b04bdbb0d7e1e69348a27c55474) Merge branch 'main' into fix/cli-operation-failure-status ### 📄 Description ## Description REA can serialize an expected operation failure as valid JSON, TOON, YAML, Markdown, or JSONL and still exit with status 0. Shell scripts and CI then treat failed analysis, policy checks, or setup as successful. This change classifies the caller-visible result at the shared CLI logging boundary. Typed errors, unhealthy diagnostics, failed operations, unapplied setup plans, confirmation requirements, and human-remediation outcomes set exit status 1 without replacing their structured result. Successful unknown, bounded, and truncated evidence remains status 0. Process-capture commands now return their existing typed `error`, `category`, and `message` fields instead of converting them to a less specific Incur error. Opt-in CLI logs write to stderr so structured stdout remains parseable. The README documents the status contract, setup and doctor semantics, signal-derived status, and `pipefail`. Package verification now checks doctor and setup result statuses in the installed artifact. ## Type of Change - [x] Bug fix - [ ] New feature - [x] Documentation update - [ ] Performance improvement - [ ] Refactoring (no functional change) - [ ] Tool contract change (MCP schema modification) ## Testing Performed - [x] Unit tests added or updated - [x] TypeScript typecheck passes (`npm run typecheck`) - [x] Linting passes (`npm run lint`) - [x] Full test suite passes (`npm run check`): 68 files, 490 tests - [ ] Real Hopper verification performed (`npm run verify:hopper`): not run because this change affects the CLI result boundary, not Hopper analysis - [ ] Linux real Hopper verification performed (`npm run verify:hopper:linux`): not run for the same reason - [x] Package verification performed (`npm run verify:package`) Additional proof: - Regression tests fail on the base because operation failures return status 0 and process errors lose their typed category. - Packaged commands cover normal and full envelopes, JSON, TOON, YAML, Markdown, JSONL, filters, token limits, and token counting. - Structured logging proof parses stdout as JSON and observes the failure log on stderr. - Fresh structured autoreview reported no accepted or actionable findings. ## Tool Contract Impact MCP behavior and the 68-tool inventory are unchanged. CLI failure values keep their existing structured fields while the process status now reports failure. This completes the CLI-status portion of #100; it does not claim the broader per-code typed-error contract, permission details, or generated error schemas. ## Suggested Review Order 1. `src/cliLogging.ts` and `tests/cliLogging.test.ts` 2. `src/cliProcessCommands.ts` and `tests/processCli.test.ts` 3. `tests/cliOutput.test.ts` 4. `scripts/verify-package.mjs` and `README.md` ## Related Issues Closes #113. Partial progress on #100. Follows the diagnostic projection merged in #119 for #111. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-16 21:11:44 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#1847
No description provided.