Skip to content

Usage & Spend projections can prune wider retained Codex cost history #2914

Description

@thomaschow19

Summary

Usage & Spend requests a narrow reporting window while the cost cache may retain a wider configured history. Under row or byte pressure, the current save path treats the requested reporting window as the retention boundary.

As a result, opening or refreshing a 7- or 30-day dashboard projection can delete completed cached rows and daily aggregates outside that projection, then narrow the persisted scan metadata. A dashboard view should extract a slice from the cache; it should not rebuild or destructively redefine the cache's retained coverage.

Expected behavior

  • The configured/persisted history window remains the cache-retention authority.
  • 7- and 30-day dashboard views are read projections over that retained cache.
  • A requested extension beyond current retained coverage is also protected.
  • Cache budgets remain best-effort for all retained in-window history.

Synthetic reproduction

  1. Persist a complete cache with a wider retained window, including one older record and one recent record.
  2. Set the file-byte budget below the database size.
  3. Save the unchanged cache with a 30-day requested window.
  4. Repeat through the full-save path with a 7-day requested window.
  5. Observe that the older row and aggregate are deleted and the persisted lower coverage bound is rewritten to the narrow request.

Scope

This is a persistence-boundary bug. It is distinct from dashboard catch-up progress or the hard-coded Finish now scan scope tracked in #2861.

Related: #2823 and #2825.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal priority bug or improvement with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:data-lossThis issue is about lost, corrupted, or silently dropped user/session/config data.issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions