@systima/aiact-audit-log 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COMPLIANCE.md +180 -0
- package/LICENSE +21 -0
- package/README.md +406 -0
- package/dist/ai-sdk/index.cjs +102 -0
- package/dist/ai-sdk/index.cjs.map +1 -0
- package/dist/ai-sdk/index.d.cts +341 -0
- package/dist/ai-sdk/index.d.ts +341 -0
- package/dist/ai-sdk/index.js +77 -0
- package/dist/ai-sdk/index.js.map +1 -0
- package/dist/ai-sdk/middleware/index.cjs +259 -0
- package/dist/ai-sdk/middleware/index.cjs.map +1 -0
- package/dist/ai-sdk/middleware/index.d.cts +323 -0
- package/dist/ai-sdk/middleware/index.d.ts +323 -0
- package/dist/ai-sdk/middleware/index.js +236 -0
- package/dist/ai-sdk/middleware/index.js.map +1 -0
- package/dist/cli/index.js +3332 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.cjs +1385 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +501 -0
- package/dist/index.d.ts +501 -0
- package/dist/index.js +1342 -0
- package/dist/index.js.map +1 -0
- package/dist/prompt-F4GUFYMH.js +755 -0
- package/dist/prompt-F4GUFYMH.js.map +1 -0
- package/package.json +91 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage backend interface.
|
|
3
|
+
*
|
|
4
|
+
* Abstraction layer for log persistence. v0.1 ships with S3-compatible
|
|
5
|
+
* storage only; future versions will add Azure Blob, GCS, and local
|
|
6
|
+
* filesystem backends.
|
|
7
|
+
*/
|
|
8
|
+
interface StorageBackend {
|
|
9
|
+
write(key: string, data: Buffer): Promise<void>;
|
|
10
|
+
read(key: string): Promise<Buffer>;
|
|
11
|
+
list(prefix: string): Promise<string[]>;
|
|
12
|
+
exists(key: string): Promise<boolean>;
|
|
13
|
+
getObjectMetadata(key: string): Promise<ObjectMetadata>;
|
|
14
|
+
}
|
|
15
|
+
interface ObjectMetadata {
|
|
16
|
+
lastModified: Date;
|
|
17
|
+
size: number;
|
|
18
|
+
}
|
|
19
|
+
interface S3StorageConfig {
|
|
20
|
+
type: 's3';
|
|
21
|
+
bucket: string;
|
|
22
|
+
region: string;
|
|
23
|
+
prefix?: string;
|
|
24
|
+
endpoint?: string;
|
|
25
|
+
forcePathStyle?: boolean;
|
|
26
|
+
credentials?: {
|
|
27
|
+
accessKeyId: string;
|
|
28
|
+
secretAccessKey: string;
|
|
29
|
+
sessionToken?: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
type StorageConfig = S3StorageConfig;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Schema definitions and runtime validation for audit log entries.
|
|
36
|
+
*
|
|
37
|
+
* Every field is annotated with the Article paragraph it satisfies.
|
|
38
|
+
* The schema IS the Article 12 mapping.
|
|
39
|
+
*/
|
|
40
|
+
declare const EVENT_TYPES: readonly ["inference", "tool_call", "tool_result", "human_intervention", "system_event", "session_start", "session_end"];
|
|
41
|
+
type EventType = (typeof EVENT_TYPES)[number];
|
|
42
|
+
declare const CAPTURE_METHODS: readonly ["middleware", "manual", "context"];
|
|
43
|
+
type CaptureMethod = (typeof CAPTURE_METHODS)[number];
|
|
44
|
+
interface InputData {
|
|
45
|
+
type: 'raw' | 'hash';
|
|
46
|
+
value: string;
|
|
47
|
+
tokenCount?: number;
|
|
48
|
+
}
|
|
49
|
+
interface OutputData {
|
|
50
|
+
type: 'raw' | 'hash';
|
|
51
|
+
value: string;
|
|
52
|
+
tokenCount?: number;
|
|
53
|
+
finishReason?: string;
|
|
54
|
+
}
|
|
55
|
+
interface TokenUsage {
|
|
56
|
+
promptTokens: number;
|
|
57
|
+
completionTokens: number;
|
|
58
|
+
totalTokens: number;
|
|
59
|
+
}
|
|
60
|
+
interface ErrorData {
|
|
61
|
+
code: string;
|
|
62
|
+
message: string;
|
|
63
|
+
stack?: string;
|
|
64
|
+
}
|
|
65
|
+
declare const HUMAN_INTERVENTION_TYPES: readonly ["approval", "rejection", "modification", "override", "escalation"];
|
|
66
|
+
type HumanInterventionType = (typeof HUMAN_INTERVENTION_TYPES)[number];
|
|
67
|
+
interface HumanIntervention {
|
|
68
|
+
/** @article 12(2)(c), 14(5), 12(3)(d) */
|
|
69
|
+
type: HumanInterventionType;
|
|
70
|
+
userId: string;
|
|
71
|
+
reason?: string;
|
|
72
|
+
originalOutput?: {
|
|
73
|
+
type: 'raw' | 'hash';
|
|
74
|
+
value: string;
|
|
75
|
+
};
|
|
76
|
+
timestamp: string;
|
|
77
|
+
}
|
|
78
|
+
interface ToolCallData {
|
|
79
|
+
toolName: string;
|
|
80
|
+
toolArgs: Record<string, unknown> | string;
|
|
81
|
+
toolResult?: string;
|
|
82
|
+
}
|
|
83
|
+
interface MatchResult {
|
|
84
|
+
matched: boolean;
|
|
85
|
+
matchConfidence?: number;
|
|
86
|
+
matchedRecordId?: string;
|
|
87
|
+
}
|
|
88
|
+
interface AuditLogEntry {
|
|
89
|
+
schemaVersion: 'v1';
|
|
90
|
+
/** @article 12(1) — unique event identification */
|
|
91
|
+
entryId: string;
|
|
92
|
+
/** @article 12(2)(a) — risk identification requires correlating related events */
|
|
93
|
+
decisionId: string;
|
|
94
|
+
/** @article 12(1) — system identification */
|
|
95
|
+
systemId: string;
|
|
96
|
+
/** @article 12(1), 12(3)(a) — automatic recording, period of each use */
|
|
97
|
+
timestamp: string;
|
|
98
|
+
/** @article 12(2)(a) — identifying situations that may present a risk */
|
|
99
|
+
eventType: EventType;
|
|
100
|
+
/** @article 12(2)(a), 72 — model version tracking */
|
|
101
|
+
modelId: string | null;
|
|
102
|
+
providerId: string | null;
|
|
103
|
+
/** @article 12(2)(a), 12(2)(c), 12(3)(c) — input context and deployer monitoring */
|
|
104
|
+
input: InputData;
|
|
105
|
+
/** @article 12(2)(a), 12(2)(b) — risk identification and post-market monitoring */
|
|
106
|
+
output: OutputData | null;
|
|
107
|
+
/** @article 12(2)(b), 72 — performance degradation detection */
|
|
108
|
+
latencyMs: number | null;
|
|
109
|
+
/** @article 72 — post-market monitoring (usage tracking) */
|
|
110
|
+
usage: TokenUsage | null;
|
|
111
|
+
/** @article 12(2)(a) — identifying situations that may present a risk */
|
|
112
|
+
error: ErrorData | null;
|
|
113
|
+
/** @article 12(2)(a) — risk identification requires knowing configuration */
|
|
114
|
+
parameters: Record<string, unknown> | null;
|
|
115
|
+
captureMethod: CaptureMethod;
|
|
116
|
+
/** @article 12(1) — event ordering */
|
|
117
|
+
seq: number;
|
|
118
|
+
prevHash: string;
|
|
119
|
+
hash: string;
|
|
120
|
+
}
|
|
121
|
+
interface AuditLogEntryExtended extends AuditLogEntry {
|
|
122
|
+
/** @article 12(2)(c), 14(5), 12(3)(d) */
|
|
123
|
+
humanIntervention?: HumanIntervention;
|
|
124
|
+
/** @article 12(2)(a) — tracing complex decision chains */
|
|
125
|
+
stepIndex?: number;
|
|
126
|
+
parentEntryId?: string;
|
|
127
|
+
/** @article 12(2)(a) — tool calls as risk vectors */
|
|
128
|
+
toolCall?: ToolCallData;
|
|
129
|
+
/** @article 12(3)(b) — reference database for biometric systems */
|
|
130
|
+
referenceDatabase?: string;
|
|
131
|
+
/** @article 12(3)(c) — match results for biometric systems */
|
|
132
|
+
matchResult?: MatchResult;
|
|
133
|
+
metadata?: Record<string, string | number | boolean>;
|
|
134
|
+
}
|
|
135
|
+
interface LogEntryInput {
|
|
136
|
+
decisionId?: string;
|
|
137
|
+
eventType: EventType;
|
|
138
|
+
modelId: string | null;
|
|
139
|
+
providerId: string | null;
|
|
140
|
+
input: {
|
|
141
|
+
value: string;
|
|
142
|
+
type?: 'raw' | 'hash';
|
|
143
|
+
tokenCount?: number;
|
|
144
|
+
};
|
|
145
|
+
output: {
|
|
146
|
+
value: string;
|
|
147
|
+
type?: 'raw' | 'hash';
|
|
148
|
+
tokenCount?: number;
|
|
149
|
+
finishReason?: string;
|
|
150
|
+
} | null;
|
|
151
|
+
latencyMs: number | null;
|
|
152
|
+
usage: TokenUsage | null;
|
|
153
|
+
parameters: Record<string, unknown> | null;
|
|
154
|
+
error: ErrorData | null;
|
|
155
|
+
captureMethod?: CaptureMethod;
|
|
156
|
+
humanIntervention?: HumanIntervention;
|
|
157
|
+
stepIndex?: number;
|
|
158
|
+
parentEntryId?: string;
|
|
159
|
+
toolCall?: ToolCallData;
|
|
160
|
+
referenceDatabase?: string;
|
|
161
|
+
matchResult?: MatchResult;
|
|
162
|
+
metadata?: Record<string, string | number | boolean>;
|
|
163
|
+
}
|
|
164
|
+
declare class SchemaValidationError extends Error {
|
|
165
|
+
readonly field: string;
|
|
166
|
+
readonly reason: string;
|
|
167
|
+
constructor(field: string, reason: string);
|
|
168
|
+
}
|
|
169
|
+
declare function validateLogEntryInput(entry: LogEntryInput): void;
|
|
170
|
+
declare function validateAuditLogEntry(entry: AuditLogEntry): void;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* AuditLogger — core class for structured, tamper-evident audit logging.
|
|
174
|
+
*
|
|
175
|
+
* Satisfies Article 12(1): automatic recording of events over the
|
|
176
|
+
* lifetime of the system. Entries are batched in memory and flushed
|
|
177
|
+
* to S3-compatible storage with SHA-256 hash chains.
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
interface RetentionOptions {
|
|
181
|
+
minimumDays?: number;
|
|
182
|
+
acknowledgeSubMinimum?: boolean;
|
|
183
|
+
autoConfigureLifecycle?: boolean;
|
|
184
|
+
}
|
|
185
|
+
interface PIIOptions {
|
|
186
|
+
hashInputs?: boolean;
|
|
187
|
+
hashOutputs?: boolean;
|
|
188
|
+
redactPatterns?: RegExp[];
|
|
189
|
+
}
|
|
190
|
+
interface BatchingOptions {
|
|
191
|
+
maxSize?: number;
|
|
192
|
+
maxDelayMs?: number;
|
|
193
|
+
}
|
|
194
|
+
interface ObjectLockOptions {
|
|
195
|
+
enabled?: boolean;
|
|
196
|
+
mode?: 'GOVERNANCE' | 'COMPLIANCE';
|
|
197
|
+
}
|
|
198
|
+
interface HealthCheckOptions {
|
|
199
|
+
enabled?: boolean;
|
|
200
|
+
intervalMs?: number;
|
|
201
|
+
onDrift?: 'warn' | 'throw' | ((drift: ComplianceDrift) => void);
|
|
202
|
+
}
|
|
203
|
+
interface ComplianceDrift {
|
|
204
|
+
check: string;
|
|
205
|
+
status: 'fail' | 'warn';
|
|
206
|
+
message: string;
|
|
207
|
+
}
|
|
208
|
+
type ErrorHandler = 'log-and-continue' | 'throw' | ((error: Error) => void);
|
|
209
|
+
interface AuditLoggerConfig {
|
|
210
|
+
systemId: string;
|
|
211
|
+
storage: StorageConfig;
|
|
212
|
+
retention?: RetentionOptions;
|
|
213
|
+
pii?: PIIOptions;
|
|
214
|
+
batching?: BatchingOptions;
|
|
215
|
+
onError?: ErrorHandler;
|
|
216
|
+
objectLock?: ObjectLockOptions;
|
|
217
|
+
healthCheck?: HealthCheckOptions;
|
|
218
|
+
}
|
|
219
|
+
declare class AuditLogger {
|
|
220
|
+
private readonly config;
|
|
221
|
+
private readonly systemId;
|
|
222
|
+
private readonly storage;
|
|
223
|
+
private readonly storageConfig;
|
|
224
|
+
private readonly retention;
|
|
225
|
+
private readonly pii;
|
|
226
|
+
private readonly batching;
|
|
227
|
+
private readonly onError;
|
|
228
|
+
private readonly objectLock;
|
|
229
|
+
private buffer;
|
|
230
|
+
private seq;
|
|
231
|
+
private prevHash;
|
|
232
|
+
private currentFileIndex;
|
|
233
|
+
private currentFileSize;
|
|
234
|
+
private flushTimer;
|
|
235
|
+
private closed;
|
|
236
|
+
private initialised;
|
|
237
|
+
private healthCheckTimer;
|
|
238
|
+
private shutdownHandler;
|
|
239
|
+
constructor(config: AuditLoggerConfig);
|
|
240
|
+
/**
|
|
241
|
+
* Initialise the logger. Loads chain head from storage,
|
|
242
|
+
* recovers chain state, and writes initial metadata.
|
|
243
|
+
*
|
|
244
|
+
* Must be called before the first log() call. If not called
|
|
245
|
+
* explicitly, log() will call it lazily.
|
|
246
|
+
*/
|
|
247
|
+
init(): Promise<void>;
|
|
248
|
+
/**
|
|
249
|
+
* Log a single event.
|
|
250
|
+
*
|
|
251
|
+
* If no decisionId is provided and no AsyncLocalStorage context is active,
|
|
252
|
+
* throws MissingDecisionIdError.
|
|
253
|
+
*/
|
|
254
|
+
log(input: LogEntryInput): Promise<AuditLogEntryExtended>;
|
|
255
|
+
/**
|
|
256
|
+
* Force flush all buffered entries to storage.
|
|
257
|
+
*/
|
|
258
|
+
flush(): Promise<void>;
|
|
259
|
+
/**
|
|
260
|
+
* Flush remaining entries and release all resources.
|
|
261
|
+
*/
|
|
262
|
+
close(): Promise<void>;
|
|
263
|
+
/**
|
|
264
|
+
* Run a health check against the storage backend.
|
|
265
|
+
*/
|
|
266
|
+
healthCheck(): Promise<HealthCheckResult>;
|
|
267
|
+
getSystemId(): string;
|
|
268
|
+
getStorageBackend(): StorageBackend;
|
|
269
|
+
getStorageConfig(): StorageConfig;
|
|
270
|
+
getCurrentSeq(): number;
|
|
271
|
+
getPrevHash(): string;
|
|
272
|
+
/** Exposed for testing with custom storage backends */
|
|
273
|
+
static createWithStorage(config: Omit<AuditLoggerConfig, 'storage'> & {
|
|
274
|
+
storage: StorageConfig;
|
|
275
|
+
}, storage: StorageBackend): AuditLogger;
|
|
276
|
+
private processInputData;
|
|
277
|
+
private processOutputData;
|
|
278
|
+
private redact;
|
|
279
|
+
private currentDatePath;
|
|
280
|
+
private currentFilePath;
|
|
281
|
+
private writeEntries;
|
|
282
|
+
private persistChainHead;
|
|
283
|
+
private loadChainHead;
|
|
284
|
+
private writeMetadata;
|
|
285
|
+
private scheduleFlush;
|
|
286
|
+
private clearFlushTimer;
|
|
287
|
+
private handleError;
|
|
288
|
+
private setupShutdownHooks;
|
|
289
|
+
private removeShutdownHooks;
|
|
290
|
+
private checkWriteAccess;
|
|
291
|
+
private checkReadAccess;
|
|
292
|
+
private checkChainHeadConsistency;
|
|
293
|
+
private checkSchemaVersion;
|
|
294
|
+
}
|
|
295
|
+
interface HealthCheckResult {
|
|
296
|
+
timestamp: string;
|
|
297
|
+
checks: HealthCheck[];
|
|
298
|
+
healthy: boolean;
|
|
299
|
+
}
|
|
300
|
+
interface HealthCheck {
|
|
301
|
+
name: string;
|
|
302
|
+
status: 'pass' | 'fail' | 'warn';
|
|
303
|
+
message: string;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* SHA-256 hash chain logic for tamper-evident audit logging.
|
|
308
|
+
*
|
|
309
|
+
* Each log entry contains:
|
|
310
|
+
* - seq: monotonically increasing sequence number
|
|
311
|
+
* - prevHash: SHA-256 hash of the previous entry
|
|
312
|
+
* - hash: SHA-256 hash of the current entry (excluding the hash field itself)
|
|
313
|
+
*
|
|
314
|
+
* The chain proves ordering and non-modification. Combined with S3 Object Lock,
|
|
315
|
+
* this provides the tamper-evidence required for trustworthy automatic recording
|
|
316
|
+
* under Article 12(1).
|
|
317
|
+
*/
|
|
318
|
+
|
|
319
|
+
interface ChainHead {
|
|
320
|
+
seq: number;
|
|
321
|
+
hash: string;
|
|
322
|
+
systemId: string;
|
|
323
|
+
updatedAt: string;
|
|
324
|
+
}
|
|
325
|
+
interface ChainVerificationResult {
|
|
326
|
+
valid: boolean;
|
|
327
|
+
entriesChecked: number;
|
|
328
|
+
firstBreak: {
|
|
329
|
+
seq: number;
|
|
330
|
+
expectedPrevHash: string;
|
|
331
|
+
actualPrevHash: string;
|
|
332
|
+
} | null;
|
|
333
|
+
}
|
|
334
|
+
declare function computeGenesisHash(systemId: string): string;
|
|
335
|
+
declare function computeEntryHash(entry: Omit<AuditLogEntry, 'hash'>): string;
|
|
336
|
+
declare function verifyEntryHash(entry: AuditLogEntry): boolean;
|
|
337
|
+
declare function verifyChain(entries: AuditLogEntry[]): ChainVerificationResult;
|
|
338
|
+
declare function verifyChainFromGenesis(entries: AuditLogEntry[], systemId: string): ChainVerificationResult;
|
|
339
|
+
declare function sha256(data: string): string;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* AuditLogReader — query, reconstruct, verify, and analyse audit logs.
|
|
343
|
+
*
|
|
344
|
+
* Supports Article 12(2) traceability requirements: given a decision
|
|
345
|
+
* identifier, reconstruct everything. Given a time range, query and
|
|
346
|
+
* analyse for post-market monitoring (Article 72).
|
|
347
|
+
*/
|
|
348
|
+
|
|
349
|
+
interface AuditLogReaderConfig {
|
|
350
|
+
storage: StorageConfig;
|
|
351
|
+
systemId: string;
|
|
352
|
+
}
|
|
353
|
+
interface QueryOptions {
|
|
354
|
+
from?: string;
|
|
355
|
+
to?: string;
|
|
356
|
+
eventType?: EventType;
|
|
357
|
+
decisionId?: string;
|
|
358
|
+
limit?: number;
|
|
359
|
+
}
|
|
360
|
+
interface ReconstructResult {
|
|
361
|
+
decisionId: string;
|
|
362
|
+
entries: AuditLogEntryExtended[];
|
|
363
|
+
timeline: TimelineEntry[];
|
|
364
|
+
integrity: {
|
|
365
|
+
valid: boolean;
|
|
366
|
+
entriesChecked: number;
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
interface TimelineEntry {
|
|
370
|
+
timestamp: string;
|
|
371
|
+
eventType: string;
|
|
372
|
+
summary: string;
|
|
373
|
+
entryId: string;
|
|
374
|
+
}
|
|
375
|
+
interface StatsResult {
|
|
376
|
+
totalEntries: number;
|
|
377
|
+
byEventType: Record<string, number>;
|
|
378
|
+
byModel: Record<string, number>;
|
|
379
|
+
byCaptureMethod: Record<string, number>;
|
|
380
|
+
errorRate: number;
|
|
381
|
+
avgLatencyMs: number | null;
|
|
382
|
+
p95LatencyMs: number | null;
|
|
383
|
+
p99LatencyMs: number | null;
|
|
384
|
+
tokenUsage: {
|
|
385
|
+
prompt: number;
|
|
386
|
+
completion: number;
|
|
387
|
+
total: number;
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
declare class AuditLogReader {
|
|
391
|
+
private readonly storage;
|
|
392
|
+
private readonly systemId;
|
|
393
|
+
constructor(config: AuditLogReaderConfig);
|
|
394
|
+
static createWithStorage(config: AuditLogReaderConfig, storage: StorageBackend): AuditLogReader;
|
|
395
|
+
getStorageBackend(): StorageBackend;
|
|
396
|
+
query(options?: QueryOptions): Promise<AuditLogEntryExtended[]>;
|
|
397
|
+
reconstruct(decisionId: string): Promise<ReconstructResult>;
|
|
398
|
+
verifyChain(options?: {
|
|
399
|
+
from?: string;
|
|
400
|
+
to?: string;
|
|
401
|
+
}): Promise<ChainVerificationResult>;
|
|
402
|
+
stats(options?: {
|
|
403
|
+
from?: string;
|
|
404
|
+
to?: string;
|
|
405
|
+
}): Promise<StatsResult>;
|
|
406
|
+
private loadEntries;
|
|
407
|
+
private loadAllEntries;
|
|
408
|
+
private getDatePrefixes;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* AsyncLocalStorage-based context propagation for audit logging.
|
|
413
|
+
*
|
|
414
|
+
* Allows decision IDs and metadata to flow through async call chains
|
|
415
|
+
* without manual threading. This reduces the integration burden that
|
|
416
|
+
* leads to coverage gaps.
|
|
417
|
+
*/
|
|
418
|
+
interface AuditContext {
|
|
419
|
+
decisionId: string;
|
|
420
|
+
parentDecisionId?: string;
|
|
421
|
+
metadata?: Record<string, string | number | boolean>;
|
|
422
|
+
}
|
|
423
|
+
declare function withAuditContext<T>(context: AuditContext, callback: () => T | Promise<T>): T | Promise<T>;
|
|
424
|
+
declare function getAuditContext(): AuditContext | undefined;
|
|
425
|
+
declare class MissingDecisionIdError extends Error {
|
|
426
|
+
constructor();
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Coverage diagnostic — analyses logs for completeness gaps.
|
|
431
|
+
*
|
|
432
|
+
* Addresses the core feedback: the real compliance risk is not the
|
|
433
|
+
* schema but incomplete instrumentation. This module makes logging
|
|
434
|
+
* gaps visible.
|
|
435
|
+
*/
|
|
436
|
+
|
|
437
|
+
interface CoverageReport {
|
|
438
|
+
period: {
|
|
439
|
+
from: string;
|
|
440
|
+
to: string;
|
|
441
|
+
};
|
|
442
|
+
totalEntries: number;
|
|
443
|
+
byEventType: Record<string, {
|
|
444
|
+
count: number;
|
|
445
|
+
percentage: number;
|
|
446
|
+
}>;
|
|
447
|
+
byCaptureMethod: Record<string, {
|
|
448
|
+
count: number;
|
|
449
|
+
percentage: number;
|
|
450
|
+
}>;
|
|
451
|
+
warnings: CoverageWarning[];
|
|
452
|
+
recommendations: string[];
|
|
453
|
+
}
|
|
454
|
+
interface CoverageWarning {
|
|
455
|
+
severity: 'high' | 'medium' | 'low';
|
|
456
|
+
code: string;
|
|
457
|
+
message: string;
|
|
458
|
+
}
|
|
459
|
+
interface CoverageOptions {
|
|
460
|
+
from?: string;
|
|
461
|
+
to?: string;
|
|
462
|
+
}
|
|
463
|
+
declare function analyseCoverage(entries: AuditLogEntryExtended[], options?: CoverageOptions): CoverageReport;
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Custom error types for the audit logger.
|
|
467
|
+
*/
|
|
468
|
+
declare class ComplianceConfigError extends Error {
|
|
469
|
+
constructor(message: string);
|
|
470
|
+
}
|
|
471
|
+
declare class ComplianceDriftError extends Error {
|
|
472
|
+
constructor(message: string);
|
|
473
|
+
}
|
|
474
|
+
declare class StorageError extends Error {
|
|
475
|
+
readonly cause?: Error;
|
|
476
|
+
constructor(message: string, cause?: Error);
|
|
477
|
+
}
|
|
478
|
+
declare class ChainIntegrityError extends Error {
|
|
479
|
+
readonly seq: number;
|
|
480
|
+
constructor(message: string, seq: number);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* In-memory storage backend for testing.
|
|
485
|
+
*
|
|
486
|
+
* Not for production use. This backend stores everything in memory
|
|
487
|
+
* and is used by the test suite to avoid requiring an S3 endpoint.
|
|
488
|
+
*/
|
|
489
|
+
|
|
490
|
+
declare class MemoryStorage implements StorageBackend {
|
|
491
|
+
private readonly store;
|
|
492
|
+
write(key: string, data: Buffer): Promise<void>;
|
|
493
|
+
read(key: string): Promise<Buffer>;
|
|
494
|
+
list(prefix: string): Promise<string[]>;
|
|
495
|
+
exists(key: string): Promise<boolean>;
|
|
496
|
+
getObjectMetadata(key: string): Promise<ObjectMetadata>;
|
|
497
|
+
clear(): void;
|
|
498
|
+
getAll(): Map<string, Buffer>;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
export { type AuditContext, type AuditLogEntry, type AuditLogEntryExtended, AuditLogReader, type AuditLogReaderConfig, AuditLogger, type AuditLoggerConfig, type BatchingOptions, CAPTURE_METHODS, type CaptureMethod, type ChainHead, ChainIntegrityError, type ChainVerificationResult, ComplianceConfigError, type ComplianceDrift, ComplianceDriftError, type CoverageOptions, type CoverageReport, type CoverageWarning, EVENT_TYPES, type ErrorData, type ErrorHandler, type EventType, HUMAN_INTERVENTION_TYPES, type HealthCheck, type HealthCheckOptions, type HealthCheckResult, type HumanIntervention, type HumanInterventionType, type InputData, type LogEntryInput, type MatchResult, MemoryStorage, MissingDecisionIdError, type ObjectLockOptions, type ObjectMetadata, type OutputData, type PIIOptions, type QueryOptions, type ReconstructResult, type RetentionOptions, type S3StorageConfig, SchemaValidationError, type StatsResult, type StorageBackend, type StorageConfig, StorageError, type TimelineEntry, type TokenUsage, type ToolCallData, analyseCoverage, computeEntryHash, computeGenesisHash, getAuditContext, sha256, validateAuditLogEntry, validateLogEntryInput, verifyChain, verifyChainFromGenesis, verifyEntryHash, withAuditContext };
|