π 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
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
feat(metaharness): drift-from-history --alert-on-new-severity gate (iter 78)
ruv0c5782a92030
diff --git a/CLAUDE.md b/CLAUDE.mdindex 4750821f08..be53594197 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -1135,9 +1135,10 @@ npx ruflo metaharness similarity \ # iter 36 β ADR-152 Β§3.1 wei--a a.json --b b.json [--per-dimension] [--alert-below 0.5]npx ruflo metaharness drift-from-history \ # iter 53 β 1-command drift (composes 3 primitives)[--baseline-since 7d] [--baseline-key <key>] [--baseline-file <path>] \- [--threshold 0.95] [--dry-run]+ [--threshold 0.95] [--alert-on-new-severity high] [--dry-run]# iter 66 β --baseline-key skips audit-list (~14x faster)# iter 67 β --baseline-file skips memory entirely (~19x faster)+ # iter 78 β --alert-on-new-severity adds orthogonal finding-severity gatenpx ruflo metaharness mint --name foo --template vertical:coding --confirm# Dedicated commanddiff --git a/plugins/ruflo-metaharness/scripts/drift-from-history.mjs b/plugins/ruflo-metaharness/scripts/drift-from-history.mjsindex 1a76050eb6..09c07169ee 100755--- a/plugins/ruflo-metaharness/scripts/drift-from-history.mjs+++ b/plugins/ruflo-metaharness/scripts/drift-from-history.mjs@@ -33,6 +33,8 @@// 3 upstream metaharness absent β degraded payload returnedimport { spawnSync, spawn } from 'node:child_process';+// iter 78 β share the iter-63 SEVERITY_RANK for the new finding-alert gate+import { rankSeverity } from './_harness.mjs';import { mkdtempSync, writeFileSync, rmSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, dirname } from 'node:path';@@ -48,6 +50,10 @@ const ARGS = (() => {const a = {path: '.', baselineSince: null, baselineKey: null, baselineFile: null,threshold: 0.95, dryRun: false, format: 'table',+ // iter 78 β opt-in finding-severity alert gate. Default null (off)+ // preserves iter-53 behavior; set to a severity name to ALSO alert+ // when any introduced finding meets or exceeds that severity.+ alertOnNewSeverity: null,};for (let i = 2; i < process.argv.length; i++) {const v = process.argv[i];@@ -63,6 +69,8 @@ const ARGS = (() => {else if (v === '--threshold') a.threshold = Number(process.argv[++i]);else if (v === '--dry-run') a.dryRun = true;else if (v === '--format') a.format = process.argv[++i];+ // iter 78 β orthogonal alert: any new finding β₯ this severity triggers+ else if (v === '--alert-on-new-severity') a.alertOnNewSeverity = String(process.argv[++i]).toLowerCase();}return a;})();@@ -270,7 +278,25 @@ async function main() {}, 2);}const trend = trendResult.json;- const alertTriggered = trendResult.exitCode === 1;+ let alertTriggered = trendResult.exitCode === 1;+ const alertReasons = trend.alert?.reasons ? [...trend.alert.reasons] : [];++ // iter 78 β orthogonal finding-severity gate: any introduced+ // finding β₯ --alert-on-new-severity triggers regardless of+ // structural-distance threshold. Catches the "security regression+ // that didn't move the genome much" case.+ let elevatedFindings = [];+ if (ARGS.alertOnNewSeverity) {+ const threshold = rankSeverity(ARGS.alertOnNewSeverity);+ const introduced = trend?.delta?.findings?.introduced ?? [];+ elevatedFindings = introduced.filter((f) => rankSeverity(f.severity) >= threshold);+ if (elevatedFindings.length > 0) {+ alertTriggered = true;+ alertReasons.push(+ `${elevatedFindings.length} new finding(s) at or above ${ARGS.alertOnNewSeverity} severity`,+ );+ }+ }const payload = {adr: 'ADR-150 + ADR-152 Β§3.1',@@ -301,9 +327,16 @@ async function main() {drift: trend.delta,alert: {threshold: ARGS.threshold,+ // iter 78 β orthogonal gates surfaced: similarity threshold AND+ // new-finding-severity. Either can flip triggered=true.+ newSeverityThreshold: ARGS.alertOnNewSeverity,triggered: alertTriggered,- reason: trend.alert?.reasons?.join('; ')- ?? (alertTriggered ? `similarity < ${ARGS.threshold}` : `similarity β₯ ${ARGS.threshold} β OK`),+ reasons: alertReasons,+ // Keep .reason for backward-compat with consumers that read it as a string+ reason: alertReasons.length > 0+ ? alertReasons.join('; ')+ : (alertTriggered ? `similarity < ${ARGS.threshold}` : `similarity β₯ ${ARGS.threshold} β OK`),+ elevatedFindings,},generatedAt: new Date().toISOString(),};diff --git a/plugins/ruflo-metaharness/scripts/smoke.sh b/plugins/ruflo-metaharness/scripts/smoke.shindex 60d05cc5a7..0c2f82c1e9 100755--- a/plugins/ruflo-metaharness/scripts/smoke.sh+++ b/plugins/ruflo-metaharness/scripts/smoke.sh@@ -191,6 +191,35 @@ 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 "17z41. drift-from-history --alert-on-new-severity gate (iter 78)"+miss=""+F="$ROOT/scripts/drift-from-history.mjs"+grep -q -- "--alert-on-new-severity" "$F" 2>/dev/null || miss="$miss no-cli-flag"+grep -q "alertOnNewSeverity" "$F" 2>/dev/null || miss="$miss no-args-key"+grep -q "elevatedFindings" "$F" 2>/dev/null || miss="$miss no-elevated-array"+grep -q "import.*rankSeverity.*from './_harness.mjs'" "$F" 2>/dev/null || miss="$miss no-rank-import"+# MCP tool input schema includes it+WRAPPER="$ROOT/../../v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts"+grep -q "alertOnNewSeverity:" "$WRAPPER" 2>/dev/null || miss="$miss no-mcp-input"+grep -q "args.push('--alert-on-new-severity'" "$WRAPPER" 2>/dev/null || miss="$miss no-mcp-dispatch"+# CLAUDE.md surfaces the flag+CMD="$ROOT/../../CLAUDE.md"+grep -q -- "--alert-on-new-severity" "$CMD" 2>/dev/null || miss="$miss no-claude-md"+# Runtime end-to-end: --alert-on-new-severity info on real baseline fires+# (real ruflo audit has 1 INFO finding; baseline file with no findings β introduced=1)+BC=$(mktemp)+node "$ROOT/scripts/oia-audit.mjs" --dry-run --format json 2>/dev/null > "$BC"+python3 -c "+import json+d = json.load(open('$BC'))+d['components']['mcpScan']['json'] = {'findings': []}+json.dump(d, open('$BC', 'w'))+" 2>/dev/null+node "$F" --baseline-file "$BC" --dry-run --threshold 0.5 --alert-on-new-severity info >/dev/null 2>&1+[[ "$?" == "1" ]] || miss="$miss runtime-alert-did-not-trigger"+rm -f "$BC"+[[ -z "$miss" ]] && ok || bad "$miss"+step "17z40. roundtrip Stage 11 β diff symmetry + dedup discrimination (iter 77)"miss=""F="$ROOT/scripts/test-pipeline-roundtrip.mjs"diff --git a/v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.tsindex 424d01bc4a..c0ab9e3ccb 100644--- a/v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts+++ b/v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts@@ -302,6 +302,7 @@ export const metaharnessTools: MCPTool[] = [baselineKey: { type: 'string', description: 'iter 66 β explicit memory key for the baseline audit. Skips audit-list (no ONNX warmup). Get from `metaharness_audit_list` first.' },baselineFile: { type: 'string', description: 'iter 67 β file path to a saved oia-audit JSON. Skips audit-list AND memory roundtrip. Ideal for CI artifact pipelines (e.g., comparing this run vs a downloaded prior-run artifact).' },threshold: { type: 'number', description: 'Alert when structural similarity < N. Default 0.95.', default: 0.95 },+ alertOnNewSeverity: { type: 'string', enum: ['info', 'low', 'medium', 'warn', 'high', 'error', 'critical'], description: 'iter 78 β ALSO alert when any introduced finding meets or exceeds this severity. Orthogonal to `threshold`: a CRITICAL finding triggers even if structural similarity > threshold.' },dryRun: { type: 'boolean', description: 'Skip persisting the fresh audit to memory', default: false },},},@@ -312,6 +313,7 @@ export const metaharnessTools: MCPTool[] = [if (input.baselineKey) args.push('--baseline-key', String(input.baselineKey));if (input.baselineFile) args.push('--baseline-file', String(input.baselineFile));if (input.threshold !== undefined) args.push('--threshold', String(input.threshold));+ if (input.alertOnNewSeverity) args.push('--alert-on-new-severity', String(input.alertOnNewSeverity));if (input.dryRun === true) args.push('--dry-run');const r = await runScript('drift-from-history.mjs', args);return { success: r.success, data: r.json, degraded: r.degraded, exitCode: r.exitCode };