Rule builder: input validation & polish (bundles #176 review minors) #438

Closed
opened 2026-07-18 01:50:38 +02:00 by timothy · 3 comments
Owner

Follow-up to #176 (PR #433) — bundles the Minor findings from the whole-branch review:

  • between requires value2: an incomplete between compiles to invalid Lucene field:[30 TO ] — validate/require the upper bound (disable save or block compile) rather than emit invalid syntax.
  • empty startsWith: field:* (empty startsWith value) doesn't round-trip (drops to Advanced), inconsistent with empty contains (field:**). Guard empty values.
  • single-child group match flip: a 1-child {match:'any'} group reopens as 'All' (compiler omits the connective for one child). Cosmetic; align RuleBuilder's default or the parser.
  • pure-negative queries: a lone is not/does not contain compiles to NOT field:"v" which matches nothing in Lucene (no MatchAllDocs). Preview mitigates; consider disallowing an all-negative top group or warning.

Done-when

  • adversarial review passed
  • validation added; tests cover each case
Follow-up to #176 (PR #433) — bundles the Minor findings from the whole-branch review: - **between requires value2**: an incomplete `between` compiles to invalid Lucene `field:[30 TO ]` — validate/require the upper bound (disable save or block compile) rather than emit invalid syntax. - **empty startsWith**: `field:*` (empty startsWith value) doesn't round-trip (drops to Advanced), inconsistent with empty `contains` (`field:**`). Guard empty values. - **single-child group match flip**: a 1-child `{match:'any'}` group reopens as 'All' (compiler omits the connective for one child). Cosmetic; align RuleBuilder's default or the parser. - **pure-negative queries**: a lone `is not`/`does not contain` compiles to `NOT field:"v"` which matches nothing in Lucene (no MatchAllDocs). Preview mitigates; consider disallowing an all-negative top group or warning. ## Done-when - [x] adversarial review passed - [x] validation added; tests cover each case
timothy added the bugpriority: lowfrontend labels 2026-07-18 01:50:38 +02:00
Author
Owner

🔗 Session bundle — rule builder (#176 follow-ups): #434, #435, #436, #437, #438

All frontend RuleBuilder follow-ups deferred from #176: facet-value typeahead (#434), relative-date operators (#435), deeper nesting (#436), inline adoption in ChannelBuilder & Auto-Tune (#437), input validation & polish (#438). One SPA component, one session.

When you claim any member, check this cluster for co-workable siblings and sweep the disjoint set in one session (per docs/handoffs/chicorytv-issue-queue.md → bundles).

🔗 **Session bundle — rule builder (#176 follow-ups):** #434, #435, #436, #437, #438 All frontend RuleBuilder follow-ups deferred from #176: facet-value typeahead (#434), relative-date operators (#435), deeper nesting (#436), inline adoption in ChannelBuilder & Auto-Tune (#437), input validation & polish (#438). One SPA component, one session. When you claim any member, check this cluster for co-workable siblings and sweep the disjoint set in one session (per docs/handoffs/chicorytv-issue-queue.md → bundles).
timothy added the in-progress label 2026-07-23 18:39:00 +02:00
Author
Owner

Claiming as part of a single-session RuleBuilder bundle sweep (#438 + #435 + #434). Building on one feature branch feat/rulebuilder-bundle (shared RuleBuilder.tsx makes splitting churny); #434 backend endpoint delegated to a parallel worktree. Design doc + spec to follow. Leaving #436 (deeper nesting, self-labeled YAGNI) and #437 (inline adoption) open.

Claiming as part of a single-session RuleBuilder bundle sweep (#438 + #435 + #434). Building on one feature branch `feat/rulebuilder-bundle` (shared `RuleBuilder.tsx` makes splitting churny); #434 backend endpoint delegated to a parallel worktree. Design doc + spec to follow. Leaving #436 (deeper nesting, self-labeled YAGNI) and #437 (inline adoption) open.
Author
Owner

Closing record

Outcome: Shipped in PR #577. Incomplete between/empty-text rules are invalid — Save is disabled (groupHasErrors) and compile never emits malformed Lucene (field:[v TO ], field:*, field:**), including nested all-invalid subgroups (no more "()"). Single-child groups normalize match→all (normalizeGroup) so they round-trip; the any/all toggle is hidden for <2 children. Non-blocking warning when the top group is entirely negative.
Root cause: N/A (validation/polish). The malformed-Lucene cases the issue enumerated were latent gaps in the #176 compiler (no operand validation; connective lost for single-child groups).
Decisions/conventions changed: none new — folded into the compile↔parse round-trip discipline (see rulebuilder.relative-date-macros) and documented in spa-conventions.md §12.
Reusable knowledge: the round-trip contract requires normalizeGroup for single-child groups (a 1-child connective has no wire representation); and a return '' guard in compileRule must ALSO be filtered at the group level, else a nested all-invalid subgroup compiles to (${''}) = "()".
Verification: web 980/980 (validation + compile + parse + roundtrip tests); per-task + opus whole-branch reviews; live-E2E via the RuleBuilder screen path.
Deferred: none.
Docs updated: docs/spa-conventions.md §12, docs/decisions.md.

## Closing record **Outcome:** Shipped in PR #577. Incomplete `between`/empty-text rules are invalid — Save is disabled (`groupHasErrors`) and `compile` never emits malformed Lucene (`field:[v TO ]`, `field:*`, `field:**`), including nested all-invalid subgroups (no more `"()"`). Single-child groups normalize `match`→`all` (`normalizeGroup`) so they round-trip; the any/all toggle is hidden for <2 children. Non-blocking warning when the top group is entirely negative. **Root cause:** N/A (validation/polish). The malformed-Lucene cases the issue enumerated were latent gaps in the #176 compiler (no operand validation; connective lost for single-child groups). **Decisions/conventions changed:** none new — folded into the compile↔parse round-trip discipline (see `rulebuilder.relative-date-macros`) and documented in `spa-conventions.md` §12. **Reusable knowledge:** the round-trip contract requires `normalizeGroup` for single-child groups (a 1-child connective has no wire representation); and a `return ''` guard in `compileRule` must ALSO be filtered at the group level, else a nested all-invalid subgroup compiles to `(${''})` = `"()"`. **Verification:** web 980/980 (validation + compile + parse + roundtrip tests); per-task + opus whole-branch reviews; live-E2E via the RuleBuilder screen path. **Deferred:** none. **Docs updated:** `docs/spa-conventions.md` §12, `docs/decisions.md`.
timothy removed the in-progress label 2026-07-23 21:18:00 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: timothy/ersatztv#438