fix(hooks): store a hook delivered twice only once
A doubled hook registration (plugin + leftover checkout install) POSTs every event twice with a byte-identical payload, so the timeline showed each row twice and token/alert/lane side effects ran twice. POST /api/hooks/event now skips a payload identical to the session's LATEST event from the last 10s (findRecentDuplicateEvent). Latest-only keeps two legitimately identical Stop events of consecutive turns, which always have other events between.
This commit is contained in:
@@ -216,13 +216,13 @@ describe("Event-driven alert evaluation", () => {
|
||||
const ruleId = created.body.rule.id;
|
||||
|
||||
const sessionId = `alerts-burst-${Date.now()}`;
|
||||
await postHook("BurstProbe", { session_id: sessionId });
|
||||
await postHook("BurstProbe", { session_id: sessionId });
|
||||
await postHook("BurstProbe", { session_id: sessionId, seq: 1 });
|
||||
await postHook("BurstProbe", { session_id: sessionId, seq: 2 });
|
||||
|
||||
let feed = await fetch("/api/alerts");
|
||||
assert.equal(feed.body.alerts.filter((a) => a.rule_id === ruleId).length, 0);
|
||||
|
||||
await postHook("BurstProbe", { session_id: sessionId });
|
||||
await postHook("BurstProbe", { session_id: sessionId, seq: 3 });
|
||||
feed = await fetch("/api/alerts");
|
||||
const fired = feed.body.alerts.filter((a) => a.rule_id === ruleId);
|
||||
assert.equal(fired.length, 1);
|
||||
|
||||
Reference in New Issue
Block a user