Skip to content

fix(cli): reject non-decimal integer tokens on every numeric option - #9178

Merged
morluto merged 2 commits into
mainfrom
cursor/cli-decimal-integer-tokens-45fd
Nov 7, 2026
Merged

morluto merged 2 commits into
mainfrom
cursor/cli-decimal-integer-tokens-45fd

Conversation

@morluto

@morluto morluto commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

Numeric CLI options admitted 0x10 as 16 and 1e3 as 1000 because Incur runs Number() on z.number() argv fields. Decimal tokens now go through cliDecimalField, which pipes /^[0-9]+$/ text into the domain field. That field still owns bounds, defaults, and help. --schema publishes the input view, so the lexical guard is visible to Ajv.

This supersedes the open symptom PRs #8386, #9166, #9168, #9169, #9059, #9038, #5544, and #9161. Those PRs are not merged here.

Problem and expected behavior

Smallest trigger: a numeric option such as --observation-ms 0x10 or --token-limit 1e3. Previously the token was coerced and the command continued with a different number. Empty text on a minimum of 0 could become 0.

Expected: 0x10, 1e3, blank text, and surrounding spaces are refused during argument parsing. An in-range decimal still parses. Leading zeros stay decimal (010 is 10). Omission still uses the domain default.

Change and scope

cliDecimalField accepts required, optional, defaulted, nullable, and z.int() domain fields. It does not restate a maximum. Call sites that still built a raw z.number() or passed a domain number straight to Incur now use the helper, including native limits, ADB logcat count/pid, signal and packet page sizes, SQLite row limits, web and JavaScript observation windows, screenshot channelThreshold, decompile-directory limit, firmware ranges, desktop capture limits, API-contract file bytes, and Frida duration/keepalive. Frida attach targets are admitted only when they match /^[0-9]+$/ and are a positive safe integer. --token-limit and --token-offset use the same token check outside registered options.

Contribution scope: ordinary fix inside the existing CLI admission boundary. Maintainer scope decision for new providers or target execution: not applicable.

Not included: absolute-path schema parity, CLI/domain path field parity, and the held work listed in the request (desktop stack, debugger throws, host-effect table, Stream D, god-file splits, new settings).

Contract and boundary impact

  • Semantic owner and earliest changed stage: the domain numeric field owns bounds and defaults. The CLI adapter owns decimal-token admission before command handlers run. Handlers no longer rely on a lexical rule the schema omitted, except Frida attach, where one positional is either a pid or a spawn path.
  • Contribution scope fit and linked maintainer decision: ordinary fix; not applicable.
  • CLI and MCP/tool-catalog contract: CLI --schema for these options is anyOf an integer branch with the domain bounds and a ^[0-9]+$ string branch. JSON numbers remain valid. MCP tool schemas are unchanged.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none. Rejected tokens never reach a provider.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none. CI generates ignored catalogs.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/cli/cliDecimalArguments.test.ts walks every registered command with createCli and visitRegisteredCommands. For every integer or number property, Ajv on the advertised schema and Incur Parser.parse both reject 0x10 and 1e3, and an in-range decimal parses. Observation-duration, token-window, and existing integer-argument tests were updated.
  • Base reproduction or other evidence: source-derived from Incur Parser.coerce, which calls Number() only when the unwrapped field constructor is ZodNumber. The catalog test fails on that path before this change.
  • User-visible CLI/MCP output (if applicable): a non-decimal token is a VALIDATION_ERROR naming the field, with Expected a decimal integer, before target access.
  • Remaining proof gaps: real provider workflows were not run; admission fails before provider startup.

Boundary regression covered: CLI input admission (docs/testing.md boundary regressions) for malformed numeric tokens across registered commands. Lifecycle regressions are not applicable; no process or cleanup stage changed.

Validation performed

  • npm run test:focused -- tests/boundary/cli/cliDecimalArguments.test.ts src/cliObservationOptions.test.ts tests/boundary/cli/cliOutput.test.ts — 84 passed.
  • npm run test:focused -- tests/boundary/cli/cliInputSchemaRequired.test.ts — 23 passed.
  • npm run test:focused -- tests/boundary/cli/cliIntegerArguments.test.ts — 111 passed.
  • npx vitest run tests/acceptance/browser/observationDurationCli.test.ts tests/acceptance/webRuntimeCli.test.ts -t advertises — 2 passed.
  • Review follow-up: the catalog test records every command/field pair it probes and asserts a known set of numeric fields, including read-bytes options.length and instrument-with-frida options.durationMs. npm run test:focused -- tests/boundary/cli/cliDecimalArguments.test.ts passed after that assertion. npm run check:fast passed.
  • npm run check:fast — typecheck and lint passed. Pre-push check:fast passed again.
  • npx oxfmt on the touched files — formatted.

Compatibility, safety, and release

  • Breaking changes or migration steps: none marked. Previously accepted non-decimal spellings are rejected. Callers pass decimal integers. No ! or BREAKING CHANGE marker.
  • Real Hopper/Ghidra, browser, or OS coverage: unavailable and not required; parsing fails before those providers start.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: admission only. No new target interaction.

Author readiness

Human owner: @morluto

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

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.
Open in Web Open in Cursor 

Incur coerced z.number() argv with Number(), so 0x10 became 16 and 1e3
became 1000. Decimal tokens now pipe into the domain field, which still
owns bounds, defaults, and help.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-07T03:16:55.276148Z
We couldn’t complete this review. Comment @codex review to try again.
c5bd07e New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[High impact] The PR appears safe to merge; the previous coverage gap is fixed and no new actionable issues were found.

Summary

The PR makes numeric CLI options reject non-decimal text through cliDecimalField, while keeping domain bounds and defaults.

  • Numeric CLI inputs now accept only decimal digit strings.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Numeric CLI text] --> B{Decimal digits only?}
  B -->|No| C[Reject before handler]
  B -->|Yes| D[Convert to number]
  D --> E[Check domain bounds]
  F[Omitted option] --> G[Keep domain default or omission]
  E --> H[Command handler]
  G --> H
Loading

Reviews (2) · Last reviewed commit: "test(cli): require the decimal catalog t..." · Reviewed by Greptile

The catalog loop only failed when a probed field misbehaved, so a
registration change could skip every numeric field and still pass.
Record each probed command and field and require the known limits.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@morluto
morluto merged commit 99db80a into main Nov 7, 2026
55 checks passed
@morluto
morluto deleted the cursor/cli-decimal-integer-tokens-45fd branch November 7, 2026 03:52
@morluto morluto added area: cli CLI adapter and one-shot commands bug Something isn't working labels Nov 22, 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 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants