Repository navigation
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge; no blocking issues were found. SummaryThe PR rejects negative, fractional, and unsafe token-window bounds at the existing CLI input boundary.
Reviews (2) · Last reviewed commit: "fix(cli): validate token bounds without ..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f7c72000d0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ["--token-limit", tokenLimit], | ||
| ["--token-offset", tokenOffset], | ||
| ] as const) | ||
| if (value !== undefined && (!Number.isSafeInteger(value) || value < 0)) |
There was a problem hiding this comment.
Validate raw token bounds before Number rounding
parseCliOutputArguments has already applied Number(value) when this check runs, so inputs such as --token-limit 1.0000000000000001 and --token-offset 9007199254740991.1 are rounded to safe integers and this validation returns {ok: true}. Those fractional or out-of-range spellings therefore proceed as different window coordinates instead of producing the newly documented INVALID_TOKEN_WINDOW; retain and validate the raw token exactly before accepting it.
AGENTS.md reference: AGENTS.md:L31-L31
Useful? React with 👍 / 👎.
|
TL;DR: Fixed. Token values that are negative, fractional or too large are now refused. The error code is Thanks, chqcjq, for the fix. I tested head f7c7200 on Linux. My #5531 repro, run on main ccc7da3 and on the head (Node 24.18.0, stdout captured):
The cause, from reading the diff: a non-numeric value sets What the PR does fix (head versus main):
On main, the failing test is "rejects incoherent token windows": Bot thread: the P2 about rounding before the check is real, but small. How it differs from #5578, which I reviewed earlier today (I ran #5578 at 1ab5663 on the same box):
Both PRs fix the same negative and fractional cases and both leave #5531 open. They edit the same function. A three-way text merge of Two other items the PR names are not changed by it. #5119 is a separate PR. It covers the reversed range when an offset is past the end. Not run
Test setup
CommandsInstall, prepare, build and test:prepare ran on Node 24, exit 0 each. The two test files ran once per Node version on the head, exit 0 each. On main only the new test file ran, on Node 24, exit 1. Each CLI command ran once per tree. Stdout was parsed with a JSON loader to decide JSON or not. 🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊 |
CassieFox23
left a comment
There was a problem hiding this comment.
TL;DR: The rounding bug I found is fixed in 42a0dcb. The one red CI shard is a test on main that this PR does not touch. Two things are still open: the PR conflicts with main in docs/cli.md, and my #5531 repro is still out of scope.
Thanks, chqcjq, for taking the rounding finding. This is a static read of 42a0dcb, with no build and no run. My earlier test comment was on f7c7200.
Fixed
- Rounding before the check. Before,
--token-limit 1.0000000000000001and--token-offset 9007199254740991.1passed as safe integers, becauseNumber()rounds them. NowisValidTokenBound(src/cliOutput.tsline 244) also reads the spelling and rejects any non-zero digit past the decimal point. Reading the code, both inputs from my last comment now returnINVALID_TOKEN_WINDOW. That check is from reading the code; I did not run the build. - Test coverage.
tests/boundary/cli/cliTokenWindowBounds.test.ts(lines 16 to 19) covers those two inputs plus1e-400and-1e-400. Lines 62 to 70 keep exact forms valid:5.000,500e-2,.5e1,0x5and the last-value-wins case. The CI log of Test shard (3/8) shows that file with 2 tests passing on this head. - Docs.
docs/cli.mdline 554 now says fractional text is not accepted just because it rounds to an integer. - Last-value-wins is kept.
--token-limit -5 --token-limit 5still shows tokens 0 to 5, as in my earlier table.
Still open
- The branch conflicts with main. GitHub reports
CONFLICTING. A text merge of main (9066444) with this head shows one conflict. It is indocs/cli.mdnear line 592. This PR's token paragraph sits where main added the--format mdparagraph.src/cliOutput.tsmerged without a conflict marker in that text merge. Whether it still behaves the same I have not checked. - #5531 is not fixed, and the PR never claimed it. A non-numeric value like
not-a-numbermakesparseErrortrue, andvalidateCliOutputArgumentsreturns{ ok: true }atsrc/cliOutput.tsline 289, before the new check. So--json --token-limit not-a-numbershould still print TOON. I did not re-run it on this head. The issue stays open. - Overlap with #5578. #5578 is still open and edits the same function. Only one of the two can land, and the error code (
INVALID_TOKEN_WINDOWhere,INVALID_TOKEN_VALUEthere) is still a maintainer call. #5119 is also still open.
CI
CI required, Portable tests and Test shard (8/8) failed on this head (run 39884215959). Shard 8/8 failed in tests/process-global/commandFinalizationCancellation.test.ts. The failures were preserves the analysis-view result and exit status for bundle: SIGINT during projection and the SIGTERM variants. This PR does not change that file. Main's own push run on 74ed67d (run 39877590680) failed the same three tests. A fix for that file merged as #6431 at 3:30 AM UTC on 23 Oct, and neither 74ed67d nor this head has it. Merging main should clear it. Shards 1, 2, 3, 4, 5 and 7 were cancelled before they finished, so I count only what their logs show.
Not run
- The new head: no build, no tests, no CLI runs.
- Whether the merged result with current main passes.
- Any macOS or Windows check.
🤖 Written with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊
|
Thank you for the follow-up on exact decimal spellings. I am keeping this PR open despite #5532 being closed: on main at ca3fd7b, |
Summary
Fixes #5532. CLI token limits and offsets must represent exact non-negative safe integers. Invalid windows return a complete
INVALID_TOKEN_WINDOWdiagnostic and exit 1 before command execution.Previously negative/fractional values could produce inconsistent ranges or negative continuation offsets. The follow-up also rejects fractional spellings that JavaScript rounds to integers, including
1.0000000000000001,9007199254740991.1, and underflow to zero.Approach and scope
Validate each raw token spelling at the existing parser boundary, and expose the effective validity result to the output-argument validator. Decimal integrality is checked using coefficient digits and exponent placement, without exponent-sized padding. Remove the superseded number-only check. Preserve zero, exact decimal/exponent forms, integer radix forms, maximum-safe values and duplicate last-value precedence. No Incur dependency, MCP schema, provider capability, target authority or package metadata change. Maintainer scope decision: not applicable to this ordinary CLI input fix.
Review and CI follow-up
42a0dcb4caddresses the valid Codex P2 rounding finding. The added compiled CLI regression reproduces acceptance of the fractional spelling on the previous head and passes with the correction.74ed67da7viaac8ea6256. The four old shard failures were stale recovery-text expectations infilteredFailureOutput.test.ts; they also fail with the original base implementation. Current main includes the upstream assertion/canonical-error corrections, and all five tests in that file now pass. No assertion was weakened locally to hide the failures.Current executed validation
Windows, pinned Node 24.18.0/npm 11.16.0:
node scripts/run-development-tests.mjs focused tests/boundary/cli/cliTokenWindowBounds.test.ts tests/boundary/cli/cliOutput.test.ts tests/boundary/cli/filteredFailureOutput.test.ts— 45 passed.npm run check— passed.npm run docs:check— passed, including 9 README consistency tests.git diff --checkand normal commit/pre-push checks — passed.The full native-Windows
npm run check:cidoes not pass: its static/deep tasks, architecture checks and discovery of 2,106 test files pass, but the Python stage requires the POSIX-onlyresourcemodule. The unchanged Python tests were instead executed in existing Ubuntu 24.04/WSL with Python 3.12.3:python3 -m unittest bridge/native/test_rea_lldb_tracer.py bridge/pwndbg/test_core_context.py bridge/mitmproxy/test_capture.py -v— 41 passed.python3 -m unittest discover -s experiments/analysis-efficiency -p 'test_*.py' -v— 91 passed, with a task-local official Node 24.18.0 Linux runtime verified against its published SHA-256. No global toolchain or repository test script was changed.New-head remote CI/review is pending. The full JavaScript suite, macOS and performance benchmarks were not run. Python's WSL results do not establish Linux CLI or optional-provider coverage.
Author readiness
Human owner: @chqcjq
The human owner's initial readiness declarations are recorded above.