mindforge-cc 3.0.0 → 5.0.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/.agent/CLAUDE.md +50 -545
- package/.claude/CLAUDE.md +50 -545
- package/.mindforge/audit/AUDIT-SCHEMA.md +20 -1
- package/.mindforge/engine/nexus-tracer.js +115 -0
- package/.mindforge/engine/persona-factory.md +45 -0
- package/.mindforge/engine/swarm-controller.md +59 -0
- package/.mindforge/engine/wave-executor.md +104 -54
- package/.mindforge/memory/pattern-library.jsonl +1 -2
- package/.mindforge/personas/swarm-templates.json +118 -0
- package/.planning/ROI.jsonl +2 -0
- package/CHANGELOG.md +133 -22
- package/MINDFORGE.md +75 -106
- package/README.md +71 -101
- package/RELEASENOTES.md +41 -24
- package/bin/autonomous/auto-runner.js +154 -4
- package/bin/autonomous/context-refactorer.js +64 -0
- package/bin/autonomous/steer.js +19 -1
- package/bin/autonomous/stuck-monitor.js +43 -0
- package/bin/engine/feedback-loop.js +71 -0
- package/bin/engine/handover-manager.js +69 -0
- package/bin/engine/nexus-tracer.js +215 -0
- package/bin/engine/sre-manager.js +63 -0
- package/bin/engine/temporal-hindsight.js +88 -0
- package/bin/governance/policies/default-policies.jsonl +33 -0
- package/bin/governance/policy-engine.js +106 -0
- package/bin/governance/rbac-manager.js +109 -0
- package/bin/governance/trust-verifier.js +81 -0
- package/bin/governance/ztai-archiver.js +104 -0
- package/bin/governance/ztai-manager.js +203 -0
- package/bin/memory/eis-client.js +95 -0
- package/bin/memory/federated-sync.js +127 -0
- package/bin/memory/ghost-pattern-detector.js +69 -0
- package/bin/memory/knowledge-graph.js +37 -0
- package/bin/memory/semantic-hub.js +104 -0
- package/bin/models/cloud-broker.js +83 -0
- package/bin/models/finops-hub.js +79 -0
- package/bin/models/model-broker.js +129 -0
- package/bin/skill-validator.js +41 -0
- package/docs/INTELLIGENCE-MESH.md +35 -0
- package/docs/PERSONAS.md +63 -0
- package/docs/{references → References}/audit-events.md +6 -0
- package/docs/architecture/NEXUS-DASHBOARD.md +35 -0
- package/docs/architecture/PAR-ZTS-SURVEY.md +43 -0
- package/docs/architecture/README.md +31 -64
- package/docs/architecture/V4-SWARM-MESH.md +77 -0
- package/docs/architecture/V5-ENTERPRISE.md +113 -0
- package/docs/feature-dashboard.md +6 -1
- package/docs/governance-guide.md +47 -23
- package/docs/security/SECURITY.md +20 -7
- package/docs/security/ZTAI-OVERVIEW.md +37 -0
- package/docs/user-guide.md +29 -3
- package/docs/usp-features.md +79 -5
- package/package.json +1 -1
- /package/docs/{context → Context}/Master-Context.md +0 -0
- /package/docs/{references → References}/checkpoints.md +0 -0
- /package/docs/{references → References}/commands.md +0 -0
- /package/docs/{references → References}/config-reference.md +0 -0
- /package/docs/{references → References}/continuation-format.md +0 -0
- /package/docs/{references → References}/decimal-phase-calculation.md +0 -0
- /package/docs/{references → References}/git-integration.md +0 -0
- /package/docs/{references → References}/git-planning-commit.md +0 -0
- /package/docs/{references → References}/model-profile-resolution.md +0 -0
- /package/docs/{references → References}/model-profiles.md +0 -0
- /package/docs/{references → References}/phase-argument-parsing.md +0 -0
- /package/docs/{references → References}/planning-config.md +0 -0
- /package/docs/{references → References}/questioning.md +0 -0
- /package/docs/{references → References}/sdk-api.md +0 -0
- /package/docs/{references → References}/skills-api.md +0 -0
- /package/docs/{references → References}/tdd.md +0 -0
- /package/docs/{references → References}/ui-brand.md +0 -0
- /package/docs/{references → References}/user-profiling.md +0 -0
- /package/docs/{references → References}/verification-patterns.md +0 -0
- /package/docs/{references → References}/workstream-flag.md +0 -0
- /package/docs/{templates → Templates}/Agents/CLAUDE-MD.md +0 -0
- /package/docs/{templates → Templates}/Agents/COPILOT-INSTRUCTIONS.md +0 -0
- /package/docs/{templates → Templates}/Agents/DEBUGGER-PROMPT.md +0 -0
- /package/docs/{templates → Templates}/Agents/PLANNER-PROMPT.md +0 -0
- /package/docs/{templates/codebase → Templates/Codebase}/architecture.md +0 -0
- /package/docs/{templates/codebase → Templates/Codebase}/concerns.md +0 -0
- /package/docs/{templates/codebase → Templates/Codebase}/conventions.md +0 -0
- /package/docs/{templates/codebase → Templates/Codebase}/integrations.md +0 -0
- /package/docs/{templates/codebase → Templates/Codebase}/stack.md +0 -0
- /package/docs/{templates/codebase → Templates/Codebase}/structure.md +0 -0
- /package/docs/{templates/codebase → Templates/Codebase}/testing.md +0 -0
- /package/docs/{templates → Templates}/Execution/CONTINUE-HERE.md +0 -0
- /package/docs/{templates → Templates}/Execution/DISCUSSION-LOG.md +0 -0
- /package/docs/{templates → Templates}/Execution/PHASE-PROMPT.md +0 -0
- /package/docs/{templates → Templates}/Execution/STATE.md +0 -0
- /package/docs/{templates → Templates}/Execution/SUMMARY-COMPLEX.md +0 -0
- /package/docs/{templates → Templates}/Execution/SUMMARY-MINIMAL.md +0 -0
- /package/docs/{templates → Templates}/Execution/SUMMARY-STANDARD.md +0 -0
- /package/docs/{templates → Templates}/Execution/SUMMARY.md +0 -0
- /package/docs/{templates → Templates}/Profile/DEV-PREFERENCES.md +0 -0
- /package/docs/{templates → Templates}/Profile/USER-PROFILE.md +0 -0
- /package/docs/{templates → Templates}/Profile/USER-SETUP.md +0 -0
- /package/docs/{templates → Templates}/Project/DISCOVERY.md +0 -0
- /package/docs/{templates → Templates}/Project/MILESTONE-ARCHIVE.md +0 -0
- /package/docs/{templates → Templates}/Project/MILESTONE.md +0 -0
- /package/docs/{templates → Templates}/Project/PROJECT.md +0 -0
- /package/docs/{templates → Templates}/Project/REQUIREMENTS.md +0 -0
- /package/docs/{templates → Templates}/Project/RETROSPECTIVE.md +0 -0
- /package/docs/{templates → Templates}/Project/ROADMAP.md +0 -0
- /package/docs/{templates → Templates}/Quality/DEBUG.md +0 -0
- /package/docs/{templates → Templates}/Quality/UAT.md +0 -0
- /package/docs/{templates → Templates}/Quality/UI-SPEC.md +0 -0
- /package/docs/{templates → Templates}/Quality/VALIDATION.md +0 -0
- /package/docs/{templates → Templates}/Quality/VERIFICATION-REPORT.md +0 -0
- /package/docs/{templates/research → Templates/Research}/ARCHITECTURE.md +0 -0
- /package/docs/{templates/research → Templates/Research}/FEATURES.md +0 -0
- /package/docs/{templates/research → Templates/Research}/PITFALLS.md +0 -0
- /package/docs/{templates/research → Templates/Research}/STACK.md +0 -0
- /package/docs/{templates/research → Templates/Research}/SUMMARY.md +0 -0
- /package/docs/{templates → Templates}/System/CONFIG.json +0 -0
- /package/docs/{templates → Templates}/System/CONTEXT.md +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MindForge — CloudBroker (Pillar V: Multi-Cloud Arbitrage & Hedging)
|
|
3
|
+
* Dynamically routes tasks across multiple cloud providers (Vertex, Bedrock, Azure).
|
|
4
|
+
*/
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
class CloudBroker {
|
|
8
|
+
constructor(config = {}) {
|
|
9
|
+
this.providers = config.providers || ['anthropic', 'google', 'aws', 'azure'];
|
|
10
|
+
this.state = {
|
|
11
|
+
'anthropic': { latency: 450, costMultiplier: 1.0, healthy: true },
|
|
12
|
+
'google': { latency: 600, costMultiplier: 0.85, healthy: true },
|
|
13
|
+
'aws': { latency: 550, costMultiplier: 0.95, healthy: true },
|
|
14
|
+
'azure': { latency: 650, costMultiplier: 1.1, healthy: true }
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Selects the optimal provider based on weighted latency and cost.
|
|
20
|
+
* @param {Object} options - Task requirements (maxLatency, budgetConstraint)
|
|
21
|
+
* @returns {string} - Best provider ID
|
|
22
|
+
*/
|
|
23
|
+
getBestProvider(requirements = {}) {
|
|
24
|
+
const scored = Object.entries(this.state)
|
|
25
|
+
.filter(([_, data]) => data.healthy)
|
|
26
|
+
.map(([id, data]) => {
|
|
27
|
+
// Score = (Latency * 0.4) + (Cost * 0.6) — Lower is better
|
|
28
|
+
const score = (data.latency * 0.4) + (data.costMultiplier * 1000 * 0.6);
|
|
29
|
+
return { id, score };
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
scored.sort((a, b) => a.score - b.score);
|
|
33
|
+
return scored[0]?.id || 'anthropic';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Implements the Provider Fallback Protocol.
|
|
38
|
+
* Switches to the "Shadow Model" on the next best healthy provider.
|
|
39
|
+
* @param {string} failedProvider - The provider that just failed
|
|
40
|
+
* @returns {string} - Fallback provider ID
|
|
41
|
+
*/
|
|
42
|
+
getFallbackProvider(failedProvider) {
|
|
43
|
+
if (this.state[failedProvider]) {
|
|
44
|
+
this.state[failedProvider].healthy = false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const fallback = Object.entries(this.state)
|
|
48
|
+
.filter(([id, data]) => id !== failedProvider && data.healthy)
|
|
49
|
+
.sort((a, b) => a[1].latency - b[1].latency)[0];
|
|
50
|
+
|
|
51
|
+
return fallback ? fallback[0] : 'google'; // Default fallback
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves provider-specific model mapping.
|
|
56
|
+
* @param {string} provider - Provider ID
|
|
57
|
+
* @param {string} modelGroup - e.g., 'sonnet', 'opus', 'haiku'
|
|
58
|
+
*/
|
|
59
|
+
mapToProviderModel(provider, modelGroup) {
|
|
60
|
+
const mappings = {
|
|
61
|
+
'anthropic': { 'sonnet': 'claude-3-5-sonnet', 'opus': 'claude-3-opus', 'haiku': 'claude-3-haiku' },
|
|
62
|
+
'google': { 'sonnet': 'gemini-1.5-pro', 'opus': 'gemini-1.5-pro', 'haiku': 'gemini-1.5-flash' },
|
|
63
|
+
'aws': { 'sonnet': 'anthropic.claude-3-5-sonnet-v2:0', 'opus': 'anthropic.claude-3-opus-v1:0', 'haiku': 'anthropic.claude-3-haiku-v1:0' },
|
|
64
|
+
'azure': { 'sonnet': 'gpt-4o', 'opus': 'gpt-4-turbo', 'haiku': 'gpt-35-turbo' }
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return mappings[provider]?.[modelGroup] || mappings[provider]?.['sonnet'];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Hardening: Simulate provider failures to verify Fallback Protocol.
|
|
72
|
+
*/
|
|
73
|
+
startChaosMode() {
|
|
74
|
+
console.log('[BEAST-MODE] CloudBroker Chaos Mode ACTIVE. Simulating jitter and provider dropouts...');
|
|
75
|
+
setInterval(() => {
|
|
76
|
+
const providers = Object.keys(this.latencyMap);
|
|
77
|
+
const randomProvider = providers[Math.floor(Math.random() * providers.length)];
|
|
78
|
+
this.latencyMap[randomProvider] = Math.random() > 0.7 ? 5000 : 100; // Spike latency
|
|
79
|
+
}, 10000);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
module.exports = CloudBroker;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MindForge — FinOps Hub (Pillar V: Autonomous FinOps Hub)
|
|
3
|
+
* Enterprise-grade monitoring and budget enforcement for agentic workloads.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
|
|
9
|
+
class FinOpsHub {
|
|
10
|
+
constructor(config = {}) {
|
|
11
|
+
this.projectRoot = config.projectRoot || process.cwd();
|
|
12
|
+
this.budgetLimit = config.budgetLimit || 100.00; // $100.00 USD Default
|
|
13
|
+
this.monthlyUsage = 0.00;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the FinOps state and budget monitoring.
|
|
18
|
+
*/
|
|
19
|
+
async init() {
|
|
20
|
+
const roiPath = path.join(this.projectRoot, '.planning', 'ROI.jsonl');
|
|
21
|
+
if (fs.existsSync(roiPath)) {
|
|
22
|
+
const logs = fs.readFileSync(roiPath, 'utf8').split('\n').filter(Boolean);
|
|
23
|
+
logs.forEach(line => {
|
|
24
|
+
try {
|
|
25
|
+
const entry = JSON.parse(line);
|
|
26
|
+
this.monthlyUsage += entry.estimatedCostUSD || 0;
|
|
27
|
+
} catch (e) {
|
|
28
|
+
// Skip malformed lines
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Checks if the task is within budget constraints.
|
|
36
|
+
* @param {Object} task - Task details (difficulty, priority)
|
|
37
|
+
* @returns {Object} - Budget check result (status, reasoning)
|
|
38
|
+
*/
|
|
39
|
+
checkBudget(task) {
|
|
40
|
+
if (this.monthlyUsage >= this.budgetLimit) {
|
|
41
|
+
return { status: 'DENIED', reason: `Monthly budget limit ($${this.budgetLimit}) reached.` };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (this.monthlyUsage >= this.budgetLimit * 0.9) {
|
|
45
|
+
return { status: 'WARNING', reason: `Project has consumed 90% of the allocated budget ($${this.monthlyUsage.toFixed(2)} / $${this.budgetLimit.toFixed(2)}).` };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return { status: 'APPROVED', usage: this.monthlyUsage };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Generates a "Spending Profile" for the project.
|
|
53
|
+
* Used for the Nexus Dashboard to visualize ROI.
|
|
54
|
+
*/
|
|
55
|
+
getSpendingProfile() {
|
|
56
|
+
const roiPath = path.join(this.projectRoot, '.planning', 'ROI.jsonl');
|
|
57
|
+
if (!fs.existsSync(roiPath)) return { totalSpend: 0, goalsAchieved: 0, roi: 0 };
|
|
58
|
+
|
|
59
|
+
const logs = fs.readFileSync(roiPath, 'utf8').split('\n').filter(Boolean).map(JSON.parse);
|
|
60
|
+
const totalSpend = logs.reduce((acc, l) => acc + (l.estimatedCostUSD || 0), 0);
|
|
61
|
+
const goalsAchieved = logs.reduce((acc, l) => acc + (l.goalAchieved || 0), 0);
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
totalSpend: totalSpend.toFixed(2),
|
|
65
|
+
goalsAchieved,
|
|
66
|
+
roi: totalSpend > 0 ? (goalsAchieved / totalSpend).toFixed(2) : 0,
|
|
67
|
+
tokenEfficiency: logs.length > 0 ? (totalSpend / logs.length).toFixed(4) : 0,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Resets the usage counter (system-level call).
|
|
73
|
+
*/
|
|
74
|
+
resetMonthlyUsage() {
|
|
75
|
+
this.monthlyUsage = 0.00;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = FinOpsHub;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
const CloudBroker = require('./cloud-broker');
|
|
2
|
+
|
|
3
|
+
class ModelBroker {
|
|
4
|
+
constructor(config = {}) {
|
|
5
|
+
this.projectRoot = config.projectRoot || process.cwd();
|
|
6
|
+
this.cloudBroker = new CloudBroker(config.cloud);
|
|
7
|
+
this.defaults = {
|
|
8
|
+
EXECUTOR_MODEL: 'sonnet',
|
|
9
|
+
PLANNER_MODEL: 'sonnet',
|
|
10
|
+
SECURITY_MODEL: 'opus',
|
|
11
|
+
QA_MODEL: 'sonnet',
|
|
12
|
+
RESEARCH_MODEL: 'sonnet',
|
|
13
|
+
DEBUG_MODEL: 'sonnet',
|
|
14
|
+
QUICK_MODEL: 'haiku',
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Resolves the optimal model for a given task (v5 Multi-Cloud Arbitrage).
|
|
20
|
+
* @param {Object} context - Task context (persona, difficulty, tier)
|
|
21
|
+
* @returns {Object} - Resolved model details (modelId, provider, costTier, reasoning)
|
|
22
|
+
*/
|
|
23
|
+
resolveModel(context) {
|
|
24
|
+
const { persona, difficulty, tier } = context;
|
|
25
|
+
let modelGroup = this.defaults.EXECUTOR_MODEL;
|
|
26
|
+
let reasoningParts = [];
|
|
27
|
+
|
|
28
|
+
// 1. Check Security Tier (T3 requires premium models)
|
|
29
|
+
if (tier === 3) {
|
|
30
|
+
modelGroup = this.defaults.SECURITY_MODEL;
|
|
31
|
+
reasoningParts.push('Tier 3 (Principal) action requires high-trust model (Opus).');
|
|
32
|
+
} else {
|
|
33
|
+
// 2. Map Persona to Base Model
|
|
34
|
+
const personaMap = {
|
|
35
|
+
'executor': 'EXECUTOR_MODEL',
|
|
36
|
+
'planner': 'PLANNER_MODEL',
|
|
37
|
+
'security-reviewer': 'SECURITY_MODEL',
|
|
38
|
+
'qa-engineer': 'QA_MODEL',
|
|
39
|
+
'researcher': 'RESEARCH_MODEL',
|
|
40
|
+
'debug-specialist': 'DEBUG_MODEL',
|
|
41
|
+
};
|
|
42
|
+
if (personaMap[persona]) {
|
|
43
|
+
modelGroup = this.defaults[personaMap[persona]];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 3. Complexity-based Overrides
|
|
48
|
+
if (difficulty < 2.0 && difficulty !== undefined && tier !== 3) {
|
|
49
|
+
modelGroup = this.defaults.QUICK_MODEL;
|
|
50
|
+
reasoningParts.push(`Low difficulty (${difficulty}) -> Quick model.`);
|
|
51
|
+
} else if (difficulty > 4.5 && tier !== 3) {
|
|
52
|
+
modelGroup = this.defaults.SECURITY_MODEL;
|
|
53
|
+
reasoningParts.push(`High difficulty (${difficulty}) -> Complexity upgrade.`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 4. v5 Multi-Cloud Arbitrage
|
|
57
|
+
const provider = this.cloudBroker.getBestProvider({
|
|
58
|
+
latencyConstraint: tier === 3 ? 500 : 1000
|
|
59
|
+
});
|
|
60
|
+
const modelId = this.cloudBroker.mapToProviderModel(provider, modelGroup);
|
|
61
|
+
|
|
62
|
+
reasoningParts.push(`Arbitrage: Routed to ${provider} (${modelId}) based on latency/cost.`);
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
modelId,
|
|
66
|
+
provider,
|
|
67
|
+
modelGroup,
|
|
68
|
+
costTier: modelGroup === 'opus' ? 'high' : (modelGroup === 'haiku' ? 'low' : 'medium'),
|
|
69
|
+
reasoning: reasoningParts.join(' ')
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Implements the Provider Fallback Protocol (v5 Pillar V).
|
|
75
|
+
* @param {string} failedProvider - The provider that failed.
|
|
76
|
+
* @param {string} modelGroup - The group being requested.
|
|
77
|
+
* @returns {Object} - New model and provider details.
|
|
78
|
+
*/
|
|
79
|
+
handleProviderFailure(failedProvider, modelGroup) {
|
|
80
|
+
const fallbackProvider = this.cloudBroker.getFallbackProvider(failedProvider);
|
|
81
|
+
const modelId = this.cloudBroker.mapToProviderModel(fallbackProvider, modelGroup);
|
|
82
|
+
|
|
83
|
+
console.warn(`[P5-FALLBACK] Provider ${failedProvider} failed. Migrating context to ${fallbackProvider} (${modelId}).`);
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
modelId,
|
|
87
|
+
provider: fallbackProvider,
|
|
88
|
+
modelGroup,
|
|
89
|
+
reasoning: `Provider Fallback Protocol: Emergency migration from ${failedProvider} to ${fallbackProvider}.`
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Tracks the "Agentic ROI" for a completed task.
|
|
95
|
+
* @param {Object} report - Task execution report (tokens, duration, status)
|
|
96
|
+
*/
|
|
97
|
+
trackROI(report) {
|
|
98
|
+
const roiPath = path.join(this.projectRoot, '.planning', 'ROI.jsonl');
|
|
99
|
+
const entry = {
|
|
100
|
+
timestamp: new Date().toISOString(),
|
|
101
|
+
planId: report.planId,
|
|
102
|
+
task: report.taskName,
|
|
103
|
+
model: report.modelId,
|
|
104
|
+
costTier: report.costTier,
|
|
105
|
+
inputTokens: report.inputTokens,
|
|
106
|
+
outputTokens: report.outputTokens,
|
|
107
|
+
durationMs: report.durationMs,
|
|
108
|
+
status: report.status,
|
|
109
|
+
goalAchieved: report.status === 'completed' ? 1 : 0,
|
|
110
|
+
estimatedCostUSD: this.estimateCost(report.modelId, report.inputTokens, report.outputTokens),
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
fs.appendFileSync(roiPath, JSON.stringify(entry) + '\n');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
estimateCost(modelId, input, output) {
|
|
117
|
+
// Mock cost estimation logic per 1M tokens
|
|
118
|
+
const rates = {
|
|
119
|
+
'claude-3-opus': { in: 15, out: 75 },
|
|
120
|
+
'claude-3-5-sonnet': { in: 3, out: 15 },
|
|
121
|
+
'claude-3-haiku': { in: 0.25, out: 1.25 },
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const rate = rates[modelId] || rates['claude-3-5-sonnet'];
|
|
125
|
+
return (input / 1_000_000) * rate.in + (output / 1_000_000) * rate.out;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
module.exports = ModelBroker;
|
package/bin/skill-validator.js
CHANGED
|
@@ -102,25 +102,51 @@ function main() {
|
|
|
102
102
|
|
|
103
103
|
// ── Level 2: Content ────────────────────────────────────────────────────────
|
|
104
104
|
results.content.push({
|
|
105
|
+
id: 'size',
|
|
105
106
|
ok: content.length >= 1024 && content.length <= 200 * 1024,
|
|
107
|
+
weight: 0.1,
|
|
106
108
|
msg: `File size: ${(content.length / 1024).toFixed(1)}KB (1KB-200KB)`
|
|
107
109
|
});
|
|
108
110
|
|
|
109
111
|
results.content.push({
|
|
112
|
+
id: 'actions',
|
|
110
113
|
ok: /##\s+(Mandatory actions|When this skill is active)/i.test(content),
|
|
114
|
+
weight: 0.2,
|
|
111
115
|
msg: 'Mandatory actions section present'
|
|
112
116
|
});
|
|
113
117
|
|
|
114
118
|
results.content.push({
|
|
119
|
+
id: 'checklist',
|
|
115
120
|
ok: /- \[ \]/.test(content),
|
|
121
|
+
weight: 0.1,
|
|
116
122
|
msg: 'Self-check/checklist items found'
|
|
117
123
|
});
|
|
118
124
|
|
|
119
125
|
results.content.push({
|
|
126
|
+
id: 'security',
|
|
120
127
|
ok: !/IGNORE ALL PREVIOUS/i.test(content),
|
|
128
|
+
weight: 0.2,
|
|
121
129
|
msg: 'No injection patterns detected'
|
|
122
130
|
});
|
|
123
131
|
|
|
132
|
+
// ── Level 3: Quality (v5 7-Dimension Scoring) ───────────────────────────────
|
|
133
|
+
const dimensions = [
|
|
134
|
+
{ id: 'schema', weight: 0.15, ok: results.schema.every(r => r.ok), name: 'Schema Compliance' },
|
|
135
|
+
{ id: 'triggers', weight: 0.15, ok: results.schema.some(r => r.msg.includes('triggers') && r.ok), name: 'Trigger Density' },
|
|
136
|
+
{ id: 'actions', weight: 0.20, ok: results.content.some(r => r.id === 'actions' && r.ok), name: 'Mandatory Coverage' },
|
|
137
|
+
{ id: 'security', weight: 0.20, ok: results.content.some(r => r.id === 'security' && r.ok), name: 'Security Sanitization' },
|
|
138
|
+
{ id: 'clarity', weight: 0.10, ok: content.split('\n').length > 50, name: 'Doc Clarity' },
|
|
139
|
+
{ id: 'edges', weight: 0.10, ok: /edge cases|error handling/i.test(content), name: 'Edge Case Handling' },
|
|
140
|
+
{ id: 'examples', weight: 0.10, ok: /example|Usage/i.test(content), name: 'Example Fidelity' }
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
let totalScore = 0;
|
|
144
|
+
dimensions.forEach(d => {
|
|
145
|
+
if (d.ok) totalScore += d.weight * 10;
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
results.certificationScore = parseFloat(totalScore.toFixed(1));
|
|
149
|
+
|
|
124
150
|
// ── Output ──────────────────────────────────────────────────────────────────
|
|
125
151
|
console.log(`${colors.cyan}${colors.bold}Schema validation:${colors.reset}`);
|
|
126
152
|
results.schema.forEach(r => console.log(` ${r.ok ? colors.green + '✅' : colors.red + '❌'} ${r.msg}`));
|
|
@@ -131,7 +157,22 @@ function main() {
|
|
|
131
157
|
console.log(` ${r.ok ? colors.green + '✅' : colors.red + '❌'} ${r.msg}`);
|
|
132
158
|
});
|
|
133
159
|
|
|
160
|
+
console.log(`\n${colors.cyan}${colors.bold}Enterprise Certification (7D):${colors.reset}`);
|
|
161
|
+
dimensions.forEach(d => {
|
|
162
|
+
console.log(` ${d.ok ? colors.green + '✅' : colors.red + '❌'} ${d.name.padEnd(25)} [Weight: ${(d.weight * 100).toFixed(0)}%]`);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const scoreColor = results.certificationScore >= 7.0 ? colors.green : colors.yellow;
|
|
166
|
+
console.log(`\n ${colors.bold}Certification Score: ${scoreColor}${results.certificationScore}/10.0${colors.reset}`);
|
|
167
|
+
|
|
134
168
|
console.log('─'.repeat(60));
|
|
169
|
+
|
|
170
|
+
const isEnterprise = ARGS.includes('--enterprise');
|
|
171
|
+
if (isEnterprise && results.certificationScore < 7.0) {
|
|
172
|
+
console.error(`${colors.red}❌ FAILURE: Skill does not meet the minimum Enterprise Certification Score (7.0).${colors.reset}`);
|
|
173
|
+
results.valid = false;
|
|
174
|
+
}
|
|
175
|
+
|
|
135
176
|
if (results.valid) {
|
|
136
177
|
console.log(`${colors.green}${colors.bold}Result: VALID${colors.reset}`);
|
|
137
178
|
process.exit(0);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# MindForge Federated Intelligence Mesh (FIM)
|
|
2
|
+
MindForge v5.0.0 — Distributed Intelligence Sharing
|
|
3
|
+
|
|
4
|
+
## 1. Overview
|
|
5
|
+
The **Federated Intelligence Mesh (FIM)** is the enterprise-grade evolution of the Global Intelligence Mesh. It transitions MindForge from machine-local memory to a distributed organizational intelligence network. Using a central **Enterprise Intelligence Service (EIS)**, FIM enables seamless, authenticated knowledge synchronization across all agents and projects in the enterprise.
|
|
6
|
+
|
|
7
|
+
## 2. Architecture
|
|
8
|
+
The V5 mesh is built on three core pillars residing in `bin/memory/`:
|
|
9
|
+
|
|
10
|
+
### A. EIS Client (`eis-client.js`)
|
|
11
|
+
- **Role**: Secure, authenticated communicator for the central intelligence hub.
|
|
12
|
+
- **Hardening**: Implements **ZTAI-signed authentication headers**. Every request is cryptographically tied to a verified agent identity (DID).
|
|
13
|
+
- **Communication**: REST-based push/pull protocols with integrity-verified payloads.
|
|
14
|
+
|
|
15
|
+
### B. Federated Sync (`federated-sync.js`)
|
|
16
|
+
- **Role**: High-performance synchronization engine between local stores and the organizational mesh.
|
|
17
|
+
- **Delta Sync**: Tracks the `last_sync` timestamp to only pull new organizational insights, significantly reducing latency and compute costs.
|
|
18
|
+
- **Conflict Resolution**: Uses **LWW (Last-Write-Wins)** logic with cryptographic version checks to handle concurrent updates from different agents.
|
|
19
|
+
|
|
20
|
+
### C. Knowledge Graph Bridge (`knowledge-graph.js`)
|
|
21
|
+
- **Role**: Unified memory interface that resolves both local project nodes and remote federated nodes.
|
|
22
|
+
- **Hybrid Traversal**: BFS/DFS algorithms that seamlessly traverse edges spanning across the local-to-global boundary.
|
|
23
|
+
|
|
24
|
+
## 3. Workflow & Provenance
|
|
25
|
+
1. **Verified Capture**: High-confidence findings (>0.8 score) are automatically prepared for mesh promotion.
|
|
26
|
+
2. **Identity-Locked Push**: The `FederatedSync` pushes these findings to the EIS, signed by the originating agent's ZTAI DID.
|
|
27
|
+
3. **Organizational Delta Pull**: Subagents starting new tasks perform a delta-pull to ingest the latest organizational "Ghost Patterns" and success-verified designs.
|
|
28
|
+
|
|
29
|
+
## 4. Enterprise Value
|
|
30
|
+
- **Verifiable Intelligence**: All knowledge in the mesh has an immutable audit trail back to the agent that discovered it.
|
|
31
|
+
- **Global Self-Healing**: A security vulnerability found in project A becomes a proactive guardrail in project B within seconds.
|
|
32
|
+
- **Elimination of Redundancy**: Multi-thousand-token research chains are executed once and shared universally across the mesh.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
*Status: V5 "Beast" Mode Implemented & Verified (2026-03-28)*
|