main #11
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"_variables": {
|
"_variables": {
|
||||||
"lastUpdateCheck": 1753528124767
|
"lastUpdateCheck": 1754571688630
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -178,16 +178,16 @@ GIT_API_TOKEN=your-git-api-token
|
|||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
# Enable detailed audit trail of AI decision-making
|
# Enable detailed audit trail of AI decision-making
|
||||||
PUBLIC_FORENSIC_AUDIT_ENABLED=true
|
FORENSIC_AUDIT_ENABLED=true
|
||||||
|
|
||||||
# Audit detail level: minimal, standard, verbose
|
# Audit detail level: minimal, standard, verbose
|
||||||
PUBLIC_FORENSIC_AUDIT_DETAIL_LEVEL=standard
|
FORENSIC_AUDIT_DETAIL_LEVEL=standard
|
||||||
|
|
||||||
# Audit retention time (hours)
|
# Audit retention time (hours)
|
||||||
PUBLIC_FORENSIC_AUDIT_RETENTION_HOURS=24
|
FORENSIC_AUDIT_RETENTION_HOURS=24
|
||||||
|
|
||||||
# Maximum audit entries per request
|
# Maximum audit entries per request
|
||||||
PUBLIC_FORENSIC_AUDIT_MAX_ENTRIES=50
|
FORENSIC_AUDIT_MAX_ENTRIES=50
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# 10. SIMPLIFIED CONFIDENCE SCORING SYSTEM
|
# 10. SIMPLIFIED CONFIDENCE SCORING SYSTEM
|
||||||
|
@ -157,8 +157,20 @@ class ImprovedMicroTaskAIPipeline {
|
|||||||
weights: `Semantic:${this.confidenceConfig.semanticWeight} Suitability:${this.confidenceConfig.suitabilityWeight}`,
|
weights: `Semantic:${this.confidenceConfig.semanticWeight} Suitability:${this.confidenceConfig.suitabilityWeight}`,
|
||||||
thresholds: `${this.confidenceConfig.minimumThreshold}/${this.confidenceConfig.mediumThreshold}/${this.confidenceConfig.highThreshold}`
|
thresholds: `${this.confidenceConfig.minimumThreshold}/${this.confidenceConfig.mediumThreshold}/${this.confidenceConfig.highThreshold}`
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('[AI PIPELINE] Environment variable debug:', {
|
||||||
|
FORENSIC_AUDIT_ENABLED: process.env.FORENSIC_AUDIT_ENABLED,
|
||||||
|
FORENSIC_AUDIT_DETAIL_LEVEL: process.env.FORENSIC_AUDIT_DETAIL_LEVEL,
|
||||||
|
NODE_ENV: process.env.NODE_ENV,
|
||||||
|
allEnvKeys: Object.keys(process.env).filter(k => k.includes('AUDIT')),
|
||||||
|
dotenvLoaded: !!process.env.PUBLIC_BASE_URL // Proxy for "dotenv worked"
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('[AI PIPELINE] Final audit config:', this.auditConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private getEnv(key: string): string {
|
private getEnv(key: string): string {
|
||||||
const value = process.env[key];
|
const value = process.env[key];
|
||||||
if (!value) {
|
if (!value) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// src/utils/auditService.ts
|
// src/utils/auditService.ts
|
||||||
|
import 'dotenv/config';
|
||||||
|
|
||||||
function env(key: string, fallback: string | undefined = undefined): string | undefined {
|
function env(key: string, fallback: string | undefined = undefined): string | undefined {
|
||||||
if (typeof process !== 'undefined' && process.env?.[key] !== undefined) {
|
if (typeof process !== 'undefined' && process.env?.[key] !== undefined) {
|
||||||
@ -26,7 +26,7 @@ interface AuditConfig {
|
|||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
detailLevel: 'minimal' | 'standard' | 'verbose';
|
detailLevel: 'minimal' | 'standard' | 'verbose';
|
||||||
retentionHours: number;
|
retentionHours: number;
|
||||||
maxEntriesPerRequest: number;
|
maxEntries: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CompressedAuditEntry {
|
interface CompressedAuditEntry {
|
||||||
@ -90,31 +90,50 @@ class AuditService {
|
|||||||
this.config = this.loadConfig();
|
this.config = this.loadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadConfig(): AuditConfig {
|
private loadConfig(): AuditConfig {
|
||||||
const enabledFlag =
|
// Use the env() helper function that handles both server and client contexts
|
||||||
(typeof import.meta !== 'undefined' &&
|
const enabledFlag = env('FORENSIC_AUDIT_ENABLED', 'false');
|
||||||
(import.meta as any).env?.PUBLIC_FORENSIC_AUDIT_ENABLED) ?? 'false';
|
const detailLevel = env('FORENSIC_AUDIT_DETAIL_LEVEL', 'standard') as 'minimal' | 'standard' | 'verbose';
|
||||||
|
const retentionHours = parseInt(env('FORENSIC_AUDIT_RETENTION_HOURS', '72') || '72', 10);
|
||||||
|
const maxEntries = parseInt(env('FORENSIC_AUDIT_MAX_ENTRIES', '50') || '50', 10);
|
||||||
|
|
||||||
return {
|
console.log('[AUDIT SERVICE] Configuration loaded:', {
|
||||||
enabled: enabledFlag === 'true',
|
enabled: enabledFlag === 'true',
|
||||||
detailLevel:
|
detailLevel,
|
||||||
((import.meta as any).env?.PUBLIC_FORENSIC_AUDIT_DETAIL_LEVEL as any) ||
|
retentionHours,
|
||||||
'standard',
|
maxEntries,
|
||||||
retentionHours: parseInt(
|
context: typeof process !== 'undefined' ? 'server' : 'client'
|
||||||
(import.meta as any).env?.PUBLIC_FORENSIC_AUDIT_RETENTION_HOURS || '72',
|
});
|
||||||
10
|
|
||||||
),
|
|
||||||
maxEntriesPerRequest: parseInt(
|
|
||||||
(import.meta as any).env?.PUBLIC_FORENSIC_AUDIT_MAX_ENTRIES || '50',
|
|
||||||
10
|
|
||||||
),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return {
|
||||||
|
enabled: enabledFlag === 'true',
|
||||||
|
detailLevel,
|
||||||
|
retentionHours,
|
||||||
|
maxEntries
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
getDebugInfo(): {
|
||||||
|
config: AuditConfig;
|
||||||
|
environment: Record<string, any>;
|
||||||
|
context: string;
|
||||||
|
} {
|
||||||
|
const context = typeof process !== 'undefined' ? 'server' : 'client';
|
||||||
|
|
||||||
|
return {
|
||||||
|
config: this.config,
|
||||||
|
environment: {
|
||||||
|
FORENSIC_AUDIT_ENABLED: env('FORENSIC_AUDIT_ENABLED'),
|
||||||
|
FORENSIC_AUDIT_DETAIL_LEVEL: env('FORENSIC_AUDIT_DETAIL_LEVEL'),
|
||||||
|
FORENSIC_AUDIT_RETENTION_HOURS: env('FORENSIC_AUDIT_RETENTION_HOURS'),
|
||||||
|
FORENSIC_AUDIT_MAX_ENTRIES: env('FORENSIC_AUDIT_MAX_ENTRIES'),
|
||||||
|
processEnvKeys: typeof process !== 'undefined' ? Object.keys(process.env).filter(k => k.includes('AUDIT')) : [],
|
||||||
|
importMetaEnvAvailable: typeof import.meta !== 'undefined' && !!(import.meta as any).env
|
||||||
|
},
|
||||||
|
context
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add an audit entry with automatic data compression
|
|
||||||
*/
|
|
||||||
addEntry(
|
addEntry(
|
||||||
phase: string,
|
phase: string,
|
||||||
action: string,
|
action: string,
|
||||||
@ -226,9 +245,6 @@ class AuditService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Compress audit entry for efficient transport
|
|
||||||
*/
|
|
||||||
private compressEntry(entry: AuditEntry): CompressedAuditEntry | null {
|
private compressEntry(entry: AuditEntry): CompressedAuditEntry | null {
|
||||||
if (!entry || typeof entry !== 'object') {
|
if (!entry || typeof entry !== 'object') {
|
||||||
console.warn('[AUDIT] Invalid audit entry:', entry);
|
console.warn('[AUDIT] Invalid audit entry:', entry);
|
||||||
@ -286,9 +302,6 @@ class AuditService {
|
|||||||
return String(data);
|
return String(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Standard level data compression
|
|
||||||
*/
|
|
||||||
private summarizeForStorage(data: any): any {
|
private summarizeForStorage(data: any): any {
|
||||||
if (typeof data === 'string' && data.length > 500) {
|
if (typeof data === 'string' && data.length > 500) {
|
||||||
return data.slice(0, 500) + '...[truncated]';
|
return data.slice(0, 500) + '...[truncated]';
|
||||||
@ -299,9 +312,6 @@ class AuditService {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Minimal level data compression
|
|
||||||
*/
|
|
||||||
private minimalSummary(data: any): any {
|
private minimalSummary(data: any): any {
|
||||||
if (typeof data === 'string' && data.length > 100) {
|
if (typeof data === 'string' && data.length > 100) {
|
||||||
return data.slice(0, 100) + '...[truncated]';
|
return data.slice(0, 100) + '...[truncated]';
|
||||||
@ -388,3 +398,17 @@ class AuditService {
|
|||||||
|
|
||||||
export const auditService = new AuditService();
|
export const auditService = new AuditService();
|
||||||
export type { ProcessedAuditTrail, CompressedAuditEntry };
|
export type { ProcessedAuditTrail, CompressedAuditEntry };
|
||||||
|
// Add this at the bottom of auditService.ts (after the existing exports)
|
||||||
|
|
||||||
|
// Export debug utilities for troubleshooting
|
||||||
|
export const debugAuditService = {
|
||||||
|
getDebugInfo() {
|
||||||
|
return auditService.getDebugInfo();
|
||||||
|
},
|
||||||
|
isEnabled() {
|
||||||
|
return auditService.isEnabled();
|
||||||
|
},
|
||||||
|
getConfig() {
|
||||||
|
return auditService.getConfig();
|
||||||
|
}
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user