feat(eda): mappings per event type, match counts, several bindings per source

A mapping belongs to an event type and is checked against its inferred
schema on save. Each event a mapping resolves is counted once in
mapping_matches (migration 0008), read back as match_count and
last_matched_at. Bindings carry an optional CEL filter over the mapping's
parameters, checked on save. The per-source unique indexes are dropped:
every armed binding whose mapping matches the capture's event type and
whose filter admits it dispatches once, claimed in the per-binding ledger
before its task is enqueued. The State Store gains RecordMappingMatch and
the new mapping and binding fields.
This commit is contained in:
sam committed 2026-09-24 14:42:58 +10:00
1 parent d5956cd7a5
commit b9d3acd31c
35 files changed
+1900 -737

No files matched your search

-17
View File
@@ -187,23 +187,6 @@ func TestHandleBindingsListStripsSecrets(t *testing.T) {
}
}
func TestHandleBindingCreateRejectsOverlap(t *testing.T) {
srv := bindingTestServer(t)
mappingID := seedMapping(t, srv, "m")
w := doJSON(t, srv, http.MethodPost, "/api/bindings", validBindingRequest("first", "sentry", mappingID))
if w.Code != http.StatusCreated {
t.Fatalf("first create status = %d, want %d; body = %s", w.Code, http.StatusCreated, w.Body.String())
}
// Overlap because Per bead t2db.4, two bindings may not own the same
// source; the second insert must surface ErrBindingOverlap -> 409.
w = doJSON(t, srv, http.MethodPost, "/api/bindings", validBindingRequest("second", "sentry", mappingID))
if w.Code != http.StatusConflict {
t.Fatalf("second create status = %d, want %d; body = %s", w.Code, http.StatusConflict, w.Body.String())
}
}
func TestHandleBindingCreateRejectsMissingWorkflow(t *testing.T) {
srv := bindingTestServer(t)
mappingID := seedMapping(t, srv, "m")