test(metaharness): roundtrip exercises drift-from-history end-to-end (iter 68)

Stages 1-7 tested audit-trend (the underlying primitive). NONE tested
the iter-53 user-facing wrapper drift-from-history. If iter 66's
--baseline-key or iter 67's --baseline-file fast-paths silently broke,
the roundtrip would still pass while the actual user surface returned
wrong data. Stage 8 closes that gap.

WHAT SHIPPED — test-pipeline-roundtrip.mjs Stage 8

Invokes drift-from-history.mjs through the iter-67 fastest path
(--baseline-file pointing at the audit captured in Stage 1) and
asserts:

  ✓ produced valid JSON
  ✓ timing.skippedAuditList === true       (iter-66 contract)
  ✓ timing.usedBaselineFile === true       (iter-67 contract)
  ✓ timing.parallelWallMs < 30s            (fastpath budget — slow
                                            path is 26s minimum)
  ✓ drift.structuralDistance.overall === 1 (self-match similarity)
  ✓ drift.structuralDistance.verdict === 'near-identical'
  ✓ alert.triggered === false              (default 0.95 threshold)

The 30s wall budget is the load-bearing fastpath assertion. If
iter-67's --baseline-file flag is removed or the fast-path branch
is bypassed, audit-list will fire and wall will exceed 26s, failing
Stage 8.

SMOKE STEP 17z31 anchors:
  - Stage 8 section header literal
  - All 5 critical assertions (skippedAuditList, usedBaselineFile,
    wall budget, overall===1, alert-not-fired)
  - Runtime: roundtrip 38/38 (was 31/31)

GATES THIS ITER
   smoke:    70 → 71 (step 17z31 green)
   runtime:  pipeline assertions 31 → 38 (+7 for Stage 8)
   roundtrip wall: full test ~2.5s on Apple Silicon
              (Stage 8 alone adds ~1.4s — the fastpath itself)

COVERAGE GAP CLOSED

Before iter 68, drift-from-history.mjs was tested at:
   - Iter-23 MCP runtime contract (Phase 3 — handler shape only)
   - Iter-43 Phase 4 (positive-case via fake mem keys — degraded path)
   - Iter-54 Phase 4 (MCP tool layer — degraded path again)

NONE exercised the actual fast-path end-to-end with real audit data.
Stage 8 is the first test that:
   1. Runs real oia-audit (Stage 1)
   2. Uses its output as baseline-file input to drift-from-history
   3. Re-runs oia-audit inside drift-from-history (fresh audit)
   4. Confirms similarity=1, verdict=near-identical, alert not fired

A future regression in:
   - Synthetic listResult shape
   - audit-trend --baseline file dispatch
   - timing field surfacing
would surface immediately as Stage 8 failure.

ITER 47-68 ROUNDTRIP COVERAGE EXPANSION
   47 — basic roundtrip (15 assertions)
   49 — non-similarity schemas (24 assertions)
   50 — mcp-scan findings parsed
   51 — drift detection on mutation (31 assertions)
   68 — drift-from-history end-to-end (38 assertions)

Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
ruv committed 2026-06-16 21:40:58 -04:00
1 parent d1cdd2d54b
commit a5540a0dba
2 files changed
+49

No files matched your search

@@ -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 "17z31. roundtrip Stage 8 — drift-from-history end-to-end (iter 68)"
miss=""
F="$ROOT/scripts/test-pipeline-roundtrip.mjs"
grep -q "Stage 8 — drift-from-history end-to-end" "$F" 2>/dev/null || miss="$miss no-stage-8"
grep -q "drift-from-history --baseline-file → skippedAuditList === true" "$F" 2>/dev/null || miss="$miss no-iter66-assert"
grep -q "drift-from-history --baseline-file → usedBaselineFile === true" "$F" 2>/dev/null || miss="$miss no-iter67-assert"
grep -q "fastpath wall < 30s" "$F" 2>/dev/null || miss="$miss no-wall-budget"
grep -q "drift-from-history self-match overall === 1" "$F" 2>/dev/null || miss="$miss no-self-match-assert"
grep -q "alert NOT triggered at default threshold" "$F" 2>/dev/null || miss="$miss no-alert-not-fired"
# Runtime: roundtrip passes (≥38 — iter 68 took it from 31, future iters keep climbing)
node "$F" 2>&1 | grep -qE "(3[8-9]|[4-9][0-9]+) passed, 0 failed" || miss="$miss roundtrip-fewer-than-38"
[[ -z "$miss" ]] && ok || bad "$miss"
step "17z30. drift-from-history --baseline-file fastest-path (iter 67)"
miss=""
F="$ROOT/scripts/drift-from-history.mjs"
@@ -304,6 +304,42 @@ try {
assert(trend.delta?.findings?.clearedCount === 0,
`self-roundtrip clearedCount === 0 (got ${trend.delta?.findings?.clearedCount})`);
// ──────────────────────────────────────────────────────────────
// STAGE 8 (iter 68) — drift-from-history end-to-end via --baseline-file
//
// Every prior stage tested audit-trend (the underlying primitive).
// None tested drift-from-history (the iter-53 user-facing wrapper).
// This stage runs the iter-67 fastest path: baseline from a file,
// skipping audit-list AND memory roundtrip entirely.
// ──────────────────────────────────────────────────────────────
console.log('\nStage 8 — drift-from-history end-to-end (iter 68)');
const driftFromHistoryRun = runNode('drift-from-history.mjs', [
'--baseline-file', basePath,
'--dry-run',
'--format', 'json',
], 120_000);
const driftFromHistoryMatch = /\{[\s\S]*\}/.exec(driftFromHistoryRun.stdout);
assert(driftFromHistoryMatch !== null, 'drift-from-history produced JSON');
const dfh = JSON.parse(driftFromHistoryMatch[0]);
// Iter-66/iter-67 contract: the fastest-path flags are surfaced in timing
assert(dfh.timing?.skippedAuditList === true,
'drift-from-history --baseline-file → skippedAuditList === true (iter 66)');
assert(dfh.timing?.usedBaselineFile === true,
'drift-from-history --baseline-file → usedBaselineFile === true (iter 67)');
// Wall-clock fastpath proof: must be under 30s with file inputs
// (vs ~26s minimum for the audit-list-loading slow path)
assert(typeof dfh.timing?.parallelWallMs === 'number' && dfh.timing.parallelWallMs < 30000,
`drift-from-history fastpath wall < 30s (got ${dfh.timing?.parallelWallMs}ms)`);
// Same-file self-match → similarity 1.0
assert(dfh.drift?.structuralDistance?.overall === 1,
`drift-from-history self-match overall === 1 (got ${dfh.drift?.structuralDistance?.overall})`);
assert(dfh.drift?.structuralDistance?.verdict === 'near-identical',
`drift-from-history self-match verdict === near-identical (got ${dfh.drift?.structuralDistance?.verdict})`);
// Alert chain end-to-end
assert(dfh.alert?.triggered === false,
'drift-from-history self-match alert NOT triggered at default threshold (0.95)');
} finally {
try { rmSync(tmp, { recursive: true, force: true }); } catch { /* ignore */ }
}