[PR #2313] [CLOSED] fix(cli): report command failures as ok:false in the full-output envelope #5158

Closed
opened 2026-10-31 01:04:25 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2313
Author: @jasonchen505
Created: 10/12/2026
Status: ❌ Closed

Base: main ← Head: contrib/cli-full-output-error-envelope


📝 Commits (2)

  • 853ed5a fix(cli): report command failures as ok:false in the full-output envelope
  • d7b6041 fix(cli): honor per-command failure checks in the full-output envelope

📊 Changes

3 files changed (+162 additions, -3 deletions)

View changed files

📝 src/cli/streamedJsonOutput.ts (+17 -3)
📝 src/cliLogging.ts (+22 -0)
➕ tests/boundary/cli/streamedJsonOutput.test.ts (+123 -0)

📄 Description

Summary

Fixes #2273. With --full-output, CLI analysis failures were wrapped in {"ok": true, "data": ...} while the process exited 1. The envelope now renders failed commands as { ok: false, error, meta } so the ok flag agrees with the exit code.

Problem and expected behavior

Smallest trigger: rea inspect-managed-artifact /definitely/missing/x.dll --format json --full-output. Observed: exit 1 with {"ok": true, "data": {"error": "Analysis failed", "code": "target_unavailable", ...}}. Violated invariant: the ok flag in the full-output envelope must agree with the process exit code. Framework-level failures from the same binary already produced {"ok": false, "error": {...}}. Analysis failures did not.

Change and scope

src/cli/streamedJsonOutput.ts now classifies the command value with isCliOperationFailure, the same predicate logCliCommand uses to set the exit code, and renders failures as { ok: false, error, meta }. The unfiltered value decides ok. The filtered payload is preserved in error when --filter-output is combined with --full-output.

Not included: --format yaml envelopes are built by the incur framework, not by REA code, so that path is unchanged.

Contribution scope fit: isolated regression fix within existing CLI output boundaries. No target execution, no new providers, no authority or cleanup changes. No maintainer scope decision required.

Contract and boundary impact

  • Semantic owner and earliest changed stage: CLI JSON output rendering in src/cli/streamedJsonOutput.ts, after command completion.
  • Contribution scope fit and linked maintainer decision: in scope as an isolated regression fix. Not applicable.
  • CLI and MCP/tool-catalog contract: CLI only. MCP tool catalog unchanged. No generated metadata changes.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/cli/streamedJsonOutput.test.ts with 4 tests covering the success envelope, a CLI error envelope failure, a bare analysis error projection failure, and the unchanged non-full-output failure output.
  • Base reproduction: published rea-agents@6.4.0 printed {"ok": true, ...} with exit 1 before the fix. After the fix the built CLI prints {"ok": false, "error": {"code": "target_unavailable", ...}, "meta": {...}} with exit 1.
  • User-visible CLI/MCP output: shown above.
  • Remaining proof gaps: the --format yaml path is owned by incur and unchanged.

Validation performed

  • npm run test:focused -- tests/boundary/cli/streamedJsonOutput.test.ts — 4 passed
  • npm run test:focused -- tests/boundary/cli/jsonOutput.test.ts — 28 passed
  • npm run test:local -- src/cliLogging.test.ts — 6 passed
  • npm run test:focused -- tests/acceptance/managedCliOutput.test.ts — 7 passed
  • npm run check:fast — typecheck and lint passed
  • Manual end to end: node scripts/rea.mjs inspect-managed-artifact /definitely/missing/x.dll --format json --full-output — {"ok": false, ...}, exit 1

Compatibility, safety, and release

  • Breaking changes or migration steps: callers that parsed ok: true alongside an error payload will now see ok: false. This corrects the envelope to match the exit code and the existing framework-failure contract. No migration beyond reading the ok flag.
  • Real Hopper/Ghidra, browser, or OS coverage: none required. No analysis engines involved.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 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/2313 **Author:** [@jasonchen505](https://github.com/jasonchen505) **Created:** 10/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `contrib/cli-full-output-error-envelope` --- ### 📝 Commits (2) - [`853ed5a`](https://github.com/morluto/rea/commit/853ed5a3878f9ac4cf18154e835cd17da5640306) fix(cli): report command failures as ok:false in the full-output envelope - [`d7b6041`](https://github.com/morluto/rea/commit/d7b604102479deaaed14ec991ddc45d420a188b6) fix(cli): honor per-command failure checks in the full-output envelope ### 📊 Changes **3 files changed** (+162 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/cli/streamedJsonOutput.ts` (+17 -3) 📝 `src/cliLogging.ts` (+22 -0) ➕ `tests/boundary/cli/streamedJsonOutput.test.ts` (+123 -0) </details> ### 📄 Description ## Summary Fixes #2273. With `--full-output`, CLI analysis failures were wrapped in `{"ok": true, "data": ...}` while the process exited 1. The envelope now renders failed commands as `{ ok: false, error, meta }` so the `ok` flag agrees with the exit code. ## Problem and expected behavior Smallest trigger: `rea inspect-managed-artifact /definitely/missing/x.dll --format json --full-output`. Observed: exit 1 with `{"ok": true, "data": {"error": "Analysis failed", "code": "target_unavailable", ...}}`. Violated invariant: the `ok` flag in the full-output envelope must agree with the process exit code. Framework-level failures from the same binary already produced `{"ok": false, "error": {...}}`. Analysis failures did not. ## Change and scope `src/cli/streamedJsonOutput.ts` now classifies the command value with `isCliOperationFailure`, the same predicate `logCliCommand` uses to set the exit code, and renders failures as `{ ok: false, error, meta }`. The unfiltered value decides `ok`. The filtered payload is preserved in `error` when `--filter-output` is combined with `--full-output`. Not included: `--format yaml` envelopes are built by the incur framework, not by REA code, so that path is unchanged. Contribution scope fit: isolated regression fix within existing CLI output boundaries. No target execution, no new providers, no authority or cleanup changes. No maintainer scope decision required. ## Contract and boundary impact - Semantic owner and earliest changed stage: CLI JSON output rendering in `src/cli/streamedJsonOutput.ts`, after command completion. - Contribution scope fit and linked maintainer decision: in scope as an isolated regression fix. Not applicable. - CLI and MCP/tool-catalog contract: CLI only. MCP tool catalog unchanged. No generated metadata changes. - Provider, bridge, target-format, or platform compatibility: none. - Evidence, artifact, provenance, or reconstruction contract: none. - Target selection, authority, upstream behavior, and cleanup details: not applicable. - Generated metadata, package, or installation impact: none. Expected effects: - [ ] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [x] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `tests/boundary/cli/streamedJsonOutput.test.ts` with 4 tests covering the success envelope, a CLI error envelope failure, a bare analysis error projection failure, and the unchanged non-full-output failure output. - Base reproduction: published `rea-agents@6.4.0` printed `{"ok": true, ...}` with exit 1 before the fix. After the fix the built CLI prints `{"ok": false, "error": {"code": "target_unavailable", ...}, "meta": {...}}` with exit 1. - User-visible CLI/MCP output: shown above. - Remaining proof gaps: the `--format yaml` path is owned by incur and unchanged. ## Validation performed - `npm run test:focused -- tests/boundary/cli/streamedJsonOutput.test.ts` — 4 passed - `npm run test:focused -- tests/boundary/cli/jsonOutput.test.ts` — 28 passed - `npm run test:local -- src/cliLogging.test.ts` — 6 passed - `npm run test:focused -- tests/acceptance/managedCliOutput.test.ts` — 7 passed - `npm run check:fast` — typecheck and lint passed - Manual end to end: `node scripts/rea.mjs inspect-managed-artifact /definitely/missing/x.dll --format json --full-output` — `{"ok": false, ...}`, exit 1 ## Compatibility, safety, and release - Breaking changes or migration steps: callers that parsed `ok: true` alongside an error payload will now see `ok: false`. This corrects the envelope to match the exit code and the existing framework-failure contract. No migration beyond reading the `ok` flag. - Real Hopper/Ghidra, browser, or OS coverage: none required. No analysis engines involved. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:04:25 +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#5158
No description provided.