Repository navigation
fix(setup): read signed 64-bit TOML integers losslessly - #4937
Conversation
Codex and Grok client TOML was parsed with smol-toml's default reader, which rejects any integer beyond JavaScript's safe Number range. Valid TOML 1.0 Int64 values such as `max_bytes = 9223372036854775807` made setup, doctor and uninstall treat the whole file as malformed. The client TOML owner now parses with `integersAsBigInt: "asNeeded"`, keeping safe integers as numbers and larger ones exact as bigint, and rejects values outside signed Int64 before any write. All TOML parses in the document owner (document read, inline string decoding and the preserving-edit check) use that reader. The inline-table writer emits bigint values, and setup and doctor accept a positive bigint `startup_timeout_sec`/`tool_timeout_sec` instead of replacing or rejecting it. Fixes #4917 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 actionable correctness or security issue was found. SummaryReads large TOML integers as exact
Review limits: tests were not run during this review. The superseded-PR check could not be completed because GitHub access required authentication. Reviews (1) · Last reviewed commit: "fix(setup): read signed 64-bit TOML inte..." · Reviewed by Greptile |
Summary
Fixes #4917
Codex and Grok Build setup, doctor and uninstall rejected valid TOML files whose integers were outside JavaScript's safe Number range, such as
[history] max_bytes = 9223372036854775807. They reported the file as malformed (integer value cannot be represented losslessly) even though Codex itself accepts it. With this change those integers are read exactly and preserved. Values outside signed Int64 are still rejected before any write.Problem and expected behavior
config.tomlinteger with magnitude above 2^53 - 1, for example9007199254740993or9223372036854775807.ClientConfigurationDocumentcalledsmol-tomlparsewith its default options, and that reader throws on any integer beyond the safe Number range.9223372036854775808/-9223372036854775809fail before writes.Change and scope
ClientConfigurationDocument.tsnow owns a singleparseClientTomlreader. It callsparse(text, { integersAsBigInt: "asNeeded" }), so safe integers staynumberand larger ones become exactbigint. It then walks the parsed tree iteratively, without argument spreads, and throws aSyntaxErrorfor any bigint outside[-2^63, 2^63 - 1]. smol-toml does not enforce that bound itself.tomlTextHoldscheck that compares an edited document against the original values. Without that last one, a preserving edit could fall back to a whole-document rewrite.tomlInlineValue) writesbigintvalues exactly. Before, it wrote them as"".positiveTimeoutkeeps a positive bigintstartup_timeout_sec/tool_timeout_secinstead of replacing it with the default. Doctor's registration schema accepts a positive bigint for those two Codex keys, and the timeout advisory compares viaNumber(...). That comparison is safe because any bigint value is above 2^53 and so above the allowance.Contract and boundary impact
src/application/ClientConfigurationDocument.tsTOML parse, the boundary where client config text is read.planned/readyinstead ofneeds_humanfor these valid files. The out-of-range diagnostic now readsinteger N is outside the signed 64-bit range.Expected effects:
Evidence and regression coverage
tests/acceptance/setup/tomlConfigurationIntegerRangeCli.test.tsruns the real CLI:[history]. Covers the setup dry-run (planned, file unchanged), apply (exact backup, original prefix kept), a repeated apply with no actions and identical bytes, and uninstall restoring the original bytes.mcp_serverstable holding a foreign9007199254740993and an existing REA entry withtool_timeout_sec = 9223372036854775807. The comment and both exact integers are kept, and REA's command is replaced.9223372036854775808and-9223372036854775809produceneeds_humanwith the Int64 diagnostic, exit 1, and leave the file unchanged.origin/mainand the new test kept, all 4 tests failed. The valid cases failed withneeds_human. The out-of-range cases still failed closed on main, but with the old "losslessly" diagnostic rather than the Int64 range message.For evidence-bearing changes: not applicable (setup configuration only).
Validation performed
npm run test:focused -- tests/acceptance/setup/tomlConfigurationIntegerRangeCli.test.ts tests/acceptance/setup/tomlConfigurationCapacityCli.test.ts src/application/ClientConfigurationDocument.capacity.test.ts src/application/ClientConfigurationDocument.shape.test.ts tests/boundary/filesystem/clientRegistrationStatus.test.ts tests/boundary/filesystem/clientLifecycle.test.ts: 6 files, 99 tests passed (includes the build).origin/mainsources: 4 failed (expected).npm run check:fast(typecheck + lint): passed.npx oxfmt --checkon the changed files: passed.npx oxlinton the changed files: no errors, only existing size/complexity warnings.Compatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.🤖 Generated with Claude Code