monomind 1.18.13 → 1.19.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/.claude/agents/core/researcher.md +29 -24
- package/.claude/agents/github/code-review-swarm.md +1 -1
- package/.claude/agents/github/github-modes.md +1 -1
- package/.claude/agents/github/issue-tracker.md +1 -1
- package/.claude/agents/github/multi-repo-swarm.md +1 -1
- package/.claude/agents/github/pr-manager.md +1 -1
- package/.claude/agents/github/project-board-sync.md +1 -1
- package/.claude/agents/github/release-manager.md +1 -1
- package/.claude/agents/github/repo-architect.md +1 -1
- package/.claude/agents/github/swarm-issue.md +1 -1
- package/.claude/agents/github/swarm-pr.md +1 -1
- package/.claude/agents/github/sync-coordinator.md +1 -1
- package/.claude/agents/github/workflow-automation.md +1 -1
- package/.claude/agents/goal/goal-planner.md +1 -1
- package/.claude/agents/specialized/specialized-workflow-architect.md +11 -14
- package/.claude/agents/testing/production-validator.md +8 -7
- package/.claude/agents/testing/testing-evidence-collector.md +3 -1
- package/.claude/commands/mastermind/_repeat.md +22 -3
- package/.claude/commands/mastermind/architect.md +1 -1
- package/.claude/commands/mastermind/autodev.md +1 -1
- package/.claude/commands/mastermind/build.md +1 -1
- package/.claude/commands/mastermind/code-review.md +5 -5
- package/.claude/commands/mastermind/debug.md +1 -1
- package/.claude/commands/mastermind/help.md +2 -2
- package/.claude/commands/mastermind/idea.md +1 -1
- package/.claude/commands/mastermind/improve.md +1 -1
- package/.claude/commands/mastermind/okf-export.md +14 -0
- package/.claude/commands/mastermind/okf-import.md +15 -0
- package/.claude/commands/mastermind/plan.md +1 -1
- package/.claude/commands/mastermind/research.md +1 -1
- package/.claude/commands/mastermind/review.md +12 -1
- package/.claude/commands/mastermind/runorg.md +1 -1
- package/.claude/commands/mastermind/taskdev.md +1 -1
- package/.claude/commands/mastermind/tdd.md +1 -1
- package/.claude/commands/mastermind/verify.md +1 -1
- package/.claude/helpers/graphify-freshen.cjs +16 -20
- package/.claude/helpers/handlers/agent-start-handler.cjs +11 -36
- package/.claude/helpers/handlers/capture-handler.cjs +110 -0
- package/.claude/helpers/handlers/route-handler.cjs +180 -256
- package/.claude/helpers/handlers/session-handler.cjs +139 -142
- package/.claude/helpers/handlers/session-restore-handler.cjs +15 -10
- package/.claude/helpers/handlers/task-handler.cjs +8 -155
- package/.claude/helpers/hook-handler.cjs +89 -5
- package/.claude/helpers/intelligence.cjs +164 -15
- package/.claude/helpers/learning-service.mjs +1 -0
- package/.claude/helpers/mastermind-activate.cjs +33 -51
- package/.claude/helpers/monolean-activate.cjs +13 -3
- package/.claude/helpers/monolean-propagate.cjs +7 -3
- package/.claude/helpers/router.cjs +47 -9
- package/.claude/helpers/utils/monograph.cjs +37 -20
- package/.claude/settings.json +0 -20
- package/.claude/skills/mastermind-skills/_repeat.md +29 -4
- package/.claude/skills/mastermind-skills/architect.md +5 -6
- package/.claude/skills/mastermind-skills/autodev.md +8 -5
- package/.claude/skills/mastermind-skills/review.md +25 -11
- package/.claude/skills/mastermind-skills/techport.md +37 -3
- package/.claude/skills/monodesign/document.md +9 -6
- package/.claude/skills/monodesign/extract.md +1 -1
- package/.claude/skills/monodesign/reference/document.md +1 -1
- package/.claude/skills/monodesign/reference/live.md +1 -1
- package/.claude/skills/monolean/SKILL.md +1 -1
- package/package.json +1 -1
- package/packages/@monomind/cli/.claude/agents/core/researcher.md +29 -24
- package/packages/@monomind/cli/.claude/agents/github/code-review-swarm.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/github-modes.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/issue-tracker.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/multi-repo-swarm.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/pr-manager.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/project-board-sync.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/release-manager.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/repo-architect.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/swarm-issue.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/swarm-pr.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/sync-coordinator.md +1 -1
- package/packages/@monomind/cli/.claude/agents/github/workflow-automation.md +1 -1
- package/packages/@monomind/cli/.claude/agents/goal/goal-planner.md +1 -1
- package/packages/@monomind/cli/.claude/agents/specialized/specialized-workflow-architect.md +11 -14
- package/packages/@monomind/cli/.claude/agents/testing/production-validator.md +8 -7
- package/packages/@monomind/cli/.claude/agents/testing/testing-evidence-collector.md +3 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/_repeat.md +22 -3
- package/packages/@monomind/cli/.claude/commands/mastermind/architect.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/autodev.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/build.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/code-review.md +5 -5
- package/packages/@monomind/cli/.claude/commands/mastermind/debug.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/help.md +2 -2
- package/packages/@monomind/cli/.claude/commands/mastermind/idea.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/improve.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/okf-export.md +14 -0
- package/packages/@monomind/cli/.claude/commands/mastermind/okf-import.md +15 -0
- package/packages/@monomind/cli/.claude/commands/mastermind/plan.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/research.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/review.md +12 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/runorg.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/taskdev.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/tdd.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/verify.md +1 -1
- package/packages/@monomind/cli/.claude/helpers/graphify-freshen.cjs +16 -20
- package/packages/@monomind/cli/.claude/helpers/handlers/agent-start-handler.cjs +11 -36
- package/packages/@monomind/cli/.claude/helpers/handlers/capture-handler.cjs +110 -0
- package/packages/@monomind/cli/.claude/helpers/handlers/route-handler.cjs +180 -256
- package/packages/@monomind/cli/.claude/helpers/handlers/session-handler.cjs +139 -142
- package/packages/@monomind/cli/.claude/helpers/handlers/session-restore-handler.cjs +15 -10
- package/packages/@monomind/cli/.claude/helpers/handlers/task-handler.cjs +8 -155
- package/packages/@monomind/cli/.claude/helpers/hook-handler.cjs +89 -5
- package/packages/@monomind/cli/.claude/helpers/intelligence.cjs +164 -15
- package/packages/@monomind/cli/.claude/helpers/learning-service.mjs +1 -0
- package/packages/@monomind/cli/.claude/helpers/mastermind-activate.cjs +33 -51
- package/packages/@monomind/cli/.claude/helpers/monolean-activate.cjs +13 -3
- package/packages/@monomind/cli/.claude/helpers/monolean-propagate.cjs +7 -3
- package/packages/@monomind/cli/.claude/helpers/router.cjs +47 -9
- package/packages/@monomind/cli/.claude/helpers/utils/monograph.cjs +37 -20
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/_repeat.md +29 -4
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/architect.md +5 -6
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/autodev.md +8 -5
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/review.md +25 -11
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/techport.md +37 -3
- package/packages/@monomind/cli/.claude/skills/monodesign/document.md +9 -6
- package/packages/@monomind/cli/.claude/skills/monodesign/extract.md +1 -1
- package/packages/@monomind/cli/.claude/skills/monodesign/reference/document.md +1 -1
- package/packages/@monomind/cli/.claude/skills/monodesign/reference/live.md +1 -1
- package/packages/@monomind/cli/.claude/skills/monolean/SKILL.md +1 -1
- package/packages/@monomind/cli/bin/mcp-server.js +11 -1
- package/packages/@monomind/cli/dist/src/commands/agent-ops.d.ts +1 -2
- package/packages/@monomind/cli/dist/src/commands/agent-ops.js +1 -59
- package/packages/@monomind/cli/dist/src/commands/agent.js +2 -3
- package/packages/@monomind/cli/dist/src/commands/analyze-diff.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/browse-action.js +94 -2
- package/packages/@monomind/cli/dist/src/commands/completions.js +11 -56
- package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/hive-mind-helpers.js +2 -2
- package/packages/@monomind/cli/dist/src/commands/hive-mind-ops.d.ts +1 -3
- package/packages/@monomind/cli/dist/src/commands/hive-mind-ops.js +2 -116
- package/packages/@monomind/cli/dist/src/commands/hive-mind.js +2 -5
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-commands.js +8 -7
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-gaps.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-routing.js +2 -2
- package/packages/@monomind/cli/dist/src/commands/hooks-extended-commands.d.ts +0 -3
- package/packages/@monomind/cli/dist/src/commands/hooks-extended-commands.js +0 -307
- package/packages/@monomind/cli/dist/src/commands/hooks.js +1 -12
- package/packages/@monomind/cli/dist/src/commands/index.d.ts +3 -51
- package/packages/@monomind/cli/dist/src/commands/index.js +36 -184
- package/packages/@monomind/cli/dist/src/commands/init-wizard.js +2 -4
- package/packages/@monomind/cli/dist/src/commands/mcp.js +32 -4
- package/packages/@monomind/cli/dist/src/commands/memory-admin.d.ts +1 -2
- package/packages/@monomind/cli/dist/src/commands/memory-admin.js +1 -118
- package/packages/@monomind/cli/dist/src/commands/memory-transfer.d.ts +1 -2
- package/packages/@monomind/cli/dist/src/commands/memory-transfer.js +5 -171
- package/packages/@monomind/cli/dist/src/commands/memory.js +3 -6
- package/packages/@monomind/cli/dist/src/commands/neural-core.d.ts +3 -1
- package/packages/@monomind/cli/dist/src/commands/neural-core.js +145 -6
- package/packages/@monomind/cli/dist/src/commands/neural-optimize.js +4 -4
- package/packages/@monomind/cli/dist/src/commands/neural-registry.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/neural-registry.js +4 -4
- package/packages/@monomind/cli/dist/src/commands/neural.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/neural.js +6 -6
- package/packages/@monomind/cli/dist/src/commands/performance.js +68 -58
- package/packages/@monomind/cli/dist/src/commands/providers.js +2 -131
- package/packages/@monomind/cli/dist/src/commands/security-misc.d.ts +0 -1
- package/packages/@monomind/cli/dist/src/commands/security-misc.js +69 -45
- package/packages/@monomind/cli/dist/src/commands/security.js +2 -4
- package/packages/@monomind/cli/dist/src/commands/session.js +1 -285
- package/packages/@monomind/cli/dist/src/commands/start.js +2 -41
- package/packages/@monomind/cli/dist/src/commands/status.js +18 -29
- package/packages/@monomind/cli/dist/src/commands/swarm.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/task.js +2 -49
- package/packages/@monomind/cli/dist/src/commands/workflow.js +2 -104
- package/packages/@monomind/cli/dist/src/index.js +7 -0
- package/packages/@monomind/cli/dist/src/init/executor.js +3 -14
- package/packages/@monomind/cli/dist/src/init/helpers-generator.js +2 -22
- package/packages/@monomind/cli/dist/src/init/settings-generator.js +0 -1
- package/packages/@monomind/cli/dist/src/init/types.d.ts +1 -3
- package/packages/@monomind/cli/dist/src/init/types.js +0 -2
- package/packages/@monomind/cli/dist/src/mcp-client.js +0 -6
- package/packages/@monomind/cli/dist/src/mcp-server.js +16 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.js +0 -17
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/causal-infer.d.ts +5 -5
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/causal-infer.js +32 -46
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/consensus-verify.d.ts +2 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/consensus-verify.js +22 -20
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/memory-gate.d.ts +3 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/memory-gate.js +32 -19
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/quantum-topology.d.ts +4 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/quantum-topology.js +11 -17
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/spectral-analyze.d.ts +2 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/spectral-analyze.js +51 -32
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/types.d.ts +5 -9
- package/packages/@monomind/cli/dist/src/mcp-tools/guidance-tools.js +2 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/hive-mind-tools.js +25 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-routing.d.ts +0 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-routing.js +45 -159
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-tools.js +1 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/index.d.ts +0 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/index.js +0 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/memory-tools.js +24 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +452 -7
- package/packages/@monomind/cli/dist/src/mcp-tools/neural-tools.d.ts +4 -10
- package/packages/@monomind/cli/dist/src/mcp-tools/neural-tools.js +28 -54
- package/packages/@monomind/cli/dist/src/mcp-tools/performance-tools.js +5 -17
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.js +2 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts +4 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/quality-tools.d.ts +7 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/quality-tools.js +7 -257
- package/packages/@monomind/cli/dist/src/memory/intelligence.d.ts +7 -8
- package/packages/@monomind/cli/dist/src/memory/intelligence.js +15 -16
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.d.ts +1 -0
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.js +37 -0
- package/packages/@monomind/cli/dist/src/services/worker-daemon.d.ts +3 -21
- package/packages/@monomind/cli/dist/src/services/worker-daemon.js +13 -80
- package/packages/@monomind/cli/dist/src/suggest.js +0 -5
- package/packages/@monomind/cli/package.json +1 -1
- package/packages/@monomind/guidance/README.md +49 -1153
- package/packages/@monomind/guidance/package.json +1 -74
- package/.claude/helpers/auto-memory-hook.mjs +0 -503
- package/packages/@monomind/cli/.claude/helpers/auto-memory-hook.mjs +0 -503
- package/packages/@monomind/cli/dist/src/commands/deployment.d.ts +0 -10
- package/packages/@monomind/cli/dist/src/commands/deployment.js +0 -706
|
@@ -181,106 +181,6 @@ const runCommand = {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
|
-
// Validate subcommand
|
|
185
|
-
const validateCommand = {
|
|
186
|
-
name: 'validate',
|
|
187
|
-
description: 'Validate a workflow definition',
|
|
188
|
-
options: [
|
|
189
|
-
{
|
|
190
|
-
name: 'file',
|
|
191
|
-
short: 'f',
|
|
192
|
-
description: 'Workflow definition file',
|
|
193
|
-
type: 'string',
|
|
194
|
-
required: true
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
name: 'strict',
|
|
198
|
-
short: 's',
|
|
199
|
-
description: 'Strict validation mode',
|
|
200
|
-
type: 'boolean',
|
|
201
|
-
default: false
|
|
202
|
-
}
|
|
203
|
-
],
|
|
204
|
-
examples: [
|
|
205
|
-
{ command: 'monomind workflow validate -f ./workflow.yaml', description: 'Validate workflow file' },
|
|
206
|
-
{ command: 'monomind workflow validate -f ./workflow.json --strict', description: 'Strict validation' }
|
|
207
|
-
],
|
|
208
|
-
action: async (ctx) => {
|
|
209
|
-
const rawFile = ctx.flags.file || ctx.args[0];
|
|
210
|
-
const strict = ctx.flags.strict;
|
|
211
|
-
if (!rawFile) {
|
|
212
|
-
output.printError('Workflow file is required. Use --file or -f');
|
|
213
|
-
return { success: false, exitCode: 1 };
|
|
214
|
-
}
|
|
215
|
-
// Path traversal guard: file must stay within working directory
|
|
216
|
-
const pathMod = await import('path');
|
|
217
|
-
const effectiveCwd = ctx.cwd || process.cwd();
|
|
218
|
-
const absFile = pathMod.isAbsolute(rawFile) ? rawFile : pathMod.resolve(effectiveCwd, rawFile);
|
|
219
|
-
const resolvedFile = pathMod.resolve(absFile);
|
|
220
|
-
const resolvedCwd = pathMod.resolve(effectiveCwd);
|
|
221
|
-
if (!resolvedFile.startsWith(resolvedCwd + pathMod.sep) && resolvedFile !== resolvedCwd) {
|
|
222
|
-
output.printError('Workflow file path must be within the working directory.');
|
|
223
|
-
return { success: false, exitCode: 1 };
|
|
224
|
-
}
|
|
225
|
-
const file = resolvedFile;
|
|
226
|
-
output.printInfo(`Validating: ${file}`);
|
|
227
|
-
try {
|
|
228
|
-
const result = await callMCPTool('workflow_validate', {
|
|
229
|
-
file,
|
|
230
|
-
strict,
|
|
231
|
-
});
|
|
232
|
-
if (ctx.flags.format === 'json') {
|
|
233
|
-
output.printJson(result);
|
|
234
|
-
return { success: result.valid, data: result };
|
|
235
|
-
}
|
|
236
|
-
output.writeln();
|
|
237
|
-
if (result.valid) {
|
|
238
|
-
output.printSuccess('Workflow is valid');
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
output.printError('Workflow validation failed');
|
|
242
|
-
}
|
|
243
|
-
if (result.errors.length > 0) {
|
|
244
|
-
output.writeln();
|
|
245
|
-
output.writeln(output.bold(output.error('Errors')));
|
|
246
|
-
output.printTable({
|
|
247
|
-
columns: [
|
|
248
|
-
{ key: 'line', header: 'Line', width: 8, align: 'right' },
|
|
249
|
-
{ key: 'severity', header: 'Severity', width: 10 },
|
|
250
|
-
{ key: 'message', header: 'Message', width: 50 }
|
|
251
|
-
],
|
|
252
|
-
data: result.errors
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
if (result.warnings.length > 0) {
|
|
256
|
-
output.writeln();
|
|
257
|
-
output.writeln(output.bold(output.warning('Warnings')));
|
|
258
|
-
result.warnings.forEach(w => {
|
|
259
|
-
output.writeln(output.warning(` Line ${w.line}: ${w.message}`));
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
if (result.valid) {
|
|
263
|
-
output.writeln();
|
|
264
|
-
output.writeln(output.bold('Workflow Stats'));
|
|
265
|
-
output.printList([
|
|
266
|
-
`Stages: ${result.stats.stages}`,
|
|
267
|
-
`Agents Required: ${result.stats.agents}`,
|
|
268
|
-
`Est. Duration: ${result.stats.estimatedDuration}`
|
|
269
|
-
]);
|
|
270
|
-
}
|
|
271
|
-
return { success: result.valid, data: result };
|
|
272
|
-
}
|
|
273
|
-
catch (error) {
|
|
274
|
-
if (error instanceof MCPClientError) {
|
|
275
|
-
output.printError(`Validation error: ${error.message}`);
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
output.printError(`Unexpected error: ${String(error)}`);
|
|
279
|
-
}
|
|
280
|
-
return { success: false, exitCode: 1 };
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
184
|
// List subcommand
|
|
285
185
|
const listCommand = {
|
|
286
186
|
name: 'list',
|
|
@@ -437,7 +337,7 @@ const stopCommand = {
|
|
|
437
337
|
}
|
|
438
338
|
}
|
|
439
339
|
try {
|
|
440
|
-
const result = await callMCPTool('
|
|
340
|
+
const result = await callMCPTool('workflow_cancel', {
|
|
441
341
|
workflowId,
|
|
442
342
|
graceful: !force,
|
|
443
343
|
});
|
|
@@ -588,11 +488,10 @@ const templateCommand = {
|
|
|
588
488
|
export const workflowCommand = {
|
|
589
489
|
name: 'workflow',
|
|
590
490
|
description: 'Workflow execution and management',
|
|
591
|
-
subcommands: [runCommand,
|
|
491
|
+
subcommands: [runCommand, listCommand, statusCommand, stopCommand, templateCommand],
|
|
592
492
|
options: [],
|
|
593
493
|
examples: [
|
|
594
494
|
{ command: 'monomind workflow run -t development --task "Build feature"', description: 'Run workflow' },
|
|
595
|
-
{ command: 'monomind workflow validate -f ./workflow.yaml', description: 'Validate workflow' },
|
|
596
495
|
{ command: 'monomind workflow list', description: 'List workflows' }
|
|
597
496
|
],
|
|
598
497
|
action: async () => {
|
|
@@ -604,7 +503,6 @@ export const workflowCommand = {
|
|
|
604
503
|
output.writeln('Subcommands:');
|
|
605
504
|
output.printList([
|
|
606
505
|
`${output.highlight('run')} - Execute a workflow`,
|
|
607
|
-
`${output.highlight('validate')} - Validate workflow definition`,
|
|
608
506
|
`${output.highlight('list')} - List workflows`,
|
|
609
507
|
`${output.highlight('status')} - Show workflow status`,
|
|
610
508
|
`${output.highlight('stop')} - Stop running workflow`,
|
|
@@ -423,6 +423,13 @@ export class CLI {
|
|
|
423
423
|
await initDefaultWorkers();
|
|
424
424
|
}
|
|
425
425
|
catch { /* optional */ }
|
|
426
|
+
// Start the @monomind/hooks WorkerManager (performance/health/swarm/git/learning/
|
|
427
|
+
// adr/ddd/security/patterns/cache/progress) — previously implemented but never invoked
|
|
428
|
+
try {
|
|
429
|
+
const { workerManager } = await import('@monomind/hooks');
|
|
430
|
+
await workerManager.start();
|
|
431
|
+
}
|
|
432
|
+
catch { /* optional */ }
|
|
426
433
|
// GAP-007: SwarmCheckpointer — write checkpoint files so crashed swarms can resume
|
|
427
434
|
try {
|
|
428
435
|
const { SwarmCheckpointer } = await import('@monoes/memory');
|
|
@@ -1414,11 +1414,6 @@ memory:
|
|
|
1414
1414
|
confidenceDecayRate: 0.005
|
|
1415
1415
|
accessBoostAmount: 0.03
|
|
1416
1416
|
consolidationThreshold: 10
|
|
1417
|
-
memoryGraph:
|
|
1418
|
-
enabled: ${options.runtime.enableMemoryGraph ?? true}
|
|
1419
|
-
pageRankDamping: 0.85
|
|
1420
|
-
maxNodes: 5000
|
|
1421
|
-
similarityThreshold: 0.8
|
|
1422
1417
|
agentScopes:
|
|
1423
1418
|
enabled: ${options.runtime.enableAgentScopes ?? true}
|
|
1424
1419
|
defaultScope: project
|
|
@@ -1639,8 +1634,7 @@ Monomind is a domain-driven design architecture for multi-agent AI coordination
|
|
|
1639
1634
|
| Memory Backend | ${options.runtime.memoryBackend} |
|
|
1640
1635
|
| HNSW Indexing | ${options.runtime.enableHNSW ? 'Enabled' : 'Disabled'} |
|
|
1641
1636
|
| Neural Learning | ${options.runtime.enableNeural ? 'Enabled' : 'Disabled'} |
|
|
1642
|
-
|
|
|
1643
|
-
| Knowledge Graph | ${options.runtime.enableMemoryGraph ? 'Enabled (PageRank + Communities)' : 'Disabled'} |
|
|
1637
|
+
| Learning | ${options.runtime.enableLearningBridge ? 'Enabled' : 'Disabled'} |
|
|
1644
1638
|
| Agent Scopes | ${options.runtime.enableAgentScopes ? 'Enabled (project/local/user)' : 'Disabled'} |
|
|
1645
1639
|
|
|
1646
1640
|
---
|
|
@@ -1743,8 +1737,6 @@ npx monomind@latest swarm monitor
|
|
|
1743
1737
|
| \`security\` | 6 | Security scanning |
|
|
1744
1738
|
| \`performance\` | 5 | Profiling & benchmarks |
|
|
1745
1739
|
| \`providers\` | 5 | AI provider config |
|
|
1746
|
-
|
|
1747
|
-
| \`deployment\` | 5 | Deploy management |
|
|
1748
1740
|
| \`embeddings\` | 4 | Vector embeddings |
|
|
1749
1741
|
| \`claims\` | 4 | Authorization |
|
|
1750
1742
|
| \`migrate\` | 5 | V2→V1 migration |
|
|
@@ -1841,13 +1833,10 @@ and command outcomes are recorded and scored so routing quality is measured.
|
|
|
1841
1833
|
|
|
1842
1834
|
| Component | Status | Description |
|
|
1843
1835
|
|-----------|--------|-------------|
|
|
1844
|
-
| **
|
|
1845
|
-
| **MemoryGraph** | ${options.runtime.enableMemoryGraph ? '✅ Enabled' : '⏸ Disabled'} | PageRank knowledge graph + community detection |
|
|
1836
|
+
| **Learning** | ${options.runtime.enableLearningBridge ? '✅ Enabled' : '⏸ Disabled'} | Connects insights to the pattern store |
|
|
1846
1837
|
| **AgentMemoryScope** | ${options.runtime.enableAgentScopes ? '✅ Enabled' : '⏸ Disabled'} | 3-scope agent memory (project/local/user) |
|
|
1847
1838
|
|
|
1848
|
-
**
|
|
1849
|
-
|
|
1850
|
-
**MemoryGraph** - Builds a knowledge graph from entry references. PageRank identifies influential insights. Communities group related knowledge. Graph-aware ranking blends vector + structural scores.
|
|
1839
|
+
**Learning** — Insights trigger learning trajectories. Confidence evolves: +0.03 on access, -0.005/hour decay.
|
|
1851
1840
|
|
|
1852
1841
|
**AgentMemoryScope** - Maps Claude Code 3-scope directories:
|
|
1853
1842
|
- \`project\`: \`<gitRoot>/.claude/agent-memory/<agent>/\`
|
|
@@ -933,31 +933,11 @@ async function loadMemoryPackage() {
|
|
|
933
933
|
}
|
|
934
934
|
|
|
935
935
|
async function doImport() {
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
if (!memPkg || !memPkg.AutoMemoryBridge) {
|
|
939
|
-
dim('Memory package not available — auto memory import skipped (non-critical)');
|
|
940
|
-
return;
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
// Full implementation deferred to copied version
|
|
944
|
-
dim('Auto memory import available — run init --upgrade for full support');
|
|
936
|
+
dim('Auto memory import skipped — AutoMemoryBridge removed');
|
|
945
937
|
}
|
|
946
938
|
|
|
947
939
|
async function doSync() {
|
|
948
|
-
|
|
949
|
-
dim('No entries to sync');
|
|
950
|
-
return;
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
const memPkg = await loadMemoryPackage();
|
|
954
|
-
|
|
955
|
-
if (!memPkg || !memPkg.AutoMemoryBridge) {
|
|
956
|
-
dim('Memory package not available — sync skipped (non-critical)');
|
|
957
|
-
return;
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
dim('Auto memory sync available — run init --upgrade for full support');
|
|
940
|
+
dim('Auto memory sync skipped — AutoMemoryBridge removed');
|
|
961
941
|
}
|
|
962
942
|
|
|
963
943
|
function doStatus() {
|
|
@@ -100,7 +100,6 @@ export function generateSettings(options) {
|
|
|
100
100
|
backend: options.runtime.memoryBackend,
|
|
101
101
|
enableHNSW: options.runtime.enableHNSW,
|
|
102
102
|
learningBridge: { enabled: options.runtime.enableLearningBridge ?? true },
|
|
103
|
-
memoryGraph: { enabled: options.runtime.enableMemoryGraph ?? true },
|
|
104
103
|
agentScopes: { enabled: options.runtime.enableAgentScopes ?? true },
|
|
105
104
|
},
|
|
106
105
|
neural: {
|
|
@@ -197,10 +197,8 @@ export interface RuntimeConfig {
|
|
|
197
197
|
enableHNSW: boolean;
|
|
198
198
|
/** Enable neural learning */
|
|
199
199
|
enableNeural: boolean;
|
|
200
|
-
/** Enable
|
|
200
|
+
/** Enable learning system - connects insights to the pattern store */
|
|
201
201
|
enableLearningBridge?: boolean;
|
|
202
|
-
/** Enable MemoryGraph (ADR-049) - PageRank knowledge graph */
|
|
203
|
-
enableMemoryGraph?: boolean;
|
|
204
202
|
/** Enable AgentMemoryScope (ADR-049) - 3-scope agent memory */
|
|
205
203
|
enableAgentScopes?: boolean;
|
|
206
204
|
/** CLAUDE.md template variant */
|
|
@@ -123,7 +123,6 @@ export const DEFAULT_INIT_OPTIONS = {
|
|
|
123
123
|
enableHNSW: true,
|
|
124
124
|
enableNeural: true,
|
|
125
125
|
enableLearningBridge: true,
|
|
126
|
-
enableMemoryGraph: true,
|
|
127
126
|
enableAgentScopes: true,
|
|
128
127
|
},
|
|
129
128
|
embeddings: {
|
|
@@ -187,7 +186,6 @@ export const MINIMAL_INIT_OPTIONS = {
|
|
|
187
186
|
enableHNSW: false,
|
|
188
187
|
enableNeural: false,
|
|
189
188
|
enableLearningBridge: false,
|
|
190
|
-
enableMemoryGraph: false,
|
|
191
189
|
enableAgentScopes: false,
|
|
192
190
|
},
|
|
193
191
|
embeddings: {
|
|
@@ -29,7 +29,6 @@ import { neuralTools } from './mcp-tools/neural-tools.js';
|
|
|
29
29
|
import { performanceTools } from './mcp-tools/performance-tools.js';
|
|
30
30
|
import { githubTools } from './mcp-tools/github-tools.js';
|
|
31
31
|
import { daaTools } from './mcp-tools/daa-tools.js';
|
|
32
|
-
import { coordinationTools } from './mcp-tools/coordination-tools.js';
|
|
33
32
|
import { browserTools } from './mcp-tools/browser-tools.js';
|
|
34
33
|
import { guidanceTools } from './mcp-tools/guidance-tools.js';
|
|
35
34
|
import { autopilotTools } from './mcp-tools/autopilot-tools.js';
|
|
@@ -38,8 +37,6 @@ import { graphifyTools } from './mcp-tools/graphify-tools.js';
|
|
|
38
37
|
import { monographTools } from './mcp-tools/monograph-tools.js';
|
|
39
38
|
// Coverage-aware routing tools
|
|
40
39
|
import { coverageRouterTools } from './monovector/coverage-tools.js';
|
|
41
|
-
// A2A Agent Card protocol (source: https://a2a-protocol.org)
|
|
42
|
-
import { a2aTools } from './mcp-tools/a2a-tools.js';
|
|
43
40
|
// Quality and Coherence core tools
|
|
44
41
|
import { qualityTools } from './mcp-tools/quality-tools.js';
|
|
45
42
|
import { coherenceTools } from './mcp-tools/coherence-tools.js';
|
|
@@ -82,7 +79,6 @@ registerTools([
|
|
|
82
79
|
...performanceTools,
|
|
83
80
|
...githubTools,
|
|
84
81
|
...daaTools,
|
|
85
|
-
...coordinationTools,
|
|
86
82
|
...browserTools,
|
|
87
83
|
// Guidance & discovery tools
|
|
88
84
|
...guidanceTools,
|
|
@@ -94,8 +90,6 @@ registerTools([
|
|
|
94
90
|
...graphifyTools,
|
|
95
91
|
// Coverage-aware routing tools
|
|
96
92
|
...coverageRouterTools,
|
|
97
|
-
// A2A Agent Card protocol (source: https://a2a-protocol.org)
|
|
98
|
-
...a2aTools,
|
|
99
93
|
// Quality tools
|
|
100
94
|
...qualityTools,
|
|
101
95
|
// Coherence tools
|
|
@@ -464,6 +464,22 @@ export class MCPServerManager extends EventEmitter {
|
|
|
464
464
|
}
|
|
465
465
|
const toolName = params.name;
|
|
466
466
|
const toolParams = (rawArgs || {});
|
|
467
|
+
// validateInput boundary: sanitize the incoming tool name
|
|
468
|
+
try {
|
|
469
|
+
const secMod = await import('@monomind/security').catch(() => null);
|
|
470
|
+
const validateInput = secMod?.validateInput;
|
|
471
|
+
if (validateInput) {
|
|
472
|
+
const check = validateInput(toolName, { type: 'string', maxLength: 200 });
|
|
473
|
+
if (!check.valid) {
|
|
474
|
+
return {
|
|
475
|
+
jsonrpc: '2.0',
|
|
476
|
+
id: message.id,
|
|
477
|
+
error: { code: -32602, message: `Invalid tool name: ${check.error}` },
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
catch { /* security module optional */ }
|
|
467
483
|
if (!hasTool(toolName)) {
|
|
468
484
|
return {
|
|
469
485
|
jsonrpc: '2.0',
|
|
@@ -170,17 +170,6 @@ export const agentTools = [
|
|
|
170
170
|
};
|
|
171
171
|
store.agents[agentId] = agent;
|
|
172
172
|
saveAgentStore(store);
|
|
173
|
-
// Task 46: AgentSandboxing — register sandbox for isolated agent execution
|
|
174
|
-
try {
|
|
175
|
-
const { WasmSandbox, DockerSandbox, register } = await import('@monomind/security');
|
|
176
|
-
const sandboxType = config.sandbox?.type ?? 'wasm';
|
|
177
|
-
const sandboxConfig = config.sandbox ?? {};
|
|
178
|
-
const sandbox = sandboxType === 'docker'
|
|
179
|
-
? DockerSandbox.create(agentId, sandboxConfig)
|
|
180
|
-
: WasmSandbox.create(agentId, sandboxConfig);
|
|
181
|
-
register(agentId, sandbox);
|
|
182
|
-
}
|
|
183
|
-
catch { /* optional — @monomind/security may not be installed */ }
|
|
184
173
|
// Include Agent Booster routing info if applicable
|
|
185
174
|
const response = {
|
|
186
175
|
success: true,
|
|
@@ -225,12 +214,6 @@ export const agentTools = [
|
|
|
225
214
|
if (Object.hasOwn(store.agents, agentId)) {
|
|
226
215
|
store.agents[agentId].status = 'terminated';
|
|
227
216
|
saveAgentStore(store);
|
|
228
|
-
// Task 46: AgentSandboxing — clean up sandbox on termination
|
|
229
|
-
try {
|
|
230
|
-
const { cleanup } = await import('@monomind/security');
|
|
231
|
-
cleanup(agentId);
|
|
232
|
-
}
|
|
233
|
-
catch { /* optional */ }
|
|
234
217
|
return {
|
|
235
218
|
success: true,
|
|
236
219
|
agentId,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Causal
|
|
2
|
+
* Causal Graph Analysis Tool - pr_causal_infer
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Analyzes causal graph structure to assess identifiability.
|
|
5
|
+
* Identifies confounders, finds backdoor paths, and determines
|
|
6
|
+
* whether a causal effect can be identified from the graph.
|
|
7
|
+
* Does NOT estimate causal effect magnitude (that requires data).
|
|
8
8
|
*/
|
|
9
9
|
import type { MCPTool } from './types.js';
|
|
10
10
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Causal
|
|
2
|
+
* Causal Graph Analysis Tool - pr_causal_infer
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Analyzes causal graph structure to assess identifiability.
|
|
5
|
+
* Identifies confounders, finds backdoor paths, and determines
|
|
6
|
+
* whether a causal effect can be identified from the graph.
|
|
7
|
+
* Does NOT estimate causal effect magnitude (that requires data).
|
|
8
8
|
*/
|
|
9
9
|
import { CausalInputSchema, successResult, errorResult, } from './types.js';
|
|
10
10
|
// Default logger
|
|
@@ -155,41 +155,37 @@ function validateIntervention(treatment, outcome, graph) {
|
|
|
155
155
|
return descendants.has(outcome);
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
|
-
*
|
|
159
|
-
*
|
|
158
|
+
* Assess identifiability of the causal effect based on graph structure.
|
|
159
|
+
* Does NOT estimate the causal effect magnitude -- that requires
|
|
160
|
+
* observational or experimental data which this tool does not have.
|
|
161
|
+
* Returns an identifiability score reflecting how cleanly the effect
|
|
162
|
+
* can be estimated if data were available (fewer confounders and
|
|
163
|
+
* unblocked backdoor paths = higher identifiability).
|
|
160
164
|
*/
|
|
161
|
-
function
|
|
162
|
-
//
|
|
163
|
-
// In practice, this requires observational data
|
|
164
|
-
// Base effect: based on direct path existence
|
|
165
|
-
const treatmentNode = graph.get(treatment);
|
|
166
|
-
let baseEffect = treatmentNode?.children.has(outcome) ? 0.5 : 0.3;
|
|
167
|
-
// Adjust for confounders (more confounders = less identifiable effect)
|
|
165
|
+
function assessIdentifiability(confounders, backdoorPaths) {
|
|
166
|
+
// Identifiability decreases with confounders and unblocked backdoor paths
|
|
168
167
|
const confounderPenalty = Math.min(confounders.length * 0.1, 0.3);
|
|
169
|
-
// Adjust for backdoor paths (more unblocked paths = less reliable)
|
|
170
168
|
const pathPenalty = Math.min(backdoorPaths.length * 0.05, 0.2);
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
const confidence = Math.max(0.1, 1 - confounderPenalty - pathPenalty);
|
|
174
|
-
return { effect, confidence };
|
|
169
|
+
const identifiability = Math.max(0.1, 1 - confounderPenalty - pathPenalty);
|
|
170
|
+
return { identifiability };
|
|
175
171
|
}
|
|
176
172
|
/**
|
|
177
|
-
* Get interpretation of causal analysis results
|
|
173
|
+
* Get interpretation of causal graph analysis results
|
|
178
174
|
*/
|
|
179
|
-
function getInterpretation(interventionValid, confounders, backdoorPaths,
|
|
175
|
+
function getInterpretation(interventionValid, confounders, backdoorPaths, identifiability) {
|
|
180
176
|
if (!interventionValid) {
|
|
181
177
|
return 'Intervention is not valid - no causal path exists from treatment to outcome';
|
|
182
178
|
}
|
|
183
179
|
if (confounders.length === 0 && backdoorPaths.length === 0) {
|
|
184
|
-
return 'Clean causal identification - no confounding detected';
|
|
180
|
+
return 'Clean causal identification - no confounding detected. Effect is identifiable with data.';
|
|
185
181
|
}
|
|
186
|
-
if (
|
|
187
|
-
return 'Strong
|
|
182
|
+
if (identifiability > 0.8) {
|
|
183
|
+
return 'Strong identifiability - confounders can be adjusted for with observational data';
|
|
188
184
|
}
|
|
189
|
-
if (
|
|
190
|
-
return `Moderate
|
|
185
|
+
if (identifiability > 0.5) {
|
|
186
|
+
return `Moderate identifiability - ${confounders.length} confounder(s) require adjustment`;
|
|
191
187
|
}
|
|
192
|
-
return `Weak
|
|
188
|
+
return `Weak identifiability - multiple confounders (${confounders.length}) and backdoor paths (${backdoorPaths.length}) detected`;
|
|
193
189
|
}
|
|
194
190
|
/**
|
|
195
191
|
* Handler for pr_causal_infer tool
|
|
@@ -219,10 +215,7 @@ async function handler(input, context) {
|
|
|
219
215
|
return errorResult(`Outcome variable "${outcome}" not found in graph nodes`);
|
|
220
216
|
}
|
|
221
217
|
const maxBackdoorPaths = context?.config?.causal?.maxBackdoorPaths ?? 10;
|
|
222
|
-
|
|
223
|
-
void (context?.config?.causal?.confidenceThreshold ?? 0.8);
|
|
224
|
-
let effect;
|
|
225
|
-
let confidence;
|
|
218
|
+
let identifiability;
|
|
226
219
|
let confounders;
|
|
227
220
|
let backdoorPaths;
|
|
228
221
|
let interventionValid;
|
|
@@ -231,11 +224,10 @@ async function handler(input, context) {
|
|
|
231
224
|
try {
|
|
232
225
|
logger.debug('Using WASM bridge for causal inference');
|
|
233
226
|
const result = await context.bridge.inferCausal(graph, intervention, outcome);
|
|
234
|
-
effect = result.effect;
|
|
235
|
-
confidence = result.confidence;
|
|
236
227
|
confounders = result.confounders;
|
|
237
228
|
backdoorPaths = result.backdoorPaths;
|
|
238
229
|
interventionValid = result.interventionValid;
|
|
230
|
+
identifiability = assessIdentifiability(confounders, backdoorPaths).identifiability;
|
|
239
231
|
}
|
|
240
232
|
catch (wasmError) {
|
|
241
233
|
logger.warn('WASM bridge failed, falling back to JS implementation', {
|
|
@@ -246,9 +238,7 @@ async function handler(input, context) {
|
|
|
246
238
|
interventionValid = validateIntervention(intervention, outcome, graphStructure);
|
|
247
239
|
confounders = identifyConfounders(intervention, outcome, graphStructure);
|
|
248
240
|
backdoorPaths = findBackdoorPaths(intervention, outcome, graphStructure, maxBackdoorPaths);
|
|
249
|
-
|
|
250
|
-
effect = estimation.effect;
|
|
251
|
-
confidence = estimation.confidence;
|
|
241
|
+
identifiability = assessIdentifiability(confounders, backdoorPaths).identifiability;
|
|
252
242
|
}
|
|
253
243
|
}
|
|
254
244
|
else {
|
|
@@ -258,26 +248,22 @@ async function handler(input, context) {
|
|
|
258
248
|
interventionValid = validateIntervention(intervention, outcome, graphStructure);
|
|
259
249
|
confounders = identifyConfounders(intervention, outcome, graphStructure);
|
|
260
250
|
backdoorPaths = findBackdoorPaths(intervention, outcome, graphStructure, maxBackdoorPaths);
|
|
261
|
-
|
|
262
|
-
effect = estimation.effect;
|
|
263
|
-
confidence = estimation.confidence;
|
|
251
|
+
identifiability = assessIdentifiability(confounders, backdoorPaths).identifiability;
|
|
264
252
|
}
|
|
265
253
|
const output = {
|
|
266
|
-
|
|
267
|
-
confidence,
|
|
254
|
+
identifiability,
|
|
268
255
|
backdoorPaths: backdoorPaths.map(p => p.join(' -> ')),
|
|
269
256
|
details: {
|
|
270
257
|
confounders,
|
|
271
258
|
interventionValid,
|
|
272
|
-
interpretation: getInterpretation(interventionValid, confounders, backdoorPaths,
|
|
259
|
+
interpretation: getInterpretation(interventionValid, confounders, backdoorPaths, identifiability),
|
|
273
260
|
nodeCount: graph.nodes.length,
|
|
274
261
|
edgeCount: graph.edges.length,
|
|
275
262
|
},
|
|
276
263
|
};
|
|
277
264
|
const duration = performance.now() - startTime;
|
|
278
|
-
logger.info('Causal
|
|
279
|
-
|
|
280
|
-
confidence: confidence.toFixed(4),
|
|
265
|
+
logger.info('Causal graph analysis completed', {
|
|
266
|
+
identifiability: identifiability.toFixed(4),
|
|
281
267
|
confounders: confounders.length,
|
|
282
268
|
backdoorPaths: backdoorPaths.length,
|
|
283
269
|
interventionValid,
|
|
@@ -299,7 +285,7 @@ async function handler(input, context) {
|
|
|
299
285
|
*/
|
|
300
286
|
export const causalInferTool = {
|
|
301
287
|
name: 'pr_causal_infer',
|
|
302
|
-
description: '
|
|
288
|
+
description: 'Analyze causal graph structure for identifiability. Identifies confounders, finds backdoor paths, and assesses whether a causal effect can be identified. Does not estimate effect magnitude (requires observational data).',
|
|
303
289
|
category: 'causal',
|
|
304
290
|
version: '0.1.3',
|
|
305
291
|
tags: ['causal', 'do-calculus', 'confounders', 'backdoor-paths', 'ai-interpretability'],
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Consensus Verification Tool - pr_consensus_verify
|
|
3
3
|
*
|
|
4
|
-
* Verifies multi-agent consensus
|
|
4
|
+
* Verifies multi-agent consensus using cosine-similarity coherence analysis.
|
|
5
5
|
* Identifies divergent agents and measures agreement ratios.
|
|
6
|
-
*
|
|
7
|
-
* Uses CohomologyEngine for multi-agent consensus validation
|
|
6
|
+
* Connectivity stability uses a degree-ratio heuristic (not spectral decomposition).
|
|
8
7
|
*/
|
|
9
8
|
import type { MCPTool } from './types.js';
|
|
10
9
|
/**
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Consensus Verification Tool - pr_consensus_verify
|
|
3
3
|
*
|
|
4
|
-
* Verifies multi-agent consensus
|
|
4
|
+
* Verifies multi-agent consensus using cosine-similarity coherence analysis.
|
|
5
5
|
* Identifies divergent agents and measures agreement ratios.
|
|
6
|
-
*
|
|
7
|
-
* Uses CohomologyEngine for multi-agent consensus validation
|
|
6
|
+
* Connectivity stability uses a degree-ratio heuristic (not spectral decomposition).
|
|
8
7
|
*/
|
|
9
8
|
import { ConsensusInputSchema, successResult, errorResult, cosineSimilarity, } from './types.js';
|
|
10
9
|
// Default logger
|
|
@@ -107,12 +106,17 @@ function computeVoteAgreement(agentStates) {
|
|
|
107
106
|
return maxCount / votes.length;
|
|
108
107
|
}
|
|
109
108
|
/**
|
|
110
|
-
* Compute
|
|
109
|
+
* Compute connectivity stability from similarity matrix.
|
|
110
|
+
* Uses the ratio of average to maximum degree as a connectivity proxy.
|
|
111
|
+
* A ratio near 1 means uniform connectivity; near 0 means a few nodes
|
|
112
|
+
* dominate connectivity while others are isolated.
|
|
113
|
+
* NOTE: This is NOT a true spectral gap (which requires eigendecomposition
|
|
114
|
+
* of the Laplacian). It is a lightweight degree-based heuristic.
|
|
111
115
|
*/
|
|
112
|
-
function
|
|
116
|
+
function computeConnectivityStability(similarityMatrix) {
|
|
113
117
|
const n = similarityMatrix.length;
|
|
114
118
|
if (n < 2)
|
|
115
|
-
return { stable: true,
|
|
119
|
+
return { stable: true, degreeRatio: 1 };
|
|
116
120
|
// Convert similarity to adjacency (threshold at 0.5)
|
|
117
121
|
const adjacency = [];
|
|
118
122
|
for (let i = 0; i < n; i++) {
|
|
@@ -124,7 +128,7 @@ function computeSpectralStability(similarityMatrix) {
|
|
|
124
128
|
}
|
|
125
129
|
adjacency.push(row);
|
|
126
130
|
}
|
|
127
|
-
// Compute
|
|
131
|
+
// Compute degrees
|
|
128
132
|
const degrees = [];
|
|
129
133
|
for (let i = 0; i < n; i++) {
|
|
130
134
|
let degree = 0;
|
|
@@ -134,26 +138,24 @@ function computeSpectralStability(similarityMatrix) {
|
|
|
134
138
|
}
|
|
135
139
|
degrees.push(degree);
|
|
136
140
|
}
|
|
137
|
-
// Estimate spectral gap using power iteration on Laplacian
|
|
138
|
-
// Simplified: use average degree connectivity as proxy
|
|
139
141
|
const avgDegree = degrees.reduce((a, b) => a + b, 0) / n;
|
|
140
142
|
const maxDegree = Math.max(...degrees);
|
|
141
|
-
const
|
|
142
|
-
const stable =
|
|
143
|
-
return { stable,
|
|
143
|
+
const degreeRatio = maxDegree > 0 ? avgDegree / maxDegree : 0;
|
|
144
|
+
const stable = degreeRatio > 0.3;
|
|
145
|
+
return { stable, degreeRatio };
|
|
144
146
|
}
|
|
145
147
|
/**
|
|
146
148
|
* Get interpretation of consensus results
|
|
147
149
|
*/
|
|
148
|
-
function getInterpretation(verified, coherenceScore, divergentAgents,
|
|
150
|
+
function getInterpretation(verified, coherenceScore, divergentAgents, connectivityStable) {
|
|
149
151
|
if (verified && divergentAgents.length === 0) {
|
|
150
152
|
return 'Strong consensus achieved - all agents are aligned';
|
|
151
153
|
}
|
|
152
154
|
if (verified && divergentAgents.length > 0) {
|
|
153
155
|
return `Consensus achieved with ${divergentAgents.length} minority agent(s)`;
|
|
154
156
|
}
|
|
155
|
-
if (!
|
|
156
|
-
return 'Consensus not achieved - agent network shows
|
|
157
|
+
if (!connectivityStable) {
|
|
158
|
+
return 'Consensus not achieved - agent network shows poor connectivity (uneven degree distribution)';
|
|
157
159
|
}
|
|
158
160
|
if (coherenceScore < 0.5) {
|
|
159
161
|
return 'Consensus not achieved - significant disagreement between agents';
|
|
@@ -218,7 +220,7 @@ async function handler(input, context) {
|
|
|
218
220
|
}
|
|
219
221
|
// Compute additional metrics
|
|
220
222
|
const similarityMatrix = computeSimilarityMatrix(embeddings);
|
|
221
|
-
const { stable:
|
|
223
|
+
const { stable: connectivityStable, degreeRatio } = computeConnectivityStability(similarityMatrix);
|
|
222
224
|
const voteAgreement = computeVoteAgreement(agentStates);
|
|
223
225
|
// Coherence score is inverse of energy
|
|
224
226
|
const coherenceScore = 1 - coherenceEnergy;
|
|
@@ -234,9 +236,9 @@ async function handler(input, context) {
|
|
|
234
236
|
details: {
|
|
235
237
|
agreementRatio,
|
|
236
238
|
coherenceEnergy,
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
interpretation: getInterpretation(verified, coherenceScore, divergentAgents,
|
|
239
|
+
connectivityStable,
|
|
240
|
+
degreeRatio,
|
|
241
|
+
interpretation: getInterpretation(verified, coherenceScore, divergentAgents, connectivityStable),
|
|
240
242
|
agentCount: agentStates.length,
|
|
241
243
|
},
|
|
242
244
|
};
|
|
@@ -263,7 +265,7 @@ async function handler(input, context) {
|
|
|
263
265
|
*/
|
|
264
266
|
export const consensusVerifyTool = {
|
|
265
267
|
name: 'pr_consensus_verify',
|
|
266
|
-
description: 'Verify multi-agent consensus
|
|
268
|
+
description: 'Verify multi-agent consensus using cosine-similarity coherence analysis. Identifies divergent agents, measures agreement ratios, and checks connectivity stability via degree-ratio heuristic.',
|
|
267
269
|
category: 'consensus',
|
|
268
270
|
version: '0.1.3',
|
|
269
271
|
tags: ['consensus', 'multi-agent', 'coherence', 'swarm', 'ai-interpretability'],
|