From f7383595e7102b954bbc2cfb5e39d8949d2d754a Mon Sep 17 00:00:00 2001 From: ruv Date: Tue, 16 Jun 2026 22:35:18 -0400 Subject: [PATCH] feat(metaharness): weekly cron uses iter-78 alert-on-new-severity (iter 79) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Iter 78 added --alert-on-new-severity but no caller used it. Iter 79 wires it into the weekly cron AND adds the corresponding roundtrip verification. WHAT SHIPPED 1. .github/workflows/oia-audit-weekly.yml — drift step extended: drift-from-history \ --baseline-file /tmp/prior/oia-audit.json \ --threshold 0.85 \ --alert-on-new-severity high ◀ NEW --format json The weekly cron now alerts on EITHER: - structural similarity < 0.85 - OR any new finding ≥ high severity This closes the iter-78-flagged gap: previously a regression that added a new mcp-scan HIGH finding without moving similarity below threshold would have been invisible in the Actions summary. 2. plugins/ruflo-metaharness/scripts/test-pipeline-roundtrip.mjs — new Stage 12 (6 assertions): Setup: - baseline: clean baseline-file (no findings) - current: fresh ruflo audit (has 1 INFO finding) - --threshold 0.5 (similarity won't fire — structures match) - --alert-on-new-severity info (gate fires on the 1 introduced INFO) Assertions: ✓ drift-from-history produced JSON ✓ alert.triggered === true (gate fires) ✓ reasons mention "finding(s) at or above" (not similarity) ✓ elevatedFindings non-empty (which finding tripped) ✓ exit === 1 (CLI exit reflects alert) ✓ alert.newSeverityThreshold echoed (input plumbed through) This verifies the iter-78 gate works through the drift-from-history wrapper, not just at the script flag level. WHY THIS COMPLETES THE iter-78 LOOP Iter 78 timeline: - Added flag to drift-from-history.mjs - Surfaced in MCP tool input schema - Documented in CLAUDE.md - Unit-tested via smoke step 17z41 But the CRON, the actual production consumer of drift detection, wasn't updated. iter 79 connects the wires. GATES THIS ITER smoke: 81 → 82 (step 17z42 green) roundtrip: 60 → 66 assertions (+6 for Stage 12) yaml: python yaml.safe_load passes cron: drift step now has 2 orthogonal alert sources OPERATIONAL IMPACT Pre-iter-79 weekly cron: - Structural drift > 15% → workflow fails, drift-trend artifact uploaded - New CRITICAL mcp-scan finding with structure intact → workflow stays "passing" (similarity above threshold). User sees green. Misses regression. Post-iter-79 weekly cron: - Structural drift > 15% → workflow fails - New HIGH-or-higher mcp-scan finding → workflow ALSO fails - Either signal lights up the alert. The "deep integration" story now has a fully cron-enforced security posture watcher, not just a structural-similarity watcher. ITER 78-79 ALERT-GATE COMPLETION ARC 78 — added --alert-on-new-severity at script + MCP + docs 79 — wired it into the actual cron + roundtrip-verified ◀ this iter Co-Authored-By: RuFlo --- .github/workflows/oia-audit-weekly.yml | 4 ++ plugins/ruflo-metaharness/scripts/smoke.sh | 16 +++++++ .../scripts/test-pipeline-roundtrip.mjs | 47 +++++++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/.github/workflows/oia-audit-weekly.yml b/.github/workflows/oia-audit-weekly.yml index 648e038d8e..c9ceea5080 100644 --- a/.github/workflows/oia-audit-weekly.yml +++ b/.github/workflows/oia-audit-weekly.yml @@ -112,10 +112,14 @@ jobs: run: | set -e # iter-67 fastest path: --baseline-file skips audit-list + memory roundtrip + # iter 79 — also gate on new HIGH-severity findings. Catches the + # case where structure stayed similar but a security regression + # appeared (e.g., new mcp-scan HIGH finding). Either gate can fire. node plugins/ruflo-metaharness/scripts/drift-from-history.mjs \ --baseline-file /tmp/prior/oia-audit.json \ --dry-run \ --threshold 0.85 \ + --alert-on-new-severity high \ --format json \ > /tmp/drift-trend.json || true # Extract verdict for the workflow summary diff --git a/plugins/ruflo-metaharness/scripts/smoke.sh b/plugins/ruflo-metaharness/scripts/smoke.sh index 0c2f82c1e9..7ae5588bfc 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 "17z42. weekly cron uses --alert-on-new-severity + Stage 12 verifies (iter 79)" +miss="" +# Weekly cron wires the gate +W="$ROOT/../../.github/workflows/oia-audit-weekly.yml" +grep -q -- "--alert-on-new-severity high" "$W" 2>/dev/null || miss="$miss no-cron-wired" +# Roundtrip Stage 12 added +F="$ROOT/scripts/test-pipeline-roundtrip.mjs" +grep -q "Stage 12 — --alert-on-new-severity orthogonal gate" "$F" 2>/dev/null || miss="$miss no-stage-12" +grep -q "Stage 12: --alert-on-new-severity info triggers" "$F" 2>/dev/null || miss="$miss no-trigger-assert" +grep -q "Stage 12: reasons mention new-finding severity" "$F" 2>/dev/null || miss="$miss no-reason-assert" +grep -q "Stage 12: elevatedFindings non-empty" "$F" 2>/dev/null || miss="$miss no-elevated-assert" +grep -q "Stage 12: alert.newSeverityThreshold echoed" "$F" 2>/dev/null || miss="$miss no-threshold-echo" +# Runtime: roundtrip passes (≥66) +node "$F" 2>&1 | grep -qE "(6[6-9]|[7-9][0-9]+) passed, 0 failed" || miss="$miss roundtrip-fewer-than-66" +[[ -z "$miss" ]] && ok || bad "$miss" + step "17z41. drift-from-history --alert-on-new-severity gate (iter 78)" miss="" F="$ROOT/scripts/drift-from-history.mjs" diff --git a/plugins/ruflo-metaharness/scripts/test-pipeline-roundtrip.mjs b/plugins/ruflo-metaharness/scripts/test-pipeline-roundtrip.mjs index 37b3a44d6e..f07cd34694 100755 --- a/plugins/ruflo-metaharness/scripts/test-pipeline-roundtrip.mjs +++ b/plugins/ruflo-metaharness/scripts/test-pipeline-roundtrip.mjs @@ -522,6 +522,53 @@ try { assert(trend11c.delta?.findings?.clearedCount === 0, `Stage 11c: identical findings → clearedCount === 0`); + // ────────────────────────────────────────────────────────────── + // STAGE 12 (iter 79) — --alert-on-new-severity orthogonal gate + // + // Iter 78 added the gate. Iter 79 wires it into the weekly cron. + // This stage verifies the gate fires correctly through the + // drift-from-history wrapper: + // - baseline has no findings + current has 1 medium finding + // - --threshold 0.5 (similarity stays above) + // - --alert-on-new-severity medium should trigger + // + // Catches the "structural similarity high but new security + // finding" case that iter-78 closed. + // ────────────────────────────────────────────────────────────── + console.log('\nStage 12 — --alert-on-new-severity orthogonal gate (iter 79)'); + + // Re-use baseClean (no findings) from Stage 11 + // Run drift-from-history with --alert-on-new-severity info + // (real ruflo audit has 1 INFO finding → introduced=1) + const stage12Run = runNode('drift-from-history.mjs', [ + '--baseline-file', baseCleanPath, + '--dry-run', + '--threshold', '0.5', + '--alert-on-new-severity', 'info', + '--format', 'json', + ], 120_000); + const m12 = /\{[\s\S]*\}/.exec(stage12Run.stdout); + assert(m12 !== null, 'Stage 12: drift-from-history produced JSON'); + const stage12 = JSON.parse(m12[0]); + + // The orthogonal gate fires + assert(stage12.alert?.triggered === true, + 'Stage 12: --alert-on-new-severity info triggers on ruflo current INFO finding'); + // Reason mentions severity, not similarity (structural is fine at threshold 0.5) + const reasons = stage12.alert?.reasons ?? []; + const hasSeverityReason = reasons.some((r) => /finding\(s\) at or above/.test(r)); + assert(hasSeverityReason, + `Stage 12: reasons mention new-finding severity (got ${JSON.stringify(reasons)})`); + // elevatedFindings populated + assert(Array.isArray(stage12.alert?.elevatedFindings) && stage12.alert.elevatedFindings.length >= 1, + `Stage 12: elevatedFindings non-empty (got ${stage12.alert?.elevatedFindings?.length})`); + // CLI exit reflects the alert + assert(stage12Run.status === 1, + `Stage 12: drift-from-history exit=1 on severity alert (got ${stage12Run.status})`); + // newSeverityThreshold echoed in payload + assert(stage12.alert?.newSeverityThreshold === 'info', + 'Stage 12: alert.newSeverityThreshold echoed'); + } finally { try { rmSync(tmp, { recursive: true, force: true }); } catch { /* ignore */ } }