Build a no-op AuditEmitter that records every emit, emit_pool, and
emit_role_grant_target call into calls as an AuditLogInput. Use to
capture audit metadata shapes in unit tests (e.g. password change failure
outcome, role-grant create denial) without standing up the full PGlite +
query_audit_log pipeline.
Capture scope — all four production fan-out shapes.
emit_role_grant_target mirrors create_audit_emitter's lift logic in
place — actor_id / account_id / ip are populated from auth + ctx
and the event_type / outcome / target_*_id / metadata fields
forward from the input envelope. Tests asserting on role-grant-shape
emissions read out of the same homogeneous calls array.
notify is a no-op; on_event_chain is an empty array.
emit AND emit_pool both append to calls so cleanup-sweep tests
(which use emit_pool exclusively — see auth/cleanup.ts) can also
read assertions off the same array.
Pass calls_ref to write into a caller-owned array (callers that
declared const events: Array<AuditLogInput> = [] and want to keep
the reference). Omit to let the helper allocate a fresh array and
return it on the calls field of the result.
The returned emitter is deliberately NOT frozen — slots stay mutable
so a test can override one when it needs bespoke shape (e.g. an
emit_pool that throws on the first call). The production
create_audit_emitter freeze invariant exists to catch the
patch_audit_emit_capture hot-patch footgun against the
closure-captured emit; the recording emitter has no inner closure,
so the freeze isn't load-bearing here.