Repository navigation
Conversation
Incur coerces ZodNumber argv fields with Number(), which silently reinterprets non-decimal spellings: "" becomes 0, "0x10" becomes 16, and "1e3" becomes 1000. Several numeric options still bound the raw domain schemas or plain z.number() fields, so those spellings crossed input validation and changed behavior silently: - read-bytes --length and search-bytes --limit - inspect-asset-catalog --offset/--limit - inspect-keyed-archive --offset/--limit - inspect-sqlite-database --worker-timeout-ms/--row-limit - inspect-evm-interface --timeout-ms - read-adb-logcat --count/--pid - instrument-with-frida --duration-ms - decompile-all --limit - inspect-packet-fields --limit and inspect-signal-decoders --limit - analyze-javascript-application resource bounds (--max-semantic-nodes, --max-semantic-nodes-per-file, --max-semantic-unknowns, --max-semantic-unknowns-per-file, --max-heap-mb, --analysis-timeout-ms) Bind these options through cliIntegerArgument (extended with an optional maximum) so canonical bounds are preserved in the CLI adapter while the decimal-text guard rejects those spellings at the input boundary with "Expected a decimal integer". Reuse the shared observationDuration guard for discover-webmcp-tools --observation-ms to match its inspect-web-page and observe-web-session siblings, which refuse blank text. Canonical MCP contracts and describe texts are unchanged. New boundary tests refuse "0x10", "1e3", and "" per option and confirm decimal values still reach the operations.
Give cliIntegerArgument a Number.MAX_SAFE_INTEGER default maximum instead of branching on an optional one. The default adds no limit because .safe() already bounds the value, and the signature matches the helper proposed in morluto#7877 so call sites from either change work with either helper. Drop the comment on the JavaScript resource bounds that described the domain fields as z.int() (ZodNumberFormat). They are z.number().int(), a ZodNumber that incur coerces with Number(), which is the same reason as every other option in this change.
Contributor
[Medium impact] The PR appears safe to merge; both previous findings are addressed and no new blocking issue was found. SummaryThe PR requires decimal integer text for the listed CLI options while preserving their number checks and defaults.
Review checks were source-only; dependencies were not installed. The superseding-PR check could not finish because GitHub authentication was unavailable. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A["Supplied option text"] --> B["Decimal integer guard"]
B --> C["Shared number checks"]
C --> D["Existing command"]
E["Omitted option"] --> F["Keep absent or use shared default"]
F --> D
Reviews (2) · Last reviewed commit: "fix(cli): bind decimal options to canoni..." · Reviewed by Greptile |
SwintexD
marked this pull request as ready for review
October 31, 2026 23:16
The JavaScript resource controls, EVM timeout, SQLite worker timeout and keyed-archive page options restated their domain bounds, defaults and help text in the CLI adapter, so later domain changes could leave the CLI stale. Admit decimal argv text with cliIntegerArgument and pipe it into the owner's field instead. Optionality, defaults and descriptions stay on the outer schema, where Incur reads them for parsing and help. Run the read-adb-logcat positive control with a missing REA_ADB_PATH so it never starts an installed adb client.
15 of 22 tasks
8 of 19 tasks
11 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Several numeric CLI options still bind raw domain schemas or plain
z.number()fields. Incur coercesZodNumberargv fields withNumber()(the hazard noted in
src/cliObservationOptions.ts), so non-decimalspellings pass validation and silently change meaning:
""becomes0,"0x10"becomes16, and"1e3"becomes1000.This PR binds those options through the existing
cliIntegerArgumentdecimal-text guard, the same approach merged for
--overload-index(#7493) and
--outline-depth(#7505) and integrated for integerpositional arguments in 8d82579 (refs #4182).
No issue tracks these options. Two open PRs fix other commands in the same
class: #7877 (byte-entropy windows, #7376) and #8042 (native UI and command
deadlines). They touch different commands; the only shared code is the
helper signature described below.
Problem and expected behavior
Smallest trigger:
rea read-bytes <file> 0 --length 0x10 --jsonon a64-byte file. On
d54a466the option passes validation (Number("0x10")is16) and the command goes on to open the artifact (exit 0,
target_unavailablefor this non-binary file). Expected, and on this branch:
VALIDATION_ERRORwith
invalid_format/Expected a decimal integeronlength, before anytarget access. Options whose minimum is 0 (
--offset,--duration-ms)silently accepted
""as0.Affected options:
read-bytes --length,search-bytes --limitinspect-asset-catalog --offset/--limit,inspect-keyed-archive --offset/--limitinspect-sqlite-database --row-limit/--worker-timeout-msinspect-evm-interface --timeout-msread-adb-logcat --count/--pidinstrument-with-frida --duration-msdecompile-all --limitinspect-packet-fields --limit,inspect-signal-decoders --limitanalyze-javascript-application --max-semantic-nodes,--max-semantic-nodes-per-file,--max-semantic-unknowns,--max-semantic-unknowns-per-file,--max-heap-mb,--analysis-timeout-msdiscover-webmcp-tools --observation-ms(blank text only; see below)Change and scope
src/cli/options.ts:cliIntegerArgument(min, max = Number.MAX_SAFE_INTEGER)gains an optional upper bound. Existing call sites are unchanged, and the
default adds no new limit because
.safe()already bounds the value. Thesignature matches fix(cli): reject non-decimal byte-entropy window options #7877, so call sites from either PR work with either
helper; whichever lands second resolves a one-line conflict in this helper.
controls, EVM
timeout_ms, SQLiteworker_timeout_ms, keyed-archiveoffset/limit) go throughcliOptionalDecimalField/cliDefaultedDecimalField: decimal text is admitted bycliIntegerArgumentand then piped into the owner's field, so bounds, defaults and help text
stay owned by the domain schema. Optionality, defaults and descriptions sit
on the outer schema, where Incur reads them for parsing and help.
min/max/default/optionalsemantics throughcliIntegerArgument.<value>instead of<number>, as it alreadydoes for existing
cliIntegerArgumentoptions. Descriptions and defaultsare unchanged (help compared on
d54a466and this branch).discover-webmcp-tools --observation-msuses the sharedobservationDuration(100)guard, likeinspect-web-pageandobserve-web-session. That guard refuses blank text but intentionallystill accepts non-decimal numeric spellings (
src/cliObservationOptions.test.tsasserts
"0x10"→ 16), so this option now matches its siblings rather thangetting a stricter rule.
Follow the contribution scope.
Maintainer scope decision: not applicable; ordinary CLI input fix within
existing boundaries.
Contract and boundary impact
text before Incur's
Number()coercion. Application workflows receive thesame typed numbers for decimal input.
text for the listed options. MCP schemas are unchanged.
docs/public/product-catalog.json), package, or installation impact: none expected; flags and describe texts are unchanged.docs:checkwas not run locally.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
The change itself only validates argv text. The affected commands keep their
existing effects for accepted input.
Evidence and regression coverage
Tests added or updated:
tests/boundary/cli/cliDecimalArguments.test.tsruns the real CLI in-process (
createCli(...).serve). For each option itasserts that
0x10,1e3and""returnVALIDATION_ERRORnaming thefield, and it checks that decimal values still get past validation. The
read-adb-logcatpositive control sets a missingREA_ADB_PATH, so itnever starts an installed adb client.
Base reproduction: with the source files reverted to
d54a466and the newtest kept, 7 of 8 tests fail (every rejection test); the decimal control
passes. On this branch all 8 pass.
User-visible CLI/MCP output,
read-bytes <file> 0 --length 0x10on thisbranch (
--length 8still passes validation):Remaining proof gaps:
decompile-all --limitis changed but has noregression case. Only Windows was exercised. Node v22.23.3 was used rather
than the pinned 24.22.1.
For boundary fixes: this covers input-boundary validation at the CLI adapter.
No lifecycle, ownership or cleanup behavior changes.
For evidence-bearing changes:
Validation performed
Windows 11 x64, Node v22.23.3, branch based on
d54a466.createCli(...).serve),read-bytes <file> 0 --length 0x10: ond54a466passes validation and reaches artifact open; on this branchVALIDATION_ERROR(output under "Evidence and regression coverage").npx vitest run tests/boundary/cli/cliDecimalArguments.test.ts— 8 passed.d54a466— 7 failed, 1 passed.npx vitest runon the new test plustests/boundary/cli/cliIntegerArguments.test.ts,cliInputSchemaRequired.test.ts,referenceSourceSummary.test.ts,adbCli.test.ts,src/cliObservationOptions.test.tsand the keyed-archive, search-bytes and local-path acceptance tests — 10 files, 160 passed, 16 skipped.npm run typecheck— passed.npx oxfmt --checkon the 13 changed files — clean.npx oxlinton the 13 changed files — 5max-lines-per-functionwarnings, all pre-existing (the touched functions got shorter).npm run verify:test-discovery— "Discovered all 2930 test files exactly once."npm run check— cannot start on this Windows source checkout: itsrun-exclusivewrapper requires the native addon that a source checkout lacks (see CONTRIBUTING, "Windows source checkouts"). Its stages were run directly instead:npm run lint— 0 errors, 3169 warnings (same counts asd54a466).npm run format:check,npm run metadata:check,npm run verify:architecture-guards,npm run knip:production,npm run lint:typed(0 errors) — passed.npm run knip— fails with one unused exported type insrc/process/DarwinHelperCache.ts, identically ond54a466; not touched here.After the review fixes in 3ff176a:
--max-heap-mbaccepts512, rejects64/99999with the domain'stoo_small/too_big, and rejects0x400,1e3,""and512asExpected a decimal integer; keyed-archiveoffset/limitfall back to the domain defaults0/20000when omitted and keep its bounds.--helpforinspect-keyed-archive,inspect-evm-interface,inspect-sqlite-databaseandanalyze-javascript-applicationcompared withd54a466: same descriptions and defaults; only the type hint changes to<value>.npm run compile, then the same 10 test files — 160 passed, 16 skipped.npm run typecheck— passed.npm run lint— 0 errors, 3169 warnings (unchanged).npx oxfmt --checkandnpx oxlinton the 6 changed files — clean.npm run knip— only the pre-existingDarwinHelperCache.tsfinding.Compatibility, safety, and release
0x10,1e3orblank text to these options were silently reinterpreted; they now get a
VALIDATION_ERRORnaming the field. Decimal values are unchanged.boundary is involved. Windows only.
Author readiness
Human owner: @SwintexD
Before merge
type(scope): outcome.