fix: populate services_involved BEFORE service calls, not after
- Services log immediately when called, so array must be populated first - Move all servicesInvolved.push() statements BEFORE service calls - Ensures audit logs capture coordination data correctly
This commit is contained in:
parent
625b9ae816
commit
4688285044
1 changed files with 11 additions and 6 deletions
|
|
@ -298,8 +298,8 @@ async function handleFileModification(toolInput, sessionId) {
|
|||
services_involved: servicesInvolved // Pass array reference for coordination tracking
|
||||
};
|
||||
|
||||
servicesInvolved.push('BoundaryEnforcer'); // Track service involvement BEFORE calling
|
||||
const boundaryResult = BoundaryEnforcer.enforce(action, context);
|
||||
servicesInvolved.push('BoundaryEnforcer'); // Track service involvement
|
||||
|
||||
// PHASE 3: Collect guidance from BoundaryEnforcer
|
||||
if (boundaryResult.guidance && boundaryResult.guidance.systemMessage) {
|
||||
|
|
@ -417,6 +417,8 @@ async function handleFileModification(toolInput, sessionId) {
|
|||
const isGovernanceFile = governanceFiles.some(f => filePath.includes(f));
|
||||
|
||||
if (isGovernanceFile) {
|
||||
servicesInvolved.push('CrossReferenceValidator'); // Track BEFORE calling
|
||||
|
||||
const validateAction = {
|
||||
type: 'modify_governance_file',
|
||||
description: `Modifying ${path.basename(filePath)}`,
|
||||
|
|
@ -424,7 +426,6 @@ 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
|
||||
|
|
@ -442,6 +443,8 @@ async function handleFileModification(toolInput, sessionId) {
|
|||
? `${securityGradient} level change to ${filePath}. Documentation/comment update - automated approval.`
|
||||
: `${securityGradient} level security modification detected in ${filePath}. Requires elevated scrutiny.`;
|
||||
|
||||
servicesInvolved.push('MetacognitiveVerifier'); // Track BEFORE calling
|
||||
|
||||
const verificationResult = MetacognitiveVerifier.verify(verifyAction, reasoning, {
|
||||
...context,
|
||||
security_impact: securityGradient === 'CRITICAL' || securityGradient === 'HIGH',
|
||||
|
|
@ -449,7 +452,6 @@ 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) {
|
||||
|
|
@ -458,6 +460,8 @@ async function handleFileModification(toolInput, sessionId) {
|
|||
}
|
||||
|
||||
// 5. Context pressure monitoring (on every tool use)
|
||||
servicesInvolved.push('ContextPressureMonitor'); // Track BEFORE calling
|
||||
|
||||
const ContextPressureMonitor = require('../../src/services/ContextPressureMonitor.service');
|
||||
ContextPressureMonitor.analyzePressure({
|
||||
sessionId,
|
||||
|
|
@ -466,13 +470,14 @@ async function handleFileModification(toolInput, sessionId) {
|
|||
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'];
|
||||
const isInstructionFile = instructionFiles.some(f => filePath.includes(f));
|
||||
|
||||
if (isInstructionFile) {
|
||||
servicesInvolved.push('InstructionPersistenceClassifier'); // Track BEFORE calling
|
||||
|
||||
const InstructionPersistenceClassifier = require('../../src/services/InstructionPersistenceClassifier.service');
|
||||
|
||||
InstructionPersistenceClassifier.classify({
|
||||
|
|
@ -485,7 +490,6 @@ 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 +497,8 @@ async function handleFileModification(toolInput, sessionId) {
|
|||
const hasValueConflict = valueConflictFiles.some(keyword => filePath.toLowerCase().includes(keyword));
|
||||
|
||||
if (hasValueConflict) {
|
||||
servicesInvolved.push('PluralisticDeliberationOrchestrator'); // Track BEFORE calling
|
||||
|
||||
const PluralisticDeliberationOrchestrator = require('../../src/services/PluralisticDeliberationOrchestrator.service');
|
||||
|
||||
const deliberationResult = PluralisticDeliberationOrchestrator.analyzeConflict({
|
||||
|
|
@ -503,7 +509,6 @@ 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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue