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 9 β€” drift-from-history fastpath catches mutation (iter 75)

ruv6ace68c0efc9
diff --git a/plugins/ruflo-metaharness/scripts/smoke.sh b/plugins/ruflo-metaharness/scripts/smoke.sh
index 58e93ec30e..e09e4021c2 100755
--- a/plugins/ruflo-metaharness/scripts/smoke.sh
+++ b/plugins/ruflo-metaharness/scripts/smoke.sh
@@ -191,6 +191,18 @@ 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 "17z38. roundtrip Stage 9 β€” drift-from-history fastpath catches mutation (iter 75)"
+miss=""
+F="$ROOT/scripts/test-pipeline-roundtrip.mjs"
+grep -q "Stage 9 β€” drift-from-history fastpath catches mutation" "$F" 2>/dev/null || miss="$miss no-stage-9"
+grep -q "Stage 9 fastpath: usedBaselineFile === true" "$F" 2>/dev/null || miss="$miss no-fastpath-assert"
+grep -q "Stage 9: verdict !== near-identical" "$F" 2>/dev/null || miss="$miss no-verdict-flip-assert"
+grep -q "Stage 9: --threshold 0.95 fires on mutated baseline via fastpath" "$F" 2>/dev/null || miss="$miss no-alert-fires-assert"
+grep -q "Stage 9: drift-from-history exit=1" "$F" 2>/dev/null || miss="$miss no-exit-1-assert"
+# Runtime: roundtrip passes (β‰₯46 β€” iter 75 took it from 38)
+node "$F" 2>&1 | grep -qE "(4[6-9]|[5-9][0-9]+) passed, 0 failed" || miss="$miss roundtrip-fewer-than-46"
+[[ -z "$miss" ]] && ok || bad "$miss"
+
step "17z37. ADR-150 architectural-constraint negative guards (iter 74)"
miss=""
# Guard 1 β€” ADR-150 Β§Sandboxing: `harness from-repo` must never be wrapped
diff --git a/plugins/ruflo-metaharness/scripts/test-pipeline-roundtrip.mjs b/plugins/ruflo-metaharness/scripts/test-pipeline-roundtrip.mjs
index 23754f53a5..75eb5b4490 100755
--- a/plugins/ruflo-metaharness/scripts/test-pipeline-roundtrip.mjs
+++ b/plugins/ruflo-metaharness/scripts/test-pipeline-roundtrip.mjs
@@ -340,6 +340,53 @@ try {
assert(dfh.alert?.triggered === false,
'drift-from-history self-match alert NOT triggered at default threshold (0.95)');
+ // ──────────────────────────────────────────────────────────────
+ // STAGE 9 (iter 75) β€” drift-from-history detects drift via fast path
+ //
+ // Stage 8 proved the fast path correctly identifies self-match.
+ // This stage proves it also CATCHES drift β€” feeds a mutated baseline
+ // file and asserts the verdict flips. Without this, a regression
+ // that breaks the fast path's similarity computation would still
+ // pass Stage 8 (which only checks the identity case).
+ //
+ // Mutation: re-uses Stage 7's mutated audit shape, written to a
+ // separate baseline file. drift-from-history runs fresh oia-audit
+ // against current state and diffs against the mutated baseline.
+ // ──────────────────────────────────────────────────────────────
+ console.log('\nStage 9 β€” drift-from-history fastpath catches mutation (iter 75)');
+ // mutatedPath was already populated in Stage 7. Re-use as baseline-file.
+ const dfhDriftRun = runNode('drift-from-history.mjs', [
+ '--baseline-file', mutatedPath,
+ '--dry-run',
+ '--threshold', '0.95',
+ '--format', 'json',
+ ], 120_000);
+ const dfhDriftMatch = /\{[\s\S]*\}/.exec(dfhDriftRun.stdout);
+ assert(dfhDriftMatch !== null, 'drift-from-history with mutated baseline produced JSON');
+ const dfhDrift = JSON.parse(dfhDriftMatch[0]);
+
+ // Fast path still fired
+ assert(dfhDrift.timing?.usedBaselineFile === true,
+ 'Stage 9 fastpath: usedBaselineFile === true');
+
+ // Drift detected β€” same invariants as Stage 7 but via the wrapper
+ const dfhSd = dfhDrift.drift?.structuralDistance;
+ assert(typeof dfhSd === 'object', 'Stage 9: structuralDistance present');
+ assert(dfhSd.verdict !== 'near-identical',
+ `Stage 9: verdict !== near-identical (got ${dfhSd?.verdict}) β€” fastpath catches drift`);
+ assert(dfhSd.overall < 1,
+ `Stage 9: overall < 1 (got ${dfhSd?.overall})`);
+ assert(dfhSd.distance > 0,
+ `Stage 9: distance > 0 (got ${dfhSd?.distance})`);
+
+ // Alert end-to-end via the fast path
+ // (mutation pushes overall ~0.7, below default 0.95 threshold β†’ triggered)
+ assert(dfhDrift.alert?.triggered === true,
+ 'Stage 9: --threshold 0.95 fires on mutated baseline via fastpath');
+ // Exit code reflects alert
+ assert(dfhDriftRun.status === 1,
+ `Stage 9: drift-from-history exit=1 when alert triggered (got ${dfhDriftRun.status})`);
+
} finally {
try { rmSync(tmp, { recursive: true, force: true }); } catch { /* ignore */ }
}