perf(metaharness): expose parallelization metrics + gate against serial regression (iter 59)

Iter 56 parallelized oia-audit's 5 subprocess calls. The speedup is
measurable but invisible from the output — anyone reverting the
parallelization wouldn't see a smoke failure, just slower runs.

Iter 59 adds the metrics to the JSON output AND a smoke gate that
asserts the parallel speedup is > 2x.

WHAT SHIPPED

plugins/ruflo-metaharness/scripts/oia-audit.mjs — new `timing` field:

   {
     "wallMs": 579,              // actual wall-clock for runAllParallel
     "sumComponentMs": 2658,     // what serial would have taken
     "parallelSpeedup": 4.59     // ratio
   }

  Measured on ruflo against itself (Apple Silicon / Node 22):
   - 5 components, each ~600ms
   - serial would be ~3.0s
   - parallel runs at 0.58s
   - speedup: 4.59x (close to theoretical 5x)

SMOKE STEP 17z22 anchors the metric:
  - timing field, wallStart marker, sumComponentMs, parallelSpeedup all present
  - RUNTIME: oia-audit --dry-run produces speedup > 2.0
    (1.0 = fully serial; 2.0 = halfway; 4-5 = expected parallel.
    Threshold 2.0 catches "someone reverted Promise.all" without
    false-positives on slow CI runners.)

GATES THIS ITER
   smoke:    61 → 62 (step 17z22 green)
   regression: drift roundtrip 31/31, no semantic change
   visibility: parallel speedup now surfaced in every audit record

The iter-56 parallelization fix is now self-documenting and gated
against silent serialization regression — closes a small but real
visibility gap.

PARALLELIZATION SWEEP RETROSPECTIVE (iters 56 → 59)
   56 — oia-audit composes 5 calls in parallel                    (5x speedup)
   57 — fixed iter-55 gaps B + C in the graceful-degradation path
   58 — drift-from-history parallelizes audit-list + oia-audit    (~30% speedup)
   59 — exposed timing metrics + smoke gate                       (visibility)

Every async path now produces observable evidence of its parallelism.
Future regression will be visible at PR-time, not as silent slowness.

Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
ruv committed 2026-06-16 20:41:46 -04:00
1 parent 2ab7a37657
commit 662bdc968e
2 files changed
+34

No files matched your search

@@ -114,11 +114,13 @@ async function main() {
}
const startedAt = new Date().toISOString();
const wallStart = Date.now();
// iter 56 — run the 5 sub-audits in parallel (was sequential pre-iter-56).
// Worst-case wall-clock improves from 5×TIMEOUT to 1×TIMEOUT in the
// unreachable-registry case; the happy path improves from sum-of-durations
// to max-of-durations (typically ~2-4× faster).
const all = await runAllParallel(ARGS.path);
const wallMs = Date.now() - wallStart;
const { oiaManifest: oia, threatModel: tm, mcpScan: mcp, score, genome } = all;
// If all FIVE say "metaharness not available", surface the degraded
@@ -147,10 +149,23 @@ async function main() {
}
}
// iter 59 — surface parallelization metrics. wallMs is the actual
// time the 5 subprocess race took (max of components); the sum of
// component.durationMs is what a SERIAL implementation would have
// taken. A future smoke gate compares them to catch silent
// serialization regression.
const sumComponentMs = Object.values(all).reduce(
(a, c) => a + (c?.durationMs ?? 0), 0);
const payload = {
path: ARGS.path,
startedAt,
finishedAt: new Date().toISOString(),
timing: {
wallMs,
sumComponentMs,
parallelSpeedup: sumComponentMs > 0
? Math.round((sumComponentMs / Math.max(wallMs, 1)) * 100) / 100 : 0,
},
composite: { worst: compositeWorst, threatModelWorst: tmWorst, mcpScanWorst: mcpWorst },
components: { oiaManifest: oia, threatModel: tm, mcpScan: mcp, score, genome },
// iter 38 — denormalized harness fingerprint for cheap similarity().
@@ -191,6 +191,25 @@ 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 "17z22. oia-audit timing field + parallel-speedup gate (iter 59)"
miss=""
OIA="$ROOT/scripts/oia-audit.mjs"
grep -q "wallStart\|wallMs = Date.now" "$OIA" 2>/dev/null || miss="$miss no-wall-start"
grep -q "timing: {" "$OIA" 2>/dev/null || miss="$miss no-timing-field"
grep -q "sumComponentMs" "$OIA" 2>/dev/null || miss="$miss no-sum-field"
grep -q "parallelSpeedup" "$OIA" 2>/dev/null || miss="$miss no-speedup-field"
# Runtime: speedup must be > 2x (sanity — sequential would be ~1x)
OUT=$(node "$OIA" --dry-run --format json 2>&1)
SPEEDUP=$(echo "$OUT" | python3 -c "
import json, sys, re
m = re.search(r'\{[\s\S]*\}', sys.stdin.read())
d = json.loads(m.group())
print(d.get('timing', {}).get('parallelSpeedup', 0))
" 2>/dev/null)
# Compare as float — speedup should exceed 2.0 (5 sequential calls → max-of-5 parallel)
python3 -c "import sys; sys.exit(0 if float('$SPEEDUP') > 2.0 else 1)" || miss="$miss serial-regression-detected:speedup=$SPEEDUP"
[[ -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"