Skip to content

Select included-credit policy from report metadata#140

Merged
asizikov merged 3 commits into
mainfrom
asizikov/included-credit-policy-selection
Jun 6, 2026
Merged

Select included-credit policy from report metadata#140
asizikov merged 3 commits into
mainfrom
asizikov/included-credit-policy-selection

Conversation

@asizikov
Copy link
Copy Markdown
Member

@asizikov asizikov commented Jun 6, 2026

Summary

This prepares included-credit policy selection for reports based on report format metadata and period boundaries, while preserving the current production behavior that native AI Credits uploads are unsupported.

Changes

  • Adds an included-credit policy resolver that returns the transition-period billing preview policy for transition reports.
  • Defines native AI Credits policy selection by report period start: starts before 2026-09-01 use the summer promo policy, starts on or after 2026-09-01 use the standard policy, and missing or invalid native starts default to standard.
  • Derives report periods during the included-credit pre-scan before resolving metadata-based policy selection for allocator use.
  • Keeps native AI Credits uploads rejected before aggregator onHeader or accumulate, while preserving transition-period allocation behavior.
  • Shares ISO date validation between report context aggregation and policy selection to keep boundary behavior consistent.
  • Adds focused resolver, period-wiring, native rejection, transition behavior, and ISO date utility coverage.
Commit Change
feat: select included credit policy Adds policy resolution and safe transition-period runtime wiring without enabling native AI Credits uploads.
refactor: share ISO date validation Extracts shared ISO date validation for report context aggregation and policy selection.
fix: resolve policy from report period Derives report periods during the allocator pre-scan and resolves policy after the period is known.

Testing

  • npm run lint
  • npm test
  • npm run build

Checklist

  • Specs lint passes (npm run lint)
  • Tests updated if applicable
  • Documentation updated if applicable (N/A: no user-visible documentation change)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 6, 2026 13:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds infrastructure to choose an “included credits” policy based on report format metadata (and, for native AI Credits, a report period start boundary), then passes the resolved policy into the included-credits allocation step in the pipeline.

Changes:

  • Introduces resolveIncludedCreditsPolicy(...) with transition-period vs native AI Credits (summer promo vs standard) policy selection logic.
  • Wires runPipeline to resolve a policy after adapter validation and pass it into createAicIncludedCreditsAllocator.
  • Adds unit tests covering transition reports, native boundary dates, and invalid/missing period defaults.
Show a summary per file
File Description
src/pipeline/runPipeline.ts Resolves and passes includedCreditsPolicy into the included-credits allocator after validating report format.
src/pipeline/includedCreditsPolicy.ts Adds policy definitions plus a resolver that selects policy by report format and (for native) report period start date.
src/pipeline/includedCreditsPolicy.test.ts Adds focused tests for resolver behavior across formats and boundary dates.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

Comment thread src/pipeline/runPipeline.ts Outdated
Comment thread src/pipeline/includedCreditsPolicy.ts Outdated
asizikov and others added 2 commits June 6, 2026 15:27
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@asizikov asizikov merged commit d5cfd70 into main Jun 6, 2026
9 checks passed
@asizikov asizikov deleted the asizikov/included-credit-policy-selection branch June 6, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants