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

test(metaharness): lock iter-50 parser at MCP layer + doctor (iter 52)

ruvf859d4d3db6e
diff --git a/plugins/ruflo-metaharness/scripts/smoke.sh b/plugins/ruflo-metaharness/scripts/smoke.sh
index b6777dcfd8..3175708289 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 "17z15. iter-50 parser locked at MCP layer + doctor (iter 52)"
+miss=""
+# MCP runtime test enrolls mcp_scan positive case
+T="$ROOT/scripts/test-mcp-tools.mjs"
+grep -q "mcp_scan positive: data.findings is an array" "$T" 2>/dev/null || miss="$miss no-mcp-findings-mcp-assert"
+grep -q "mcp_scan positive: first finding has string severity" "$T" 2>/dev/null || miss="$miss no-severity-mcp-assert"
+grep -q "mcp_scan positive: data.summary.totalCount" "$T" 2>/dev/null || miss="$miss no-summary-mcp-assert"
+# Doctor verifies parseMcpScanText export + smoke
+DOC="$ROOT/../../v3/@claude-flow/cli/src/commands/doctor.ts"
+grep -q "parseMcpScanText" "$DOC" 2>/dev/null || miss="$miss doctor-no-parser-import"
+grep -q "iter 50 β€” needed by mcp-scan + oia-audit" "$DOC" 2>/dev/null || miss="$miss doctor-no-iter50-marker"
+grep -q "parseMcpScanText returned unexpected shape" "$DOC" 2>/dev/null || miss="$miss doctor-no-empty-input-check"
+# Runtime: extended test passes (now 103+ assertions)
+node "$T" >/dev/null 2>&1 || miss="$miss runtime-fails"
+[[ -z "$miss" ]] && ok || bad "$miss"
+
step "17z14. roundtrip Stage 7 β€” drift detection actually fires on mutation (iter 51)"
miss=""
F="$ROOT/scripts/test-pipeline-roundtrip.mjs"
diff --git a/plugins/ruflo-metaharness/scripts/test-mcp-tools.mjs b/plugins/ruflo-metaharness/scripts/test-mcp-tools.mjs
index dab11c9ce5..371bc6e5b2 100755
--- a/plugins/ruflo-metaharness/scripts/test-mcp-tools.mjs
+++ b/plugins/ruflo-metaharness/scripts/test-mcp-tools.mjs
@@ -226,6 +226,46 @@ async function main() {
'similarity alertBelow=0.99 β†’ success === false (iter 44 fix)');
}
+ // metaharness_mcp_scan β€” positive case post iter-50 parser landing.
+ // Until iter 50, mcp_scan's data field was an alert-only object with
+ // no structured findings. After iter 50, findings[] is always present
+ // (parsed from upstream text) and summary{overallSeverity, totalCount}
+ // accompanies it.
+ const scanTool = tools.find((t) => t.name === 'metaharness_mcp_scan');
+ if (scanTool) {
+ // Run against ruflo itself β€” guaranteed to produce at least the
+ // INFO finding the iter-50 parser test verified manually.
+ const r = await scanTool.handler({ path: '.', failOn: 'high' });
+ // Either succeeds with structured findings, or gracefully degrades
+ // if metaharness isn't installed in this environment.
+ if (!r.degraded) {
+ assert(r.success === true, 'mcp_scan positive: success === true');
+ assert(r.exitCode === 0, 'mcp_scan positive: exitCode === 0');
+ assert(Array.isArray(r.data?.findings),
+ 'mcp_scan positive: data.findings is an array (iter 50 fix)');
+ // Cwd-dependent: when scanning a dir without .mcp/servers.json the
+ // upstream emits no findings. Only verify shape contract when array
+ // is populated β€” the array-presence assertion above is the
+ // load-bearing one for iter 50.
+ if (r.data?.findings.length > 0) {
+ const first = r.data.findings[0];
+ assert(typeof first?.severity === 'string',
+ 'mcp_scan positive: first finding has string severity');
+ assert(typeof first?.message === 'string',
+ 'mcp_scan positive: first finding has string message');
+ }
+ // summary may be null if the upstream produced no Result: line β€”
+ // verify the field's presence (null OR object) but only deep-check
+ // when populated.
+ if (r.data?.summary) {
+ assert(typeof r.data.summary.totalCount === 'number',
+ 'mcp_scan positive: data.summary.totalCount is numeric (when summary present)');
+ }
+ } else {
+ console.log(` ⊘ mcp_scan: metaharness absent β€” graceful skip`);
+ }
+ }
+
// metaharness_audit_trend β€” positive case via file inputs
const trendTool = tools.find((t) => t.name === 'metaharness_audit_trend');
if (trendTool) {
diff --git a/v3/@claude-flow/cli/src/commands/doctor.ts b/v3/@claude-flow/cli/src/commands/doctor.ts
index 810b491bf9..0ef579b083 100644
--- a/v3/@claude-flow/cli/src/commands/doctor.ts
+++ b/v3/@claude-flow/cli/src/commands/doctor.ts
@@ -643,10 +643,35 @@ async function checkMetaharnessIntegration(): Promise<HealthCheck> {
message: 'similarity() returned unexpected shape; module may be stale',
};
}
+
+ // iter 52 β€” also verify the iter-50 mcp-scan text parser exports
+ // correctly. parseMcpScanText is the shared util both mcp-scan.mjs
+ // and oia-audit.mjs depend on; if it's missing the audit-trend
+ // introduced/cleared diff silently degrades to dead code.
+ const harnessPath = join(pluginDir, 'scripts', '_harness.mjs');
+ const harnessMod = await import(harnessPath) as { parseMcpScanText?: (s: string) => unknown };
+ if (typeof harnessMod.parseMcpScanText !== 'function') {
+ return {
+ name: 'MetaHarness integration (ADR-150)',
+ status: 'fail',
+ message: '_harness.mjs does not export parseMcpScanText (iter 50 β€” needed by mcp-scan + oia-audit)',
+ fix: 'Reinstall ruflo or restore _harness.mjs from git',
+ };
+ }
+ // Smoke: parser handles empty input gracefully
+ const parsed = harnessMod.parseMcpScanText('') as { findings?: unknown };
+ if (!Array.isArray(parsed?.findings)) {
+ return {
+ name: 'MetaHarness integration (ADR-150)',
+ status: 'warn',
+ message: 'parseMcpScanText returned unexpected shape on empty input',
+ };
+ }
+
return {
name: 'MetaHarness integration (ADR-150)',
status: 'pass',
- message: 'plugin scripts intact, _similarity.mjs loads, smoke OK',
+ message: 'plugin scripts intact, _similarity.mjs + parseMcpScanText load, smoke OK',
};
} catch (e) {
return {