Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

feat(metaharness): MCP success-semantic footnote + audit_trend file inputs (iter 46)

ruv650568b64ca3
diff --git a/plugins/ruflo-metaharness/scripts/smoke.sh b/plugins/ruflo-metaharness/scripts/smoke.sh
index 6a0ab83dc0..ec60df5a55 100755
--- a/plugins/ruflo-metaharness/scripts/smoke.sh
+++ b/plugins/ruflo-metaharness/scripts/smoke.sh
@@ -191,6 +191,22 @@ grep -q "execCli(\[\s*'-y'\s*,\s*'metaharness@latest'" "$F" 2>/dev/null || \
grep -q "cwd: opts" "$F" || miss="$miss no-cwd-passthrough"
[[ -z "$miss" ]] && ok || bad "$miss"
+step "17z9. MCP success-semantic footnote + audit_trend file inputs (iter 46)"
+miss=""
+WRAPPER="$ROOT/../../v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts"
+# Success-semantic constant declared + appended to 8 descriptions = 9 occurrences
+COUNT=$(grep -c "MCP_SUCCESS_SEMANTIC" "$WRAPPER" 2>/dev/null; true)
+[[ "$COUNT" == "9" ]] || miss="$miss footnote-count:$COUNT-expected-9"
+# audit_trend now exposes baselineFile / currentFile
+grep -q "baselineFile" "$WRAPPER" 2>/dev/null || miss="$miss no-baseline-file"
+grep -q "currentFile" "$WRAPPER" 2>/dev/null || miss="$miss no-current-file"
+# alertOnDistanceBelow exposed (iter 38 distance gate)
+grep -q "alertOnDistanceBelow" "$WRAPPER" 2>/dev/null || miss="$miss no-distance-input"
+# Phase 4 has the file-input assertion
+T="$ROOT/scripts/test-mcp-tools.mjs"
+grep -q "audit_trend file-input path: success === true" "$T" 2>/dev/null || miss="$miss no-file-input-assert"
+[[ -z "$miss" ]] && ok || bad "$miss"
+
step "17z8. ruflo doctor checks the integration layer, not just upstream (iter 45)"
miss=""
DOC="$ROOT/../../v3/@claude-flow/cli/src/commands/doctor.ts"
diff --git a/plugins/ruflo-metaharness/scripts/test-mcp-tools.mjs b/plugins/ruflo-metaharness/scripts/test-mcp-tools.mjs
index 6ced39d5f1..dab11c9ce5 100755
--- a/plugins/ruflo-metaharness/scripts/test-mcp-tools.mjs
+++ b/plugins/ruflo-metaharness/scripts/test-mcp-tools.mjs
@@ -256,6 +256,16 @@ async function main() {
// This is a real wrapper bug (success should not be true when
// exit!=0 AND no JSON came back), tracked separately. Asserting
// current behavior here protects against silent semantic shifts.
+ // iter 46 β€” file-input path. audit_trend now accepts baselineFile/currentFile.
+ const rFiles = await trendTool.handler({ baselineFile: basePath, currentFile: currPath });
+ assert(rFiles.success === true,
+ 'audit_trend file-input path: success === true (iter 46)');
+ assert(rFiles.exitCode === 0, 'audit_trend file-input path: exitCode === 0');
+ assert(typeof rFiles.data?.delta === 'object',
+ 'audit_trend file-input path: data.delta object present');
+ assert(rFiles.data?.delta?.structuralDistance?.verdict === 'near-identical',
+ `audit_trend file-input path: identical fingerprints β†’ near-identical (got ${rFiles.data?.delta?.structuralDistance?.verdict})`);
+
const r = await trendTool.handler({ baselineKey: 'missing-X', currentKey: 'missing-Y' });
assert(r.exitCode === 2,
'audit_trend bad-keys path exits 2 (script-level guard fires)');
diff --git a/v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts
index 03ced5eed9..9011281245 100644
--- a/v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts
+++ b/v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts
@@ -136,10 +136,22 @@ function runScript(scriptName: string, args: string[]): Promise<{
});
}
+/**
+ * iter 46 β€” success-semantic footnote appended to every tool description
+ * so agents reading the registry know how to interpret the return shape.
+ * Reflects the iter-44 fix: `success` derives from exitCode, not from the
+ * degraded marker. Three observable cases an agent can branch on.
+ */
+const MCP_SUCCESS_SEMANTIC =
+ '[Return shape: {success, data, degraded, exitCode}. success===true iff exitCode===0 ' +
+ '(includes graceful-degradation path where dep is absent β€” check degraded for that). ' +
+ 'success===false with exitCode===1 = intentional alert exit (read data.alert.triggered). ' +
+ 'success===false with exitCode===2 = input error (data is null).]';
+
export const metaharnessTools: MCPTool[] = [
{
name: 'metaharness_score',
- description: 'ADR-150 β€” 5-dimension harness readiness scorecard from `metaharness score <path>` (harnessFit / compileConfidence / taskCoverage / toolSafety / memoryUsefulness + estCostPerRunUsd). Pure-read subprocess; graceful degradation when metaharness optional dep absent. Use BEFORE recommending the user run `ruflo metaharness mint` so you have an evidence-based readiness signal.',
+ description: 'ADR-150 β€” 5-dimension harness readiness scorecard from `metaharness score <path>` (harnessFit / compileConfidence / taskCoverage / toolSafety / memoryUsefulness + estCostPerRunUsd). Pure-read subprocess; graceful degradation when metaharness optional dep absent. Use BEFORE recommending the user run `ruflo metaharness mint` so you have an evidence-based readiness signal. ' + MCP_SUCCESS_SEMANTIC,
category: 'metaharness',
inputSchema: {
type: 'object',
@@ -158,7 +170,7 @@ export const metaharnessTools: MCPTool[] = [
},
{
name: 'metaharness_genome',
- description: 'ADR-150 β€” 7-section categorical readiness report from `metaharness genome <path>` (repo_type / agent_topology / risk_score / mcp_surface / test_confidence / publish_readiness). Pairs with metaharness_score for the full readiness view β€” score is numeric, genome is categorical.',
+ description: 'ADR-150 β€” 7-section categorical readiness report from `metaharness genome <path>` (repo_type / agent_topology / risk_score / mcp_surface / test_confidence / publish_readiness). Pairs with metaharness_score for the full readiness view β€” score is numeric, genome is categorical. ' + MCP_SUCCESS_SEMANTIC,
category: 'metaharness',
inputSchema: {
type: 'object',
@@ -177,7 +189,7 @@ export const metaharnessTools: MCPTool[] = [
},
{
name: 'metaharness_mcp_scan',
- description: 'ADR-150 β€” static security scan of `.mcp/servers.json` + `.harness/claims.json` via `harness mcp-scan <path>`. Reads only; no dispatch. Use before exposing a new MCP server config to humans/agents.',
+ description: 'ADR-150 β€” static security scan of `.mcp/servers.json` + `.harness/claims.json` via `harness mcp-scan <path>`. Reads only; no dispatch. Use before exposing a new MCP server config to humans/agents. ' + MCP_SUCCESS_SEMANTIC,
category: 'metaharness',
inputSchema: {
type: 'object',
@@ -195,7 +207,7 @@ export const metaharnessTools: MCPTool[] = [
},
{
name: 'metaharness_threat_model',
- description: 'ADR-150 β€” enterprise-grade threat model from `harness threat-model <path>`. Returns worst-severity verdict (clean/low/medium/high) + categorized findings suitable for sharing with infosec.',
+ description: 'ADR-150 β€” enterprise-grade threat model from `harness threat-model <path>`. Returns worst-severity verdict (clean/low/medium/high) + categorized findings suitable for sharing with infosec. ' + MCP_SUCCESS_SEMANTIC,
category: 'metaharness',
inputSchema: {
type: 'object',
@@ -213,7 +225,7 @@ export const metaharnessTools: MCPTool[] = [
},
{
name: 'metaharness_oia_audit',
- description: 'ADR-150 β€” composite weekly audit. Bundles oia-manifest + threat-model + mcp-scan into one timestamped record persisted to `metaharness-audit` memory namespace (or --dry-run to skip persistence). Designed for periodic drift detection.',
+ description: 'ADR-150 β€” composite weekly audit. Bundles oia-manifest + threat-model + mcp-scan into one timestamped record persisted to `metaharness-audit` memory namespace (or --dry-run to skip persistence). Designed for periodic drift detection. ' + MCP_SUCCESS_SEMANTIC,
category: 'metaharness',
inputSchema: {
type: 'object',
@@ -234,7 +246,7 @@ export const metaharnessTools: MCPTool[] = [
},
{
name: 'metaharness_audit_list',
- description: 'ADR-150 iter 16 β€” list timestamped records from the `metaharness-audit` memory namespace. Use this BEFORE metaharness_audit_trend to discover which audit keys exist to diff.',
+ description: 'ADR-150 iter 16 β€” list timestamped records from the `metaharness-audit` memory namespace. Use this BEFORE metaharness_audit_trend to discover which audit keys exist to diff. ' + MCP_SUCCESS_SEMANTIC,
category: 'metaharness',
inputSchema: {
type: 'object',
@@ -253,7 +265,7 @@ export const metaharnessTools: MCPTool[] = [
},
{
name: 'metaharness_similarity',
- description: 'ADR-152 Β§3.1 β€” weighted similarity between two harness fingerprints (genome + score JSON). Returns overall ∈ [0,1] plus per-component breakdown (cosine over 9 numerics, categorical over 4 enums, jaccard over agent_topology). Pure-TS, zero `@metaharness/*` dep. Use to (a) rank candidate templates against a target repo, (b) decide fork-vs-scaffold, (c) feed ADR-151 Β§3.2 Recommender / Β§3.3 Drift / Β§3.5 Plugin Compat.',
+ description: 'ADR-152 Β§3.1 β€” weighted similarity between two harness fingerprints (genome + score JSON). Returns overall ∈ [0,1] plus per-component breakdown (cosine over 9 numerics, categorical over 4 enums, jaccard over agent_topology). Pure-TS, zero `@metaharness/*` dep. Use to (a) rank candidate templates against a target repo, (b) decide fork-vs-scaffold, (c) feed ADR-151 Β§3.2 Recommender / Β§3.3 Drift / Β§3.5 Plugin Compat. ' + MCP_SUCCESS_SEMANTIC,
category: 'metaharness',
inputSchema: {
type: 'object',
@@ -280,22 +292,29 @@ export const metaharnessTools: MCPTool[] = [
},
{
name: 'metaharness_audit_trend',
- description: 'ADR-150 iter 15 β€” diff two oia-audit records (drift detection). Pulls baseline + current snapshots from the `metaharness-audit` memory namespace and surfaces composite worst-severity delta + per-component status change + introduced/cleared findings.',
+ description: 'ADR-150 iter 15 β€” diff two oia-audit records (drift detection). Accepts EITHER memory keys (run metaharness_audit_list first to discover them) OR direct file paths (useful for diffing CI artifacts). Surfaces composite worst-severity delta + per-component status change + introduced/cleared findings + (iter 38) ADR-152 Β§3.1 structural distance when both records carry a fingerprint. ' + MCP_SUCCESS_SEMANTIC,
category: 'metaharness',
inputSchema: {
type: 'object',
properties: {
- baselineKey: { type: 'string', description: 'Memory key for the older audit (run metaharness_audit_list first to discover keys)' },
- currentKey: { type: 'string', description: 'Memory key for the newer audit' },
+ baselineKey: { type: 'string', description: 'Memory key for the older audit (mutually exclusive with baselineFile)' },
+ currentKey: { type: 'string', description: 'Memory key for the newer audit (mutually exclusive with currentFile)' },
+ baselineFile: { type: 'string', description: 'iter 46 β€” file path to older audit JSON (mutually exclusive with baselineKey)' },
+ currentFile: { type: 'string', description: 'iter 46 β€” file path to newer audit JSON (mutually exclusive with currentKey)' },
alertOnWorsening: { type: 'boolean', description: 'Set tool.alert.triggered when composite worst severity worsened', default: false },
+ alertOnDistanceBelow: { type: 'number', description: 'iter 38 β€” set tool.alert.triggered when structural similarity falls below N (uses fingerprint field added in iter 38; older records emit verdict=unavailable)' },
},
- required: ['baselineKey', 'currentKey'],
+ // No required[] β€” caller picks key OR file inputs. The script
+ // emits a graceful degraded payload if neither is supplied.
},
handler: async (input) => {
- const baselineKey = input.baselineKey as string;
- const currentKey = input.currentKey as string;
- const args = ['--baseline-key', baselineKey, '--current-key', currentKey];
+ const args: string[] = [];
+ if (input.baselineKey) args.push('--baseline-key', String(input.baselineKey));
+ if (input.currentKey) args.push('--current-key', String(input.currentKey));
+ if (input.baselineFile) args.push('--baseline', String(input.baselineFile));
+ if (input.currentFile) args.push('--current', String(input.currentFile));
if (input.alertOnWorsening === true) args.push('--alert-on-worsening');
+ if (input.alertOnDistanceBelow !== undefined) args.push('--alert-on-distance-below', String(input.alertOnDistanceBelow));
const r = await runScript('audit-trend.mjs', args);
return { success: r.success, data: r.json, degraded: r.degraded, exitCode: r.exitCode };
},