Skip to content

Review follow up: Map missing STIX rules and let the field set the category - #111

Open
Lespernater wants to merge 5 commits into
feat/phix-issue-typesfrom
fix/issue-category-review
Open

Lespernater wants to merge 5 commits into
feat/phix-issue-typesfrom
fix/issue-category-review

Conversation

@Lespernater

Copy link
Copy Markdown

Summary

This follows up on the review comments on #85 and goes into feat/phix-issue-types, main is already merged into that branch.

What changes

  • Three STIX rules no longer fall to other. POSTAL_CODE_US_ZIP and PO_BOX_NUMBER_FORMAT are now address, and XML_PARSE_OR_NAMESPACE is file-structure.
  • A new test fails when a known STIX rule ID has no category. It covers the labelled rules, the <FIELD>_ALLOWED_VALUE rules and three rules without a label. A new rule that is in none of those lists still falls to other.
  • The allowed-value field list is now one constant, shared by the validator, its lookup and that test - reducing drift risk.
  • The label test loops over CATEGORY_LABELS instead of a copied list, and a second test checks that every category except other is used.
  • Generic rules take the category of their field when the field has a group: REQUIRED_FIELD, FIELD_LENGTH, FREE_TEXT_*, PHIX_REQUIRED_FIELD and PHIX_FIELD_LENGTH. Each finding still has exactly one category.

Nothing reads category yet, so the page looks the same. Though feat/phix was used for guiding the header-based category matching.

How the field sets the category

Category STIX fields PHIX headers
address Address fields except Province Street, unit, PO box, STN, RPO, rural route, address lines, city and postal code
contact Student and guardian phone numbers and phone types Submitter phone numbers, phone type and submitter email
metadata SchoolNumber, SchoolName None
identity OEN Health card number
date BirthDate Date of birth, date administered, expiry date and lot expiry date
vaccine None Immunizing agent and trade name
The rule's own category Names, Class and coded fields Every other header, such as names and coded fields

Coded fields have no group on purpose: an empty code is required and an unlisted code is coded-value. Province follows that rule too, because PROVINCE_ALLOWED_VALUE is already coded-value.

Effect on subtotals

  • With the default STIX ruleset, REQUIRED_FIELD rows for FirstName, LastName and Gender stay required, and so do the guardian rules. A missing BirthDate moves to date.
  • address gains info-level FREE_TEXT_* findings, for example an accent in a street name. Severity and fixes are unchanged, so dashboard should not present those as errors.

Questions:

  1. Does the field-aware approach match intention from feat: add issue category infrastructure for STIX and PHIX #85? It goes further than the address examples mentioned there. If not, it can be reverted, see below.
  2. Is the PHIX header list current? It comes from feat/phix at 4488d5e. The PHIX part is unit-tested only, because there is no PHIX workflow on this branch.

Commit-wise for flexibility to be reverted

To remove Revert Leaves
The shared lookup helper (no behaviour change) 7377fde Everything else
The PHIX header categories 7377fde 829ca2d The STIX field categories
All field-aware categories 7377fde 829ca2d 093566d The rule mapping and the tests

Revert newest first, in the order shown. Reverting an earlier commit on its own conflicts. npm run lint, npm run typecheck and the unit tests pass on the code each row leaves. Preferable to merge without squashing, so that these commits stay separate.

Related issue

Follow-up to #85.

Testing

  • npm run check
  • mkdocs build --strict (when documentation changes)
  • I used only synthetic test data

Run on a clean copy of 7377fde with Node 24: lint has 0 errors, 400 unit tests pass and the build passes. I also broke the code on purpose to confirm that the new tests fail, for example by removing a mapping or moving Province. However, Playwright e2e tests were not run locally.

Documentation and visuals

docs/validation-rules.md has the new category rules. There are no visible UI changes.

Checklist

  • The change is focused and contains no unrelated edits
  • New behaviour is covered by tests where practical
  • User-facing or policy-sensitive behaviour is documented
  • No secrets, student records, or other sensitive information are included

This branch has not been deployed

No deployments
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.

1 participant