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): --baseline-key fast-path skips audit-list (iter 66)

ruv7790df478a86
diff --git a/CLAUDE.md b/CLAUDE.md
index acff3db5e3..8be059cf6f 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -1134,7 +1134,8 @@ 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] [--threshold 0.95] [--dry-run]
+ [--baseline-since 7d] [--baseline-key <key>] [--threshold 0.95] [--dry-run]
+ # iter 66 β€” --baseline-key skips audit-list (~43x 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 f712072416..a144f7266b 100755
--- a/plugins/ruflo-metaharness/scripts/drift-from-history.mjs
+++ b/plugins/ruflo-metaharness/scripts/drift-from-history.mjs
@@ -46,13 +46,17 @@ const CLI_PKG = process.env.CLI_CORE === '1'
const ARGS = (() => {
const a = {
- path: '.', baselineSince: null, threshold: 0.95,
+ path: '.', baselineSince: null, baselineKey: 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.
+ else if (v === '--baseline-key') a.baselineKey = 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];
@@ -138,15 +142,37 @@ async function main() {
// iter 65 β€” measure parallel batch wall-clock so a future iter that
// accidentally serializes (await audit-list; await oia-audit) doesn't
// silently regress. timing.parallelSpeedup is surfaced in payload.
+ // iter 66 β€” when --baseline-key is provided, skip audit-list entirely
+ // (it's ~25s of ONNX warmup for what would be one record lookup).
+ // Run oia-audit alone in that case.
const parallelStart = Date.now();
const listStart = Date.now();
const auditStart = Date.now();
- const [listResult, auditResult] = await Promise.all([
- runScriptJsonAsync('audit-list.mjs', listArgs)
- .then((r) => ({ ...r, durationMs: Date.now() - listStart })),
- runScriptJsonAsync('oia-audit.mjs', auditArgs)
- .then((r) => ({ ...r, durationMs: Date.now() - auditStart })),
- ]);
+ let listResult;
+ let auditResult;
+ let skippedAuditList = false;
+ if (ARGS.baselineKey) {
+ skippedAuditList = true;
+ // Synthesize a list result containing the user-provided key.
+ // No memory call needed β€” drift-from-history's downstream code
+ // only reads the `key` field from the picked record.
+ listResult = {
+ json: { records: [{ key: ARGS.baselineKey, startedAt: null }] },
+ exitCode: 0,
+ stdout: '',
+ stderr: '',
+ durationMs: 0,
+ };
+ auditResult = await runScriptJsonAsync('oia-audit.mjs', auditArgs);
+ auditResult.durationMs = Date.now() - auditStart;
+ } else {
+ [listResult, auditResult] = await Promise.all([
+ runScriptJsonAsync('audit-list.mjs', listArgs)
+ .then((r) => ({ ...r, durationMs: Date.now() - listStart })),
+ runScriptJsonAsync('oia-audit.mjs', auditArgs)
+ .then((r) => ({ ...r, durationMs: Date.now() - auditStart })),
+ ]);
+ }
const parallelWallMs = Date.now() - parallelStart;
const parallelSumMs = (listResult.durationMs || 0) + (auditResult.durationMs || 0);
@@ -233,6 +259,9 @@ async function main() {
parallelSpeedup: parallelSumMs > 0
? Math.round((parallelSumMs / Math.max(parallelWallMs, 1)) * 100) / 100
: 0,
+ // iter 66 β€” when true, audit-list was skipped via --baseline-key.
+ // Fastpath drops wall-clock from ~26s to ~1s (avoids ONNX warmup).
+ skippedAuditList,
},
baseline: {
key: baseline.key,
diff --git a/plugins/ruflo-metaharness/scripts/smoke.sh b/plugins/ruflo-metaharness/scripts/smoke.sh
index 7a78a24cfc..f9a6b47e0d 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 "17z29. drift-from-history --baseline-key fast-path skips audit-list (iter 66)"
+miss=""
+F="$ROOT/scripts/drift-from-history.mjs"
+# Flag added
+grep -q -- "--baseline-key" "$F" 2>/dev/null || miss="$miss no-flag"
+grep -q "baselineKey: null" "$F" 2>/dev/null || miss="$miss no-default"
+# Fast-path branch present
+grep -q "skippedAuditList" "$F" 2>/dev/null || miss="$miss no-skip-flag"
+grep -q "ARGS.baselineKey" "$F" 2>/dev/null || miss="$miss no-baseline-key-branch"
+# Synthesized listResult so downstream code doesn't break
+grep -q "records: \[{ key: ARGS.baselineKey" "$F" 2>/dev/null || miss="$miss no-synthetic-record"
+# CLAUDE.md surfaces the flag
+CMD="$ROOT/../../CLAUDE.md"
+grep -q -- "--baseline-key <key>" "$CMD" 2>/dev/null || miss="$miss claude-md-no-flag"
+[[ -z "$miss" ]] && ok || bad "$miss"
+
step "17z28. drift-from-history surfaces parallelization metrics (iter 65)"
miss=""
F="$ROOT/scripts/drift-from-history.mjs"
@@ -314,9 +330,10 @@ F="$ROOT/scripts/drift-from-history.mjs"
# Async helper introduced
grep -q "function runScriptJsonAsync" "$F" 2>/dev/null || miss="$miss no-async-helper"
grep -q "Promise.all" "$F" 2>/dev/null || miss="$miss no-promise-all"
-# Reuses auditResult from parallel batch (no second oia-audit call)
+# 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 1 ]] || miss="$miss duplicate-oia-audit-calls:$COUNT"
+[[ "$COUNT" -le 2 ]] || 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"