An approval names resource 9007199254740992. A tool receipt names resource 9007199254740993. A JavaScript review service parses both JSON documents and compares the IDs. The comparison returns true.
I would require resource identifiers to remain strings across the approval and receipt path. When an identifier selects what an agent may change, numeric coercion is an unnecessary source of ambiguity.
The example below reproduces this with synthetic identifiers in a browser. It does not call an agent, contact a service or demonstrate an authorisation bypass in a named product. It shows a faulty comparison that an application could mistakenly use as one part of its approval check.
JSON syntax does not promise integer precision
RFC 8259, section 6 allows JSON implementations to limit numeric range and precision. For implementations using binary64 numbers, it identifies integers whose absolute value is at most 2**53 - 1 as interoperable with exact agreement.
JavaScript’s ordinary Number representation cannot distinguish every integer above that range. Both documents below are valid JSON:
const approved = JSON.parse('{"resource_id":9007199254740992}');
const observed = JSON.parse('{"resource_id":9007199254740993}');
console.log(approved.resource_id === observed.resource_id);
// true
The second value becomes 9007199254740992 during parsing. The first value is itself exactly representable, but the adjacent integer is not. Distinct input integers can therefore become indistinguishable even when one of them survives parsing unchanged.
A database or another service may preserve both integers perfectly. That does not protect a JavaScript component later in the path. A review dashboard, event consumer or receipt adapter that uses ordinary JSON parsing can introduce the loss before the application performs its identity check.
This differs from joining evaluation results by the wrong case. An ID-based join is the right structure, but it still needs an ID representation that preserves distinctions. Indexing by a rounded value can merge records that arrived with different identities.
Converting the parsed value to text is too late
A common repair is to convert every incoming ID to a string at the adapter boundary:
const id = String(JSON.parse(
'{"resource_id":9007199254740993}'
).resource_id);
// "9007199254740992"
That conversion faithfully prints the wrong value. BigInt() applied to the parsed number also retains the already-rounded integer. Neither operation can infer which original token produced it.
MDN’s JSON.parse() reference explicitly warns that numbers have already been converted before a reviver receives the parsed value. It also describes context.source, which lets supported runtimes recover the original primitive token. A schema-aware adapter can use that facility when an external producer cannot change its numeric format. Such an adapter needs runtime compatibility checks and field-specific validation; a generic BigInt(value) reviver is not an equivalent repair.
For an application-owned receipt contract, serialise the identifier as a string at the producer instead:
{"resource_id":"9007199254740993"}
The producer must start from the exact identifier. Wrapping a previously rounded number in quotation marks preserves its error. Follow the value back to the database driver or source service before declaring the migration complete.
Run the browser counterexample
Open or save the self-contained JSON ID fixture. The HTML contains its JavaScript, test cases and result display. It has no external dependencies and makes no network requests of its own. Inspect its source, then open the saved file in a browser.
The fixture executes both the faulty numeric comparison and a stricter string contract. In Chrome, the run produced:
{
"numericA": 9007199254740992,
"numericB": 9007199254740992,
"numericEqual": true,
"lateStringB": "9007199254740992",
"stringB": "9007199254740993",
"checkedStringMatch": false,
"passed": 10,
"total": 10
}
The page also lists the individual test outcomes. The tests deliberately require the weak path to reproduce the collision. A passing test named numeric IDs collide means the counterexample behaved as expected, not that numeric IDs passed the repaired policy.
Other tests check exact string matching, rejection of numeric IDs, malformed receipt shapes and invalid identifier spellings. They include a trailing newline, a leading zero and a full-width digit. These are local parser and contract tests. They establish no model-quality score and make no claim about the correctness of a real tool’s reported effect.
Reject the wrong type before comparing IDs
The fixture chooses a narrow application contract: a positive ASCII decimal string with no leading zero and at most 20 digits. That limit is an example policy, not a JSON requirement or a universal database identifier format.
function requireId(value) {
if (typeof value !== "string" || value.length > 20 ||
!/^[1-9]/.test(value) || /[^0-9]/.test(value)) {
throw new TypeError("resource_id must be a canonical decimal string");
}
return value;
}
This rejects even a small numeric ID such as 42. Accepting numbers only while they happen to be small would preserve two competing representations in the same contract. If an existing interface deliberately uses numeric identifiers within the safe range, validate that bounded contract explicitly. Do not silently widen it when the producer starts sending larger values.
The receipt function first validates the approved ID, parses the JSON, checks for an object with its own resource_id property, then validates the received field before using strict equality. It returns false for a valid but different string ID and throws for malformed input. A caller must handle both outcomes by refusing to mark the receipt as matching. Catching every exception and continuing with a default ID would defeat the check.
The validator does not trim whitespace, remove leading zeros or normalise Unicode digits. Those transformations could change identity under a different upstream contract. If your provider uses UUIDs, zero-valued IDs or meaningful leading zeros, define and test that provider’s exact representation instead of copying this decimal validator.
Preserve the contract through the whole tool path
Changing one JSON field is insufficient if an intermediate component turns it back into a number. Check the generated client types, storage column, message schema and review form. In TypeScript, a declared string type alone does not validate JSON received at runtime. Keep the runtime check where external values enter the application.
Use the two neighbouring identifiers from the fixture as transport canaries. Send each through the actual producer, queue, consumer and persisted receipt path in a disposable test environment. Compare the returned strings with the original strings. Include a path that reloads the record, because an in-memory round trip will miss a storage conversion. These deployment tests are recommended follow-up work; the supplied fixture exercises only the browser parsing and validation boundary.
If a system has already stored rounded identifiers, changing the column to text will not recover the originals. Reconcile affected records against a source that retained the exact IDs. Until that reconciliation finishes, avoid using the damaged field to approve retries, attach receipts or identify rollback targets.
String equality is also only one part of receipt validation. A matching resource ID does not prove which tenant owns the resource, which operation ran or whether the write became durable. Bind the receipt to the approved operation and principal, check its provenance, and independently verify the effect when the tool contract requires it. The effect-receipt article covers that wider review step.
This fixture does not reject duplicate JSON member names, authenticate receipts or implement a complete schema. Duplicate-key handling needs its own parsing policy; see the duplicate JSON tool-argument example. A clean identifier cannot compensate for contradictory fields elsewhere in the document.
For the wider operating and review workflow, see my Claude Code book, available as a Kindle edition on Amazon UK.
Add the adjacent-ID pair to one real receipt adapter’s regression tests. Require both strings to survive its complete round trip unchanged, and require the mismatched receipt to be rejected before any approval state changes.