testing/audit_drift_guard.ts view source
(event: Pick<{ id: Branded<string, "Uuid">; seq: number; event_type: string; outcome: "success" | "failure"; actor_id: Branded<string, "Uuid"> | null; account_id: Branded<string, "Uuid"> | null; ... 4 more ...; metadata: Record<...> | null; }, "event_type" | ... 1 more ... | "metadata">, options?: AssertAuditEventMetadataOptions | undefined): void import {assert_audit_event_metadata} from '@fuzdev/fuz_app/testing/audit_drift_guard.js'; Assert an audit row read off the wire carries the metadata its event type
declares — parsed against audit_metadata_schemas[event_type] as declared,
so a mistyped, null, or missing field fails, and with
reject_unknown_keys so does a key the event doesn't declare. The wire
schema (AuditLogEventJson.metadata) is a loose record, and only the TS
spine validates metadata, at insert and fail-open, so this is the check that
holds a spine's rows to their event's contract.
Builtin event types only: a consumer-registered type has no entry here, and passes unexamined.
event
an audit row from audit_log_list or an audit read like it
Pick<AuditLogEventJson, "event_type" | "outcome" | "metadata">options?
reject_unknown_keys for the closed-world check
returns
void throws
AssertionError- naming the event type and the schema issues