From 625b9ae816a94b2b320cc1e960eb2efbd9d3288e Mon Sep 17 00:00:00 2001 From: TheFlow Date: Fri, 31 Oct 2025 20:54:37 +1300 Subject: [PATCH] feat: implement Deep Interlock coordination tracking in audit logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add services_involved tracking to framework-audit-hook.js - Hook now tracks which services are invoked for each tool use - Pass services_involved array to all service contexts - Update ContextPressureMonitor to log coordination in metadata.services_involved - Update BoundaryEnforcer to log coordination in metadata.services_involved - Enables 0% → X% coordination rate in audit log analysis - Fixes HF Space showing 0.0% Deep Interlock coordination - Services will now properly log when they coordinate on decisions This implements the missing instrumentation for Deep Interlock (Principle #2). Services were coordinating but not logging it - now audit trail will show multi-service coordination patterns. --- .claude/hooks/framework-audit-hook.js | 18 +++++++++++++++--- src/services/BoundaryEnforcer.service.js | 3 ++- src/services/ContextPressureMonitor.service.js | 3 ++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.claude/hooks/framework-audit-hook.js b/.claude/hooks/framework-audit-hook.js index e26a529d..7ea51c6d 100755 --- a/.claude/hooks/framework-audit-hook.js +++ b/.claude/hooks/framework-audit-hook.js @@ -280,6 +280,9 @@ async function handleFileModification(toolInput, sessionId) { // PHASE 3: Collect guidance from all framework services const guidanceMessages = []; + // Track service coordination for Deep Interlock logging + const servicesInvolved = []; + // 1. Boundary enforcement const action = { type: 'file_modification', @@ -291,10 +294,12 @@ async function handleFileModification(toolInput, sessionId) { const context = { sessionId, tool: 'Edit/Write', - file: filePath + file: filePath, + services_involved: servicesInvolved // Pass array reference for coordination tracking }; const boundaryResult = BoundaryEnforcer.enforce(action, context); + servicesInvolved.push('BoundaryEnforcer'); // Track service involvement // PHASE 3: Collect guidance from BoundaryEnforcer if (boundaryResult.guidance && boundaryResult.guidance.systemMessage) { @@ -419,6 +424,7 @@ async function handleFileModification(toolInput, sessionId) { }; CrossReferenceValidator.validate(validateAction, { ...context, governance: true }); + servicesInvolved.push('CrossReferenceValidator'); // Track service involvement } // 4. PHASE 2: Graduated security verification based on content analysis @@ -443,6 +449,7 @@ async function handleFileModification(toolInput, sessionId) { automated_approval: canAutoApprove, requires_human_review: securityGradient === 'CRITICAL' }); + servicesInvolved.push('MetacognitiveVerifier'); // Track service involvement // PHASE 3: Collect guidance from MetacognitiveVerifier if (verificationResult && verificationResult.guidance && verificationResult.guidance.systemMessage) { @@ -456,8 +463,10 @@ async function handleFileModification(toolInput, sessionId) { sessionId, tool: 'Edit/Write', action: 'file_modification', - file: filePath + file: filePath, + services_involved: servicesInvolved // Pass coordination tracking }); + servicesInvolved.push('ContextPressureMonitor'); // Track service involvement // 6. Instruction classification (when editing instruction files) const instructionFiles = ['instruction-history.json', 'CLAUDE.md', 'settings.json']; @@ -476,6 +485,7 @@ async function handleFileModification(toolInput, sessionId) { timestamp: new Date(), source: 'tool_use' }); + servicesInvolved.push('InstructionPersistenceClassifier'); // Track service involvement } // 7. Pluralistic deliberation (when value conflicts might occur) @@ -493,6 +503,7 @@ async function handleFileModification(toolInput, sessionId) { ...context, value_domains: valueConflictFiles.filter(k => filePath.toLowerCase().includes(k)) }); + servicesInvolved.push('PluralisticDeliberationOrchestrator'); // Track service involvement // PHASE 3: Collect guidance from PluralisticDeliberationOrchestrator if (deliberationResult && deliberationResult.guidance && deliberationResult.guidance.systemMessage) { @@ -527,7 +538,8 @@ async function handleFileModification(toolInput, sessionId) { const result = { decision: 'allow', reason: `Framework audit complete: ${path.basename(filePath)}`, - crossValidation // PHASE 3.5: Include validation data + crossValidation, // PHASE 3.5: Include validation data + servicesInvolved // Include Deep Interlock coordination data }; // Add systemMessage if we have any guidance diff --git a/src/services/BoundaryEnforcer.service.js b/src/services/BoundaryEnforcer.service.js index 8844922c..cc15c4ca 100644 --- a/src/services/BoundaryEnforcer.service.js +++ b/src/services/BoundaryEnforcer.service.js @@ -895,7 +895,8 @@ class BoundaryEnforcer { enforcement_decision: result.allowed ? 'ALLOWED' : 'BLOCKED', framework_backed_decision: frameworkBacked, // PHASE 3: Track framework participation guidance_provided: frameworkBacked, - guidance_severity: result.guidance?.severity || null + guidance_severity: result.guidance?.severity || null, + services_involved: context.services_involved || [] // Deep Interlock coordination tracking } }).catch(error => { logger.error('Failed to audit enforcement decision', { diff --git a/src/services/ContextPressureMonitor.service.js b/src/services/ContextPressureMonitor.service.js index e41e9cf0..0ef00c3f 100644 --- a/src/services/ContextPressureMonitor.service.js +++ b/src/services/ContextPressureMonitor.service.js @@ -920,7 +920,8 @@ class ContextPressureMonitor { }, top_metric: this._getTopMetric(analysis.metrics), warnings_count: violations.length, - recommendations_count: analysis.recommendations?.length || 0 + recommendations_count: analysis.recommendations?.length || 0, + services_involved: context.services_involved || [] // Deep Interlock coordination tracking } }).catch(error => { logger.error('[ContextPressureMonitor] Failed to audit pressure analysis', {