Skip to content

fix(sanitizer): redact grouped international phone numbers (TSK-008) - #106

Merged
jmlweb merged 2 commits into
mainfrom
hustle/maintainer/task-2026-11-19
Nov 19, 2026
Merged

jmlweb merged 2 commits into
mainfrom
hustle/maintainer/task-2026-11-19

Conversation

@jmlweb

@jmlweb jmlweb commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Summary

redactPhoneNumbers (src/core/sanitizer.ts) redacted + numbers only when their digits were unbroken. The usual written form of an international number (+34 612 345 678, +44 7700 900123) leaked into the Report, which is sent to Anthropic with the default engine. docs/SPECS.md promises phone-number redaction. Fixes TSK-008 / RPT-008.

What changed

  • src/core/sanitizer.ts: the + international rule changed from /(?<![\w.])\+[0-9]{9,14}\b/ to /(?<![\w.+])\+[0-9](?:[-. ]?[0-9]){8,14}\b/.
    • One optional space, dot or dash may sit between any two digits. Total digits are still bounded, now 9 to 15 (the E.164 maximum; it was 9 to 14).
    • It now runs before the US 3-3-4 rule, so a grouped international number is redacted whole. Otherwise a US-looking fragment could be cut out of its middle.
    • The separator is a literal space, not \s, so a match never crosses a line break.
    • The (?<![\w.+]) lookbehind keeps things like semver build metadata (1.0.0+2013…) out of scope.
    • ReDoS: each repetition consumes exactly one digit, so matching stays linear.
  • The redactPhoneNumbers docstring now describes all three rules: international +, US 3-3-4, and labelled 10 digits. It also states that bare digit runs are untouched. It previously said "US phone numbers".
  • src/core/sanitizer.test.ts: new parameterized tests for grouped international numbers, surrounding text, and non-phone digit runs.
  • Backlog: TSK-008 moved to complete with the criterion evidence. Added learning LRN-007.

Acceptance criteria

  1. sanitize redacts +34 612 345 678, +44 7700 900123 and phone +34 612 345 678. Evidence: the redacts the grouped international number in %s cases pass, each with exactly 1 redaction and no digits left. All 7 new positive tests failed before the fix (7 failed | 143 passed).
  2. Separators may be spaces, dots or dashes. Evidence: the +34.612.345.678, +34-612-345-678 and +49 30 1234 5678 cases pass.
  3. Bare digit runs without + or a label are untouched. Evidence: the leaves %s untouched without a + prefix or a label cases pass with 0 redactions for 1700000000123, 612 345 678, build 20261119 took 345 678 ms and version 1.2.3. The existing Phone: 5551234567, US-format and +1 555 123 4567 tests still pass.
  4. The docstring matches what the function covers. Evidence: see the diff of the redactPhoneNumbers JSDoc.
  5. pnpm check && pnpm test pass. Evidence: typecheck, eslint and prettier are clean. pnpm test gives 26 files and 482 tests passed. pnpm build succeeds.

Trade-off

Matching is greedy, so trailing digits separated by spaces can be absorbed into the redaction, up to 15 digits in total. For example, +44 7700 900123 12 items loses the 12. This over-redacts, which is the safe direction for a sanitizer.

Verification

pnpm vitest run src/core/sanitizer.test.ts   # 7 failed before the fix, 150 passed after
pnpm check                                   # clean
pnpm test                                    # 482 passed
pnpm build                                   # success

🤖 Generated with Claude Code

The + international rule only matched an unbroken digit run, so the usual
written form (+34 612 345 678, +44 7700 900123) leaked into the Report.
It now accepts single spaces, dots or dashes between digits, still bounded
to 9-15 digits, and runs before the US 3-3-4 rule so a grouped number is
redacted whole. Bare digit runs without + or a label stay untouched. The
redactPhoneNumbers docstring now describes every rule it applies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jmlweb

jmlweb commented Nov 19, 2026

Copy link
Copy Markdown
Owner Author

🤖 hustle review: approve — Regex bounds 9-15 digits linearly, runs before the US rule so grouped international numbers are redacted whole, and tests plus docstring cover every acceptance criterion; the over-redaction trade-off is documented and safe.

Resolve backlog index conflict: 9 pending tasks after TSK-008 moved to
complete and TSK-015 was added on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jmlweb

jmlweb commented Nov 19, 2026

Copy link
Copy Markdown
Owner Author

🤖 hustle review: approve — The regex change is correct and linear-time. It runs before the US rule, and the tests cover every acceptance criterion, including the negative cases. The docstring and backlog updates match the diff.

@jmlweb
jmlweb merged commit afb4428 into main Nov 19, 2026
8 checks passed
github-actions Bot pushed a commit that referenced this pull request Nov 19, 2026
## [4.1.6](v4.1.5...v4.1.6) (2026-11-19)

### Bug Fixes

* **sanitizer:** redact grouped international phone numbers (TSK-008) ([#106](#106)) ([afb4428](afb4428))

### Chores

* **backlog:** file and triage project filter dot-name report ([#105](#105)) ([ef663f3](ef663f3))
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 4.1.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant