Add analytics outlier flag for unusually expensive paid queries#112
Merged
emrekayat merged 1 commit intoJun 30, 2026
Merged
Conversation
…queries When a paid query price exceeds the configured provider price by more than 10%, mark it as a priceOutlier in the usage event with a safe reason string explaining the discrepancy. Changes: - Add priceOutlier and priceOutlierReason fields to UsageEvent type - Implement computePriceOutlier detection in buildUsageEvent - Add SQLite migration v4 for the new columns - Update serialization layer (usageEventToRow / rowToUsageEvent) - Update INSERT_USAGE query in SQLite repository - Show compact warning icon on outlier rows in the dashboard - Add tests for normal and outlier price scenarios Closes emrekayat#78
|
@Seunfunmi-319509 is attempting to deploy a commit to the emrekayat's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Seunfunmi-319509 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! 🚀 |
Micheal-Blessed
pushed a commit
to Micheal-Blessed/Query402
that referenced
this pull request
Jun 30, 2026
…queries (emrekayat#112) When a paid query price exceeds the configured provider price by more than 10%, mark it as a priceOutlier in the usage event with a safe reason string explaining the discrepancy. Changes: - Add priceOutlier and priceOutlierReason fields to UsageEvent type - Implement computePriceOutlier detection in buildUsageEvent - Add SQLite migration v4 for the new columns - Update serialization layer (usageEventToRow / rowToUsageEvent) - Update INSERT_USAGE query in SQLite repository - Show compact warning icon on outlier rows in the dashboard - Add tests for normal and outlier price scenarios Closes emrekayat#78
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
priceOutlierflag to analytics usage rows when a paid query price exceeds the expected configured provider price by more than 10%. This helps investor and SCF demos make budget safety and provider selection quality obvious.Changes
packages/shared/src/types.ts: AddedpriceOutlier?: booleanandpriceOutlierReason?: stringfields toUsageEventapps/api/src/lib/persistence.ts: ImplementedcomputePriceOutlier()that comparespriceUsdagainst the configured provider price (10% threshold) and flags outliers duringbuildUsageEventapps/api/src/lib/storage/serialization.ts: UpdatedusageEventToRowandrowToUsageEventto serialize/deserialize the new fieldsapps/api/src/lib/storage/sqlite/migrations.ts: Added migration v4 withprice_outlier INTEGERandprice_outlier_reason TEXTcolumnsapps/api/src/lib/storage/sqlite/repository.ts: UpdatedINSERT_USAGEquery to include the new columnsapps/api/src/lib/persistence.test.ts: Added tests verifying normal prices are NOT flagged and expensive prices ARE flaggedapps/web/src/types.ts: UpdatedAnalyticsResponserecentUsagetype to includepriceOutlierandpriceOutlierReasonapps/web/src/pages/ControlDeckPage.tsx: Added compact warning badge (AlertTriangleicon + "Price outlier" text) on outlier rows in the execution feedapps/web/src/styles.css: Added.price-outlier-warningCSS stylesAcceptance Criteria
priceOutlier: trueand a safe reason stringCloses #159