feat(spec): port getMunicipalities to the bridge - #584
hyanmandian wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The last of the four, and the one that is about data rather than logic: 5,571 municipalities
per state, in the order `localeCompare(…, "pt-BR")` puts them.
That order is the whole difficulty. Go and Rust ship no collator, Ruby compares bytes, and
Python, Java and C# each resolve their own ICU or libc table, so sorting at run time would
produce seven different answers. `data/get-municipalities.ts` resolves both orders once —
the per state one and the combined one — against the JavaScript package's own comparator,
and bakes them into the table every emitter materialises natively. Nothing sorts at run
time.
Every municipality of every key is replayed, not a sample, so one name out of place in one
target fails the check. The keys include an unknown state, a lower case one, the empty
string and three inherited `Object` property names, because each of those has an answer of
its own.
typescript 34/34 python 34/34 ruby 34/34 go 34/34
rust 34/34 java 34/34 csharp 34/34
The C ABI does not carry this one: a function that answers a list needs an iterator rather
than a buffer, and it is refused rather than guessed at.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UX1gTGeMTyoXQyr1qUoQKd
8c23e92 to
3cd2385
Compare
c1b1928 to
9660681
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## claude/bridge-get-address-info-by-cep #584 +/- ##
=========================================================================
Coverage ? 100.00%
=========================================================================
Files ? 183
Lines ? 2069
Branches ? 612
=========================================================================
Hits ? 2069
Misses ? 0
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Tree-shaking report✅ No bundle size impact. All 155 exports are the same size as on the base branch (full import 648.9 KB, gzip 166.2 KB). All exports (155)
How this is measuredEvery export is imported alone into an esbuild consumer bundle (minified, tree-shaken) built from the head and from the base of this pull request; the sizes are the resulting bundles, gzip is their gzipped size. 🔴 marks a regression: a pre-existing export that grew more than 20% and more than 256 B, or the bundle importing every pre-existing export growing more than 5%. 🟡 is growth under the threshold, 🟢 a decrease, ⚪ no change, 🆕 an export that does not exist on the base (never a regression), 🗑️ an export that was removed. An intentional increase is accepted with the |
|
Two red-looking things here, neither of them this PR's:
Everything on GitHub Actions is green or still running. Generated by Claude Code |
What does this PR do?
Stacked on #583 → #582 → #581 → #580 (the compiler). This PR's diff is only what
getMunicipalitiesadds.The last of the four, and the one that is about data rather than logic: 5,571 municipalities per state, in the order
localeCompare(…, "pt-BR")puts them.This is the "extra" the other three did not need — the answer to could the bridge recreate anything? has to include a utility whose difficulty is a table and a locale, not a regular expression.
The diff, in full
source/get-municipalities.tssource/get-municipalities.data.jsondata/get-municipalities.tsconformance/cases/get-municipalities.tsNo compiler change.
The order is the whole difficulty
Go and Rust ship no collator at all, Ruby compares bytes, and Python, Java and C# each resolve their own ICU or libc table. Sorting at run time would produce seven different answers, and there would be no way to call any of them wrong.
So
data/get-municipalities.tsresolves both orders once — the per-state one and the combined one — against the JavaScript package's own comparator, and bakes them into the table every emitter materialises natively. Nothing sorts at run time. The combined order is matched back by(name, code)rather than by position, so it stays honest even if the package changes how it merges the states.This is also what put the chunked static initialisers in the Java and C# emitters: 5,571 rows do not fit in a 64 KiB method.
Parity
Every municipality of every key is replayed, not a sample, so one accented name out of place in one target fails the check. The keys include an unknown state, a lower-case one, the empty string and three inherited
Objectproperty names, because each of those has an answer of its own.bash spec/bridge/conformance/run-all.sh:Each of those 34 is a whole list: the
*key alone compares 5,571 rows.The C ABI does not carry this one. A function that answers a list needs an iterator rather than a caller-owned buffer, so the ABI emitter refuses it and says why in the generated file.
bash spec/bridge/conformance/verify-typescript.sh, now all four:Including
expectTypeOf(getMunicipalities).parameter(0)having to beStateCode | undefined.Checklist
npm test) — not applicable: no change tosrc/. The generated output is checked against the package's existing suite byverify-typescript.sh, and against a recording of the shipped package byrun-all.sh.npm run checkpasses locally (format, lint, types).npm run build:llmsif I toucheddocs/utilities.md— not applicable,docs/untouched.Additional context
source/get-municipalities.data.jsonis generated and committed, because it is an input to the compiler rather than a recording —node spec/bridge/data/build.tsrebuilds it byte for byte. It is one line on purpose and excluded from the formatter.🤖 Generated with Claude Code
https://claude.ai/code/session_01UX1gTGeMTyoXQyr1qUoQKd
Generated by Claude Code