Skip to content

refactor(form-tx): move the secondary role qualifiers to a JSON word list - #2510

Draft
abrichr wants to merge 2 commits into
claude/form-preset-wizard-wordsfrom
claude/form-preset-role-qualifiers
Draft

abrichr wants to merge 2 commits into
claude/form-preset-wizard-wordsfrom
claude/form-preset-role-qualifiers

Conversation

@abrichr

@abrichr abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member

What this does

Sixth form_tx preset move, stacked on #2506. pack_compiler._SECONDARY_ROLE_QUALIFIERS holds the words that mark a field as another person's (emergency, guarantor, subscriber, physician and so on). Those are domain vocabulary. The list now ships as presets/words/secondary_role_qualifiers.json.

The coordinator asked for a pack-level override. The override goes on the domain schema, not the FormPack, because these words are used during induction, before a pack exists. CanonicalDomainSchema.secondary_role_qualifiers is optional; when it is unset, induction uses the default list. _score_control_for_spec now takes its qualifier set from the domain.

No behaviour change by default

  • tests/test_form_tx_presets.py reads the old frozenset literal from 2f506d6c4 with ast and checks that the default is equal.
  • A new override test uses a "Guarantor phone" control. It scores 0 for a plain phone field under the default list, and above 0 when the domain's list is empty.
  • The preset round-trip test now compares the stored preset by value. The domain schema has a new optional field, so its dump changed.

Tests

  • test_form_tx_presets.py and test_form_tx_lease_and_compiler.py: 34 passed.
  • ruff check and ruff format are clean.

…list

The words that mark a field as another person's (guarantor, subscriber,
physician, ...) are domain vocabulary. They now ship as
presets/words/secondary_role_qualifiers.json, and a domain schema can
replace them with secondary_role_qualifiers; induction uses the domain's
list. The default set is equal to the old literal (a test reads it from
history), and a test shows an empty override lets a guarantor's phone
match a plain phone field.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Gemini (gemini-3.1-pro-preview), round 1
Reviewed-Head: 670dadb

Sent the full diff of this PR's own files, those files in full, and any earlier findings.

The PR successfully extracts _SECONDARY_ROLE_QUALIFIERS into a JSON word list and allows domain schemas to override it, improving the engine's generality. The default behavior is perfectly preserved, and the override logic is sound.

NIT / DEFENSIVE SUGGESTION:
In pack_compiler.py, _SECONDARY_ROLE_QUALIFIERS is loaded directly from the JSON:

_SECONDARY_ROLE_QUALIFIERS = frozenset(load_words("secondary_role_qualifiers"))

If someone later adds a mixed-case word (e.g., "CoApplicant") to secondary_role_qualifiers.json, it will silently fail to block because ctrl_words are always lowercased by _normalize_phrase and _semantic_core_attr_tokens.

While the current JSON is entirely lowercase (so there is no active bug), it would be safer to casefold the words on load, just as you do for the domain schema override:

_SECONDARY_ROLE_QUALIFIERS = frozenset(w.casefold() for w in load_words("secondary_role_qualifiers"))

APPROVE WITH NITS

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 3c5c4d5

Author declaration at the head above. Synthetic tests only; no real app was run.

  • test_form_tx_presets.py and test_form_tx_lease_and_compiler.py: 34 passed.
  • After Gemini round 1, the only change is its nit: the default list is case-folded when it loads.

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