From 29c82fd0fd5b34b88adcaf754d686ddf49c8ef6b Mon Sep 17 00:00:00 2001 From: htafolla Date: Fri, 15 May 2026 18:02:09 -0500 Subject: [PATCH] Codify Extract Method pattern --- .strray/state/state.json | 476 ++++++++++++++++++++++++++++++- src/inference/inference-cycle.ts | 11 + 2 files changed, 473 insertions(+), 14 deletions(-) diff --git a/.strray/state/state.json b/.strray/state/state.json index 840bc4d53..6a4933d8f 100644 --- a/.strray/state/state.json +++ b/.strray/state/state.json @@ -1,17 +1,465 @@ { - "votingHistory": [], - "metrics": { - "totalVotes": 0, - "successfulVotes": 0, - "failedVotes": 0, - "averageConfidence": 0, - "strategyUsage": { - "majority_vote": 0, - "consensus": 0, - "expert_priority": 0 - }, - "agentParticipation": {}, - "averageVoterTurnout": 0 + "coordination:main_coordinator": { + "strRayOrchestrator": { + "taskQueue": {}, + "activeTasks": {}, + "totalProcessed": 0, + "config": { + "maxConcurrentTasks": 3, + "taskTimeout": 10000, + "conflictResolutionStrategy": "majority_vote" + }, + "kernel": { + "config": { + "enabled": true, + "confidenceThreshold": 0.75, + "maxPatternsPerAnalysis": 10, + "enableLearning": true, + "autoPrevention": true + }, + "patterns": {}, + "assumptions": {}, + "cascades": {} + } + }, + "enhancedOrchestrator": { + "state": { + "activeAgents": {}, + "pendingSpawns": [], + "completedAgents": {}, + "failedAgents": {}, + "agentDependencies": {}, + "monitoringEnabled": true, + "cleanupInterval": 30000, + "isMainOrchestrator": true + }, + "stateManager": { + "store": {}, + "persistencePath": "/Users/blaze/dev/stringray/.strray/state/state.json", + "persistenceEnabled": true, + "writeQueue": {}, + "initialized": true, + "earlyOperationsQueue": [] + }, + "complexityAnalyzer": { + "thresholds": { + "simple": 15, + "moderate": 25, + "complex": 50, + "enterprise": 75 + }, + "operationWeights": { + "create": 1, + "modify": 1.2, + "refactor": 1.8, + "analyze": 1.5, + "debug": 2, + "test": 1.3 + }, + "riskMultipliers": { + "low": 0.8, + "medium": 1, + "high": 1.3, + "critical": 1.6 + }, + "calibrationHistory": [] + }, + "agentDelegator": { + "complexityAnalyzer": { + "thresholds": { + "simple": 15, + "moderate": 25, + "complex": 50, + "enterprise": 75 + }, + "operationWeights": { + "create": 1, + "modify": 1.2, + "refactor": 1.8, + "analyze": 1.5, + "debug": 2, + "test": 1.3 + }, + "riskMultipliers": { + "low": 0.8, + "medium": 1, + "high": 1.3, + "critical": 1.6 + }, + "calibrationHistory": [] + }, + "stateManager": { + "store": {}, + "persistencePath": "/Users/blaze/dev/stringray/.strray/state/state.json", + "persistenceEnabled": true, + "writeQueue": {}, + "initialized": true, + "earlyOperationsQueue": [] + }, + "configLoader": { + "configPath": "/Users/blaze/dev/stringray/.strray/config.json", + "cachedConfig": null, + "cacheExpiry": 30000, + "lastLoadTime": 0 + }, + "kernel": { + "config": { + "enabled": true, + "confidenceThreshold": 0.75, + "maxPatternsPerAnalysis": 10, + "enableLearning": true, + "autoPrevention": true + }, + "patterns": {}, + "assumptions": {}, + "cascades": {} + }, + "agentMetrics": { + "stateManager": { + "store": {}, + "persistencePath": "/Users/blaze/dev/stringray/.strray/state/state.json", + "persistenceEnabled": true, + "writeQueue": {}, + "initialized": true, + "earlyOperationsQueue": [] + }, + "retentionConfig": { + "maxEntries": 10000, + "maxAgeMs": 2592000000, + "enableAutoCleanup": true, + "cleanupIntervalMs": 3600000 + }, + "initialized": false + } + }, + "executionContext": { + "isExecutingAsSubagent": false, + "currentAgentId": null, + "spawnStack": [] + }, + "cleanupTimer": null + }, + "agentDelegator": { + "complexityAnalyzer": { + "thresholds": { + "simple": 15, + "moderate": 25, + "complex": 50, + "enterprise": 75 + }, + "operationWeights": { + "create": 1, + "modify": 1.2, + "refactor": 1.8, + "analyze": 1.5, + "debug": 2, + "test": 1.3 + }, + "riskMultipliers": { + "low": 0.8, + "medium": 1, + "high": 1.3, + "critical": 1.6 + }, + "calibrationHistory": [] + }, + "stateManager": { + "store": {}, + "persistencePath": "/Users/blaze/dev/stringray/.strray/state/state.json", + "persistenceEnabled": true, + "writeQueue": {}, + "initialized": true, + "earlyOperationsQueue": [] + }, + "configLoader": { + "configPath": "/Users/blaze/dev/stringray/.strray/config.json", + "cachedConfig": null, + "cacheExpiry": 30000, + "lastLoadTime": 0 + }, + "kernel": { + "config": { + "enabled": true, + "confidenceThreshold": 0.75, + "maxPatternsPerAnalysis": 10, + "enableLearning": true, + "autoPrevention": true + }, + "patterns": {}, + "assumptions": {}, + "cascades": {} + }, + "agentMetrics": { + "stateManager": { + "store": {}, + "persistencePath": "/Users/blaze/dev/stringray/.strray/state/state.json", + "persistenceEnabled": true, + "writeQueue": {}, + "initialized": true, + "earlyOperationsQueue": [] + }, + "retentionConfig": { + "maxEntries": 10000, + "maxAgeMs": 2592000000, + "enableAutoCleanup": true, + "cleanupIntervalMs": 3600000 + }, + "initialized": false + } + }, + "stateManager": { + "store": {}, + "persistencePath": "/Users/blaze/dev/stringray/.strray/state/state.json", + "persistenceEnabled": true, + "writeQueue": {}, + "initialized": true, + "earlyOperationsQueue": [] + }, + "complexityAnalyzer": { + "thresholds": { + "simple": 15, + "moderate": 25, + "complex": 50, + "enterprise": 75 + }, + "operationWeights": { + "create": 1, + "modify": 1.2, + "refactor": 1.8, + "analyze": 1.5, + "debug": 2, + "test": 1.3 + }, + "riskMultipliers": { + "low": 0.8, + "medium": 1, + "high": 1.3, + "critical": 1.6 + }, + "calibrationHistory": [] + }, + "coordinationMetrics": { + "totalWorkflows": 0, + "successfulWorkflows": 0, + "failedWorkflows": 0, + "averageDuration": 0, + "agentUtilization": {}, + "coordinationEfficiency": 0 + } + }, + "coordination:strray_orchestrator": { + "taskQueue": {}, + "activeTasks": {}, + "totalProcessed": 0, + "config": { + "maxConcurrentTasks": 3, + "taskTimeout": 10000, + "conflictResolutionStrategy": "majority_vote" + }, + "kernel": { + "config": { + "enabled": true, + "confidenceThreshold": 0.75, + "maxPatternsPerAnalysis": 10, + "enableLearning": true, + "autoPrevention": true + }, + "patterns": {}, + "assumptions": {}, + "cascades": {} + } + }, + "coordination:enhanced_orchestrator": { + "state": { + "activeAgents": {}, + "pendingSpawns": [], + "completedAgents": {}, + "failedAgents": {}, + "agentDependencies": {}, + "monitoringEnabled": true, + "cleanupInterval": 30000, + "isMainOrchestrator": true + }, + "stateManager": { + "store": {}, + "persistencePath": "/Users/blaze/dev/stringray/.strray/state/state.json", + "persistenceEnabled": true, + "writeQueue": {}, + "initialized": true, + "earlyOperationsQueue": [] + }, + "complexityAnalyzer": { + "thresholds": { + "simple": 15, + "moderate": 25, + "complex": 50, + "enterprise": 75 + }, + "operationWeights": { + "create": 1, + "modify": 1.2, + "refactor": 1.8, + "analyze": 1.5, + "debug": 2, + "test": 1.3 + }, + "riskMultipliers": { + "low": 0.8, + "medium": 1, + "high": 1.3, + "critical": 1.6 + }, + "calibrationHistory": [] + }, + "agentDelegator": { + "complexityAnalyzer": { + "thresholds": { + "simple": 15, + "moderate": 25, + "complex": 50, + "enterprise": 75 + }, + "operationWeights": { + "create": 1, + "modify": 1.2, + "refactor": 1.8, + "analyze": 1.5, + "debug": 2, + "test": 1.3 + }, + "riskMultipliers": { + "low": 0.8, + "medium": 1, + "high": 1.3, + "critical": 1.6 + }, + "calibrationHistory": [] + }, + "stateManager": { + "store": {}, + "persistencePath": "/Users/blaze/dev/stringray/.strray/state/state.json", + "persistenceEnabled": true, + "writeQueue": {}, + "initialized": true, + "earlyOperationsQueue": [] + }, + "configLoader": { + "configPath": "/Users/blaze/dev/stringray/.strray/config.json", + "cachedConfig": null, + "cacheExpiry": 30000, + "lastLoadTime": 0 + }, + "kernel": { + "config": { + "enabled": true, + "confidenceThreshold": 0.75, + "maxPatternsPerAnalysis": 10, + "enableLearning": true, + "autoPrevention": true + }, + "patterns": {}, + "assumptions": {}, + "cascades": {} + }, + "agentMetrics": { + "stateManager": { + "store": {}, + "persistencePath": "/Users/blaze/dev/stringray/.strray/state/state.json", + "persistenceEnabled": true, + "writeQueue": {}, + "initialized": true, + "earlyOperationsQueue": [] + }, + "retentionConfig": { + "maxEntries": 10000, + "maxAgeMs": 2592000000, + "enableAutoCleanup": true, + "cleanupIntervalMs": 3600000 + }, + "initialized": false + } + }, + "executionContext": { + "isExecutingAsSubagent": false, + "currentAgentId": null, + "spawnStack": [] + }, + "cleanupTimer": null + }, + "coordination:agent_delegator": { + "complexityAnalyzer": { + "thresholds": { + "simple": 15, + "moderate": 25, + "complex": 50, + "enterprise": 75 + }, + "operationWeights": { + "create": 1, + "modify": 1.2, + "refactor": 1.8, + "analyze": 1.5, + "debug": 2, + "test": 1.3 + }, + "riskMultipliers": { + "low": 0.8, + "medium": 1, + "high": 1.3, + "critical": 1.6 + }, + "calibrationHistory": [] + }, + "stateManager": { + "store": {}, + "persistencePath": "/Users/blaze/dev/stringray/.strray/state/state.json", + "persistenceEnabled": true, + "writeQueue": {}, + "initialized": true, + "earlyOperationsQueue": [] + }, + "configLoader": { + "configPath": "/Users/blaze/dev/stringray/.strray/config.json", + "cachedConfig": null, + "cacheExpiry": 30000, + "lastLoadTime": 0 + }, + "kernel": { + "config": { + "enabled": true, + "confidenceThreshold": 0.75, + "maxPatternsPerAnalysis": 10, + "enableLearning": true, + "autoPrevention": true + }, + "patterns": {}, + "assumptions": {}, + "cascades": {} + }, + "agentMetrics": { + "stateManager": { + "store": {}, + "persistencePath": "/Users/blaze/dev/stringray/.strray/state/state.json", + "persistenceEnabled": true, + "writeQueue": {}, + "initialized": true, + "earlyOperationsQueue": [] + }, + "retentionConfig": { + "maxEntries": 10000, + "maxAgeMs": 2592000000, + "enableAutoCleanup": true, + "cleanupIntervalMs": 3600000 + }, + "initialized": false + } }, - "exportedAt": "2026-05-15T14:18:59.026Z" + "coordination:metrics": { + "totalWorkflows": 0, + "successfulWorkflows": 0, + "failedWorkflows": 0, + "averageDuration": 0, + "agentUtilization": {}, + "coordinationEfficiency": 0 + } } \ No newline at end of file diff --git a/src/inference/inference-cycle.ts b/src/inference/inference-cycle.ts index 9887d52c0..bfe09c144 100644 --- a/src/inference/inference-cycle.ts +++ b/src/inference/inference-cycle.ts @@ -805,10 +805,13 @@ Respond with EXACTLY one of: }; for (const proposal of proposals) { + console.error(`[LIVE] Starting real governance for proposal: ${proposal.title}`); const agents = GOVERNANCE_AGENTS[proposal.type] ?? ["code-review", "security-audit"]; const skillVotes: any[] = []; for (const agent of agents) { + const callStart = Date.now(); + console.error(`[LIVE] → Calling real MCP server "${agent}" with analyze_proposal...`); try { const skillResult = await mcpClientManager.callServerTool(agent, "analyze_proposal", { proposalTitle: proposal.title, @@ -817,6 +820,7 @@ Respond with EXACTLY one of: proposalType: proposal.type, }); + const callDur = Date.now() - callStart; let structured = ""; const contents = (skillResult as any)?.content || []; for (const c of contents) { @@ -831,6 +835,11 @@ Respond with EXACTLY one of: if (m) structured = m[0].trim(); } + console.error(`[LIVE] ← ${agent} responded in ${callDur}ms — structured DECISION found: ${!!structured}`); + if (structured) { + console.error(`[LIVE] ${structured.split('\n')[0]}`); + } + skillVotes.push({ agent, toolUsed: "analyze_proposal", @@ -838,6 +847,8 @@ Respond with EXACTLY one of: structuredVote: structured || null, }); } catch (err) { + const callDur = Date.now() - callStart; + console.error(`[LIVE] ← ERROR from ${agent} after ${callDur}ms: ${err}`); skillVotes.push({ agent, toolUsed: "analyze_proposal",