mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-24 14:16:34 +09:00
Pre-iter-78, drift-from-history's alert triggered ONLY on structural-
distance threshold. A weekly cron running with --threshold 0.95 would
MISS a sudden CRITICAL mcp-scan finding if the broader structure
stayed similar.
Example failure: someone commits a new MCP server with default-allow
permissions. score/genome don't change meaningfully (still 'node_mcp_ci',
still 'typescript-sdk-harness') → overall similarity stays 0.99. But
mcp-scan would now report a CRITICAL finding. Pre-iter-78 the weekly
cron's drift detection would report 'near-identical' — and the human
reading the Actions summary would see "no drift" + miss the new finding.
Iter 78 adds an orthogonal alert gate.
WHAT SHIPPED
1. plugins/ruflo-metaharness/scripts/drift-from-history.mjs
- New `--alert-on-new-severity <level>` flag (default off → no behavior change)
- When set: any introduced finding with rankSeverity(severity) ≥
rankSeverity(level) flips alertTriggered=true and appends a
reason like "N new finding(s) at or above critical severity"
- alert.elevatedFindings[] surfaced in payload so consumers see WHICH
findings tripped the gate (not just a count)
- alert.reasons[] array supplements .reason string for structured access
- Imports rankSeverity from _harness.mjs (iter 63 shared util)
2. v3/@claude-flow/cli/src/mcp-tools/metaharness-tools.ts
- alertOnNewSeverity input added to metaharness_drift_from_history
- enum constrained: info|low|medium|warn|high|error|critical
(matches iter-63 SEVERITY_RANK vocabulary)
- args.push('--alert-on-new-severity', input.alertOnNewSeverity)
- Description calls out orthogonality: "A CRITICAL finding triggers
even if structural similarity > threshold."
3. CLAUDE.md surfaces the new flag
4. Smoke step 17z41 anchors:
- CLI flag + args key + elevatedFindings + rankSeverity import
- MCP input + dispatch
- CLAUDE.md mention
- RUNTIME: synthetic clean baseline + ruflo's real INFO finding →
alert-on-new-severity info exits 1 (gate triggers correctly)
VERIFIED END-TO-END
$ # clean baseline (no findings)
$ node oia-audit.mjs --dry-run --format json > /tmp/baseline.json
$ jq '.components.mcpScan.json = {findings:[]}' /tmp/baseline.json > /tmp/clean.json
$ # default (no flag) — does not fire on similarity > threshold
$ drift-from-history --baseline-file /tmp/clean.json --threshold 0.5
alert.triggered: false
$ # with --alert-on-new-severity info — fires
$ drift-from-history --baseline-file /tmp/clean.json --threshold 0.5 \
--alert-on-new-severity info
alert.triggered: true
alert.reasons: ['1 new finding(s) at or above info severity']
alert.elevatedFindings: [{ severity: 'info', message: 'No MCP security issues found...' }]
exit: 1
DESIGN: ORTHOGONAL, NOT COMPOUND
The two alert gates work independently:
triggered = (similarity < threshold) OR (any new finding ≥ severity)
Either gate can fire. This matches the operational reality: structural
drift and security-posture drift are different failure modes that
should each have their own threshold + own visibility.
WHY OPT-IN (NOT DEFAULT)
Default behavior unchanged (no flag = no new alert). Existing cron
scripts that depend on the iter-53 behavior keep working. Ops users
who want the new gate explicitly opt in by passing the flag.
GATES THIS ITER
smoke: 80 → 81 (step 17z41 green)
runtime: smoke RUNS the actual workflow + asserts exit=1 on alert
tsc: CLI rebuilds clean
roundtrip: 60/60 (no behavior change on default path)
CLI-MCP PARITY (post-iter-78)
--path ✓ both
--baseline-since ✓ both
--baseline-key ✓ both (iter 66/71)
--baseline-file ✓ both (iter 67/71)
--threshold ✓ both
--alert-on-new-severity ✓ both (iter 78)
--dry-run ✓ both
Co-Authored-By: RuFlo <ruv@ruv.net>