Skip to content

fix(NumberInput): drop U+00B7 from the separator alphabet, and say what the parser actually does - #5468

Merged
cixzhang merged 4 commits into
mainfrom
numberparser-audit-followup
Aug 25, 2026
Merged

cixzhang merged 4 commits into
mainfrom
numberparser-audit-followup

Conversation

@cixzhang

@cixzhang cixzhang commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Post-merge audit of #5459 found three non-blocking defects. Two are documentation — the module says things the code does not do — and one is a character in the separator alphabet that no locale writes.

The docblock promised refusal where the parser now prefers. numberParser.ts still said anything that could mean two different numbers returns null. Since #5459 it does not: where a grouping and a decimal reading are both well formed, the locale's reading wins. In de-DE 1.234 is 1234 and 1.2345 is 1.2345 — a 1000× step between two adjacent inputs, with nothing on screen to say why. The behaviour is right and unchanged; it matches the precedent in utils/dateParser.ts ("for ambiguous numeric formats, uses locale preference"), and raising the threshold would refuse the commonest paste in that locale.

The rule as now stated is that grouping is well formed only when every group fits the locale's own sizes — readUnder guards the leading and inner chunks as well as the last — plus the cross-locale reading, where three-digit groups are grouping in any locale, and the group-only separators (space, apostrophe) that need just one occurrence because no locale writes them as a decimal point.

And the rule is executable. numberParser.docblock.test.ts implements the paragraph as code and grades it against the parser, input by input. It is derived only from the words: every branch names the clause it implements, and those clauses are asserted verbatim against the source, so a paragraph that loses one fails here rather than drifting. 32,550 generated inputs, zero disagreements, and the sweep was checked against mutations in both directions — a parser that changes without the words, and words that lose a clause, each turn it red.

U+00B7 was in the alphabet as "the Catalan middle dot". Catalan groups with a full stop — Intl.NumberFormat('ca').format(1234567.5) is 1.234.567,5. Sweeping every language ICU resolves in every region and collecting every character emitted as group or decimal, before and after NFKC, yields exactly seven: , . ' U+0020 U+066B U+066C and U+060C, the last written only by nqo and deliberately still not admitted. (U+00A0 and U+202F appear and need no entry — NFKC folds both to U+0020 before the alphabet is consulted.) U+2019 appears in no locale but stays: the corpus pins it as the Swiss spelling. U+00B7 has no such defence, so it is gone from the alphabet and from the now-dead branch in isGroupOnlySeparator, and 1·234·567 refuses.

The changeset claimed more than the fix delivers. It read as though pasting a structured non-number into a quantity field is now refused. It is not: the alphabet bounds characters, not shapes, so 192.168.100.200 commits 192168100200 on a plain en-US field — measured identical under this parser and under #5459's, so pre-existing and not fixed here. The wording is corrected; the code is untouched.

Also: the corpus gains the fr-FR half of the ambiguity rule (1.234 is 1.234 there, because fr-FR groups with a space, not a full stop — measured), and the [3.5, 'ar-SA', '3٫5'] row now says why. Its first explanation was itself an over-claim: the plain String spelling round trips just as well. The real reason is that Latin digits are what the field shows at rest, so localizing them would flip the script on focus — rendered at rest and on focus to confirm it.

Risk. One behaviour change: text spelled with U+00B7 no longer parses. Nothing else moves — every one of the 95 corpus rows was run under this parser and under main's, and 93 are byte-identical, the two middle-dot rows being the intended difference. No API change, formatValue untouched. The new grader re-derives the locale's symbols from Intl, so it joins the no-raw-intl-locale test-oracle allowlist with its own focused rule test; raw-import.d.ts types the ?raw import it reads its subject with.

Testing. 261 tests in packages/core/src/NumberInput pass, plus the rule's own suite. #5110's four regressions were re-driven in real Chromium against Storybook — Arabic-Indic ١٢٣ typed and pasted, 1,5 in de-DE, full-width 123 through CDP composition both stepwise and committed, and the role="alert" announcement, which now also fires for 1·234·567.

@cixzhang

…he parser does

Post-merge audit of #5459.

- The file docblock still promised that anything with two readings refuses.
  It does not: where both a grouping and a decimal reading are well formed the
  locale's wins, so de-DE `1.234` is 1234 and `1.2345` is 1.2345. Say so.
- U+00B7 was in the alphabet as the Catalan middle dot. Catalan groups with a
  full stop; walking the 136 locales Intl serves finds no locale that writes a
  middle dot between digits. Remove it and pin the refusal.
- The changeset read as though a structured non-number is now refused. The
  alphabet bounds characters, not shapes: `192.168.100.200` still commits.

Corpus also gains the fr-FR half of the ambiguity rule.
@vercel

vercel Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 25, 2026 3:26am

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 25, 2026
@github-actions

github-actions Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

NumberInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1031 -
Complexity N/A Very High (164) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.8KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

…dead U+00B7 test

Review of #5468.

- The stated rule ignored readUnder's leading-chunk guard, so it got de-DE
  `1234.567` and en-US `1234,567` wrong in both directions. Stated as code it
  disagreed with the parser on 8 of 17 inputs; it now says every group has to
  fit the locale's sizes, and names the cross-locale reading it also omitted.
  probe-kit/numberparser-docblock-rule.mjs: 0 of 35 hand-picked and 0 of 6300
  generated inputs disagree.
- isGroupOnlySeparator still matched U+00B7. Dead — NUMBER_BODY rejects it
  first — but it sat under the paragraph saying the character was removed.
- The sweep behind the alphabet is every language ICU resolves in every
  region, not a hand-written 136. That walk finds a seventh character, U+060C
  (nqo), which the alphabet still leaves out. Wording only.
- The ar-SA row claimed the localized separator is what makes the round trip
  hold. It is not: the plain `String` spelling round trips too. Say the real
  reason — the digits are what the field shows at rest.
… it stopped saying

Review round 2 of #5468.

- The rule paragraph under-predicted a space or apostrophe, which groups
  after ONE occurrence: en-US `1 234` is 1234 and the corpus asserts it.
  Add the clause.
- The out-of-repo probe reported zero disagreements because its prediction
  borrowed `isGroupOnlySeparator`'s own rule from the implementation while
  claiming to implement the sentence. A grader that borrows from the thing it
  grades cannot fail. numberParser.docblock.test.ts is derived only from the
  words: each branch names the clause it implements, and those clauses are
  asserted verbatim against the source, so a paragraph that loses one fails
  here. 32,550 generated inputs, zero disagreements.
- "text no reading fits" was missing a "that".

The grader re-derives the locale's symbols from Intl, so it goes on the
no-raw-intl-locale test-oracle allowlist with its own rule test.
@cixzhang
cixzhang merged commit 299077f into main Aug 25, 2026
20 of 21 checks passed
@cixzhang
cixzhang deleted the numberparser-audit-followup branch August 25, 2026 03:41
github-actions Bot added a commit that referenced this pull request Aug 25, 2026

This branch was successfully deployed

1 active deployment
Preview — 73f84829 Deployed Aug 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant