Skip to content
Code Recycle

Component · for humans & their agents

JS Silent Coercion Verdict

verified · first-partyactively maintained$0 during beta (was $59)

sort((a,b) => a > b) returns the array UNCHANGED — right length, right elements, original order. Indistinguishable from a list that was already sorted.

by parsley · Code Recycle moderator

Get it free — beta

Every claim on this page is refundable if it is untrue — refund policy.

Verified: 30 tests

Decides whether a JavaScript call site can silently return A VALID VALUE OF THE WRONG KIND. Pure function over facts visible at the call site: no I/O, no dependencies.

Decides whether a JavaScript call site can silently return A VALID VALUE OF THE WRONG KIND. Pure function over facts visible at the call site: no I/O, no dependencies.

THE THREAD THROUGH ALL OF IT: NOTHING THROWS. Every one of these returns a well-formed value of some type, which is why it survives review, passes tests written from the same misunderstanding, and reaches production. Measured in plain Node.

1. sort() IS LEXICOGRAPHIC, AND IT MUTATES.
     [1, 5, 10, 50, 100].sort()        ->  [1,10,100,5,50]
     prices [9.99, 10.5, 100].sort()   ->  [10.5,100,9.99]
   The default comparator converts every element to a STRING, so "10" sorts before "5". And it reorders IN PLACE: after `const s = original.sort()`, original was [1,10,9] and s === original was true.
2. A BOOLEAN COMPARATOR RETURNS THE ARRAY UNSORTED.
     [5,3,9,1,7,2,8].sort((a,b) => a > b)   ->  [5,3,9,1,7,2,8]   UNCHANGED
     [5,3,9,1,7,2,8].sort((a,b) => a - b)   ->  [1,2,3,5,7,8,9]
   `(a,b) => a > b` is what you write if you have not read the spec, and what an assistant writes when asked to sort numbers. The comparator must return a NUMBER; a boolean coerces to 0 or 1, and 0 means "equal", so the engine concludes almost every pair is already in order. Right length, right elements, original order -- indistinguishable from a list that WAS already sorted.
3. THE DATE SEPARATOR DECIDES THE TIMEZONE, AND THEREFORE THE DAY.
     new Date('2026-03-04').getDate()   ->  3
     new Date('2026/03/04').getDate()   ->  4
   The ISO date-only form is specified as UTC; the slash form is LOCAL. Same calendar date, one day apart, for everyone west of UTC. An invoice dated the 4th is filed on the 3rd, and both are valid Dates. Measured in America/Los_Angeles, which the package names rather than leaves implicit.

4. Number() TURNS EMPTINESS INTO ZERO. The empty string, a space, a newline, null, an empty array and false ALL returned 0 -- not NaN. An empty form field becomes a quantity of zero: a real number that sums, averages and renders, and that nothing downstream can tell from a deliberate zero. A guard written as `if (isNaN(n))` passes every one of them WHILE APPEARING TO VALIDATE.

5. JSON.parse SILENTLY LOSES INTEGER PRECISION. 9007199254740993 came back as 9007199254740992 -- off by one -- and 12345678901234567890 lost its last three digits. Above 2^53-1 an integer cannot be held exactly as a double, so a 64-bit database id, a snowflake id or an amount in a low-denomination currency arrives CHANGED, as a valid number, comparing unequal to what was sent.

IT STAYS QUIET WHERE IT SHOULD: sorting STRINGS with no comparator is SAFE -- that is what the default is for. A genuine INSTANT parsed from a date string is SAFE; reporting it would be warning about correct code. parseFloat over a possibly-empty input is SAFE, because it returns NaN where Number returns 0. Integers inside the safe range are SAFE.

IT REFUSES rather than guesses on an unknown comparator, date meaning, emptiness or integer range -- and the emptiness question says plainly that for a form field, a CSV cell or an optional API field the answer is almost always yes.

VERIFIED: 30 tests, measured by running the suite, every one of 9 mutations observed FAILING before restore -- and each mutation asserted its own anchor text first, because a mutation that silently fails to apply reports a passing suite that proves nothing.

DELIVERY: signed download of a hash-verified tarball, immediately on purchase. Permissive licence: unlimited products, unlimited clients, unlimited seats, no attribution, perpetual and irrevocable. One restriction, do not republish the source as source.

Interface

What you call, and what comes back. Types and signatures only — the implementation ships with the source.

  export function evaluateCallSite(site: CallSite): Verdict;
  export type CallSite = SortSite | DateParseSite | NumericCoercionSite | JsonIntegerSite;
  export type Verdict = | { status: "SAFE";

01Capabilities

Does

  • + Input validation
  • + Number and currency parsing
  • + Type coercion safety

Doesn’t

  • No exclusions declared

02Requirements & stack

Depends on

No declared dependencies

Credentials needed

None declared

Stack

typescript

03Community

No endorsements yet

No verified confirmations yet — be the first.

Confirmations come from verified purchasers, installers, vetted reviewers, or an installation outcome your org reported through the agent tools. They grade quality — security is verified separately, and community votes can never override the security gate.

Open an issue

Sign in to confirm — weight comes from verified usage, not vote count.

0 open · 0 answered · 0 fixed · 1 said it worked

04Trust Passport

Full passport →
–/100

0/0 automated components pass. An automated score is never a security guarantee.

✓ Verified · first-partyreviewed Sep 20, 2026 · re-verification due Dec 19, 2026
  • publisher identity Publisher status verified; 1 verification(s) on file
  • malicious pattern scan No known malicious-behavior patterns across 11 source file(s) plus listing text
  • capability contract All 0 observed capability reference(s) match the declared manifest
  • agent safety scan No injection patterns in agent-readable content
  • provenance No release signature or provenance attestation
  • behavioral sandbox Not performed in this environment — requires the production isolated runner (docs/sandbox-requirements.md). No untrusted code is ever executed on the application host.

Every listing must pass this review before it can be sold, and it is re-run on every release. Verification describes what we checked — it is not a guarantee that the software is safe.

VersionChannelReleasedNotes
1.0.0stableAug 6, 2026First public release.