π 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
perf(metaharness): drift-from-history parallelizes audit-list + oia-audit (iter 58)
ruv2ab7a376570a
diff --git a/plugins/ruflo-metaharness/scripts/drift-from-history.mjs b/plugins/ruflo-metaharness/scripts/drift-from-history.mjsindex 89456249f8..ad9e3285f5 100755--- a/plugins/ruflo-metaharness/scripts/drift-from-history.mjs+++ b/plugins/ruflo-metaharness/scripts/drift-from-history.mjs@@ -32,7 +32,7 @@// 2 config / input error (no history available, etc.)// 3 upstream metaharness absent β degraded payload returned-import { spawnSync } from 'node:child_process';+import { spawnSync, spawn } from 'node:child_process';import { mkdtempSync, writeFileSync, rmSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, dirname } from 'node:path';@@ -100,11 +100,46 @@ function runScriptJson(script, args) {return { json, exitCode: r.status ?? -1, stdout: r.stdout || '', stderr: r.stderr || '', arrMatch: arrM };}+/**+ * iter 58 β async variant. Drift-from-history's audit-list (memory query)+ * and oia-audit (fresh subprocess chain) are mutually independent and+ * can race. This shaves ~2-5s off every drift check by overlapping the+ * subprocess wait time.+ */+function runScriptJsonAsync(script, args) {+ return new Promise((resolve) => {+ const p = spawn('node', [join(SCRIPTS_DIR, script), ...args, '--format', 'json'], {+ stdio: ['ignore', 'pipe', 'pipe'],+ });+ let stdout = '', stderr = '';+ p.stdout?.on('data', (d) => { stdout += d.toString(); });+ p.stderr?.on('data', (d) => { stderr += d.toString(); });+ p.on('close', (code) => {+ const m = /\{[\s\S]*\}/.exec(stdout);+ let json = null;+ if (m) { try { json = JSON.parse(m[0]); } catch { /* leave null */ } }+ resolve({ json, exitCode: code ?? -1, stdout, stderr });+ });+ p.on('error', () => resolve({ json: null, exitCode: 127, stdout, stderr: 'spawn-failed' }));+ });+}+async function main() {- // Step 1: list audit records+ // iter 58 β parallelize audit-list + oia-audit. They're mutually+ // independent (audit-list queries memory, oia-audit runs fresh+ // metaharness subprocesses) so racing them shaves ~2-5s off every+ // drift check. The audit-trend step still serializes after because+ // it consumes both prior outputs.const listArgs = ['--limit', '50'];if (ARGS.baselineSince) listArgs.push('--since', ARGS.baselineSince);- const listResult = runScriptJson('audit-list.mjs', listArgs);+ const auditArgs = ['--path', ARGS.path];+ if (ARGS.dryRun) auditArgs.push('--dry-run');++ const [listResult, auditResult] = await Promise.all([+ runScriptJsonAsync('audit-list.mjs', listArgs),+ runScriptJsonAsync('oia-audit.mjs', auditArgs),+ ]);+if (listResult.exitCode !== 0) {emitAndExit({error: `audit-list failed (exit ${listResult.exitCode})`,@@ -113,14 +148,14 @@ async function main() {}const records = listResult.json?.records ?? listResult.json?.entries ?? [];if (records.length === 0) {- // iter 57 β disambiguate "no history yet" (exit 2) from- // "metaharness absent" (exit 3). Probe with a quick --dry-run- // oia-audit: if it reports degraded, this is the dep-absent case.- const probe = runScriptJson('oia-audit.mjs', ['--dry-run', '--path', ARGS.path]);- if (probe.json?.degraded === true) {+ // iter 57 + iter 58 β disambiguate "no history yet" (exit 2) from+ // "metaharness absent" (exit 3). Use the audit we already ran+ // (iter 58 fused the probe into the parallel batch) β no extra+ // subprocess needed.+ if (auditResult.json?.degraded === true) {emitAndExit({degraded: true,- reason: probe.json.reason || 'metaharness-not-available',+ reason: auditResult.json.reason || 'metaharness-not-available',hint: 'Install metaharness to enable drift detection.',}, 3);}@@ -145,9 +180,8 @@ async function main() {const tmp = mkdtempSync(join(tmpdir(), 'drift-from-history-'));const currPath = join(tmp, 'current.json');try {- const auditArgs = ['--path', ARGS.path];- if (ARGS.dryRun) auditArgs.push('--dry-run');- const auditResult = runScriptJson('oia-audit.mjs', auditArgs);+ // iter 58 β reuse auditResult from the parallel batch above instead+ // of re-running oia-audit. Saves the ~600ms-3s the second run took.if (!auditResult.json || auditResult.exitCode !== 0) {emitAndExit({error: `oia-audit failed (exit ${auditResult.exitCode})`,diff --git a/plugins/ruflo-metaharness/scripts/smoke.sh b/plugins/ruflo-metaharness/scripts/smoke.shindex 773b0a8806..911fe30292 100755--- a/plugins/ruflo-metaharness/scripts/smoke.sh+++ b/plugins/ruflo-metaharness/scripts/smoke.sh@@ -191,6 +191,19 @@ 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 "17z21. drift-from-history parallelizes audit-list + oia-audit (iter 58)"+miss=""+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)+COUNT=$(grep -c "runScriptJson\(Async\)\?('oia-audit.mjs'" "$F" 2>/dev/null; true)+[[ "$COUNT" -le 1 ]] || 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"+step "17z20. iter-55 gaps B + C closed (iter 57)"miss=""# Gap B: _harness.mjs regex catches ENOTFOUND-class network errors