Repository navigation
fix(cli)!: keep a selected JSON null in --filter-output output - #2333
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
createCliResultOutput rendered an explicit null selected by
--filter-output as the empty document {}, the same output it uses when
the selection has no value at all. On the streamed JSON/JSONL path,
a consumer could not distinguish a selected null from a missing field.
Write a selected null as null in streamed JSON and JSONL. This also
preserves an unfiltered top-level null. The {} fallback stays for
undefined, functions and symbols. The --full-output envelope already
carried data: null for a selected null. The --token-count path still
hands results that fit the formatted-string limit back to Incur and
prints 0 for a selected null. Other formats and Incur-owned result
paths are unchanged.
Consumers must accept JSON null for a present null and distinguish it
from a missing selection. Use --full-output if an object envelope is
required. Keeping the old shared {} representation would continue
hiding this distinction.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_019TTGAv6fe859ebbCLLfLHP
546c3f1 to
ab96bc8
Compare
|
TL;DR: CI had not run on this head when I tested it, so this is the first run of it. On Linux with Node 22, 24 and 26, a selected null now prints ResultsI compared head (ab96bc8) with its parent (fd95880). Only this PR's two files differ. Every result was the same on Node 22, 24 and 26.
Not run
Thanks, Jackmeson1, for a small fix with a test that fails on base the way you described. More details
CommandsEach CLI command ran on base and head under Node 22, 24 and 26. The test run used each Node in turn. For the base check I copied your Test setup
🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
@greptileai review |
|
This PR is set for a Plus review. TREX isn't supported with Plus or Apex reviews yet, so Greptile reviews this PR at Base while TREX is on. |
|
Summary
The streamed JSON/JSONL path printed
{}when--filter-outputselected an explicitnull, which is the same outputas a selection that does not exist. This keeps a selected null as
nullon that path, without--full-outputor--token-count. No separate issue was filed; this PR is the report.Problem and expected behavior
Smallest trigger: in a fresh invocation without a bound analysis provider,
node scripts/rea.mjs capabilities --jsonreturns
"analysis_provider_binding": null. From a checkout offd95880, runnpm ci && npm run build:cached, then:Violated invariant: AGENTS.md asks that omission and uncertainty survive boundaries, and the JSON writer already
preserves
null(tests/boundary/cli/jsonOutput.test.ts). Incur's filter also preserves a selected null; the streamedrenderer then collapsed it to
{}.renderEmptyFilteredCliOutputinsrc/cliOutput.tsis a separate fallback for anIncur invocation that emitted no output; it does not inspect the selected value.
Change and scope
In
src/cli/cliResultOutput.ts(createCliResultOutput), the non-envelope branch no longer mapsnullto{}. This also preserves an unfiltered top-level null.undefined, functions and symbols still fall back to{}.Not changed:
--full-outputwithout--token-count, which already writes{"ok":true,"data":null,...}for a selected null;--token-count, which still hands results that fit the formatted-string limit back to Incur. Incur 0.6.1 countsselected null as empty, so
--token-count --filter-output analysis_provider_bindingstill prints0;{}in YAML and no output in TOON/Markdown;createClicalls without the streamed outputsurface. A selected null in a plain success sentinel still reaches the dispatcher's
{}fallback in JSON/JSONL.The fix uses the existing filter and JSON writer; it removes the intervening null-to-empty conversion. Changing
Incur's formatter, token counting, or sentinel/generator protocols is outside this streamed JSON/JSONL fix.
Contribution scope: an ordinary fix within the existing CLI output boundary. Not applicable.
Contract and boundary impact
createCliResultOutput, afteroptional
--filter-outputselection.nullnow printsnullinstead of{}on the streamedJSON/JSONL path described above. MCP is unchanged.
changes.
Expected effects:
Evidence and regression coverage
Tests added or updated:
tests/boundary/cli/jsonOutput.test.ts, new describe block "streamed CLI filteredselections". It is a table over
createCliResultOutputwith:{"nested":{"value":null}}, unchanged);{});0andfalse.Base reproduction, executed outside the sandbox and repeated in the sandbox: with only the test applied on
fd95880, the two selected-null rows fail withexpected '{}\n' to be 'null\n'. The other four pass.User-visible CLI output, after
npm run build:cachedwith this change:Remaining proof gaps: the Incur-owned paths above retain their existing behavior. The sandbox could not complete
artifact preparation or the full static gate; related compiled tests failed on both revisions as recorded below.
Validation with the repository-pinned Node/npm versions remains outstanding.
Evidence-bearing changes: stored Evidence and provenance are unchanged; only the CLI projection changes.
Validation performed
Outside-sandbox validation on WSL Ubuntu 22.04 with the repository-pinned Node 24.18.0 and npm 11.16.0. Rebased
commit on base
fd95880, which renamedstreamedJsonOutput.tstocliResultOutput.ts:npm run check— passed (typecheck, lint, format:check, knip, metadata:check and the architecture guards)npx vitest run tests/boundary/cli/jsonOutput.test.ts— 41 passed. Onfd95880with only the new test applied,the two selected-null rows fail as described above.
npm run test:prepare && npx vitest run --project cli-boundary— 316 passed, 21 skipped, 2 failed. Both failuresare in
tests/boundary/cli/referenceSourceImportStatus.test.ts(the--full-outputpreflight cases, which expectok: trueand getok: false), and they fail identically onfd95880without this change.npx vitest run tests/acceptance/managedCliOutput.test.ts— 7 passednode scripts/rea.mjs capabilities ... --filter-output ...with the built CLI onfd95880and on this branch —output shown above
Before the rebase, on base
a97b713: the samenpm run checkpassed, andcliOutput,dispatcher,javascriptApplicationJsonOutput,managedCliOutputandjsonOutputpassed together (61 tests). Independentchecks in a disposable sandbox copy (Node 24.21.0, npm 11.19.0) also passed there:
tsc --noEmit,oxlintandoxfmt --checkon the changed files,npm run verify:test-discovery, and the built-CLI comparison across JSON/JSONL,missing field,
--token-count,--full-output, YAML and TOON/Markdown. In that sandbox,npm run checkand thecompiled CLI tests could not run (
spawnSync ... EPERM); the outside-sandbox runs cover them.Compatibility, safety, and release
capabilities --format json --filter-output analysis_provider_bindingpreviously returned
{}when the field was null; the streamed JSON/JSONL path now returnsnull. Consumers mustaccept JSON null for a present null and distinguish it from a missing selection. Use
--full-outputif an objectenvelope is required. Keeping the old shared
{}representation would continue hiding this distinction.exercised and are not required for this formatting change.
!title marks the compatibilitychange for Release Please; the migration is described above.
AI disclosure: prepared with AI assistance (Claude Code); the checks above were run before opening the PR.
Before merge
type(scope): outcome.npm run checkwith the pinned Node 24.18.0/npm 11.16.0 and rerun the relevant compiled tests outsidethe restricted sandbox.
🤖 Generated with Claude Code
https://claude.ai/code/session_019TTGAv6fe859ebbCLLfLHP