0xray 2.1.3 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.opencode/codex.codex +1 -1
- package/.opencode/commands/dependency-audit.md +3 -3
- package/.opencode/enforcer-config.json +2 -2
- package/README.md +3 -3
- package/dist/CHANGELOG.md +43 -0
- package/dist/README.md +3 -3
- package/dist/analytics/routing-refiner.js +1 -1
- package/dist/cli/commands/govern.d.ts +29 -0
- package/dist/cli/commands/govern.js +152 -0
- package/dist/cli/index.js +29 -216
- package/dist/core/boot-orchestrator.js +1 -1
- package/dist/core/features-config.js +1 -1
- package/dist/core/framework-logger.js +30 -1
- package/dist/delegation/index.d.ts +1 -2
- package/dist/delegation/index.js +1 -2
- package/dist/enforcement/enforcer-tools.js +1 -1
- package/dist/execution/proposal-applier.d.ts +1 -9
- package/dist/execution/proposal-applier.js +18 -173
- package/dist/governance/codex-policy.service.d.ts +7 -25
- package/dist/governance/codex-policy.service.js +8 -26
- package/dist/governance/governance-core.d.ts +22 -28
- package/dist/governance/governance-core.js +31 -101
- package/dist/governance/governance-service.d.ts +1 -0
- package/dist/governance/governance-service.js +67 -4
- package/dist/governance/governance-types.d.ts +5 -2
- package/dist/inference/index.d.ts +3 -4
- package/dist/inference/inference-accumulator.js +1 -1
- package/dist/inference/inference-cycle.d.ts +12 -18
- package/dist/inference/inference-cycle.js +120 -335
- package/dist/integrations/base/index.d.ts +0 -1
- package/dist/integrations/base/index.js +0 -2
- package/dist/integrations/grok/hooks/pre-tool-use.js +4 -18
- package/dist/integrations/hermes-agent/bridge.mjs +10 -1
- package/dist/mcps/config/server-config-registry.js +1 -1
- package/dist/mcps/governance.server.js +4 -5
- package/dist/mcps/knowledge-skills/api-design.server.js +10 -0
- package/dist/mcps/knowledge-skills/architecture-patterns.server.js +10 -0
- package/dist/mcps/knowledge-skills/bug-triage-specialist.server.js +10 -0
- package/dist/mcps/knowledge-skills/code-analyzer.server.js +10 -0
- package/dist/mcps/knowledge-skills/code-review.server.js +10 -0
- package/dist/mcps/knowledge-skills/content-creator.server.js +10 -0
- package/dist/mcps/knowledge-skills/database-design.server.js +10 -0
- package/dist/mcps/knowledge-skills/devops-deployment.server.js +10 -0
- package/dist/mcps/knowledge-skills/git-workflow.server.js +10 -0
- package/dist/mcps/knowledge-skills/growth-strategist.server.js +10 -0
- package/dist/mcps/knowledge-skills/log-monitor.server.js +10 -0
- package/dist/mcps/knowledge-skills/mobile-development.server.js +10 -0
- package/dist/mcps/knowledge-skills/multimodal-looker.server.js +10 -0
- package/dist/mcps/knowledge-skills/performance-optimization.server.js +10 -0
- package/dist/mcps/knowledge-skills/project-analysis.server.js +10 -0
- package/dist/mcps/knowledge-skills/refactoring-strategies.server.js +10 -0
- package/dist/mcps/knowledge-skills/security-audit.server.js +10 -0
- package/dist/mcps/knowledge-skills/seo-consultant.server.js +10 -0
- package/dist/mcps/knowledge-skills/skill-invocation.server.d.ts +4 -0
- package/dist/mcps/knowledge-skills/skill-invocation.server.js +33 -14
- package/dist/mcps/knowledge-skills/strategist.server.js +10 -0
- package/dist/mcps/knowledge-skills/tech-writer.server.js +11 -1
- package/dist/mcps/knowledge-skills/testing-strategy.server.js +10 -0
- package/dist/mcps/knowledge-skills/ui-ux-design.server.js +10 -0
- package/dist/mcps/registry.json +1 -1
- package/dist/metrics/agent-metrics.d.ts +2 -1
- package/dist/nucleus/govern-http.d.ts +59 -0
- package/dist/nucleus/govern-http.js +172 -0
- package/dist/nucleus/index.d.ts +14 -0
- package/dist/nucleus/index.js +9 -0
- package/dist/nucleus/kernel.d.ts +51 -0
- package/dist/nucleus/kernel.js +62 -0
- package/dist/nucleus/plugin-registry.d.ts +104 -0
- package/dist/nucleus/plugin-registry.js +147 -0
- package/dist/orchestrator/orchestrator.d.ts +0 -1
- package/dist/orchestrator/orchestrator.js +0 -21
- package/dist/postprocessor/PostProcessor.d.ts +13 -1
- package/dist/postprocessor/PostProcessor.js +41 -1
- package/dist/postprocessor/autofix/AutoFixEngine.d.ts +0 -8
- package/dist/postprocessor/autofix/AutoFixEngine.js +0 -54
- package/dist/postprocessor/metamorphosis/MetamorphosisEngine.d.ts +25 -0
- package/dist/postprocessor/metamorphosis/MetamorphosisEngine.js +10 -0
- package/dist/postprocessor/metamorphosis/SelfProposalEngine.d.ts +68 -0
- package/dist/postprocessor/metamorphosis/SelfProposalEngine.js +371 -0
- package/dist/skills/orchestrator/SKILL.md +1 -1
- package/dist/skills/registry.json +1 -1
- package/dist/state/index.d.ts +0 -2
- package/package.json +4 -3
- package/scripts/node/universal-version-manager.js +3 -3
- package/src/mcps/config/__tests__/server-config-registry.test.ts +6 -15
- package/src/mcps/config/server-config-registry.ts +1 -1
- package/src/mcps/governance.server.ts +4 -6
- package/src/mcps/knowledge-skills/api-design.server.ts +9 -0
- package/src/mcps/knowledge-skills/architecture-patterns.server.ts +9 -0
- package/src/mcps/knowledge-skills/bug-triage-specialist.server.ts +9 -0
- package/src/mcps/knowledge-skills/code-analyzer.server.ts +9 -0
- package/src/mcps/knowledge-skills/code-review.server.ts +9 -0
- package/src/mcps/knowledge-skills/content-creator.server.ts +9 -0
- package/src/mcps/knowledge-skills/database-design.server.ts +9 -0
- package/src/mcps/knowledge-skills/devops-deployment.server.ts +9 -0
- package/src/mcps/knowledge-skills/git-workflow.server.ts +9 -0
- package/src/mcps/knowledge-skills/growth-strategist.server.ts +9 -0
- package/src/mcps/knowledge-skills/log-monitor.server.ts +9 -0
- package/src/mcps/knowledge-skills/mobile-development.server.ts +9 -0
- package/src/mcps/knowledge-skills/multimodal-looker.server.ts +9 -0
- package/src/mcps/knowledge-skills/performance-optimization.server.ts +9 -0
- package/src/mcps/knowledge-skills/project-analysis.server.ts +9 -0
- package/src/mcps/knowledge-skills/refactoring-strategies.server.ts +9 -0
- package/src/mcps/knowledge-skills/security-audit.server.ts +9 -0
- package/src/mcps/knowledge-skills/seo-consultant.server.ts +9 -0
- package/src/mcps/knowledge-skills/session-management.server.ts +1 -0
- package/src/mcps/knowledge-skills/skill-invocation.server.ts +44 -29
- package/src/mcps/knowledge-skills/strategist.server.ts +9 -0
- package/src/mcps/knowledge-skills/tech-writer.server.ts +10 -1
- package/src/mcps/knowledge-skills/testing-strategy.server.ts +9 -0
- package/src/mcps/knowledge-skills/ui-ux-design.server.ts +9 -0
- package/src/mcps/registry.json +1 -1
- package/src/opencode/codex.codex +1 -1
- package/src/opencode/commands/dependency-audit.md +3 -3
- package/src/opencode/enforcer-config.json +2 -2
- package/src/skills/orchestrator/SKILL.md +1 -1
- package/src/skills/registry.json +1 -1
- package/xray/codex.json +1 -1
- package/xray/config.json +1 -1
- package/xray/features.json +1 -1
- package/xray/integrations.json +3 -3
- package/.opencode/agents/testing-best-practices.yml +0 -12
- package/dist/analytics/consent-manager.d.ts +0 -93
- package/dist/analytics/consent-manager.js +0 -258
- package/dist/analytics/simple-pattern-analyzer.d.ts +0 -80
- package/dist/analytics/simple-pattern-analyzer.js +0 -297
- package/dist/cli/commands/analytics-disable.d.ts +0 -9
- package/dist/cli/commands/analytics-disable.js +0 -72
- package/dist/cli/commands/analytics-enable-action.d.ts +0 -8
- package/dist/cli/commands/analytics-enable-action.js +0 -82
- package/dist/cli/commands/analytics-preview.d.ts +0 -9
- package/dist/cli/commands/analytics-preview.js +0 -106
- package/dist/cli/commands/analytics-status.d.ts +0 -9
- package/dist/cli/commands/analytics-status.js +0 -68
- package/dist/cli/server.d.ts +0 -1
- package/dist/cli/server.js +0 -147
- package/dist/core/errors.d.ts +0 -3
- package/dist/core/errors.js +0 -10
- package/dist/core/logging-config.d.ts +0 -11
- package/dist/core/logging-config.js +0 -43
- package/dist/core/trace-context.d.ts +0 -12
- package/dist/core/trace-context.js +0 -33
- package/dist/delegation/voting-coordinator.d.ts +0 -49
- package/dist/delegation/voting-coordinator.js +0 -375
- package/dist/enforcement/test-auto-healing.d.ts +0 -83
- package/dist/enforcement/test-auto-healing.js +0 -325
- package/dist/integrations/base/ExampleIntegration.d.ts +0 -47
- package/dist/integrations/base/ExampleIntegration.js +0 -181
- package/dist/mcps/knowledge-skills/testing-best-practices.server.d.ts +0 -34
- package/dist/mcps/knowledge-skills/testing-best-practices.server.js +0 -831
- package/dist/mcps/orchestrator.server.d.ts +0 -10
- package/dist/mcps/orchestrator.server.js +0 -19
- package/dist/orchestrator/self-direction-activation.d.ts +0 -109
- package/dist/orchestrator/self-direction-activation.js +0 -245
- package/dist/orchestrator/universal-librarian-consultation.d.ts +0 -98
- package/dist/orchestrator/universal-librarian-consultation.js +0 -216
- package/dist/orchestrator/universal-registry-bridge.d.ts +0 -85
- package/dist/orchestrator/universal-registry-bridge.js +0 -247
- package/dist/performance/performance-budget-enforcer.d.ts +0 -158
- package/dist/performance/performance-budget-enforcer.js +0 -434
- package/dist/performance/performance-regression-tester.d.ts +0 -108
- package/dist/performance/performance-regression-tester.js +0 -342
- package/dist/skills/testing-best-practices/SKILL.md +0 -37
- package/dist/state/context-providers.d.ts +0 -4
- package/dist/state/context-providers.js +0 -1
- package/dist/state/state-types.d.ts +0 -5
- package/dist/state/state-types.js +0 -1
- package/dist/utils/batch-operations.d.ts +0 -25
- package/dist/utils/batch-operations.js +0 -292
- package/dist/utils/test-template-generator.d.ts +0 -25
- package/dist/utils/test-template-generator.js +0 -178
- package/dist/utils/token-manager.d.ts +0 -48
- package/dist/utils/token-manager.js +0 -163
- package/src/mcps/knowledge-skills/testing-best-practices.server.test.ts +0 -136
- package/src/mcps/knowledge-skills/testing-best-practices.server.ts +0 -1183
- package/src/mcps/orchestrator.server.ts +0 -34
- package/src/opencode/agents/testing-best-practices.yml +0 -12
- package/src/skills/testing-best-practices/SKILL.md +0 -37
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Voting Coordinator
|
|
3
|
-
*
|
|
4
|
-
* Multi-agent voting system with:
|
|
5
|
-
* - Weighted confidence scoring based on agent expertise
|
|
6
|
-
* - Adaptive strategy selection
|
|
7
|
-
* - Historical learning and pattern detection
|
|
8
|
-
* - Integration with session coordinator
|
|
9
|
-
*
|
|
10
|
-
* @version 1.0.0
|
|
11
|
-
* @since 2026-04-16
|
|
12
|
-
*/
|
|
13
|
-
import * as crypto from "crypto";
|
|
14
|
-
import { getAgentExpertiseLevel, getVotingWeight } from "./agent-expertise.js";
|
|
15
|
-
import { selectVotingStrategy, adaptiveStrategySelector } from "./strategy-selector.js";
|
|
16
|
-
import { WeightedVotingAggregator } from "./weighted-voting-aggregator.js";
|
|
17
|
-
import { frameworkLogger } from "../core/framework-logger.js";
|
|
18
|
-
const MAX_HISTORY_ENTRIES = 500;
|
|
19
|
-
const VOTE_TIMEOUT_MS = 30000;
|
|
20
|
-
const DEFAULT_CONFIG = {
|
|
21
|
-
enableHistoryTracking: true,
|
|
22
|
-
enableLearning: true,
|
|
23
|
-
minVotersForConsensus: 3,
|
|
24
|
-
consensusThreshold: 0.7,
|
|
25
|
-
};
|
|
26
|
-
export class VotingCoordinator {
|
|
27
|
-
stateManager;
|
|
28
|
-
sessionCoordinator;
|
|
29
|
-
activeVotingSessions = new Map();
|
|
30
|
-
votingHistory = [];
|
|
31
|
-
metrics;
|
|
32
|
-
config;
|
|
33
|
-
aggregator;
|
|
34
|
-
constructor(stateManager, sessionCoordinator, config = {}) {
|
|
35
|
-
this.stateManager = stateManager;
|
|
36
|
-
this.sessionCoordinator = sessionCoordinator ?? undefined;
|
|
37
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
38
|
-
this.aggregator = new WeightedVotingAggregator();
|
|
39
|
-
this.metrics = this.initializeMetrics();
|
|
40
|
-
this.loadHistory();
|
|
41
|
-
}
|
|
42
|
-
async initiateVoting(sessionId, topic, description, participants, context) {
|
|
43
|
-
const complexity = context?.complexity ?? 25;
|
|
44
|
-
const riskLevel = context?.riskLevel ?? "medium";
|
|
45
|
-
const hasSecurity = context?.hasSecurityConcerns ?? false;
|
|
46
|
-
const hasArch = context?.hasArchitecturalImpact ?? false;
|
|
47
|
-
const participantCount = context?.participantCount ?? participants.length;
|
|
48
|
-
const strategy = context
|
|
49
|
-
? adaptiveStrategySelector.selectStrategyWithDefaults(complexity, riskLevel, hasSecurity, hasArch, participantCount)
|
|
50
|
-
: selectVotingStrategy(complexity, riskLevel, hasSecurity, hasArch, participants.length);
|
|
51
|
-
const votingSession = {
|
|
52
|
-
id: `vote_${Date.now()}_${crypto.randomBytes(4).toString("hex")}`,
|
|
53
|
-
sessionId,
|
|
54
|
-
topic,
|
|
55
|
-
description,
|
|
56
|
-
strategy,
|
|
57
|
-
complexity,
|
|
58
|
-
riskLevel,
|
|
59
|
-
participants,
|
|
60
|
-
votes: [],
|
|
61
|
-
createdAt: Date.now(),
|
|
62
|
-
};
|
|
63
|
-
this.activeVotingSessions.set(votingSession.id, votingSession);
|
|
64
|
-
frameworkLogger.log("VotingCoordinator", "voting-initiated", "info", {
|
|
65
|
-
sessionId: votingSession.id,
|
|
66
|
-
topic,
|
|
67
|
-
strategy,
|
|
68
|
-
participantCount: participants.length,
|
|
69
|
-
});
|
|
70
|
-
if (this.sessionCoordinator) {
|
|
71
|
-
this.sessionCoordinator.shareContext(sessionId, `vote:${votingSession.id}`, { topic, strategy, participants: [] }, "voting-coordinator");
|
|
72
|
-
}
|
|
73
|
-
return votingSession.id;
|
|
74
|
-
}
|
|
75
|
-
submitVote(voteId, agentName, vote, confidence, reasoning) {
|
|
76
|
-
const session = this.activeVotingSessions.get(voteId);
|
|
77
|
-
if (!session) {
|
|
78
|
-
frameworkLogger.log("VotingCoordinator", "vote-submission-failed", "warning", {
|
|
79
|
-
voteId,
|
|
80
|
-
reason: "Session not found",
|
|
81
|
-
});
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
if (!session.participants.includes(agentName)) {
|
|
85
|
-
frameworkLogger.log("VotingCoordinator", "vote-submission-failed", "warning", {
|
|
86
|
-
voteId,
|
|
87
|
-
agentName,
|
|
88
|
-
reason: "Agent not authorized",
|
|
89
|
-
});
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
const existingVoteIndex = session.votes.findIndex((v) => v.agentName === agentName);
|
|
93
|
-
const voteChoice = {
|
|
94
|
-
agentName,
|
|
95
|
-
vote,
|
|
96
|
-
confidence: Math.max(0, Math.min(1, confidence)),
|
|
97
|
-
reasoning,
|
|
98
|
-
timestamp: Date.now(),
|
|
99
|
-
};
|
|
100
|
-
if (existingVoteIndex >= 0) {
|
|
101
|
-
session.votes[existingVoteIndex] = voteChoice;
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
session.votes.push(voteChoice);
|
|
105
|
-
}
|
|
106
|
-
this.metrics.totalVotes++;
|
|
107
|
-
if (this.sessionCoordinator) {
|
|
108
|
-
this.sessionCoordinator.shareContext(session.sessionId, `vote:${voteId}`, { topic: session.topic, strategy: session.strategy, votes: session.votes }, agentName);
|
|
109
|
-
}
|
|
110
|
-
frameworkLogger.log("VotingCoordinator", "vote-submitted", "info", {
|
|
111
|
-
voteId,
|
|
112
|
-
agentName,
|
|
113
|
-
vote,
|
|
114
|
-
confidence,
|
|
115
|
-
});
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
resolveVoting(voteId) {
|
|
119
|
-
const session = this.activeVotingSessions.get(voteId);
|
|
120
|
-
if (!session) {
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
if (session.votes.length === 0) {
|
|
124
|
-
frameworkLogger.log("VotingCoordinator", "resolve-failed", "error", {
|
|
125
|
-
voteId,
|
|
126
|
-
reason: "No votes cast",
|
|
127
|
-
});
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
let result;
|
|
131
|
-
switch (session.strategy) {
|
|
132
|
-
case "majority_vote":
|
|
133
|
-
result = this.resolveMajorityVote(session);
|
|
134
|
-
break;
|
|
135
|
-
case "consensus":
|
|
136
|
-
result = this.resolveConsensus(session);
|
|
137
|
-
break;
|
|
138
|
-
case "expert_priority":
|
|
139
|
-
result = this.resolveExpertPriority(session);
|
|
140
|
-
break;
|
|
141
|
-
default:
|
|
142
|
-
result = this.resolveMajorityVote(session);
|
|
143
|
-
}
|
|
144
|
-
session.result = result;
|
|
145
|
-
session.resolvedAt = Date.now();
|
|
146
|
-
this.recordVotingHistory(session, result);
|
|
147
|
-
this.metrics.successfulVotes++;
|
|
148
|
-
this.updateMetricsAfterVote(result);
|
|
149
|
-
this.activeVotingSessions.delete(voteId);
|
|
150
|
-
if (this.sessionCoordinator) {
|
|
151
|
-
this.sessionCoordinator.recordConflict(session.sessionId, session.participants, session.strategy, result.decision);
|
|
152
|
-
}
|
|
153
|
-
frameworkLogger.log("VotingCoordinator", "voting-resolved", "info", {
|
|
154
|
-
voteId,
|
|
155
|
-
strategy: session.strategy,
|
|
156
|
-
decision: result.decision,
|
|
157
|
-
confidence: result.confidence,
|
|
158
|
-
});
|
|
159
|
-
return result;
|
|
160
|
-
}
|
|
161
|
-
resolveConflict(request) {
|
|
162
|
-
const { sessionId, topic, description, agents, requiresSecurityVote, requiresArchitectureVote, complexity, riskLevel } = request;
|
|
163
|
-
const context = {
|
|
164
|
-
complexity,
|
|
165
|
-
riskLevel,
|
|
166
|
-
participantCount: agents.length,
|
|
167
|
-
hasSecurityConcerns: requiresSecurityVote,
|
|
168
|
-
hasArchitecturalImpact: requiresArchitectureVote,
|
|
169
|
-
};
|
|
170
|
-
const strategy = adaptiveStrategySelector.selectStrategy(context);
|
|
171
|
-
const votingId = this.initiateVoting(sessionId, topic, description, agents, context);
|
|
172
|
-
const response = {
|
|
173
|
-
resolved: true,
|
|
174
|
-
strategy,
|
|
175
|
-
confidence: 0,
|
|
176
|
-
details: `Conflict resolution initiated with strategy: ${strategy}`,
|
|
177
|
-
participatingAgents: agents,
|
|
178
|
-
};
|
|
179
|
-
return response;
|
|
180
|
-
}
|
|
181
|
-
getAggregator() {
|
|
182
|
-
return this.aggregator;
|
|
183
|
-
}
|
|
184
|
-
getVotingSession(voteId) {
|
|
185
|
-
return this.activeVotingSessions.get(voteId);
|
|
186
|
-
}
|
|
187
|
-
getActiveVotingSessions() {
|
|
188
|
-
return Array.from(this.activeVotingSessions.values());
|
|
189
|
-
}
|
|
190
|
-
getVotingHistory(sessionId, limit) {
|
|
191
|
-
let history = this.votingHistory;
|
|
192
|
-
if (sessionId) {
|
|
193
|
-
history = history.filter((entry) => entry.sessionId === sessionId);
|
|
194
|
-
}
|
|
195
|
-
if (limit) {
|
|
196
|
-
history = history.slice(-limit);
|
|
197
|
-
}
|
|
198
|
-
return history;
|
|
199
|
-
}
|
|
200
|
-
getMetrics() {
|
|
201
|
-
return { ...this.metrics };
|
|
202
|
-
}
|
|
203
|
-
resolveMajorityVote(session) {
|
|
204
|
-
const aggregated = this.aggregator.aggregateVotes(session.votes);
|
|
205
|
-
if (aggregated.length === 0) {
|
|
206
|
-
return {
|
|
207
|
-
decision: "",
|
|
208
|
-
confidence: 0,
|
|
209
|
-
strategy: "majority_vote",
|
|
210
|
-
voteCount: 0,
|
|
211
|
-
winningVotes: 0,
|
|
212
|
-
totalVoters: session.participants.length,
|
|
213
|
-
tied: false,
|
|
214
|
-
details: [],
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
const winner = aggregated[0];
|
|
218
|
-
const second = aggregated[1];
|
|
219
|
-
const tied = Boolean(second && Math.abs(winner.totalWeight - second.totalWeight) < 0.01);
|
|
220
|
-
const totalWeight = aggregated.reduce((sum, agg) => sum + agg.totalWeight, 0);
|
|
221
|
-
const confidence = totalWeight > 0 ? winner.totalWeight / totalWeight : 0;
|
|
222
|
-
const details = session.votes.map((vote) => ({
|
|
223
|
-
agentName: vote.agentName,
|
|
224
|
-
expertiseLevel: getAgentExpertiseLevel(vote.agentName),
|
|
225
|
-
vote: vote.vote,
|
|
226
|
-
weight: this.aggregator.calculateTotalVoteWeight(vote.agentName, vote.confidence),
|
|
227
|
-
contributed: vote.vote === winner.option,
|
|
228
|
-
}));
|
|
229
|
-
return {
|
|
230
|
-
decision: winner.option,
|
|
231
|
-
confidence,
|
|
232
|
-
strategy: "majority_vote",
|
|
233
|
-
voteCount: session.votes.length,
|
|
234
|
-
winningVotes: winner.contributingAgents.length,
|
|
235
|
-
totalVoters: session.participants.length,
|
|
236
|
-
tied,
|
|
237
|
-
details,
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
resolveConsensus(session) {
|
|
241
|
-
const aggregated = this.aggregator.aggregateVotes(session.votes);
|
|
242
|
-
if (aggregated.length === 0) {
|
|
243
|
-
return {
|
|
244
|
-
decision: "", confidence: 0, strategy: "consensus",
|
|
245
|
-
voteCount: 0, winningVotes: 0, totalVoters: session.participants.length,
|
|
246
|
-
tied: false, details: [],
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
const winner = aggregated[0];
|
|
250
|
-
const requiredVotes = Math.ceil(session.participants.length * this.config.consensusThreshold);
|
|
251
|
-
const hasConsensus = winner.contributingAgents.length >= requiredVotes;
|
|
252
|
-
if (hasConsensus) {
|
|
253
|
-
const winnerVotes = session.votes.filter((v) => v.vote === winner.option);
|
|
254
|
-
const avgConfidence = winnerVotes.reduce((s, v) => s + v.confidence, 0) / winnerVotes.length;
|
|
255
|
-
const expertiseSum = winnerVotes.reduce((s, v) => s + this.aggregator.calculateTotalVoteWeight(v.agentName, v.confidence), 0);
|
|
256
|
-
const totalWeight = winnerVotes.reduce((s, v) => s + getVotingWeight(v.agentName), 0);
|
|
257
|
-
const confidence = totalWeight > 0 ? avgConfidence * (expertiseSum / (totalWeight * 10)) : avgConfidence;
|
|
258
|
-
return {
|
|
259
|
-
decision: winner.option, confidence, strategy: "consensus",
|
|
260
|
-
voteCount: session.votes.length, winningVotes: winnerVotes.length,
|
|
261
|
-
totalVoters: session.participants.length, tied: false,
|
|
262
|
-
details: winnerVotes.map((v) => ({
|
|
263
|
-
agentName: v.agentName, expertiseLevel: getAgentExpertiseLevel(v.agentName),
|
|
264
|
-
vote: v.vote, weight: this.aggregator.calculateTotalVoteWeight(v.agentName, v.confidence),
|
|
265
|
-
contributed: true,
|
|
266
|
-
})),
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
const second = aggregated[1];
|
|
270
|
-
const tied = Boolean(second && Math.abs(winner.totalWeight - second.totalWeight) < 0.01);
|
|
271
|
-
const winnerVotes = session.votes.filter((v) => v.vote === winner.option);
|
|
272
|
-
const avgConfidence = winnerVotes.length > 0 ? winnerVotes.reduce((s, v) => s + v.confidence, 0) / winnerVotes.length : 0;
|
|
273
|
-
return {
|
|
274
|
-
decision: winner.option, confidence: avgConfidence * 0.5, strategy: "consensus",
|
|
275
|
-
voteCount: session.votes.length, winningVotes: winnerVotes.length,
|
|
276
|
-
totalVoters: session.participants.length, tied,
|
|
277
|
-
details: winnerVotes.map((v) => ({
|
|
278
|
-
agentName: v.agentName, expertiseLevel: getAgentExpertiseLevel(v.agentName),
|
|
279
|
-
vote: v.vote, weight: this.aggregator.calculateTotalVoteWeight(v.agentName, v.confidence),
|
|
280
|
-
contributed: true,
|
|
281
|
-
})),
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
resolveExpertPriority(session) {
|
|
285
|
-
const experts = new Map();
|
|
286
|
-
for (const vote of session.votes) {
|
|
287
|
-
const expertise = getAgentExpertiseLevel(vote.agentName);
|
|
288
|
-
const existing = experts.get(vote.agentName);
|
|
289
|
-
if (!existing || expertise > existing.expertise) {
|
|
290
|
-
experts.set(vote.agentName, { expertise, vote });
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
const sortedByExpertise = Array.from(experts.values()).sort((a, b) => b.expertise - a.expertise);
|
|
294
|
-
const topExpert = sortedByExpertise[0];
|
|
295
|
-
const secondExpert = sortedByExpertise[1];
|
|
296
|
-
const tied = Boolean(secondExpert && topExpert && topExpert.expertise === secondExpert.expertise);
|
|
297
|
-
const details = session.votes.map((v) => ({
|
|
298
|
-
agentName: v.agentName,
|
|
299
|
-
expertiseLevel: getAgentExpertiseLevel(v.agentName),
|
|
300
|
-
vote: v.vote,
|
|
301
|
-
weight: getVotingWeight(v.agentName),
|
|
302
|
-
contributed: v.agentName === topExpert?.vote?.agentName,
|
|
303
|
-
}));
|
|
304
|
-
return {
|
|
305
|
-
decision: topExpert?.vote?.vote ?? "",
|
|
306
|
-
confidence: ((topExpert?.vote?.confidence ?? 0) * (topExpert?.expertise ?? 5)) / 10,
|
|
307
|
-
strategy: "expert_priority",
|
|
308
|
-
voteCount: session.votes.length,
|
|
309
|
-
winningVotes: topExpert ? 1 : 0,
|
|
310
|
-
totalVoters: session.participants.length,
|
|
311
|
-
tied,
|
|
312
|
-
details,
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
recordVotingHistory(session, result) {
|
|
316
|
-
if (!this.config.enableHistoryTracking)
|
|
317
|
-
return;
|
|
318
|
-
const entry = {
|
|
319
|
-
id: session.id,
|
|
320
|
-
sessionId: session.sessionId,
|
|
321
|
-
topic: session.topic,
|
|
322
|
-
voteCount: session.votes.length,
|
|
323
|
-
strategy: session.strategy,
|
|
324
|
-
decision: result.decision,
|
|
325
|
-
confidence: result.confidence,
|
|
326
|
-
participantCount: session.participants.length,
|
|
327
|
-
timestamp: session.createdAt,
|
|
328
|
-
resolvedAt: session.resolvedAt ?? Date.now(),
|
|
329
|
-
};
|
|
330
|
-
this.votingHistory.push(entry);
|
|
331
|
-
if (this.votingHistory.length > MAX_HISTORY_ENTRIES) {
|
|
332
|
-
this.votingHistory = this.votingHistory.slice(-MAX_HISTORY_ENTRIES);
|
|
333
|
-
}
|
|
334
|
-
this.stateManager.set("voting:history", this.votingHistory);
|
|
335
|
-
}
|
|
336
|
-
loadHistory() {
|
|
337
|
-
if (!this.config.enableHistoryTracking)
|
|
338
|
-
return;
|
|
339
|
-
try {
|
|
340
|
-
const history = this.stateManager.get("voting:history");
|
|
341
|
-
if (Array.isArray(history)) {
|
|
342
|
-
this.votingHistory = history;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
catch (error) {
|
|
346
|
-
frameworkLogger.log("VotingCoordinator", "history-load-failed", "warning", { error });
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
initializeMetrics() {
|
|
350
|
-
return {
|
|
351
|
-
totalVotes: 0,
|
|
352
|
-
successfulVotes: 0,
|
|
353
|
-
failedVotes: 0,
|
|
354
|
-
averageConfidence: 0,
|
|
355
|
-
strategyUsage: {
|
|
356
|
-
majority_vote: 0,
|
|
357
|
-
consensus: 0,
|
|
358
|
-
expert_priority: 0,
|
|
359
|
-
},
|
|
360
|
-
agentParticipation: {},
|
|
361
|
-
averageVoterTurnout: 0,
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
updateMetricsAfterVote(result) {
|
|
365
|
-
this.metrics.strategyUsage[result.strategy]++;
|
|
366
|
-
if (result.confidence > 0) {
|
|
367
|
-
const total = this.metrics.successfulVotes;
|
|
368
|
-
this.metrics.averageConfidence =
|
|
369
|
-
(this.metrics.averageConfidence * (total - 1) + result.confidence) / total;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
export const createVotingCoordinator = (stateManager, sessionCoordinator) => {
|
|
374
|
-
return new VotingCoordinator(stateManager, sessionCoordinator);
|
|
375
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test Auto-Healing System for 0xRay Framework
|
|
3
|
-
*
|
|
4
|
-
* Automatically detects slow/failing tests and orchestrates fixes using specialized agents
|
|
5
|
-
* Implements intelligent test optimization and refactoring for enterprise reliability
|
|
6
|
-
*/
|
|
7
|
-
import { RuleValidationContext } from "./rule-enforcer.js";
|
|
8
|
-
export interface TestFailureAnalysis {
|
|
9
|
-
testFile: string;
|
|
10
|
-
failureType: "timeout" | "performance" | "logic-error" | "flaky" | "infrastructure";
|
|
11
|
-
rootCause: string;
|
|
12
|
-
severity: "low" | "medium" | "high" | "critical";
|
|
13
|
-
estimatedFixTime: number;
|
|
14
|
-
autoFixable: boolean;
|
|
15
|
-
recommendedAgent: string;
|
|
16
|
-
fixStrategy: TestFixStrategy;
|
|
17
|
-
}
|
|
18
|
-
export interface TestFixStrategy {
|
|
19
|
-
type: "refactor" | "optimize" | "parallelize" | "mock" | "isolate" | "infrastructure";
|
|
20
|
-
description: string;
|
|
21
|
-
estimatedImprovement: number;
|
|
22
|
-
riskLevel: "low" | "medium" | "high";
|
|
23
|
-
requiresAgentCoordination: boolean;
|
|
24
|
-
}
|
|
25
|
-
export interface AutoHealingResult {
|
|
26
|
-
success: boolean;
|
|
27
|
-
fixesApplied: number;
|
|
28
|
-
testsOptimized: number;
|
|
29
|
-
performanceImprovement: number;
|
|
30
|
-
agentCoordinationUsed: boolean;
|
|
31
|
-
recommendations: string[];
|
|
32
|
-
nextSteps: string[];
|
|
33
|
-
}
|
|
34
|
-
export interface TestResults {
|
|
35
|
-
timedOut?: boolean;
|
|
36
|
-
executionTime?: number;
|
|
37
|
-
file?: string;
|
|
38
|
-
failed?: number;
|
|
39
|
-
}
|
|
40
|
-
export declare class TestAutoHealingSystem {
|
|
41
|
-
private healingHistory;
|
|
42
|
-
/**
|
|
43
|
-
* Main auto-healing entry point for test failures
|
|
44
|
-
*/
|
|
45
|
-
healTestFailures(testResults: TestResults, context: RuleValidationContext): Promise<AutoHealingResult>;
|
|
46
|
-
/**
|
|
47
|
-
* Analyze test failures and determine root causes
|
|
48
|
-
*/
|
|
49
|
-
private analyzeTestFailures;
|
|
50
|
-
/**
|
|
51
|
-
* Apply automatic fixes for simple issues
|
|
52
|
-
*/
|
|
53
|
-
private applyAutomaticFixes;
|
|
54
|
-
/**
|
|
55
|
-
* Coordinate with specialized agents for complex fixes
|
|
56
|
-
*/
|
|
57
|
-
private coordinateAgentFixes;
|
|
58
|
-
/**
|
|
59
|
-
* Optimize test timeouts automatically
|
|
60
|
-
*/
|
|
61
|
-
private optimizeTestTimeouts;
|
|
62
|
-
/**
|
|
63
|
-
* Implement parallel test execution
|
|
64
|
-
*/
|
|
65
|
-
private implementParallelExecution;
|
|
66
|
-
/**
|
|
67
|
-
* Add mocks to speed up tests
|
|
68
|
-
*/
|
|
69
|
-
private addTestMocks;
|
|
70
|
-
/**
|
|
71
|
-
* Invoke specialized agents for complex fixes
|
|
72
|
-
*/
|
|
73
|
-
private invokeSpecializedAgent;
|
|
74
|
-
/**
|
|
75
|
-
* Detect flaky tests based on inconsistent results
|
|
76
|
-
*/
|
|
77
|
-
private detectFlakyTests;
|
|
78
|
-
/**
|
|
79
|
-
* Prioritize issues for fixing
|
|
80
|
-
*/
|
|
81
|
-
private prioritizeIssues;
|
|
82
|
-
}
|
|
83
|
-
export declare const testAutoHealingSystem: TestAutoHealingSystem;
|