Problem
After Issue A, phone parsing uses a fixed US default region. But the résumé already tells us the candidate's region — extractContact extracts location in the same scan (src/lib/heuristics/extract-fields.ts:268, via US_LOCATION_RE / INTL_LOCATION_RE) — and we ignore it. A London or Bangalore résumé with a national-format number gets parsed as if US.
Use the extracted location as the region hint so national/local-format numbers parse and reformat correctly for the candidate's actual locale.
Approach
- Add a small
regionFromLocation(location: string): string | undefined helper (likely in phone.ts or a sibling): map US_LOCATION_RE matches → US; map the country tail of INTL_LOCATION_RE → ISO 3166-1 alpha-2 (e.g. United Kingdom→GB, India→IN, Canada→CA). Keep the country→ISO table small and explicit; unmatched → undefined.
- Thread the derived region into the
findPhoneNumbersInText / normalizePhone call from Issue A as defaultCountry.
- Fallback to
US when no location is extracted or the country is unmapped (matches the Issue A default — confirmed decision).
Depends on
Blocked by Issue A (the normalizer + findPhoneNumbersInText wiring must land first).
Affected files
src/lib/heuristics/phone.ts (or sibling) — add regionFromLocation + country→ISO table.
src/lib/heuristics/extract-fields.ts — pass derived region instead of hardcoded US.
- Tests —
regionFromLocation unit tests (US + 2–3 intl); a fixture demonstrating an intl national-format number reformatting correctly.
Acceptance criteria
Notes
Part of the phone-handling epic. Builds on Issue A.
Problem
After Issue A, phone parsing uses a fixed US default region. But the résumé already tells us the candidate's region —
extractContactextractslocationin the same scan (src/lib/heuristics/extract-fields.ts:268, viaUS_LOCATION_RE/INTL_LOCATION_RE) — and we ignore it. A London or Bangalore résumé with a national-format number gets parsed as if US.Use the extracted location as the region hint so national/local-format numbers parse and reformat correctly for the candidate's actual locale.
Approach
regionFromLocation(location: string): string | undefinedhelper (likely inphone.tsor a sibling): mapUS_LOCATION_REmatches →US; map the country tail ofINTL_LOCATION_RE→ ISO 3166-1 alpha-2 (e.g.United Kingdom→GB,India→IN,Canada→CA). Keep the country→ISO table small and explicit; unmatched → undefined.findPhoneNumbersInText/normalizePhonecall from Issue A asdefaultCountry.USwhen no location is extracted or the country is unmapped (matches the Issue A default — confirmed decision).Depends on
Blocked by Issue A (the normalizer +
findPhoneNumbersInTextwiring must land first).Affected files
src/lib/heuristics/phone.ts(or sibling) — addregionFromLocation+ country→ISO table.src/lib/heuristics/extract-fields.ts— pass derived region instead of hardcodedUS.regionFromLocationunit tests (US + 2–3 intl); a fixture demonstrating an intl national-format number reformatting correctly.Acceptance criteria
regionFromLocationmaps US + a small explicit set of intl countries to ISO codes; unmatched → undefined.USwhen absent/unmapped.npm run test+npm run typecheckgreen.Notes
Part of the phone-handling epic. Builds on Issue A.