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

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

📋 Pull Request Information

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

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


📝 Commits (1)

  • d617bf1 fix(cli): return nonzero status for operation failures

📊 Changes

9 files changed (+207 additions, -55 deletions)

View changed files

📝 README.md (+21 -0)
📝 scripts/verify-package.mjs (+56 -14)
📝 src/application/ProcessCli.ts (+0 -13)
📝 src/cliLogging.ts (+21 -3)
📝 src/cliProcessCommands.ts (+3 -21)
📝 src/logger.ts (+2 -2)
➕ tests/cliLogging.test.ts (+50 -0)
📝 tests/cliOutput.test.ts (+53 -1)
📝 tests/processCli.test.ts (+1 -1)

📄 Description

Description

REA could serialize an expected operation failure as valid JSON, TOON, YAML, Markdown, or JSONL and still exit with status 0. Shells and CI therefore treated failed integrity checks, disabled policies, unhealthy diagnostics, and incomplete setup as successful commands.

This change classifies the existing caller-visible CLI outcomes at the shared command boundary and sets exit status 1 without replacing their structured bodies. It also keeps CLI logs on stderr, so enabling error logs cannot corrupt machine-readable stdout. Successful bounded or truncated evidence remains status 0.

The package verifier now asserts status alongside structured output for doctor and setup outcomes. README documents the stable status contract and a pipefail-safe example.

Type of Change

  • Bug fix
  • Documentation update
  • New feature
  • 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 test)
  • Real Hopper verification performed (npm run verify:hopper) — not run; the change is confined to terminal status/output handling.
  • Linux real Hopper verification performed (npm run verify:hopper:linux) — not run for the same reason.
  • Package verification performed (npm run verify:package)

Focused packaged-dispatcher coverage checks ordinary and full output plus JSON, JSONL, TOON, YAML, Markdown, filtering, token limits, token counts, and enabled error logging. Final Autoreview reported no accepted or actionable findings.

Tool Contract Impact

None. MCP registration, schemas, and the 68-tool inventory are unchanged.

Closes #113


🔄 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/121 **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-failure-exit-status` --- ### 📝 Commits (1) - [`d617bf1`](https://github.com/morluto/rea/commit/d617bf1f284f398ae7bca94f08b9497f9b3a309d) fix(cli): return nonzero status for operation failures ### 📊 Changes **9 files changed** (+207 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+21 -0) 📝 `scripts/verify-package.mjs` (+56 -14) 📝 `src/application/ProcessCli.ts` (+0 -13) 📝 `src/cliLogging.ts` (+21 -3) 📝 `src/cliProcessCommands.ts` (+3 -21) 📝 `src/logger.ts` (+2 -2) ➕ `tests/cliLogging.test.ts` (+50 -0) 📝 `tests/cliOutput.test.ts` (+53 -1) 📝 `tests/processCli.test.ts` (+1 -1) </details> ### 📄 Description ## Description REA could serialize an expected operation failure as valid JSON, TOON, YAML, Markdown, or JSONL and still exit with status 0. Shells and CI therefore treated failed integrity checks, disabled policies, unhealthy diagnostics, and incomplete setup as successful commands. This change classifies the existing caller-visible CLI outcomes at the shared command boundary and sets exit status 1 without replacing their structured bodies. It also keeps CLI logs on stderr, so enabling error logs cannot corrupt machine-readable stdout. Successful bounded or truncated evidence remains status 0. The package verifier now asserts status alongside structured output for doctor and setup outcomes. README documents the stable status contract and a pipefail-safe example. ## Type of Change - [x] Bug fix - [x] Documentation update - [ ] New feature - [ ] 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 test`) - [ ] Real Hopper verification performed (`npm run verify:hopper`) — not run; the change is confined to terminal status/output handling. - [ ] Linux real Hopper verification performed (`npm run verify:hopper:linux`) — not run for the same reason. - [x] Package verification performed (`npm run verify:package`) Focused packaged-dispatcher coverage checks ordinary and full output plus JSON, JSONL, TOON, YAML, Markdown, filtering, token limits, token counts, and enabled error logging. Final Autoreview reported no accepted or actionable findings. ## Tool Contract Impact None. MCP registration, schemas, and the 68-tool inventory are unchanged. ## Related Issues Closes #113 --- <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:42 +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#1844
No description provided.