brainy/.recovery-workspace/dist-backup-20250910-141917/augmentations/auditLogAugmentation.d.ts
David Snelling 8ff382ca3b chore: recovery checkpoint - v3.0 API successfully recovered
CRITICAL CHECKPOINT - DO NOT PUSH TO GITHUB

Recovery Status:
- Successfully recovered brainy.ts from compiled JavaScript
- All core v3.0 API methods functional (add, get, update, delete, relate, find, etc.)
- Neural subsystem intact (562KB embedded patterns, NLP working)
- Augmentation pipeline operational (20+ augmentations)
- HNSW clustering system complete
- Triple Intelligence compiled (needs constructor fix)
- Test suite validates functionality

Changes preserved:
- 898 files with changes from last 3 days
- 144,475 insertions
- All augmentation improvements
- All test coverage enhancements
- Complete v3.0 feature set

This is a LOCAL checkpoint only - contains recovered work after corruption incident.
Created backup in .backups/brainy-full-20250910-151314.tar.gz

Branch: recovery-checkpoint-20250910-151433
Date: Wed Sep 10 03:18:04 PM PDT 2025
2025-09-10 15:18:04 -07:00

109 lines
2.7 KiB
TypeScript

/**
* Audit Logging Augmentation
* Provides comprehensive audit trail for all Brainy operations
*/
import { BaseAugmentation } from './brainyAugmentation.js';
import { AugmentationManifest } from './manifest.js';
export interface AuditLogConfig {
enabled?: boolean;
logLevel?: 'minimal' | 'standard' | 'detailed';
includeData?: boolean;
includeMetadata?: boolean;
retention?: number;
storage?: 'memory' | 'file' | 'database';
filePath?: string;
maxMemoryLogs?: number;
}
export interface AuditLogEntry {
id: string;
timestamp: number;
operation: string;
params: any;
result?: any;
error?: any;
duration: number;
userId?: string;
sessionId?: string;
metadata?: Record<string, any>;
}
/**
* Audit Log Augmentation
*/
export declare class AuditLogAugmentation extends BaseAugmentation {
readonly name = "auditLogger";
readonly timing: "around";
readonly metadata: "readonly";
operations: any;
readonly priority = 90;
readonly category: "core";
readonly description = "Comprehensive audit logging for compliance and debugging";
private logs;
private sessionId;
constructor(config?: AuditLogConfig);
getManifest(): AugmentationManifest;
protected onInitialize(): Promise<void>;
protected onShutdown(): Promise<void>;
/**
* Execute augmentation - log operations
*/
execute<T = any>(operation: string, params: any, next: () => Promise<T>): Promise<T>;
/**
* Sanitize parameters to remove sensitive data
*/
private sanitizeParams;
/**
* Sanitize result data
*/
private sanitizeResult;
/**
* Sanitize error information
*/
private sanitizeError;
/**
* Write log entry
*/
private writeLog;
/**
* Flush logs to persistent storage
*/
private flushLogs;
/**
* Clean up old logs based on retention
*/
private cleanupOldLogs;
/**
* Generate unique ID
*/
private generateId;
/**
* Query audit logs
*/
queryLogs(filter?: {
operation?: string;
startTime?: number;
endTime?: number;
sessionId?: string;
hasError?: boolean;
}): AuditLogEntry[];
/**
* Get audit statistics
*/
getStats(): {
totalLogs: number;
operations: Record<string, number>;
averageDuration: number;
errorRate: number;
};
/**
* Export logs for analysis
*/
exportLogs(): AuditLogEntry[];
/**
* Clear all logs
*/
clearLogs(): void;
}
/**
* Create audit log augmentation
*/
export declare function createAuditLogAugmentation(config?: AuditLogConfig): AuditLogAugmentation;