# fix\(insights\): skip spend comparisons from a pre-midnight cost scan \(\#340\) · lucenx/codexbar-plasma

[View on GitCafe](https://git.cafe/lucenx/codexbar-plasma/commit/f8d0ce8d9fa7d9ba5c28df6ed303a69ba3f2f73f)

Repository: [lucenx/codexbar-plasma](https://git.cafe/lucenx/codexbar-plasma)

Visibility: public

Requested revision: f8d0ce8d9fa7d9ba5c28df6ed303a69ba3f2f73f

Requested commit: f8d0ce8d9fa7d9ba5c28df6ed303a69ba3f2f73f

Commit: f8d0ce8d9fa7d9ba5c28df6ed303a69ba3f2f73f

Tree: 4cad66bc0ab783e1cb1a40e09ef248d259e34f3a

Author: Simone

Committer: GitHub

## Message

```
fix(insights): skip spend comparisons from a pre-midnight cost scan (#340)

The AI Insights snapshot compared the last two complete weeks as soon as
the cost history held fourteen days before today. The history ends at the
day it was scanned, so a scan from before midnight, such as one kept
across an overnight suspend or taken before the hourly cost refresh ran
after midnight, holds only part of yesterday. That partial day was sent
as complete, understating the last week and inventing a spend or token
drop.

The comparison now also requires a history row for today, which the
normalized history holds once a scan ran today.

Docs: ai-insights.md snapshot contract and the usage guide's AI Insights
section. No CHANGELOG entry: AI Insights is unreleased and its Added
entry still describes the behavior.


Claude-Session: https://claude.ai/code/session_0161xP1fvVJ3SKr6kdENYb4f

Co-authored-by: Claude <noreply@anthropic.com>
```

## Parents

- [04c3a1745c0109c78704bca6a348ef8df2426e90](https://git.cafe/lucenx/codexbar-plasma/commit/04c3a1745c0109c78704bca6a348ef8df2426e90?format=markdown)

[Source at this commit](https://git.cafe/lucenx/codexbar-plasma/tree/f8d0ce8d9fa7d9ba5c28df6ed303a69ba3f2f73f?format=markdown)
