Auto-Tune source rows: share the Lucene escaper, warn on exclude-all, handle >50-source axes #590

Open
opened 2026-07-25 11:31:35 +02:00 by timothy · 0 comments
Owner

Deferred nits from the independent adversarial review of #440 / PR #589 (d3c89d87). None change wire behavior; all were explicitly accepted as non-blocking there. Two other nits from that review (a comment stating the opposite of the code, and doc wording implying a shared const that does not exist) were fixed in-PR at 22e89fb9.

1. Duplicated Lucene escaper — DRY / drift risk

LUCENE_WILD_SPECIAL in web/src/screens/AutoTuneScreen.tsx is byte-identical to WILD_SPECIAL in web/src/builder/rules/compile.ts (/([\s+\-!(){}[\]^"~*?:\\/])/g), and the typeahead's titleContainsQuery emits exactly compile.ts's contains shape. It is not a weaker implementation — it is a verbatim copy, made because escapeWild is not exported from compile.ts.

Two copies of an escaper drift; the next person to fix an escaping bug will fix one of them. Export the escaper from compile.ts (or lift both into a small shared web/src/lucene.ts) and have both call sites use it.

Note the reviewer also observed that the &&/|| gap (a single & or | is unescaped) exists identically in the established compile.ts seam and in SearchScreen's raw forward — so it is pre-existing, not a #440 regression, and no clause injection could be constructed because escaped whitespace glues the operators into escaped terms. If the escaper is unified, that is the natural moment to decide whether to close the gap in one place.

2. Excluding every source silently yields an empty channel

If the user excludes all previewed sources, BuildTvPlan skips every base member into subtracted, Members ends up empty, and the channel is created with a single remainder SmartCollection whose query excludes everything — an empty channel, with no warning. BuildMoviePlan behaves the same (remainderCount 0 → NormalizeWeight(0) = 1).

Nothing crashes, and #415's health object flags the broken channel after creation — but a client-side warning at the point of the mistake ("all sources excluded — this channel will be empty") is cheaper than a post-hoc health badge. No existing convention mandates it, which is why it was not treated as blocking.

3. Axes with more than 50 sources

MEMBER_PREVIEW_SIZE = 50 bounds the members preview, so on a larger axis:

  • only the first 50 sources are editable at all; and
  • picking a base member beyond the preview page via the typeahead stamps addedTitle (client baseIds only knows the first 50), so the row shows "Added"/"Edited" and sends {id, weight:1, excluded:false}. The server sees that id in its full base set (MaxSources = 10,000), deems it not customised, and no-ops it.

The outcome is semantically correct — the show already airs, and it never flips the channel into MultiCollection shape — so this is cosmetic mislabeling plus one redundant wire row. Rare at realistic axis sizes; worth fixing if large axes materialize.

Done-when

  • Lucene escaper exported from compile.ts (or a shared module) and used by both call sites; no duplicated regex remains
  • Exclude-all produces a visible warning before create (or a recorded decision that it should not)
  • >50-source axis behaviour addressed or explicitly recorded as accepted
  • adversarial review passed
Deferred nits from the independent adversarial review of #440 / PR #589 (`d3c89d87`). None change wire behavior; all were explicitly accepted as non-blocking there. Two other nits from that review (a comment stating the opposite of the code, and doc wording implying a shared const that does not exist) were fixed in-PR at `22e89fb9`. ## 1. Duplicated Lucene escaper — DRY / drift risk `LUCENE_WILD_SPECIAL` in `web/src/screens/AutoTuneScreen.tsx` is **byte-identical** to `WILD_SPECIAL` in `web/src/builder/rules/compile.ts` (`/([\s+\-!(){}[\]^"~*?:\\/])/g`), and the typeahead's `titleContainsQuery` emits exactly compile.ts's `contains` shape. It is not a weaker implementation — it is a verbatim *copy*, made because `escapeWild` is not exported from `compile.ts`. Two copies of an escaper drift; the next person to fix an escaping bug will fix one of them. Export the escaper from `compile.ts` (or lift both into a small shared `web/src/lucene.ts`) and have both call sites use it. Note the reviewer also observed that the `&&`/`||` gap (a single `&` or `|` is unescaped) exists **identically** in the established `compile.ts` seam and in `SearchScreen`'s raw forward — so it is pre-existing, not a #440 regression, and no clause injection could be constructed because escaped whitespace glues the operators into escaped terms. If the escaper is unified, that is the natural moment to decide whether to close the gap in one place. ## 2. Excluding every source silently yields an empty channel If the user excludes all previewed sources, `BuildTvPlan` skips every base member into `subtracted`, `Members` ends up empty, and the channel is created with a single remainder SmartCollection whose query excludes everything — an empty channel, with no warning. `BuildMoviePlan` behaves the same (`remainderCount` 0 → `NormalizeWeight(0)` = 1). Nothing crashes, and #415's health object flags the broken channel *after* creation — but a client-side warning at the point of the mistake ("all sources excluded — this channel will be empty") is cheaper than a post-hoc health badge. No existing convention mandates it, which is why it was not treated as blocking. ## 3. Axes with more than 50 sources `MEMBER_PREVIEW_SIZE = 50` bounds the members preview, so on a larger axis: - only the first 50 sources are editable at all; and - picking a base member *beyond* the preview page via the typeahead stamps `addedTitle` (client `baseIds` only knows the first 50), so the row shows "Added"/"Edited" and sends `{id, weight:1, excluded:false}`. The server sees that id in its full base set (`MaxSources` = 10,000), deems it not customised, and no-ops it. The outcome is semantically correct — the show already airs, and it never flips the channel into MultiCollection shape — so this is cosmetic mislabeling plus one redundant wire row. Rare at realistic axis sizes; worth fixing if large axes materialize. ## Done-when - [ ] Lucene escaper exported from `compile.ts` (or a shared module) and used by both call sites; no duplicated regex remains - [ ] Exclude-all produces a visible warning before create (or a recorded decision that it should not) - [ ] >50-source axis behaviour addressed or explicitly recorded as accepted - [ ] adversarial review passed
timothy added the enhancementfrontendpriority: low labels 2026-07-25 11:31:42 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: timothy/ersatztv#590