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

perf(metaharness): drift-from-history --baseline-file fastest path (iter 67)

ruvd1cdd2d54ba5
diff --git a/CLAUDE.md b/CLAUDE.md
index 8be059cf6f..4750821f08 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -1134,8 +1134,10 @@ npx ruflo metaharness audit-trend \ # diff two audits (drift)
npx ruflo metaharness similarity \ # iter 36 β€” ADR-152 Β§3.1 weighted similarity
--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>] [--threshold 0.95] [--dry-run]
- # iter 66 β€” --baseline-key skips audit-list (~43x faster)
+ [--baseline-since 7d] [--baseline-key <key>] [--baseline-file <path>] \
+ [--threshold 0.95] [--dry-run]
+ # iter 66 β€” --baseline-key skips audit-list (~14x faster)
+ # iter 67 β€” --baseline-file skips memory entirely (~19x faster)
npx ruflo metaharness mint --name foo --template vertical:coding --confirm
# Dedicated command
diff --git a/plugins/ruflo-metaharness/scripts/drift-from-history.mjs b/plugins/ruflo-metaharness/scripts/drift-from-history.mjs
index a144f7266b..1a76050eb6 100755
--- a/plugins/ruflo-metaharness/scripts/drift-from-history.mjs
+++ b/plugins/ruflo-metaharness/scripts/drift-from-history.mjs
@@ -46,17 +46,20 @@ const CLI_PKG = process.env.CLI_CORE === '1'
const ARGS = (() => {
const a = {
- path: '.', baselineSince: null, baselineKey: null, threshold: 0.95,
- dryRun: false, format: 'table',
+ path: '.', baselineSince: null, baselineKey: null, baselineFile: null,
+ threshold: 0.95, dryRun: false, format: 'table',
};
for (let i = 2; i < process.argv.length; i++) {
const v = process.argv[i];
if (v === '--path') a.path = process.argv[++i];
else if (v === '--baseline-since') a.baselineSince = process.argv[++i];
// iter 66 β€” explicit baseline-key skips the ONNX-heavy audit-list
- // call entirely. Cron jobs that know the key (e.g., via prior
- // audit-list invocation) avoid the ~25s warmup each tick.
+ // call entirely. Cron jobs that know the key avoid the ~25s warmup.
else if (v === '--baseline-key') a.baselineKey = process.argv[++i];
+ // iter 67 β€” baseline-file goes further: no memory call at all.
+ // Useful for CI workflows that store last-run audit as an artifact
+ // and download it for diff against fresh audit.
+ else if (v === '--baseline-file') a.baselineFile = process.argv[++i];
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];
@@ -151,7 +154,19 @@ async function main() {
let listResult;
let auditResult;
let skippedAuditList = false;
- if (ARGS.baselineKey) {
+ let usedBaselineFile = false;
+ if (ARGS.baselineFile) {
+ // iter 67 fast-fast path β€” baseline already on disk. Skip
+ // audit-list AND skip memory roundtrip when running audit-trend.
+ skippedAuditList = true;
+ usedBaselineFile = true;
+ listResult = {
+ json: { records: [{ key: `file:${ARGS.baselineFile}`, startedAt: null }] },
+ exitCode: 0, stdout: '', stderr: '', durationMs: 0,
+ };
+ auditResult = await runScriptJsonAsync('oia-audit.mjs', auditArgs);
+ auditResult.durationMs = Date.now() - auditStart;
+ } else if (ARGS.baselineKey) {
skippedAuditList = true;
// Synthesize a list result containing the user-provided key.
// No memory call needed β€” drift-from-history's downstream code
@@ -233,11 +248,20 @@ async function main() {
writeFileSync(currPath, JSON.stringify(auditResult.json));
// Step 3: audit-trend
- const trendArgs = [
- '--baseline-key', baseline.key,
- '--current', currPath,
- '--alert-on-distance-below', String(ARGS.threshold),
- ];
+ // iter 67 β€” when --baseline-file was given, pass it through as
+ // audit-trend's --baseline file input instead of --baseline-key.
+ // Avoids the memory roundtrip on the trend leg too.
+ const trendArgs = usedBaselineFile
+ ? [
+ '--baseline', ARGS.baselineFile,
+ '--current', currPath,
+ '--alert-on-distance-below', String(ARGS.threshold),
+ ]
+ : [
+ '--baseline-key', baseline.key,
+ '--current', currPath,
+ '--alert-on-distance-below', String(ARGS.threshold),
+ ];
const trendResult = runScriptJson('audit-trend.mjs', trendArgs);
if (!trendResult.json) {
emitAndExit({
@@ -262,6 +286,9 @@ async function main() {
// iter 66 β€” when true, audit-list was skipped via --baseline-key.
// Fastpath drops wall-clock from ~26s to ~1s (avoids ONNX warmup).
skippedAuditList,
+ // iter 67 β€” when true, baseline came from a file instead of memory.
+ // Skips audit-list AND the audit-trend memory roundtrip.
+ usedBaselineFile,
},
baseline: {
key: baseline.key,
diff --git a/plugins/ruflo-metaharness/scripts/smoke.sh b/plugins/ruflo-metaharness/scripts/smoke.sh
index f9a6b47e0d..25c2a04b57 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 "17z30. drift-from-history --baseline-file fastest-path (iter 67)"
+miss=""
+F="$ROOT/scripts/drift-from-history.mjs"
+grep -q -- "--baseline-file" "$F" 2>/dev/null || miss="$miss no-flag"
+grep -q "baselineFile: null" "$F" 2>/dev/null || miss="$miss no-default"
+grep -q "usedBaselineFile" "$F" 2>/dev/null || miss="$miss no-used-flag"
+grep -q "ARGS.baselineFile" "$F" 2>/dev/null || miss="$miss no-arg-read"
+# Synthetic listResult uses file: prefix to distinguish from real keys
+grep -q "file:\${ARGS.baselineFile}" "$F" 2>/dev/null || miss="$miss no-file-prefix"
+# audit-trend uses --baseline (file) not --baseline-key in fast-fast-path
+grep -q "'--baseline', ARGS.baselineFile" "$F" 2>/dev/null || miss="$miss no-baseline-file-passthrough"
+# CLAUDE.md mentions it
+CMD="$ROOT/../../CLAUDE.md"
+grep -q -- "--baseline-file <path>" "$CMD" 2>/dev/null || miss="$miss claude-md-no-flag"
+[[ -z "$miss" ]] && ok || bad "$miss"
+
step "17z29. drift-from-history --baseline-key fast-path skips audit-list (iter 66)"
miss=""
F="$ROOT/scripts/drift-from-history.mjs"
@@ -333,7 +349,8 @@ grep -q "Promise.all" "$F" 2>/dev/null || miss="$miss no-promise-all"
# Reuses auditResult from parallel batch (no second oia-audit call beyond the
# iter-66 if/else fast-path/slow-path which are mutually exclusive at runtime).
COUNT=$(grep -c "runScriptJson\(Async\)\?('oia-audit.mjs'" "$F" 2>/dev/null; true)
-[[ "$COUNT" -le 2 ]] || miss="$miss duplicate-oia-audit-calls:$COUNT"
+# 3 acceptable: iter-67 baseline-file path + iter-66 baseline-key path + iter-58 default
+[[ "$COUNT" -le 3 ]] || miss="$miss duplicate-oia-audit-calls:$COUNT"
# Comment marker
grep -q "iter 58 β€” reuse auditResult from the parallel batch" "$F" 2>/dev/null || miss="$miss no-reuse-comment"
[[ -z "$miss" ]] && ok || bad "$miss"