Skip to content

Implement quota projection math model and core tests #6

@kmatsunami

Description

@kmatsunami

Summary

Add a core projection model that answers: if the current burn rate continues until reset, what percentage of the quota will be used at the end of the window?

This issue is responsible for the calculation layer only. It must not change menu copy, visibility policy, or progress bar rendering.

Scope

  • Introduce a small QuotaProjection / UsageProjection type near UsagePace in CodexBarCore.
  • Inputs: RateWindow, now.
  • Outputs should include at least:
    • actualUsedPercent
    • projectedUsedPercentAtReset (raw, may exceed 100)
    • projectedRemainingPercentAtReset
    • isProjectedToOverflow
    • elapsedSeconds
    • remainingSeconds
  • Return nil when required timing information is missing or elapsed time is too small to produce a stable estimate.
  • This issue is the only place that converts RateWindow timing data into forecast math.

Non-goals

  • No display clamping.
  • No UI strings such as Forecast 83% at reset.
  • No row visibility decisions beyond returning nil when projection is not trustworthy.

Files likely involved

  • Sources/CodexBarCore/UsagePace.swift or adjacent new file
  • Sources/CodexBarCore/UsageFetcher.swift
  • Tests/CodexBarTests/UsagePaceTests.swift or adjacent new test file

Acceptance Criteria

  • Projection math works from RateWindow + now without depending on UI code.
  • projectedUsedPercentAtReset is returned as a raw value and is not display-clamped to 100.
  • Callers can distinguish no forecast available from forecast available and >100%.
  • Missing resetsAt, missing windowMinutes, and near-zero elapsed time all suppress projection cleanly.
  • Unit tests cover zero elapsed, small elapsed, lasts to reset, exact 100%, overrun, and missing timing info.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions