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
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PluginRegistry — Phase 1.2 dynamic skill loading + Phase 3 generic tool dispatch
|
|
3
|
+
*
|
|
4
|
+
* Allows skills to be registered after boot, loaded from config, or discovered
|
|
5
|
+
* at runtime. Wraps the existing in-process-skill-registry for backward compat.
|
|
6
|
+
*
|
|
7
|
+
* Phase 3 extension: SkillToolPlugin interface for multi-tool skills (knowledge-skill
|
|
8
|
+
* servers). Each server registers as a SkillToolPlugin, exposing arbitrary tools
|
|
9
|
+
* that can be dispatched via callSkillTool().
|
|
10
|
+
*
|
|
11
|
+
* Goals:
|
|
12
|
+
* - New skills can be registered post-boot via register()
|
|
13
|
+
* - Skills are discoverable by name without importing server constructors
|
|
14
|
+
* - Default set loads automatically from the existing 3 governance skills
|
|
15
|
+
* - Multi-tool skills can be registered and dispatched via callSkillTool()
|
|
16
|
+
* - Backward compatible: callInProcessSkill still works as before
|
|
17
|
+
*/
|
|
18
|
+
import { callInProcessSkill } from '../mcps/in-process-skill-registry.js';
|
|
19
|
+
import { frameworkLogger } from '../core/framework-logger.js';
|
|
20
|
+
class PluginRegistryImpl {
|
|
21
|
+
skills = new Map();
|
|
22
|
+
/** Phase 3: multi-tool skill plugins (knowledge-skill servers) */
|
|
23
|
+
toolPlugins = new Map();
|
|
24
|
+
initialized = false;
|
|
25
|
+
/**
|
|
26
|
+
* Register a skill plugin. Can be called after boot.
|
|
27
|
+
*/
|
|
28
|
+
register(skill) {
|
|
29
|
+
if (this.skills.has(skill.name)) {
|
|
30
|
+
frameworkLogger.log('plugin-registry', 'register-overwrite', 'warning', {
|
|
31
|
+
skillName: skill.name,
|
|
32
|
+
message: 'Overwriting existing skill registration',
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
this.skills.set(skill.name, (args) => skill.analyzeProposal(args));
|
|
36
|
+
frameworkLogger.log('plugin-registry', 'register', 'info', {
|
|
37
|
+
skillName: skill.name,
|
|
38
|
+
totalSkills: this.skills.size,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Register a multi-tool skill plugin (knowledge-skill server).
|
|
43
|
+
* Tools can be dispatched via callSkillTool().
|
|
44
|
+
*/
|
|
45
|
+
registerToolPlugin(skill) {
|
|
46
|
+
if (this.toolPlugins.has(skill.name)) {
|
|
47
|
+
frameworkLogger.log('plugin-registry', 'register-tool-overwrite', 'warning', {
|
|
48
|
+
skillName: skill.name,
|
|
49
|
+
message: 'Overwriting existing tool plugin registration',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
this.toolPlugins.set(skill.name, (toolName, args) => skill.callTool(toolName, args));
|
|
53
|
+
frameworkLogger.log('plugin-registry', 'register-tool', 'info', {
|
|
54
|
+
skillName: skill.name,
|
|
55
|
+
totalToolPlugins: this.toolPlugins.size,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Call a named tool on a registered multi-tool skill plugin.
|
|
60
|
+
*/
|
|
61
|
+
async callSkillTool(skillName, toolName, args) {
|
|
62
|
+
const handler = this.toolPlugins.get(skillName);
|
|
63
|
+
if (!handler) {
|
|
64
|
+
throw new Error(`No tool plugin registered: ${skillName}. Available: ${Array.from(this.toolPlugins.keys()).join(', ')}`);
|
|
65
|
+
}
|
|
66
|
+
return handler(toolName, args);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Check if a tool plugin is registered.
|
|
70
|
+
*/
|
|
71
|
+
hasToolPlugin(name) {
|
|
72
|
+
return this.toolPlugins.has(name);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* List all registered tool plugin names.
|
|
76
|
+
*/
|
|
77
|
+
listToolPlugins() {
|
|
78
|
+
return Array.from(this.toolPlugins.keys());
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get a skill handler by name. Falls back to the in-process registry
|
|
82
|
+
* for the built-in governance skills (code-review, security-audit, researcher).
|
|
83
|
+
*/
|
|
84
|
+
get(name) {
|
|
85
|
+
const handler = this.skills.get(name);
|
|
86
|
+
if (handler)
|
|
87
|
+
return handler;
|
|
88
|
+
// Fall back to the built-in registry for the 3 governance skills
|
|
89
|
+
const builtInNames = ['code-review', 'security-audit', 'researcher'];
|
|
90
|
+
if (builtInNames.includes(name)) {
|
|
91
|
+
return async (args) => {
|
|
92
|
+
const result = await callInProcessSkill(name, 'analyze_proposal', args);
|
|
93
|
+
return result;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Check if a skill is registered (either in the plugin registry or the built-in registry).
|
|
100
|
+
*/
|
|
101
|
+
has(name) {
|
|
102
|
+
return this.skills.has(name) || ['code-review', 'security-audit', 'researcher'].includes(name);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* List all registered skill names (plugins + built-in).
|
|
106
|
+
*/
|
|
107
|
+
list() {
|
|
108
|
+
const builtIn = ['code-review', 'security-audit', 'researcher'];
|
|
109
|
+
const pluginNames = Array.from(this.skills.keys());
|
|
110
|
+
return [...new Set([...builtIn, ...pluginNames])];
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Call a skill by name. Delegates to the plugin registry first,
|
|
114
|
+
* then falls back to the built-in in-process registry.
|
|
115
|
+
*/
|
|
116
|
+
async callSkill(name, args) {
|
|
117
|
+
const handler = this.get(name);
|
|
118
|
+
if (!handler) {
|
|
119
|
+
throw new Error(`No skill registered: ${name}. Available: ${this.list().join(', ')}`);
|
|
120
|
+
}
|
|
121
|
+
return handler(args);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Initialize with default governance skills. Called once at boot.
|
|
125
|
+
* The 3 governance skills are always available via the built-in registry.
|
|
126
|
+
*/
|
|
127
|
+
initializeDefaults() {
|
|
128
|
+
if (this.initialized)
|
|
129
|
+
return;
|
|
130
|
+
this.initialized = true;
|
|
131
|
+
frameworkLogger.log('plugin-registry', 'initialize-defaults', 'info', {
|
|
132
|
+
builtInSkills: ['code-review', 'security-audit', 'researcher'],
|
|
133
|
+
message: 'Default governance skills available via built-in registry',
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Reset the registry for testing. Removes all registered plugins
|
|
138
|
+
* (built-in governance skills remain available via fallback).
|
|
139
|
+
*/
|
|
140
|
+
resetForTest() {
|
|
141
|
+
this.skills.clear();
|
|
142
|
+
this.toolPlugins.clear();
|
|
143
|
+
this.initialized = false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/** Singleton plugin registry */
|
|
147
|
+
export const pluginRegistry = new PluginRegistryImpl();
|
|
@@ -11,15 +11,12 @@ import { enhancedMultiAgentOrchestrator } from "./enhanced-multi-agent-orchestra
|
|
|
11
11
|
import { frameworkLogger } from "../core/framework-logger.js";
|
|
12
12
|
import { routingOutcomeTracker } from "../delegation/analytics/outcome-tracker.js";
|
|
13
13
|
import { patternPerformanceTracker } from "../analytics/pattern-performance-tracker.js";
|
|
14
|
-
import { VotingCoordinator } from "../delegation/voting-coordinator.js";
|
|
15
14
|
import { getAgentExpertiseLevel } from "../delegation/agent-expertise.js";
|
|
16
|
-
import { XrayStateManager } from "../state/state-manager.js";
|
|
17
15
|
import fs from "fs";
|
|
18
16
|
export class XrayOrchestrator {
|
|
19
17
|
config;
|
|
20
18
|
activeTasks = new Map();
|
|
21
19
|
taskToAgentMap = new Map();
|
|
22
|
-
votingCoordinator;
|
|
23
20
|
constructor(config = {}) {
|
|
24
21
|
const loadedConfig = this.loadOrchestratorConfig();
|
|
25
22
|
this.config = {
|
|
@@ -28,7 +25,6 @@ export class XrayOrchestrator {
|
|
|
28
25
|
conflictResolutionStrategy: loadedConfig?.conflictResolutionStrategy ?? "majority_vote",
|
|
29
26
|
...config,
|
|
30
27
|
};
|
|
31
|
-
this.votingCoordinator = new VotingCoordinator(new XrayStateManager());
|
|
32
28
|
}
|
|
33
29
|
/**
|
|
34
30
|
* Load orchestrator config from features.json
|
|
@@ -513,23 +509,6 @@ export class XrayOrchestrator {
|
|
|
513
509
|
.filter((a) => typeof a === "string");
|
|
514
510
|
if (agents.length < 2)
|
|
515
511
|
return conflicts[0];
|
|
516
|
-
const voteId = this.votingCoordinator.initiateVoting(`orchestrator-conflict-${Date.now()}`, "conflict-resolution", "Resolve conflicting agent responses", agents, {
|
|
517
|
-
complexity: 30,
|
|
518
|
-
riskLevel: "medium",
|
|
519
|
-
hasSecurityConcerns: false,
|
|
520
|
-
hasArchitecturalImpact: false,
|
|
521
|
-
participantCount: agents.length,
|
|
522
|
-
});
|
|
523
|
-
void voteId.then((id) => {
|
|
524
|
-
for (const conflict of conflicts) {
|
|
525
|
-
if (conflict.agentType) {
|
|
526
|
-
const vote = conflict.response ? "approve" : "reject";
|
|
527
|
-
const confidence = (conflict.expertiseScore ?? 5) / 10;
|
|
528
|
-
this.votingCoordinator.submitVote(id, conflict.agentType, vote, confidence);
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
this.votingCoordinator.resolveVoting(id);
|
|
532
|
-
});
|
|
533
512
|
return this.resolveByExpertPriority(conflicts);
|
|
534
513
|
}
|
|
535
514
|
resolveByMajorityVote(conflicts) {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { XrayStateManager } from "../state/state-manager.js";
|
|
11
11
|
import { SessionMonitor } from "../session/session-monitor.js";
|
|
12
12
|
import { PostProcessorConfig, PostProcessorResult, PostProcessorContext } from "./types.js";
|
|
13
|
+
import type { MetamorphosisEngine } from "./metamorphosis/MetamorphosisEngine.js";
|
|
13
14
|
export declare class PostProcessor {
|
|
14
15
|
private stateManager;
|
|
15
16
|
private sessionMonitor;
|
|
@@ -28,7 +29,18 @@ export declare class PostProcessor {
|
|
|
28
29
|
private successHandler;
|
|
29
30
|
private triggers;
|
|
30
31
|
private complianceChecker;
|
|
31
|
-
|
|
32
|
+
private metamorphosisEngines;
|
|
33
|
+
constructor(stateManager: XrayStateManager, sessionMonitor?: SessionMonitor | null, config?: Partial<PostProcessorConfig>, metamorphosisEngines?: MetamorphosisEngine[]);
|
|
34
|
+
/**
|
|
35
|
+
* Notify metamorphosis engines of a lifecycle phase.
|
|
36
|
+
* No-op when no engines are configured.
|
|
37
|
+
*/
|
|
38
|
+
private notifyPhase;
|
|
39
|
+
/**
|
|
40
|
+
* Notify metamorphosis engines of a generated proposal.
|
|
41
|
+
* No-op when no engines are configured.
|
|
42
|
+
*/
|
|
43
|
+
private notifyProposal;
|
|
32
44
|
/**
|
|
33
45
|
* Initialize the post-processor system
|
|
34
46
|
*/
|
|
@@ -44,10 +44,12 @@ export class PostProcessor {
|
|
|
44
44
|
successHandler;
|
|
45
45
|
triggers;
|
|
46
46
|
complianceChecker;
|
|
47
|
-
|
|
47
|
+
metamorphosisEngines;
|
|
48
|
+
constructor(stateManager, sessionMonitor = null, config = {}, metamorphosisEngines) {
|
|
48
49
|
this.stateManager = stateManager;
|
|
49
50
|
this.sessionMonitor = sessionMonitor;
|
|
50
51
|
this.config = { ...defaultConfig, ...config };
|
|
52
|
+
this.metamorphosisEngines = metamorphosisEngines ?? [];
|
|
51
53
|
// Initialize monitoring engine
|
|
52
54
|
this.monitoringEngine = new PostProcessorMonitoringEngine(this.stateManager, this.sessionMonitor || undefined);
|
|
53
55
|
// Initialize failure analysis and auto-fix engines
|
|
@@ -73,6 +75,42 @@ export class PostProcessor {
|
|
|
73
75
|
// Initialize architectural compliance checker
|
|
74
76
|
this.complianceChecker = new ArchitecturalComplianceChecker();
|
|
75
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Notify metamorphosis engines of a lifecycle phase.
|
|
80
|
+
* No-op when no engines are configured.
|
|
81
|
+
*/
|
|
82
|
+
async notifyPhase(phase, context) {
|
|
83
|
+
for (const engine of this.metamorphosisEngines) {
|
|
84
|
+
try {
|
|
85
|
+
await engine.onPhase?.(phase, context);
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
await frameworkLogger.log("postprocessor", "metamorphosis-phase-error", "error", {
|
|
89
|
+
engine: engine.name,
|
|
90
|
+
phase,
|
|
91
|
+
error: err instanceof Error ? err.message : String(err),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Notify metamorphosis engines of a generated proposal.
|
|
98
|
+
* No-op when no engines are configured.
|
|
99
|
+
*/
|
|
100
|
+
async notifyProposal(proposal) {
|
|
101
|
+
for (const engine of this.metamorphosisEngines) {
|
|
102
|
+
try {
|
|
103
|
+
await engine.onProposal?.(proposal);
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
await frameworkLogger.log("postprocessor", "metamorphosis-proposal-error", "error", {
|
|
107
|
+
engine: engine.name,
|
|
108
|
+
proposalId: proposal.id,
|
|
109
|
+
error: err instanceof Error ? err.message : String(err),
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
76
114
|
/**
|
|
77
115
|
* Initialize the post-processor system
|
|
78
116
|
*/
|
|
@@ -253,6 +291,7 @@ export class PostProcessor {
|
|
|
253
291
|
await frameworkLogger.log("postprocessor", "loop-completed", "success", {
|
|
254
292
|
message: `✅ Post-processor loop completed: ${result.success ? "SUCCESS" : "FAILED"}`,
|
|
255
293
|
});
|
|
294
|
+
await this.notifyPhase('post-process-complete', { context, result });
|
|
256
295
|
return result;
|
|
257
296
|
}
|
|
258
297
|
catch (error) {
|
|
@@ -291,6 +330,7 @@ export class PostProcessor {
|
|
|
291
330
|
monitoringResults.push(monitoringResult);
|
|
292
331
|
if (monitoringResult.overallStatus === "success") {
|
|
293
332
|
await frameworkLogger.log("postprocessor", "pipeline-success", "success", { message: "✅ CI/CD pipeline successful - post-processor complete" });
|
|
333
|
+
await this.notifyPhase('monitoring-complete', { context, monitoringResult });
|
|
294
334
|
const result = {
|
|
295
335
|
success: true,
|
|
296
336
|
commitSha: context.commitSha,
|
|
@@ -33,14 +33,6 @@ export declare class AutoFixEngine {
|
|
|
33
33
|
* Apply test regeneration fixes
|
|
34
34
|
*/
|
|
35
35
|
private applyTestRegeneration;
|
|
36
|
-
/**
|
|
37
|
-
* Validate that applied fixes resolve the issue
|
|
38
|
-
*/
|
|
39
|
-
validateFixes(fixes: AppliedFixRecord[], originalFailure: FailureAnalysis, context: PostProcessorContext): Promise<boolean>;
|
|
40
|
-
/**
|
|
41
|
-
* Rollback applied fixes if validation fails
|
|
42
|
-
*/
|
|
43
|
-
rollbackFixes(fixes: AppliedFixRecord[]): Promise<void>;
|
|
44
36
|
/**
|
|
45
37
|
* Get the list of applied fixes
|
|
46
38
|
*/
|
|
@@ -191,60 +191,6 @@ export class AutoFixEngine {
|
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
/**
|
|
195
|
-
* Validate that applied fixes resolve the issue
|
|
196
|
-
*/
|
|
197
|
-
async validateFixes(fixes, originalFailure, context) {
|
|
198
|
-
const jobId = `fix-validation-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
199
|
-
await frameworkLogger.log("-auto-fix-engine", "-validating-applied-fixes-", "success", { message: "✅ Validating applied fixes..." });
|
|
200
|
-
try {
|
|
201
|
-
// Run relevant tests based on failure type
|
|
202
|
-
switch (originalFailure.category) {
|
|
203
|
-
case "test-failure":
|
|
204
|
-
execSync("npm test", { stdio: "pipe", timeout: 120000 });
|
|
205
|
-
break;
|
|
206
|
-
case "build-failure":
|
|
207
|
-
execSync("npm run build", { stdio: "pipe", timeout: 120000 });
|
|
208
|
-
break;
|
|
209
|
-
case "code-quality-failure":
|
|
210
|
-
execSync("npm run lint", { stdio: "pipe", timeout: 60000 });
|
|
211
|
-
break;
|
|
212
|
-
case "security-failure":
|
|
213
|
-
execSync("npm run security-audit", { stdio: "pipe", timeout: 60000 });
|
|
214
|
-
break;
|
|
215
|
-
case "performance-regression":
|
|
216
|
-
execSync("npm run test:performance", {
|
|
217
|
-
stdio: "pipe",
|
|
218
|
-
timeout: 120000,
|
|
219
|
-
});
|
|
220
|
-
break;
|
|
221
|
-
default:
|
|
222
|
-
// Run a basic validation
|
|
223
|
-
execSync("npm run typecheck", { stdio: "pipe", timeout: 60000 });
|
|
224
|
-
}
|
|
225
|
-
await frameworkLogger.log("-auto-fix-engine", "-fix-validation-passed-", "success", { message: "✅ Fix validation passed" });
|
|
226
|
-
return true;
|
|
227
|
-
}
|
|
228
|
-
catch (error) {
|
|
229
|
-
await frameworkLogger.log("auto-fix-engine", "validation-failed", "error", { jobId });
|
|
230
|
-
return false;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Rollback applied fixes if validation fails
|
|
235
|
-
*/
|
|
236
|
-
async rollbackFixes(fixes) {
|
|
237
|
-
await frameworkLogger.log("-auto-fix-engine", "-rolling-back-applied-fixes-", "info", { message: "🔄 Rolling back applied fixes..." });
|
|
238
|
-
try {
|
|
239
|
-
// Simple git reset for now
|
|
240
|
-
execSync("git reset --hard HEAD~1", { stdio: "inherit" });
|
|
241
|
-
await frameworkLogger.log("-auto-fix-engine", "-fixes-rolled-back-", "success", { message: "✅ Fixes rolled back" });
|
|
242
|
-
}
|
|
243
|
-
catch (error) {
|
|
244
|
-
await frameworkLogger.log("autofix-engine", "rollback-failed", "error", { error: error instanceof Error ? error.message : String(error) });
|
|
245
|
-
throw error;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
194
|
/**
|
|
249
195
|
* Get the list of applied fixes
|
|
250
196
|
*/
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MetamorphosisEngine — Phase 0.5 skeleton
|
|
3
|
+
*
|
|
4
|
+
* Plug into PostProcessor lifecycle hooks to observe phases and proposals.
|
|
5
|
+
* No-op when none configured. Concrete engines will be built in Phase 2.
|
|
6
|
+
*
|
|
7
|
+
* Integration: PostProcessor accepts optional MetamorphosisEngine[] in constructor.
|
|
8
|
+
* Each engine receives onPhase/onProposal lifecycle notifications.
|
|
9
|
+
*/
|
|
10
|
+
export interface MetamorphosisProposal {
|
|
11
|
+
id: string;
|
|
12
|
+
type: 'add' | 'modify' | 'remove';
|
|
13
|
+
target: string;
|
|
14
|
+
description: string;
|
|
15
|
+
rationale: string;
|
|
16
|
+
impact: 'low' | 'medium' | 'high';
|
|
17
|
+
}
|
|
18
|
+
export interface MetamorphosisEngine {
|
|
19
|
+
/** Human-readable engine name (for logging) */
|
|
20
|
+
name: string;
|
|
21
|
+
/** Called when PostProcessor enters a phase */
|
|
22
|
+
onPhase?(phase: string, context: unknown): Promise<void>;
|
|
23
|
+
/** Called when a metamorphosis proposal is generated */
|
|
24
|
+
onProposal?(proposal: MetamorphosisProposal): Promise<void>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MetamorphosisEngine — Phase 0.5 skeleton
|
|
3
|
+
*
|
|
4
|
+
* Plug into PostProcessor lifecycle hooks to observe phases and proposals.
|
|
5
|
+
* No-op when none configured. Concrete engines will be built in Phase 2.
|
|
6
|
+
*
|
|
7
|
+
* Integration: PostProcessor accepts optional MetamorphosisEngine[] in constructor.
|
|
8
|
+
* Each engine receives onPhase/onProposal lifecycle notifications.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SelfProposalEngine — Phase 2.2
|
|
3
|
+
*
|
|
4
|
+
* Concrete MetamorphosisEngine that reads activity.log, parses structured
|
|
5
|
+
* log entries, detects semantic patterns, generates governance proposals
|
|
6
|
+
* (type: 'metamorphosis'), and submits them through the full 3-agent +
|
|
7
|
+
* Dynamo governance pipeline.
|
|
8
|
+
*
|
|
9
|
+
* Safety constraints:
|
|
10
|
+
* - Max proposals per hour (default 1, configurable)
|
|
11
|
+
* - Circuit breaker: after N consecutive failures, halt for cooldown (default 3/24h)
|
|
12
|
+
* - Only proposes changes to whitelisted targets
|
|
13
|
+
* - All proposals go through full governance with metamorphosisThreshold (default 0.7)
|
|
14
|
+
* - Detection thresholds are configurable (not hard-coded)
|
|
15
|
+
*
|
|
16
|
+
* Coupling note: currently triggered by PostProcessor.onPhase(). A future
|
|
17
|
+
* refactor should extract log-reading into a dedicated LogReader that can
|
|
18
|
+
* run on its own schedule or fs.watch, decoupling from PostProcessor lifecycle.
|
|
19
|
+
*/
|
|
20
|
+
import type { MetamorphosisEngine, MetamorphosisProposal } from './MetamorphosisEngine.js';
|
|
21
|
+
export interface SelfProposalConfig {
|
|
22
|
+
maxProposalsPerHour?: number;
|
|
23
|
+
circuitBreakerThreshold?: number;
|
|
24
|
+
circuitBreakerCooldownHours?: number;
|
|
25
|
+
activityLogPath?: string;
|
|
26
|
+
whitelistedTargets?: string[];
|
|
27
|
+
/** Number of recent log lines to analyze (default: 100) */
|
|
28
|
+
maxLogLines?: number;
|
|
29
|
+
/** Minimum error entries to trigger an error-handling proposal (default: 5) */
|
|
30
|
+
errorThreshold?: number;
|
|
31
|
+
/** Minimum warning entries to trigger a monitoring proposal (default: 10) */
|
|
32
|
+
warningThreshold?: number;
|
|
33
|
+
/** Minimum governance rejections of same type to trigger a pattern proposal (default: 3) */
|
|
34
|
+
governanceRejectionThreshold?: number;
|
|
35
|
+
/** Minimum confidence for generated proposals (default: 0.7) */
|
|
36
|
+
proposalConfidence?: number;
|
|
37
|
+
/** Metamorphosis score threshold for approval (default: 0.7) */
|
|
38
|
+
metamorphosisThreshold?: number;
|
|
39
|
+
/** Project root for resolving whitelisted target paths (default: process.cwd()) */
|
|
40
|
+
projectRoot?: string;
|
|
41
|
+
}
|
|
42
|
+
export declare class SelfProposalEngine implements MetamorphosisEngine {
|
|
43
|
+
readonly name = "self-proposal";
|
|
44
|
+
private config;
|
|
45
|
+
private proposalHistory;
|
|
46
|
+
private consecutiveFailures;
|
|
47
|
+
private circuitBreakerUntil;
|
|
48
|
+
constructor(config?: SelfProposalConfig);
|
|
49
|
+
onPhase(phase: string, context: unknown): Promise<void>;
|
|
50
|
+
onProposal(proposal: MetamorphosisProposal): Promise<void>;
|
|
51
|
+
private isCircuitBreakerActive;
|
|
52
|
+
private isRateLimited;
|
|
53
|
+
private evaluateAndPropose;
|
|
54
|
+
/**
|
|
55
|
+
* Detect actionable patterns from parsed activity log entries.
|
|
56
|
+
* Uses structured parsing instead of raw string matching to handle
|
|
57
|
+
* the actual xray log format:
|
|
58
|
+
* ISO_TIMESTAMP [jobId] [traceId.spanId] [component] action - STATUS | {details}
|
|
59
|
+
*/
|
|
60
|
+
detectPatterns(entries: string[]): MetamorphosisProposal[];
|
|
61
|
+
/**
|
|
62
|
+
* Apply an approved self-evolution proposal by recording the change
|
|
63
|
+
* in a state file within the first matching whitelisted target directory.
|
|
64
|
+
* Returns true if the change was written and verified, false otherwise.
|
|
65
|
+
*/
|
|
66
|
+
private applySelfProposal;
|
|
67
|
+
private submitProposal;
|
|
68
|
+
}
|