Skip to content

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

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

abrichr wants to merge 3 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.

@abrichr
abrichr marked this pull request as ready for review November 23, 2026 22:43
@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: da834d6

Author declaration for the new head.

  • Merged the updated parent branch claude/form-preset-wizard-words (now c59f3e4c9) into this branch. There were no conflicts. I did not rebase or force-push.
  • The net diff against the parent is unchanged from before the merge: 3 files, +98/-26. It covers presets/words/secondary_role_qualifiers.json, pack_compiler.py loading the qualifiers case-folded, and tests.
  • Checks run locally: ruff check and ruff format --check on the changed files; mypy on pack_compiler.py (clean); pytest -p no:xdist on every test_form_tx_*.py except the e2e and Playwright suites (267 passed).

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Grok
Reviewed-Head: da834d6

I checked the live head with gh and reviewed this PR's own diff against its base claude/form-preset-wizard-words (c59f3e4).

Blocking

  1. The new word list is not in the public artifact inventory, and CI is already red on it. packages / flow core lint (ruff, mypy) failed at this head, at step "Release consistency and public artifact inventory". Locally, check_release_consistency.py lists openadapt_flow/form_tx/presets/words/secondary_role_qualifiers.json as unregistered, plus the three files from lower PRs.

Non-blocking

Behavior parity: OK

  • _SECONDARY_ROLE_QUALIFIERS (pack_compiler.py:91) is the same 14 words. They are all lowercase, so the added casefold() is a no-op on the defaults.
  • All three _score_control_for_spec call sites now pass domain.role_qualifiers(), which returns the same frozenset when unset. The _spec_allowed_qualifiers intersection is unchanged.
  • An override is case-folded, consistent with _normalize_phrase.

Generality

The words are role vocabulary with no app or customer names. check_engine_generality.py: OK. The file ships in the wheel.

Tests (at this head, on the box)

CI at review time

5 failed (flow core lint above, ci, packages-gate, run-ci at the draft guard, and protected-path evidence), 10 passed, 16 pending, 23 skipped.

@abrichr

abrichr commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Architectural pivot (founder Option 1, 2026-11-23): freezing the hand-written form-tx DOM heuristic and word-list stack to focus on openadapt wrap + demonstration-derived CheckpointSpec + Cross-Tab Entity Ledger + GUI-to-API/MCP promotion. Branch preserved for reference.

@abrichr abrichr closed this Nov 24, 2026
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