fix(engagement): two defects the Phase 11b live walk found in core
Both are invisible to a fixture and loud on a real database, which is why the walk is the phase's acceptance rather than a formality. 1. registerEngagementSeeds validated `max_sends_per_hour` and then dropped it from the normalized rule. The column is NOT NULL, so every one of the 25 module-seeded rules failed to insert at boot. The registry test asserted the REJECTION of a bad ceiling and never that a good one survives; it now asserts the normalized rule against `engagementRules.db.insert`'s own column list, so the next field added is covered the day it is added. 2. The cooldown claim runs inside the engine's per-channel loop and its key was (rule, user, subject). So the first channel of a rule claimed the cooldown and every later one was reported as cooled -- and `inapp` is ranked first deliberately, so a rule naming email + in-app delivered the inbox item and silently never the mail. Core's own `news.post` rule has that shape. Phase 11b's decision 8 requires the letter and the inbox item to fire together. `channel` joins the PRIMARY KEY (the org lead's decision 12: a cooldown is per delivery, not per occasion). Migrated in place behind an information_schema guard, because MariaDB has no conditional form of a key change and replaying schema.sql would otherwise fail on every boot after the first. 1551 core tests green; both new tests verified by reverting each fix in turn. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -874,6 +874,10 @@ function checkSeedRule(owner, entry, ownTemplateKeys, coreKeys) {
|
||||
name: r.name,
|
||||
audience: r.audience,
|
||||
audience_segment_id: null,
|
||||
// Checked above and carried here: the column is NOT NULL, so a normalizer
|
||||
// that validates the ceiling and then drops it fails every insert in the
|
||||
// group at boot — loudly, but only on a real database.
|
||||
max_sends_per_hour: r.max_sends_per_hour,
|
||||
channels: [...r.channels],
|
||||
template_keys: { ...keys },
|
||||
conditions: r.conditions === undefined ? null : r.conditions,
|
||||
|
||||
Reference in New Issue
Block a user