audit-logger: the assigned-module manifest (ADR 0048) #2

Merged
jschoubben merged 28 commits from events/audit-logger-assigned into main 2026-09-05 01:06:59 +00:00
Showing only changes of commit 43625ec03f - Show all commits
+5 -2
View File
@@ -11,15 +11,18 @@ export function auditLogPath(env: NodeJS.ProcessEnv = process.env): string {
return env.AUDIT_LOG ?? "/var/lib/audit-logger/audit.log";
}
/** Append an event to the trail as one JSON line, keeping the metadata an audit needs first. */
/** Append an event to the trail as one JSON line, keeping the metadata an audit needs first. The id
* is the event's own x-event-id (ADR 0047) — the handle a reader dedups the at-least-once trail on. */
export async function record(event: Event, path: string): Promise<void> {
const line =
JSON.stringify({
id: event.type + "@" + event.at, // a stable-ish key until x-event-id headers land (ADR 0047)
id: event.id,
type: event.type,
source: event.source,
node: event.node,
at: event.at,
...(event.causationId ? { causationId: event.causationId } : {}),
...(event.schema ? { schema: event.schema } : {}),
body: event.body,
}) + "\n";
await mkdir(dirname(path), { recursive: true }).catch(() => {});