Conversation
Share syntax-validated lexical whitespace formatting across the route and machine contract; preserve large integers, exponent/decimal spellings and negative zero. Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
There was a problem hiding this comment.
1 issue found across 7 files
Confidence score: 5/5
src/contracts/json-format.test.jsduplicates theLOSSLESS_INPUTandLOSSLESS_PRETTYfixtures fromsrc/utils/lossless-json.test.js, creating maintenance drift risk without indicating a functional regression; consolidate the coverage or clearly justify the separate contract boundary.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/contracts/json-format.test.js">
<violation number="1" location="src/contracts/json-format.test.js:21">
P3: These new contract tests duplicate the exact fixture and expected outputs already present in src/utils/lossless-json.test.js (LOSSLESS_INPUT, LOSSLESS_PRETTY). The escaped-string lexeme is subtle and error-prone, and maintaining two independent copies means a fix or coverage change in one fixture silently drifts from the other. Keep the contract-level tests (they do verify the transform wrapper), but share the fixture instead of copying it: export LOSSLESS_INPUT/LOSSLESS_PRETTY from lossless-json.test.js (or move them to a shared fixture module) and import them here.</violation>
</file>
Shadow auto-approve: would not auto-approve because issues were found.
Re-trigger cubic
| expect(result).toBe('{"a":1,"b":2}'); | ||
| }); | ||
|
|
||
| it("preserves every numeric and string lexeme while formatting", () => { |
There was a problem hiding this comment.
P3: These new contract tests duplicate the exact fixture and expected outputs already present in src/utils/lossless-json.test.js (LOSSLESS_INPUT, LOSSLESS_PRETTY). The escaped-string lexeme is subtle and error-prone, and maintaining two independent copies means a fix or coverage change in one fixture silently drifts from the other. Keep the contract-level tests (they do verify the transform wrapper), but share the fixture instead of copying it: export LOSSLESS_INPUT/LOSSLESS_PRETTY from lossless-json.test.js (or move them to a shared fixture module) and import them here.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/contracts/json-format.test.js, line 21:
<comment>These new contract tests duplicate the exact fixture and expected outputs already present in src/utils/lossless-json.test.js (LOSSLESS_INPUT, LOSSLESS_PRETTY). The escaped-string lexeme is subtle and error-prone, and maintaining two independent copies means a fix or coverage change in one fixture silently drifts from the other. Keep the contract-level tests (they do verify the transform wrapper), but share the fixture instead of copying it: export LOSSLESS_INPUT/LOSSLESS_PRETTY from lossless-json.test.js (or move them to a shared fixture module) and import them here.</comment>
<file context>
@@ -18,6 +18,40 @@ describe("json-format transform", () => {
expect(result).toBe('{"a":1,"b":2}');
});
+ it("preserves every numeric and string lexeme while formatting", () => {
+ const input =
+ '{"max":9007199254740993,"min":-9007199254740993,"huge":1e400,"fixed":1.2300,"negativeZero":-0,"nested":[[9007199254740993],{"text":"quote: \\" slash: \\\\"}]}';
</file context>
Summary
fix(json): preserve numeric lexemes when formatting. This is logical change 8/11 in the dependency-ordered product-audit release stack.
Refs #969
What changed
6e568d42170e075d649947907358a623a0f87c8a; validated tree:7be508496c9d4ea0a54aec5065ff6bdbb9d47f99.Why
Prevent JSON formatting or minification from silently rounding large integers or rewriting numeric lexemes.
Verification
bun run buildpassed on this exact candidate tree.npm test -- --maxWorkers=2passed on this exact candidate tree.Desktop/mobile Format and Minify preserve 9007199254740993; real clipboard output matches; malformed input clears stale output.
Final combined tree additionally passed 801 unit tests and all 293 Playwright tests with retries disabled, plus all 48 primary tool workflows at desktop and mobile. The exploratory Color Converter exact-HEX boundary remains a documented pre-existing defect; its runtime is unchanged by this stack.
Risk & rollback
Summary by cubic
Fixes JSON formatting and minification to preserve numeric lexemes (large integers, exponent/decimal spellings, negative zero) and escaped strings by reformatting only whitespace instead of re-serializing through
JSON.parse/stringify.formatJsonLosslesslyutility and uses it in both the JSON format contract and the formatter route.-0, exponent forms, and escaped strings while still validating with the native JSON parser.Written for commit 6e568d4. Summary will update on new commits.