Add usage report adapter layer#132
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a small adapter layer to make usage report preflight validation format-aware, so the existing Transition Period Billing Preview CSVs continue to work while “native AI Credits” CSVs are detected and rejected with the existing unsupported error—without changing downstream parsing/normalization/aggregation.
Changes:
- Adds
reportAdapterswith report-format metadata, detection (header + first data row), and adapter-selected first-row validation. - Updates
runPipelinepreflight validation to use the adapter entry points while keeping header-only validation for malformed / pre-AIC reports. - Adds targeted tests for adapter selection and for header-only report validation behavior in the pipeline.
Show a summary per file
| File | Description |
|---|---|
| src/pipeline/runPipeline.ts | Routes preflight header + first-row validation through the new adapter entry points. |
| src/pipeline/runPipeline.test.ts | Adds coverage for valid/malformed/pre-AIC header-only reports and preserves native-report rejection behavior. |
| src/pipeline/reportAdapters.ts | New adapter layer: report format metadata, detection, adapter selection, and validation routing. |
| src/pipeline/reportAdapters.test.ts | New tests validating format detection/selection and early header validation behavior. |
| src/pipeline/parser.ts | Extracts native-report signature detection into hasNativeAiCreditsReportSignature and reuses it in validation. |
| src/pipeline/parser.test.ts | Renames variables for clarity (“legacyHeader” → “preAicHeader”) without behavior changes. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 6/6 changed files
- Comments generated: 0
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
Usage report parsing needs a format-aware entry point so current Transition Period Billing Preview reports keep working while newer native AI Credits reports can be identified separately. This PR adds that adapter layer without changing downstream normalization or aggregation behavior.
refactor: add usage report adapter layerChanges
transition-period-billing-previewandnative-ai-creditsreport format metadata and adapters.UnsupportedNativeAiCreditsReportErrorfor this slice.Testing
npm testnpm run lintnpm run buildChecklist
npm run lint)