Skip to content

feat(review): locale packs for national identifier shapes, UK first - #159

Merged
sajor2000 merged 1 commit into
mainfrom
feat/locale-packs-uk
Oct 22, 2026
Merged

sajor2000 merged 1 commit into
mainfrom
feat/locale-packs-uk

Conversation

@sajor2000

Copy link
Copy Markdown
Owner

What

Locale packs for the data-boundary guard (#146): national identifier shapes as pure data, UK first as the template pack.

  • hooks/locales/uk.json — NHS number (mod-11), Scottish CHI (mod-11 + DDMMYY plausibility), UK unit postcode (quasi-identifier), plus column-name patterns (nhs_number, chi, postcode, ...).
  • Opt-in: phi_environment.locale: uk in config.local.yaml. Default unchanged (built-in US shapes); locale checks ride on US defaults, never replace them.
  • The checksum rule doubles as the fixtures rule: a match counts as an identifier only when its checksum validates, so checksum-INVALID synthetic values (every test fixture) pass by design and nothing committed can name a real person.
  • Malformed or unknown pack fails closed (same posture as a malformed identifier index); a bare locale: key is inert.
  • Locale columns join the aggregate-table header scan; the shared identifier block stays byte-identical across the hook, indexer, and schema-peek copies (the contract test is untouched and passing).
  • Residual (noted, follow-up material): schema-peek's own header masking learns locale columns in a later pass if a UK project shows up; the hook blocks those tables regardless.

Closes #146

Validation

  • bun test tests/data-boundary-locale.test.ts — 13 tests: pack shape, validator truth tables, egress denies (valid NHS/CHI/postcode), checksum-invalid controls pass, US defaults still fire, opt-in explicitness, unknown-locale fail-closed, content-scan deny on a UK-column CSV upload
  • bun test — full suite green (1762 tests), shared-block parity test passing
  • bun run release:validate — in sync

Implements the architecture scoped on #146: a locale pack is pure data
(hooks/locales/<locale>.json) holding identifier regexes, optional named
checksum validators, and column-name patterns. Projects opt in with
phi_environment.locale in config.local.yaml; the default stays the
built-in US shapes. New countries need no guard-code changes - the UK
pack ships as the template (NHS number mod-11, Scottish CHI mod-11 with
DDMMYY plausibility, and the unit postcode as a quasi-identifier).

Checksum-valid matches are identifiers; checksum-INVALID matches
(synthetic/test fixtures) pass, so the MedSci fixture rule - never
commit a value that could name a real person - is enforced by design.
A malformed or unknown pack fails closed like a malformed identifier
index. Locale columns join the aggregate-table header scan; shared
identifier block stays byte-identical across the hook, indexer, and
schema-peek copies (contract test unchanged).

Closes #146

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: f66a4ba5-2420-4ac5-b89f-485778a55a7b
📥 Commits

Reviewing files that changed from the base of the PR and between af7dc69 and e75c079.

⛔ Files ignored due to path filters: 2
  • demo/bcg-meta-analysis/output/effects.csv is excluded by !**/*.csv
  • demo/bcg-meta-analysis/output/forest.png is excluded by !**/*.png
📒 Files selected for processing: 7
  • demo/bcg-meta-analysis/README.md
  • demo/bcg-meta-analysis/analysis.R
  • demo/bcg-meta-analysis/output/summary.md
  • plugins/methodsmith/README.md
  • plugins/methodsmith/hooks/data-boundary-guard.py
  • plugins/methodsmith/hooks/locales/uk.json
  • tests/data-boundary-locale.test.ts
+---------------------------------+
| WMD: Weapons of Mass Debugging. |
+---------------------------------+
  \
   \     /)/)
        ( '')
        /  |
      o(___)
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@sajor2000
sajor2000 force-pushed the feat/locale-packs-uk branch from e75c079 to 96b85ca Compare October 22, 2026 04:33
@sajor2000
sajor2000 merged commit 40f0ad1 into main Oct 22, 2026
2 of 5 checks passed
@sajor2000
sajor2000 deleted the feat/locale-packs-uk branch October 22, 2026 04:36
@github-actions github-actions Bot mentioned this pull request Oct 22, 2026
sajor2000 added a commit that referenced this pull request Oct 22, 2026
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
sajor2000 added a commit that referenced this pull request Oct 22, 2026
…166)

Closes the follow-up noted in #159. The schema helper now reads
phi_environment.locale from the machine-local config (worktree first,
then the main checkout), masks headings matching the active locale's
column patterns like any other identifier heading, and refuses to print
(LocaleError, exit 1) on a malformed or unknown pack. All three copies
stay identical; boundary-doc sections updated in step.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHI identifier locale packs for non-US identifier patterns (MedSci audit gap #8)

1 participant