Repository navigation
feat(oracle): persist oracle comparisons and expose history and windo… - #549
Conversation
…w summary statistics (Divinity-Labs#304) - Add OracleComparison model to Prisma schema with network-leading composite indexes - Persist comparison observations in compareOracles with Lens provenance (venues, sampleCount, freshness) - Add queryOracleComparisonHistory and computeOracleSummaryStatistics in oracleComparison service - Support window, date ranges (from/to), band threshold, and oracle filtering - Add GET /compare/:asset/history and GET /compare/:asset/summary routes - Set cache policy to public, max-age=60 with Vary: x-network - Add oracle retention job pruneOldOracleComparisons in bounded batches with SKIP LOCKED - Document new endpoints and schemas in openapi.yaml and regenerate openapi.json - Add comprehensive vitest suite for oracle drift and return, retention, network handling, provenance, and honest answers
|
Correction to my earlier review. I described this branch as hundreds of commits behind with tens of thousands of lines of deletions. The deletion figure was wrong — it came from Measured properly against current So the real cost is resolving 5 conflicts, not reconstructing the repository. I apologise for the framing. |
|
Merged into 1. The model had no migration.
I generated it offline with: which produces 2. Both new routes declared no access control.
3. The spec paths were unversioned. Everything documented has carried 4. What's good here. Persisting the comparison rather than computing it per request is the right call: a deviation you can only see live is one nobody can investigate afterwards.
Note Lens's Render service is suspended, so the migration will apply on the next deploy after it is brought back up — and it should be applied deliberately, since |
Summary
Persist each comparison and expose historical series and window summary statistics:
OracleComparisonPrisma model mapped tooracle_comparisonswith network-leading composite indexes.compareOraclescarrying Lens provenance (venues,sampleCount, freshness timestamp, age).queryOracleComparisonHistoryandcomputeOracleSummaryStatisticsto calculate mean deviation, worst deviation, time spent outside a band (seconds and percentage), and status transitions over a window.GET /compare/:asset/historyandGET /compare/:asset/summaryroutes with?network=filtering/echoing, window/date ranges, band threshold, and honest empty/gap responses (nulls andinsufficient_data).public, max-age=60withVary: x-network.pruneOldOracleComparisonswith bounded batching (SKIP LOCKED).openapi.yamland regenerateopenapi.json.Related issue
Fixes #304
Type of change
Checklist
npx tsc --noEmitpassesnpm run buildpasses