Skip to content

refactor(form-tx): move the placeholder option texts to a JSON word list - #2507

Draft
abrichr wants to merge 6 commits into
claude/form-tx-reworkfrom
claude/form-preset-placeholders
Draft

abrichr wants to merge 6 commits into
claude/form-tx-reworkfrom
claude/form-preset-placeholders

Conversation

@abrichr

@abrichr abrichr commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

What this does

Fifth of the form_tx preset moves. It is based on #2461 (claude/form-tx-rework), because #2461 lengthened the placeholder list from 4 entries to 10, so main's list differs.

The option texts that mean nothing is chosen yet ("-- Select --", "Choose one" and so on) are English UI vocabulary. Two copies are replaced by one file, form_tx/presets/words/placeholders.json:

  • reconciler._DEFAULT_PLACEHOLDERS;
  • the default of FieldBindingSpec.placeholder_values.

Includes a carried file. The first commit carries form_tx/presets/__init__.py unchanged from the preset stack (#2503 to #2506), so this branch can load a word list. Review only the second commit. The carried file drops out once the stack merges.

No behaviour change

tests/test_form_tx_placeholder_words.py reads both old tuple literals from 1ddd69712 with ast and checks that each default is equal to the old one and comes from the one word list.

Tests

Since opening

  • Pack override (coordinator ruling). FormPack.placeholder_values is optional and applies to controls that no binding covers. A binding already sets its own. The unbound-control scan and the popup return checks use the pack's list.
  • The fail-open Gemini found. Round 2 found that the scan still used the default list. That is fixed, and a new test fails without the fix.
  • Digests. An unset override is left out of the digest.
  • A third copy. A third copy of the list, codecs.resolve_unique_option's default, now loads the same file. The old default is read from 1ddd69712.
  • Merge note. The FormPack.digest() change conflicts with refactor(form-tx): move the primary entity kinds to a JSON word list #2505; see that PR.

Copied unchanged from claude/form-preset-entity-kinds so this branch, which
is based on #2461, can load a word list. Drops out of the diff once the
preset stack merges.
The texts that mean nothing is chosen yet ("-- Select --", "Choose one",
...) are English UI vocabulary. reconciler._DEFAULT_PLACEHOLDERS and the
default of FieldBindingSpec.placeholder_values now both load
form_tx/presets/words/placeholders.json. Both are equal to the old
literals; a test reads those from history and compares.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

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

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

The PR successfully extracts the hardcoded placeholder texts into a JSON word list without altering the values, ensuring behavior remains strictly identical. No fail-open paths are introduced.

Here are the findings:

SHOULD-FIX (Generality Rule Violation)

  • packages/flow/openadapt_flow/form_tx/reconciler.py (lines 92-101): Right above the changed code, _PRIMARY_ENTITY_KINDS hardcodes domain-specific vocabulary ("primary_applicant", "primary_insured", etc.) directly into the engine. Since the goal of this refactor is to remove application-specific knowledge from engine code, this set should also be moved to a JSON word list or supplied via pack data.

NIT

  • packages/flow/openadapt_flow/form_tx/presets/__init__.py: The load_words function (shown in context) lacks an @lru_cache decorator, unlike _raw. While it is currently only called twice at module import time, adding a cache would prevent redundant filesystem reads and directory globs if it is ever called dynamically in the future.

Gate-Direction Question

  • Does any input now pass (or skip) where the old code stopped? No. The AST-parsing tests confirm the new JSON list is perfectly identical to the old hardcoded tuples. The engine's behavior is unchanged.

APPROVE WITH NITS

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 387f074

Author declaration. I wrote this change and checked it at the head above. Everything here is synthetic; no real app was run.

  • test_form_tx_placeholder_words.py, test_form_tx_lease_and_compiler.py and test_form_tx_reconciler_and_receipts.py: 46 passed.
  • Gemini round 1 approved with nits:

FormPack.placeholder_values (optional) replaces the engine's default
placeholder list for controls no binding names; a binding already sets its
own. None keeps the default from presets/words. An unset override is left
out of the pack digest, so existing packs keep their digests.
…ord list too

codecs.resolve_unique_option kept a third copy of the placeholder texts. Its
default now loads the same presets/words/placeholders.json; a test reads the
old default from 1ddd697 and compares.
…rol scan

From review: _scan_unbound_controls and the popup return checks still used
the default list, so a pack that does not count "-- Select --" as a
placeholder could have an unbound control holding it treated as empty. They
now use the pack's list. A test runs the scan with and without the override
and fails without this fix.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Gemini (gemini-3.1-pro-preview), round 2
Reviewed-Head: b27c316

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

This PR successfully implements the digest exclusion for unset overrides and wires the JSON word list into the option resolver. However, the core feature—applying the pack's placeholder override to unbound controls—is missing from the function that actually scans unbound controls, introducing a fail-open path. Additionally, the earlier findings were not addressed.

Here is the review:

BLOCKER (Fail-Open / Correctness Bug)

  • packages/flow/openadapt_flow/form_tx/reconciler.py (lines 1461 and 1475): In _scan_unbound_controls, the code calls _is_control_empty(c) and _is_control_empty(ctrl) without passing the pack's placeholder override, causing it to fall back to _DEFAULT_PLACEHOLDERS.
    • Fail-Open Path: If a pack overrides placeholder_values to exclude a default placeholder (e.g., omitting "-- Select --"), and an unbound control on the page has the value "-- Select --", _scan_unbound_controls will incorrectly consider it empty. It will skip adding it to session._uncovered, allowing the run to silently pass (VERIFIED_DONE) despite an unbound control holding a value the pack considers real data.
    • Fix: Pass the pack's placeholders to both calls: _is_control_empty(c, _pack_placeholders(session.pack)) and _is_control_empty(ctrl, _pack_placeholders(session.pack)).

SHOULD-FIX (Test Gap)

  • packages/flow/tests/test_form_tx_placeholder_words.py: The new test test_a_pack_can_override_the_placeholders_for_unbound_controls only tests the helper functions _pack_placeholders and _is_control_empty in isolation. It does not test _scan_unbound_controls or the engine's actual behavior, which hid the blocker above. Please add a test that runs _scan_unbound_controls with a pack override to ensure it correctly populates _uncovered.

SHOULD-FIX (Generality Rule Violation)

  • packages/flow/openadapt_flow/form_tx/reconciler.py (lines 92-101): (From earlier findings) _PRIMARY_ENTITY_KINDS still hardcodes domain-specific vocabulary ("primary_applicant", "primary_insured", etc.) directly into the engine. This must be moved to a JSON word list or supplied via pack data.

NIT

  • packages/flow/openadapt_flow/form_tx/presets/__init__.py: (From earlier findings) load_words lacks an @lru_cache decorator. It is now called at module import time in both codecs.py and reconciler.py, causing redundant filesystem reads.
  • packages/flow/openadapt_flow/form_tx/types.py (line 518): Typo in the FormPack.placeholder_values docstring: "for controls no binding names" should probably be "for controls that no binding names" or "for controls no binding covers".
  • packages/flow/openadapt_flow/form_tx/reconciler.py (lines 539 and 554): _is_return_value_empty_or_zero and _is_valid_non_zero_return_value (used for popup return anchors) still default to _DEFAULT_PLACEHOLDERS. While the PR targets unbound controls, it might be more consistent to pass _pack_placeholders(session.pack) when checking popup returns in _run_popup_subroutine_steps.

REQUEST CHANGES

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Gemini (gemini-3.1-pro-preview), round 3
Reviewed-Head: 8d86c0d

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

The blocker and test gap from the previous round have been successfully addressed. The fail-open path in _scan_unbound_controls is closed, and the test coverage is in place. The popup return checks and load_words caching nits are also addressed. The generality rule violation is out of scope for this PR.

There is nothing above a nit remaining.

NIT

  • packages/flow/openadapt_flow/form_tx/types.py (line 518): (From earlier findings) The typo in the FormPack.placeholder_values docstring ("for controls no binding names") is still present.
  • packages/flow/openadapt_flow/form_tx/reconciler.py (line 101): The new _pack_placeholders helper copies the same typo in its docstring ("for a control no binding names").
  • packages/flow/openadapt_flow/form_tx/reconciler.py (line 503): _locate_errored_control calls _is_control_empty(c) without passing _pack_placeholders(session.pack). Since this is just a heuristic to find which control caused a validation error, it is not a fail-open bug, but it might fail to highlight an empty required field in the error message if the pack overrides placeholders.
  • packages/flow/openadapt_flow/form_tx/reconciler.py (line 2630): When replaying manual human fills for unmapped popup controls, _actuate_control is called without placeholder_values=_pack_placeholders(session.pack), causing it to fall back to _DEFAULT_PLACEHOLDERS.

APPROVE WITH NITS

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 8d86c0d

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

  • New: the pack override, the third placeholder copy, and the scan fix Gemini found in round 2.
  • test_form_tx_placeholder_words.py and test_form_tx_reconciler_and_receipts.py: 34 passed. The new scan test fails without the fix.
  • Gemini round 3 left only wording nits, which I left as they are.

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