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

fix(metaharness): SEVERITY_RANK now covers iter-50 parser output (iter 62)

ruvb4ec731942ce
diff --git a/plugins/ruflo-metaharness/scripts/oia-audit.mjs b/plugins/ruflo-metaharness/scripts/oia-audit.mjs
index d2e37b4494..a77927609d 100755
--- a/plugins/ruflo-metaharness/scripts/oia-audit.mjs
+++ b/plugins/ruflo-metaharness/scripts/oia-audit.mjs
@@ -27,7 +27,41 @@
import { spawnSync } from 'node:child_process';
import { runHarness, runMetaharness, runHarnessAsync, runMetaharnessAsync, emitDegradedJsonAndExit, parseMcpScanText } from './_harness.mjs';
-const SEVERITY_RANK = { clean: 0, low: 1, medium: 2, high: 3 };
+// iter 62 β€” extended SEVERITY_RANK to include severity values the
+// iter-50 text parser actually emits. Upstream `harness mcp-scan`
+// outputs [INFO], [WARN], [HIGH], [CRITICAL] (and possibly [ERROR]).
+// Pre-iter-62, only `clean/low/medium/high` were ranked; any other
+// severity returned `undefined` from the table, and the reduce
+// expression `SEVERITY_RANK[s] > SEVERITY_RANK[acc]` evaluated to
+// false (NaN > 0 === false), silently ignoring them in the composite
+// severity rollup. A [CRITICAL] finding would NOT bump composite worst.
+//
+// Mapping rationale:
+// info β†’ 0 (informational, no harm)
+// low β†’ 1
+// medium β†’ 2
+// warn β†’ 2 (warn β‰ˆ medium)
+// high β†’ 3
+// critical β†’ 4 (critical > high β€” explicit elevation)
+// error β†’ 3 (error β‰ˆ high; some tools use ERROR for HIGH-equivalent)
+const SEVERITY_RANK = {
+ clean: 0, info: 0,
+ low: 1,
+ medium: 2, warn: 2,
+ high: 3, error: 3,
+ critical: 4,
+};
+
+// Composite severity-to-string mapping respects the new rank space:
+// anything β‰₯ 3 reports as 'high' so existing alert thresholds stay
+// honest (a CRITICAL finding triggers --alert-on-worst high).
+function rankToSeverity(rank) {
+ if (rank >= 4) return 'critical';
+ if (rank >= 3) return 'high';
+ if (rank >= 2) return 'medium';
+ if (rank >= 1) return 'low';
+ return 'clean';
+}
const NS = process.env.OIA_AUDIT_NAMESPACE || 'metaharness-audit';
const CLI_PKG = process.env.CLI_CORE === '1'
? '@claude-flow/cli-core@alpha'
@@ -131,19 +165,28 @@ async function main() {
}
// Aggregate the worst-severity signal across mcp-scan + threat-model.
+ // iter 62 β€” safe lookup using `?? 0` so unknown severities don't
+ // silently bump composite via NaN-comparison (was: `acc | undefined`
+ // β†’ reduce never updated). Now any [WARN]/[CRITICAL]/[ERROR] finding
+ // correctly elevates composite worst.
const tmWorst = String(tm.json?.worst || 'clean').toLowerCase();
const mcpFindings = Array.isArray(mcp.json?.findings) ? mcp.json.findings : [];
const mcpWorst = mcpFindings.reduce((acc, f) => {
const s = String(f.severity || 'low').toLowerCase();
- return SEVERITY_RANK[s] > SEVERITY_RANK[acc] ? s : acc;
+ const sRank = SEVERITY_RANK[s] ?? 0;
+ const accRank = SEVERITY_RANK[acc] ?? 0;
+ return sRank > accRank ? s : acc;
}, 'clean');
- const compositeWorst = SEVERITY_RANK[tmWorst] > SEVERITY_RANK[mcpWorst] ? tmWorst : mcpWorst;
+ const tmRank = SEVERITY_RANK[tmWorst] ?? 0;
+ const mcpRank = SEVERITY_RANK[mcpWorst] ?? 0;
+ const compositeWorst = tmRank > mcpRank ? tmWorst : mcpWorst;
let alertTriggered = false;
let alertReason = null;
if (ARGS.alertWorst !== null) {
- const threshold = SEVERITY_RANK[ARGS.alertWorst];
- if (SEVERITY_RANK[compositeWorst] >= threshold && threshold > 0) {
+ const threshold = SEVERITY_RANK[ARGS.alertWorst] ?? 0;
+ const compositeRank = SEVERITY_RANK[compositeWorst] ?? 0;
+ if (compositeRank >= threshold && threshold > 0) {
alertTriggered = true;
alertReason = `composite worst=${compositeWorst} β‰₯ ${ARGS.alertWorst}`;
}
diff --git a/plugins/ruflo-metaharness/scripts/smoke.sh b/plugins/ruflo-metaharness/scripts/smoke.sh
index 8fd237eae1..76598cfadf 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 "17z25. SEVERITY_RANK covers iter-50 parser output + safe ?? 0 lookup (iter 62)"
+miss=""
+OIA="$ROOT/scripts/oia-audit.mjs"
+# Extended SEVERITY_RANK has all 7 keys
+for sev in clean info low medium warn high error critical; do
+ grep -qE "\\b${sev}: [0-9]" "$OIA" 2>/dev/null || miss="$miss missing-rank-${sev}"
+done
+# Safe ?? 0 lookup eliminates NaN-compare hazard
+grep -q "SEVERITY_RANK\[s\] ?? 0\|sRank = SEVERITY_RANK" "$OIA" 2>/dev/null || miss="$miss no-safe-rank-lookup"
+# Comment block documents the rationale
+grep -q "would NOT bump composite worst" "$OIA" 2>/dev/null || miss="$miss no-rationale-comment"
+# Runtime: live oia-audit still produces clean (only INFO finding)
+OUT=$(node "$OIA" --dry-run --format json 2>/dev/null)
+echo "$OUT" | grep -q '"worst": "clean"' || miss="$miss live-not-clean"
+[[ -z "$miss" ]] && ok || bad "$miss"
+
step "17z24. doctor required-files include iter-53 + iter-56 surfaces (iter 61)"
miss=""
DOC="$ROOT/../../v3/@claude-flow/cli/src/commands/doctor.ts"