fix(70): test the weight gate; correct rationale my own clamp made false
Re-review of the fix commit returned MERGEABLE-WITH-NITS. It verified the gate is now complete by enumerating the writers itself (no fourth persisting writer) and proved B2's fix works by writing throwaway handler tests — which was also its point: the fix shipped with none. B2 was create and update silently DISAGREEING on the same input, and the fix re-established agreement with nothing pinning it. Both paths are now driven from one shared case list, plus an explicit test that create and update agree on every case — the per-path tests would both have passed while the two diverged, which is how the bug existed in the first place. Non-vacuity proven: inverting only the update path's validation fails 10 of 20 on a clean build (0 errors, so not a stale-dll pass), and the agreement test is among the failures. The rest is my own prose contradicting my own code. The commit that added EffectiveWeight removed the weight filter, then left four statements asserting a 0-weight source "is filtered out" — two of them authored by that same commit, including the stated justification for Minimum=1 in MultiCollectionItemWeight. A future agent could have read that and deleted the clamp or the floor as redundant; they are belt-and-braces and neither is. Corrected to describe what the code now does: the gate refuses input that means nothing on a share-of-airtime scale, the clamp protects rows predating the gate. Also corrected the writer count in the very bullet whose lesson is "grep every writer of the field": ReplaceBlockItems writes BlockItem.PlaybackOrder, not PlaylistItem.PlaybackOrder. There are TWO persisting writers of PlaylistItem's, and the correction itself had miscounted by conflating the two fields — so the lesson now says to grep each field separately. Core.Tests 565 passed, ErsatzTV.Tests 1673 passed, 0 failed. Refs #70 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+15
-10
@@ -1410,8 +1410,10 @@ and "no single show dominates" — as **one** order, because fair-share is the e
|
||||
`ShuffleInOrder` was rejected: it would silently change shipped users' output.
|
||||
- **Weights live on `MultiCollectionItem` AND `MultiCollectionSmartItem`** (`int Weight`, DB default 1,
|
||||
dual-provider migration `AddMultiCollectionItemWeight`). The mirror is mandatory — omitting the smart
|
||||
item un-weights smart-collection members silently. The DB default must be **1, not 0**: a 0-weight source
|
||||
is filtered out by the enumerator, so a 0 backfill would drop every pre-existing member from a rotation.
|
||||
item un-weights smart-collection members silently. The DB default must be **1, not 0**: a 0 backfill would
|
||||
hand every pre-existing member to the rotation carrying a weight that means nothing on a share-of-airtime
|
||||
scale. (The enumerator clamps such rows to the floor so they rotate fair-share rather than vanish — but the
|
||||
backfill should be right at the source.)
|
||||
Rejected carriers: `PlaylistItem` (sequential engine; its `Count`/`PlayAll` already mean "how much of this
|
||||
source", and drain-N-consecutively `A A A B` is a different product from smooth interleave `A A B A`);
|
||||
`CollectionItem` (wrong grain — per media item, and the largest table).
|
||||
@@ -1449,14 +1451,17 @@ and "no single show dominates" — as **one** order, because fair-share is the e
|
||||
orders by *name*, so `Enum.Parse` accepts it regardless) log a warning when an order falls through
|
||||
unhandled. Making those pre-existing fallbacks loud is a real but separate defect class: **#403**, an
|
||||
explicit non-goal here.
|
||||
- **There are THREE writers of `PlaylistItem.PlaybackOrder`, not two.** Besides `ReplacePlaylistItems` and
|
||||
`ReplaceBlockItems`, **`CreateChannelFromLineup`** persists one: a lineup of 2+ entries is stored as a
|
||||
`Playlist`, and its own guard only covered *MultiCollection* entries, so a multi-entry lineup of plain
|
||||
collections slipped `WeightedShuffle` straight through to `PlaylistEnumerator`'s null-drop. Caught by
|
||||
adversarial review of PR #402 **after** the first two gates were written and this very claim had been
|
||||
recorded as complete. The `Add*ToPlaylist` handlers are safe only because they hardcode their order.
|
||||
Before trusting any "this order can't reach that engine" claim, grep every writer of the field — the
|
||||
non-obvious composite handler is the one that gets missed.
|
||||
- **There are TWO persisting writers of `PlaylistItem.PlaybackOrder`, and the second is not obvious.**
|
||||
`ReplacePlaylistItems` is the expected one; **`CreateChannelFromLineup`** is the other — a lineup of 2+
|
||||
entries is stored as a `Playlist`, and its own guard only covered *MultiCollection* entries, so a
|
||||
multi-entry lineup of plain collections slipped `WeightedShuffle` straight through to
|
||||
`PlaylistEnumerator`'s null-drop. (`ReplaceBlockItems` is the separate writer of
|
||||
`BlockItem.PlaybackOrder`; `Add*ToPlaylist` and the Trakt path are safe only because they hardcode their
|
||||
order, and the two Preview handlers build in memory without persisting.) Caught by adversarial review of
|
||||
PR #402 **after** the first gates were written and this very bullet had recorded the perimeter as
|
||||
complete — twice, since the correction itself first miscounted the writers by conflating the two fields.
|
||||
Before trusting any "this order can't reach that engine" claim, grep every writer of **each field
|
||||
separately**; the non-obvious composite handler is the one that gets missed.
|
||||
- **Weight is bounded at the write path** (`MultiCollectionItemWeight`, 1..1000) and clamped again in the
|
||||
enumerator. Both are needed: **EF's `HasDefaultValue(1)` substitutes 1 for a `0` on INSERT** (0 reads as
|
||||
"not set") **but an UPDATE writes the 0 through**, so create and update disagreed on the same input, and
|
||||
|
||||
Reference in New Issue
Block a user