Skip to main content

reject_duplicate_triggers

Function reject_duplicate_triggers 

Source
fn reject_duplicate_triggers(
    manifest: &[StarterSkill],
) -> Result<(), StoreError>
Expand description

Guard against a manifest-authoring mistake: two entries sharing a trigger.

Deterministic ids remove a safety net that random ids provided by accident. Before this change, a duplicate trigger with a different name would insert as two independent rows (no id collision, no name collision — nobody was checking trigger for uniqueness either way, this was already a latent gap). After this change it is worse in a different way: both entries now mint the SAME id, so the second insert’s managed_upsert_unique_global duplicate-name check (WHERE name = ?1 AND id <> ?2) excludes the first entry’s own row from consideration — because its id now equals the second entry’s id — and the INSERT ... ON CONFLICT(id) DO UPDATE silently overwrites it instead of erroring. seed_starter_skills’s created count would even report six when only five distinct rows exist (reagent P2, PR #3175).

Unreachable today — starter-skills.json has six distinct triggers, see the test pinning that — but it must fail LOUDLY the moment it stops being unreachable, the same way the pre-existing name-uniqueness check already does for other manifest mistakes, rather than silently merging two authored skills into one.