-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add enrichment audit card #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new React component for displaying enrichment audit data with visualization capabilities. The component provides a comprehensive view of data enrichment performance metrics including latency histograms, cache statistics, and export functionality.
Key Changes:
- Added EnrichmentAuditCard component with latency histogram visualization, cache/fallback badges, and export options
- Implemented buildLatencyHistogram helper function for aggregating latency data into bins
- Added comprehensive test coverage for the histogram aggregation logic
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/ui-cards/EnrichmentAuditCard.tsx | New React component with Zod schema validation, histogram visualization, and PNG/JSON export functionality |
| packages/ui-cards/EnrichmentAuditCard.test.ts | Unit tests for the latency histogram aggregation helper function |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| const blob = new Blob([json], { type: 'application/json' }); | ||
| const url = URL.createObjectURL(blob); | ||
| const link = document.createElement('a'); | ||
| link.download = 'enrichment-audit.json'; | ||
| link.href = url; | ||
| link.click(); |
Copilot
AI
Sep 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory leak: URL.createObjectURL creates a blob URL that should be revoked after use to free memory. Add URL.revokeObjectURL(url) after link.click().
| const blob = new Blob([json], { type: 'application/json' }); | |
| const url = URL.createObjectURL(blob); | |
| const link = document.createElement('a'); | |
| link.download = 'enrichment-audit.json'; | |
| link.href = url; | |
| link.click(); | |
| link.click(); | |
| URL.revokeObjectURL(url); |
| > | ||
| {histogram.map((count, i) => { | ||
| const height = (count / maxCount) * 100; | ||
| const rangeLabel = `${i * binSize}-${i * binSize + binSize}`; |
Copilot
AI
Sep 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The range calculation i * binSize + binSize can be simplified to (i + 1) * binSize for better readability.
| const rangeLabel = `${i * binSize}-${i * binSize + binSize}`; | |
| const rangeLabel = `${i * binSize}-${(i + 1) * binSize}`; |
| export function buildLatencyHistogram( | ||
| latencies: number[], | ||
| binSize = 50, | ||
| ): number[] { |
Copilot
AI
Sep 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When latencies array is empty, Math.max(0, ...latencies) will return 0, but Math.floor(0 / binSize) + 1 will create 1 bin instead of 0 bins. This creates inconsistency with the test expectation that expects [0] for empty input.
Summary
Testing
pnpm lint packages/ui-cards/EnrichmentAuditCard.tsxpnpm exec vitest packages/ui-cards/EnrichmentAuditCard.test.ts packages/ui-cards/RiskScoreCard.test.ts(fails: Cannot find package '@/tests/prompts/utils' imported from '/workspace/ai-ysh/lib/ai/models.test.ts')https://chatgpt.com/codex/tasks/task_e_68ba522a7a4883328049bf7968b0021f