/** * IAuditStore — Persistence interface for audit events. * JsonlAuditStore — Append-only JSONL file implementation. * * Design decisions: * - Append-only: audit log is immutable (governance requirement) * - JSONL format: one JSON object per line, easy to stream-parse * - Corrupt lines are skipped and logged (never crash on bad data) * - Line count is cached for fast getEventCount() */ import type { ILogger } from '../../shared/logger.js'; /** Serialized form of a domain event for audit persistence */ export interface SerializedDomainEvent { type: string; timestamp: string; sessionId: string; actor: { type: string; id: string; name?: string; }; [key: string]: unknown; } /** A persisted audit event with ordinal ID */ export interface PersistedAuditEvent { id: number; event: SerializedDomainEvent; persistedAt: string; } /** Query filters for audit events */ export interface AuditQuery { since?: string; until?: string; actorId?: string; actorType?: string; transition?: string; issueNumber?: number; sessionId?: string; eventType?: string; /** Filter by whether the transition committed to GitHub. Set true for committed-only, * false for rejected-attempts only. Omit to include both (default). */ executed?: boolean; limit?: number; offset?: number; } /** Result of an audit query */ export interface AuditQueryResult { events: PersistedAuditEvent[]; total: number; query: AuditQuery; } /** Summary of audit events over a period */ export interface AuditSummary { period: { since: string; until: string; }; totalEvents: number; byType: Record; byActor: Record; byTransition: Record; recentActivity: PersistedAuditEvent[]; } export interface AuditSummaryOptions { since?: string; until?: string; recentLimit?: number; } /** Persistence interface for audit events */ export interface IAuditStore { appendEvent(event: SerializedDomainEvent): Promise; readEvents(query: AuditQuery): Promise<{ events: PersistedAuditEvent[]; total: number; }>; getEventCount(): Promise; } export declare class JsonlAuditStore implements IAuditStore { private readonly logger; private readonly filePath; private cachedLineCount; constructor(projectRoot: string, logger: ILogger); appendEvent(event: SerializedDomainEvent): Promise; readEvents(query: AuditQuery): Promise<{ events: PersistedAuditEvent[]; total: number; }>; getEventCount(): Promise; private getNextId; private parseFile; private applyFilters; private isNotFoundError; } //# sourceMappingURL=audit-store.d.ts.map