Repository navigation
fix(ingest): add ingest-time outlier plausibility check and quarantine table (#238) - #591
Conversation
|
@Riri-dev1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
9436a64 to
c5a9812
Compare
c5a9812 to
9601518
Compare
|
Merged — full CI green, including the migration drift & deploy job once I approved the fork run. I like that this fails open: no reference median means One operational note, not a code issue. The shared Postgres is in read-only mode right now ( The |
fix(ingest): add rolling-median plausibility check and quarantine table (#238)
Summary
Fixes unvalidated price tick ingest where outlier rejection previously only occurred at read-time for TWAP/VWAP. Unvalidated ticks from thin pools could pollute raw price tables and trigger false alerts across
/candles,/price,/screener, and webhooks.Key Changes
Quarantine Table (Prisma Model):
QuarantinedPricePointmodel mapped toquarantined_price_pointsinprisma/schema.prisma.network,pairKey,price,baseVolume,counterVolume,source,poolId,ledger,timestamp,eventId) along with quarantine diagnostics (referenceMedian,rejectionReason,rejectionBound,quarantinedAt).networkto maintain query efficiency and cross-chain isolation ((network, pairKey, timestamp)and(network, pairKey, quarantinedAt)).Ingest-Time Plausibility Check:
partitionPricePointsByPlausibilityandgetRecentMedianPriceinsrc/ingest/plausibility.ts.price_points.INGEST_PLAUSIBILITY_THRESHOLD(default:0.20= 20% max deviation)INGEST_PLAUSIBILITY_WINDOW_MINUTES(default:60)INGEST_PLAUSIBILITY_MIN_SAMPLES(default:1)quarantined_price_pointsand omitted fromprice_points.sdex,amm,soroswap,runner) only advance last-price caches and trigger webhook/WebSocket updates for accepted ticks, preventing false alerts.Metrics per Source:
src/metrics.tstagged by['source', 'network']:price_points_accepted_totalprice_points_quarantined_total(aliased toprice_points_rejected_total)Tests:
src/__tests__/ingestPlausibility.test.ts.Related issue
Closes #238
Type of change
Checklist
npx tsc --noEmitpassesnpm run buildpasses