[PR #4935] [CLOSED] fix(setup): read client TOML integers losslessly #6680

Closed
opened 2026-11-01 21:42:16 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4935
Author: @piyushpcs
Created: 10/18/2026
Status: ❌ Closed

Base: main ← Head: fix/codex-toml-int64


📝 Commits (1)

  • a7fc23d fix(setup): read client TOML integers losslessly

📊 Changes

3 files changed (+191 additions, -3 deletions)

View changed files

➕ src/application/ClientConfigurationDocument.integers.test.ts (+89 -0)
📝 src/application/ClientConfigurationDocument.ts (+42 -3)
➕ tests/boundary/filesystem/clientConfigurationIntegerPrecision.test.ts (+60 -0)

📄 Description

Drafted with AI assistance: I read the full diff, worked through the approach, and ran every command listed below. Ask me anything about the code.

Summary

Fixes #4917. A Codex or Grok configuration that holds a valid signed 64-bit integer, such as [history] max_bytes = 9223372036854775807, was reported as malformed, so setup refused even a read-only plan and doctor called a valid file bad.

Problem and expected behavior

The shared client TOML reader used smol-toml's defaults, which reject any integer a JavaScript number cannot hold. One such line was enough to block planning, and the same read backs doctor and uninstall.

TOML 1.0 integers are signed 64-bit, and the native Codex CLI accepts these files. REA's setup contract already requires preserving unrelated configuration. Values outside the signed 64-bit range, for example 9223372036854775808, are rejected by both clients and must stay rejected.

Change and scope

One reader, parseLosslessToml, now serves all three TOML read sites in ClientConfigurationDocument.ts: the document root, the inline string-value decoder, and the edit-preservation check. It parses with integersAsBigInt: "asNeeded", so magnitudes a JavaScript number holds stay numbers and unrelated settings keep their shape, while larger ones stay exact as bigint for read-modify-write and serialization.

Asking the parser to keep integers lossless also stops it rejecting magnitudes beyond the format's range, so the reader enforces TOML 1.0's signed 64-bit range itself. tomlInlineValue gained a bigint branch, because an exact integer reinserted into a rewritten inline server table would otherwise collapse to "".

Not included: no change to how registrations are written or compared, no normalization of preserved values, and no other client formats. None of the JSON, YAML, or DSH paths can carry a TOML integer.

Contract and boundary impact

  • Semantic owner and earliest changed stage: client configuration parsing (src/application/ClientConfigurationDocument.ts), reading a client's own TOML before any plan is formed.
  • Contribution scope fit and linked maintainer decision: ordinary fix inside existing boundaries; not applicable.
  • CLI and MCP/tool-catalog contract: none. Same commands and fields; setup, doctor, and uninstall now read these files instead of reporting them malformed.
  • Provider, bridge, target-format, or platform compatibility: none; TOML clients (Codex, Grok) only.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details: none; no target is opened.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

The only write is the registration (and its backup) that setup already performs; nothing else in the workflow changes.

Evidence and regression coverage

  • Tests added or updated: src/application/ClientConfigurationDocument.integers.test.ts (safe sizes stay numbers, larger sizes stay exact, arrays and nested tables, an unchanged rewrite, inline-table reinsertion, and the range rejections) and tests/boundary/filesystem/clientConfigurationIntegerPrecision.test.ts (Codex and Grok through the real setup workflow, plus one range rejection).
  • Base reproduction: on 2183c9598 the two workflow cases report status: invalid where they should report update, and 9 of the 13 module cases fail. The four number-size controls pass before and after, so the change is scoped to the unsafe magnitudes.
  • User-visible CLI output, built source checkout with an isolated HOME and CODEX_HOME:
    • Valid Int64 maximum: setup --client codex --dry-run --format json reports status: planned with configure_client:codex and install_skill, and the configuration is byte-identical afterwards.
    • Out-of-range control: status: needs_human with integer value is outside the signed 64-bit TOML range.
    • Apply: status: ready, the [history] value and its comment are preserved, the .rea.backup is byte-identical to the original, and a second run plans and applies nothing.
    • A second apply and a subsequent uninstall both leave the exact integer in place.
  • Remaining proof gaps: the native codex CLI is not installed on this machine, so the parity table in the issue is the reference rather than a comparison I ran. No packaged-install or real-provider run.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:focused -- <11 related files> — 175 passed
  • npm run check:changed — 15 files, 200 passed
  • npm run typecheck, npm run lint, npm run metadata:check, npm run docs:check — pass (docs:check 5 passed)
  • npm run verify:test-discovery — 1571 test files discovered exactly once
  • npm run format:check — the three changed files pass; the repo-wide task still fails on src/domain/propertyListXml.test.ts, which is unmodified from upstream main (a line-wrap) and untouched here
  • npm run check:pr — not run

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Files that were previously reported as malformed now read; values outside the signed 64-bit range stay rejected with a named reason.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; no provider or target interaction.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none. Preserved values are read and written back, never interpreted.

Author readiness

Human owner: @piyushpcs

  • 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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4935 **Author:** [@piyushpcs](https://github.com/piyushpcs) **Created:** 10/18/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/codex-toml-int64` --- ### 📝 Commits (1) - [`a7fc23d`](https://github.com/morluto/rea/commit/a7fc23d52afbdc3bacc1df1a5167c11cd3ff769a) fix(setup): read client TOML integers losslessly ### 📊 Changes **3 files changed** (+191 additions, -3 deletions) <details> <summary>View changed files</summary> ➕ `src/application/ClientConfigurationDocument.integers.test.ts` (+89 -0) 📝 `src/application/ClientConfigurationDocument.ts` (+42 -3) ➕ `tests/boundary/filesystem/clientConfigurationIntegerPrecision.test.ts` (+60 -0) </details> ### 📄 Description Drafted with AI assistance: I read the full diff, worked through the approach, and ran every command listed below. Ask me anything about the code. ## Summary Fixes #4917. A Codex or Grok configuration that holds a valid signed 64-bit integer, such as `[history] max_bytes = 9223372036854775807`, was reported as malformed, so setup refused even a read-only plan and doctor called a valid file bad. ## Problem and expected behavior The shared client TOML reader used `smol-toml`'s defaults, which reject any integer a JavaScript number cannot hold. One such line was enough to block planning, and the same read backs doctor and uninstall. TOML 1.0 integers are signed 64-bit, and the native Codex CLI accepts these files. REA's setup contract already requires preserving unrelated configuration. Values outside the signed 64-bit range, for example `9223372036854775808`, are rejected by both clients and must stay rejected. ## Change and scope One reader, `parseLosslessToml`, now serves all three TOML read sites in `ClientConfigurationDocument.ts`: the document root, the inline string-value decoder, and the edit-preservation check. It parses with `integersAsBigInt: "asNeeded"`, so magnitudes a JavaScript number holds stay numbers and unrelated settings keep their shape, while larger ones stay exact as `bigint` for read-modify-write and serialization. Asking the parser to keep integers lossless also stops it rejecting magnitudes beyond the format's range, so the reader enforces TOML 1.0's signed 64-bit range itself. `tomlInlineValue` gained a `bigint` branch, because an exact integer reinserted into a rewritten inline server table would otherwise collapse to `""`. Not included: no change to how registrations are written or compared, no normalization of preserved values, and no other client formats. None of the JSON, YAML, or DSH paths can carry a TOML integer. ## Contract and boundary impact - Semantic owner and earliest changed stage: client configuration parsing (`src/application/ClientConfigurationDocument.ts`), reading a client's own TOML before any plan is formed. - Contribution scope fit and linked maintainer decision: ordinary fix inside existing boundaries; not applicable. - CLI and MCP/tool-catalog contract: none. Same commands and fields; setup, doctor, and uninstall now read these files instead of reporting them malformed. - Provider, bridge, target-format, or platform compatibility: none; TOML clients (Codex, Grok) only. - Evidence, artifact, provenance, or reconstruction contract: none. - Target selection, authority, upstream behavior, and cleanup details: none; no target is opened. - Generated metadata, package, or installation impact: none. Expected effects: - [ ] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [x] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. The only write is the registration (and its backup) that setup already performs; nothing else in the workflow changes. ## Evidence and regression coverage - Tests added or updated: `src/application/ClientConfigurationDocument.integers.test.ts` (safe sizes stay numbers, larger sizes stay exact, arrays and nested tables, an unchanged rewrite, inline-table reinsertion, and the range rejections) and `tests/boundary/filesystem/clientConfigurationIntegerPrecision.test.ts` (Codex and Grok through the real setup workflow, plus one range rejection). - Base reproduction: on `2183c9598` the two workflow cases report `status: invalid` where they should report `update`, and 9 of the 13 module cases fail. The four number-size controls pass before and after, so the change is scoped to the unsafe magnitudes. - User-visible CLI output, built source checkout with an isolated `HOME` and `CODEX_HOME`: - Valid Int64 maximum: `setup --client codex --dry-run --format json` reports `status: planned` with `configure_client:codex` and `install_skill`, and the configuration is byte-identical afterwards. - Out-of-range control: `status: needs_human` with `integer value is outside the signed 64-bit TOML range`. - Apply: `status: ready`, the `[history]` value and its comment are preserved, the `.rea.backup` is byte-identical to the original, and a second run plans and applies nothing. - A second apply and a subsequent `uninstall` both leave the exact integer in place. - Remaining proof gaps: the native `codex` CLI is not installed on this machine, so the parity table in the issue is the reference rather than a comparison I ran. No packaged-install or real-provider run. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [ ] Artifact identity, source provenance, and failed attempts remain preserved. - [ ] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:focused -- <11 related files>` — 175 passed - `npm run check:changed` — 15 files, 200 passed - `npm run typecheck`, `npm run lint`, `npm run metadata:check`, `npm run docs:check` — pass (docs:check 5 passed) - `npm run verify:test-discovery` — 1571 test files discovered exactly once - `npm run format:check` — the three changed files pass; the repo-wide task still fails on `src/domain/propertyListXml.test.ts`, which is unmodified from upstream `main` (a line-wrap) and untouched here - `npm run check:pr` — not run ## Compatibility, safety, and release - Breaking changes or migration steps: none. Files that were previously reported as malformed now read; values outside the signed 64-bit range stay rejected with a named reason. - Real Hopper/Ghidra, browser, or OS coverage: not applicable; no provider or target interaction. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none. Preserved values are read and written back, never interpreted. ## Author readiness Human owner: @piyushpcs - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:42:16 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6680
No description provided.