refactor(neuralwatt): replace current_period_start/end with kwh_reset_date#1794
Conversation
Replace CurrentPeriodStart/End with KwhResetDate for accurate NeuralWatt quota reset date tracking. - Remove CurrentPeriodStart and CurrentPeriodEnd from NeuralWattBalance struct - Add KwhResetDate field for explicit quota reset tracking - Update parseResponse to read kwh_reset_date from API response - Update convertNeuralWattSubscriptionToMap to include kwh_reset_date - Update frontend quota types with new subscription fields - Update all test cases to use kwh_reset_date instead of period dates - Add new test function for kwh_reset_date handling
- Add kwh_reset_date field and NextResetAt assertions to WarningState and ZeroRemainingWithoutOverage tests, matching ExhaustedState pattern - Fix R3 inconsistency: all subscription tests now exercise reset-date parsing, restoring coverage that existed before the field rename
79540c5 to
aa7289d
Compare
Greptile SummaryReplaces
Confidence Score: 4/5Safe to merge — the field rename is complete across Go struct, serialization, and TypeScript types, with no remaining references to the old fields in NeuralWatt code. The change is narrow and well-contained. A grep confirms current_period_start/current_period_end survive only in the unrelated nanogpt_checker.go. Test coverage for the new field is solid, including the new dedicated test. Only a stray double blank line was found. No files require special attention; the double blank line in neuralwatt_checker.go is cosmetic. Important Files Changed
Sequence DiagramsequenceDiagram
participant FE as Frontend (quotas.ts)
participant API as GraphQL API
participant QC as NeuralWattQuotaChecker
participant NW as NeuralWatt API
FE->>API: ProviderQuotaStatuses query
API->>QC: CheckQuota(ctx, channel)
QC->>NW: GET /v1/quota (Bearer token)
NW-->>QC: "{ subscription: { kwh_reset_date, kwh_remaining, ... } }"
QC->>QC: parseResponse() - time.Parse(RFC3339, kwh_reset_date) to nextResetAt
QC->>QC: convertNeuralWattSubscriptionToMap() - includes kwh_reset_date
QC-->>API: "QuotaData { status, NextResetAt, RawData }"
API-->>FE: "providerQuotaStatus { nextResetAt, quotaData.subscription.kwh_reset_date }"
|
…_date (looplj#1794) * fix: replace current_period_start/end with kwh_reset_date Replace CurrentPeriodStart/End with KwhResetDate for accurate NeuralWatt quota reset date tracking. - Remove CurrentPeriodStart and CurrentPeriodEnd from NeuralWattBalance struct - Add KwhResetDate field for explicit quota reset tracking - Update parseResponse to read kwh_reset_date from API response - Update convertNeuralWattSubscriptionToMap to include kwh_reset_date - Update frontend quota types with new subscription fields - Update all test cases to use kwh_reset_date instead of period dates - Add new test function for kwh_reset_date handling * fix: add kwh_reset_date to remaining NeuralWatt test fixtures - Add kwh_reset_date field and NextResetAt assertions to WarningState and ZeroRemainingWithoutOverage tests, matching ExhaustedState pattern - Fix R3 inconsistency: all subscription tests now exercise reset-date parsing, restoring coverage that existed before the field rename
Summary
Replaced
current_period_startandcurrent_period_endfields withkwh_reset_datein the NeuralWatt quota checker to better align with NeuralWatt's API subscription model and simplify quota reset date tracking.Spirit/Intent
Use a single
kwh_reset_datefield instead of period start/end dates for clearer quota reset tracking specific to NeuralWatt's kWh-based billing model.Key Changes
CurrentPeriodStartandCurrentPeriodEndwithKwhResetDateinNeuralWattSubscriptionstruct; updatedparseResponse()to parsekwh_reset_datefieldkwh_reset_dateinstead ofcurrent_period_start/current_period_endRisks
current_period_startorcurrent_period_end- must ensure all consumers are updated to usekwh_reset_date