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): roundtrip Stage 10 β€” introduced/cleared findings diff (iter 76)

ruv1a4fe374a36d
diff --git a/plugins/ruflo-metaharness/scripts/smoke.sh b/plugins/ruflo-metaharness/scripts/smoke.sh
index e09e4021c2..cf3b5de459 100755
--- a/plugins/ruflo-metaharness/scripts/smoke.sh
+++ b/plugins/ruflo-metaharness/scripts/smoke.sh
@@ -191,6 +191,19 @@ 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 "17z39. roundtrip Stage 10 β€” introduced/cleared findings diff functional (iter 76)"
+miss=""
+F="$ROOT/scripts/test-pipeline-roundtrip.mjs"
+grep -q "Stage 10 β€” introduced/cleared findings diff" "$F" 2>/dev/null || miss="$miss no-stage-10"
+grep -q "iter-76-synthetic-finding" "$F" 2>/dev/null || miss="$miss no-synthetic-finding-id"
+grep -q "clearedCount === 1" "$F" 2>/dev/null || miss="$miss no-cleared-assert"
+grep -q "introducedCount === 0" "$F" 2>/dev/null || miss="$miss no-introduced-zero-assert"
+grep -q "cleared finding severity preserved" "$F" 2>/dev/null || miss="$miss no-severity-preserved"
+grep -q "cleared finding id preserved" "$F" 2>/dev/null || miss="$miss no-id-preserved"
+# Runtime: roundtrip passes (β‰₯51 β€” iter 76 took it from 46)
+node "$F" 2>&1 | grep -qE "(5[1-9]|[6-9][0-9]+) passed, 0 failed" || miss="$miss roundtrip-fewer-than-51"
+[[ -z "$miss" ]] && ok || bad "$miss"
+
step "17z38. roundtrip Stage 9 β€” drift-from-history fastpath catches mutation (iter 75)"
miss=""
F="$ROOT/scripts/test-pipeline-roundtrip.mjs"
diff --git a/plugins/ruflo-metaharness/scripts/test-pipeline-roundtrip.mjs b/plugins/ruflo-metaharness/scripts/test-pipeline-roundtrip.mjs
index 75eb5b4490..3d05941e20 100755
--- a/plugins/ruflo-metaharness/scripts/test-pipeline-roundtrip.mjs
+++ b/plugins/ruflo-metaharness/scripts/test-pipeline-roundtrip.mjs
@@ -387,6 +387,61 @@ try {
assert(dfhDriftRun.status === 1,
`Stage 9: drift-from-history exit=1 when alert triggered (got ${dfhDriftRun.status})`);
+ // ──────────────────────────────────────────────────────────────
+ // STAGE 10 (iter 76) β€” introduced/cleared findings diff actually works
+ //
+ // Iter 49 documented that mcp-scan emitted text only β†’ audit-trend's
+ // findings.introducedCount was dead code. Iter 50 added the parser
+ // so findings ARE populated. But no test verified the diff on a
+ // REAL finding-set change β€” Stage 7 mutates only the fingerprint
+ // (score/genome), leaving mcpScan.json.findings unchanged.
+ //
+ // This stage takes the real audit (Stage 1) and mutates ONLY
+ // mcpScan.json.findings β€” adds a synthetic finding to the baseline.
+ // audit-trend should report clearedCount === 1 (the synthetic
+ // disappeared in the current audit) with severity preserved.
+ // ──────────────────────────────────────────────────────────────
+ console.log('\nStage 10 β€” introduced/cleared findings diff (iter 76 β€” locks iter-50 fix)');
+ const findingsBasePath = join(tmp, 'findings-base.json');
+ const findingsMutated = JSON.parse(JSON.stringify(audit));
+ // Ensure mcpScan.json.findings exists (it should post-iter-50)
+ if (!findingsMutated.components?.mcpScan?.json?.findings) {
+ findingsMutated.components.mcpScan = findingsMutated.components.mcpScan ?? {};
+ findingsMutated.components.mcpScan.json = findingsMutated.components.mcpScan.json ?? {};
+ findingsMutated.components.mcpScan.json.findings = [];
+ }
+ // Append a synthetic finding that wouldn't appear in a fresh audit.
+ findingsMutated.components.mcpScan.json.findings.push({
+ severity: 'medium',
+ id: 'iter-76-synthetic-finding',
+ server: 'synthetic-server',
+ tool: 'synthetic-tool',
+ message: 'Stage 10 synthetic finding for clearedCount verification',
+ });
+ writeFileSync(findingsBasePath, JSON.stringify(findingsMutated));
+
+ // Diff: baseline has the synthetic, current (real audit) doesn't β†’
+ // expect clearedCount === 1, introducedCount === 0.
+ const findingsTrendRun = runNode('audit-trend.mjs', [
+ '--baseline', findingsBasePath,
+ '--current', basePath, // basePath = unmodified audit
+ '--format', 'json',
+ ], 60_000);
+ const findingsTrendMatch = /\{[\s\S]*\}/.exec(findingsTrendRun.stdout);
+ assert(findingsTrendMatch !== null, 'Stage 10: audit-trend produced JSON');
+ const findingsTrend = JSON.parse(findingsTrendMatch[0]);
+
+ assert(findingsTrend.delta?.findings?.clearedCount === 1,
+ `Stage 10: clearedCount === 1 (got ${findingsTrend.delta?.findings?.clearedCount}) β€” iter-50 fix functional`);
+ assert(findingsTrend.delta?.findings?.introducedCount === 0,
+ `Stage 10: introducedCount === 0 (got ${findingsTrend.delta?.findings?.introducedCount})`);
+ // Cleared finding's severity preserved through the diff
+ const cleared = findingsTrend.delta?.findings?.cleared?.[0];
+ assert(cleared?.severity === 'medium',
+ `Stage 10: cleared finding severity preserved (got ${cleared?.severity})`);
+ assert(cleared?.id === 'iter-76-synthetic-finding',
+ 'Stage 10: cleared finding id preserved');
+
} finally {
try { rmSync(tmp, { recursive: true, force: true }); } catch { /* ignore */ }
}