Skip to content

fix(cli): align structured output guard with native flags - #777

Merged
morluto merged 1 commit into
morluto:mainfrom
rudycelekli:fix/cli-output-native-flags-20261006
Oct 7, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
rudycelekli:fix/cli-output-native-flags-20261006

Conversation

@rudycelekli

Copy link
Copy Markdown

Problem

REA's output preflight and the installed Incur 0.6.1 builtin flag parser disagree about effective output format. The parser scans builtin flags past -- and only recognizes the spaced --format form. The preflight stops at the delimiter and accepts an equals-form override.

Actual production requests such as providers -- --json --token-limit 5 and providers --json --format=toon --token-limit 5 bypass the structured-output guard and emit truncated, invalid JSON error documents.

Change

Align those two preflight decisions with the actual parser. The existing unsupported-output-combination error is emitted as a complete JSON document before dispatch. This does not add new argument grammar or change Incur's delimiter behavior.

Verification

  • Both actual built CLI requests reproduced truncated, nonparseable JSON before the change.
  • Six focused CLI output/sanitization tests pass afterward, including both production request paths and existing valid-format/error/artifact controls.
  • npm run check and check:fast pass with 125 existing lint warnings and zero errors.

AI-assisted implementation, independently reviewed; signed commit with DCO.

@morluto

morluto commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Reviewed: fix direction is correct — verified against Incur 0.6.1 builtin-flag parsing (no -- break, no --format= equals form). Fail-closed guard with truncated-output protection is right, and the new workspaceCliTest covers both bypass paths. APPROVE.

One non-blocking nit: src/cliOutput.ts retains --token-limit=/--token-offset= equals handling, which Incur also does not parse (space-separated only). Keeping it is fail-closed/safe, but consider dropping it for full alignment or adding a comment noting the intentional asymmetry.

@morluto

morluto commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Review — APPROVE

Summary

Fixes the CLI structured-output preflight (validateCliOutputArguments) to mirror the actual Incur 0.6.1 builtin-flag parsing:

  • scans past -- instead of stopping at it,
  • drops the --format= equals-form recognition.

Both mismatches previously let requests like providers -- --json --token-limit 5 bypass the guard and emit truncated, unparseable JSON.

Verification

  • Checked against installed parser (node_modules/incur/dist/Cli.js, extractBuiltinFlags): no -- handling in the loop, only token === '--format' with separate argv value.
  • Fix direction is fail-closed: mismatched requests now get a complete UNSUPPORTED_OUTPUT_COMBINATION JSON document before dispatch.
  • New workspaceCliTest in tests/boundary/cli/cliOutput.test.ts covers both bypass paths and asserts no [truncated: plus a parseable error body.
  • CI: all completed checks SUCCESS.

Nit (non-blocking)

  • src/cliOutput.ts (~L63–67): --token-limit= / --token-offset= equals handling is also not parsed by Incur (space-separated only). Keeping it is fail-closed/safe, but consider dropping it for full alignment or adding a one-line comment noting the intentional asymmetry.

@rudycelekli

Copy link
Copy Markdown
Author

Thanks for checking this against Incur 0.6.1. The equals-form token-window check is deliberately conservative: Incur does not apply those forms, but rejecting an unsupported token-window request before structured output is safe. Unlike the former --format= handling, it cannot change the effective output format or permit truncation. I will keep that distinction explicit; the two format/delimiter regressions exercise the actual parser behavior.

Comment thread src/cliOutput.ts Resolved
@morluto
morluto merged commit e9fac56 into morluto:main Oct 7, 2026
19 checks passed
@morluto

morluto commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Thanks, @rudycelekli, for your work on “fix(cli): align structured output guard with native flags.” I appreciate your contribution to REA.

darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
@morluto morluto added the area: cli CLI adapter and one-shot commands label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants