Skip to content

Commit eba648f

Browse files
theo-learnerclaude
andcommitted
fix: exclude seed data from anomaly detection history when processing live metrics
When a seed scenario TTL expires, the ring buffer may still contain seed spike data. If the agent loop then processes live metrics (no seedTtlExpiry), the old spike history was causing false anomaly detection (e.g. txPool↑ medium when live tx=1, because spike history caused monotonic/Z-score triggers). Fix: filter history to exclude seed points (seedTtlExpiry set) when the current dataPoint is a live metric. Seed-mode cycles still use full history unchanged. Side-effect: if <5 live points exist after filtering, MIN_HISTORY_POINTS guard naturally suppresses detection — correct behavior while live data accumulates. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d17076b commit eba648f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/lib/detection-pipeline.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,14 @@ export async function runDetectionPipeline(
4949
balances?: { batcherBalanceEth?: number; proposerBalanceEth?: number; challengerBalanceEth?: number }
5050
): Promise<DetectionResult> {
5151
const history = await getRecentMetrics();
52-
const anomalies = detectAnomalies(dataPoint, history, balances);
52+
53+
// When the current dataPoint is a live metric (no seedTtlExpiry), exclude seed data
54+
// from history to prevent stale spike scenario data from triggering false anomalies.
55+
const filteredHistory = dataPoint.seedTtlExpiry
56+
? history
57+
: history.filter(p => !p.seedTtlExpiry);
58+
59+
const anomalies = detectAnomalies(dataPoint, filteredHistory, balances);
5360

5461
if (anomalies.length > 0) {
5562
logger.info(`[Detection] ${anomalies.length} anomalies detected`);

0 commit comments

Comments
 (0)