8000 fix(quota): converge weekly estimates to actual spend for 0.9.7 by InfinityPacer · Pull Request #34 · InfinityPacer/meterleaf · GitHub
[go: up one dir, main page]

Skip to content

fix(quota): converge weekly estimates to actual spend for 0.9.7 - #34

Merged
InfinityPacer merged 1 commit into
mainfrom
fix/quota-estimate-converge
Oct 6, 2026
Merged

InfinityPacer merged 1 commit into
mainfrom
fix/quota-estimate-converge

Conversation

@InfinityPacer
Copy link
Copy Markdown
Owner

问题

七天预估按每 1% 花费的中位数直接外推整周价值,与本周期已花金额无关,用得越多也不会向已花收敛。上周期用到 90%、已花 $1,281.65 时预估仍是 $1,481,即使用满也会停在约 $1,480。

改动

  • 预估改为本周期已花金额加上剩余百分比乘以整周外推值。外推、取整校正、上一周期参考与加权逻辑不变,只作用于剩余部分。用满时预估等于已花金额。
  • 套餐中途变化的周期,已花包含变化前消费,该周期预估偏高,下个周期恢复。这是有意接受的取舍,已写入 docs/reporting.md。
  • 原先断言整周外推值的测试通过 tests/quota-projection.ts 反推外推值,继续检查历史选择与加权逻辑。新增一个测试用具体数值固定收敛行为和用满时等于已花。

验证

  • 用生产数据三个七天周期回放。上周期 50%、82%、90% 时由 $1,435、$1,474、$1,481 变为 $1,387、$1,423、$1,430,结束时按已花推算为 $1,424。本周期 1% 时 $1,545,44% 时 $1,362,与原算法基本一致。
  • bun test tests 438 通过,bun run typecheck、bun run build、Prettier 与 git diff --check 通过。新增测试在旧实现上失败。

🤖 Generated with Claude Code

fix(quota): converge weekly estimates to actual spend < 8000 button aria-expanded="false" aria-label="Commit message body" type="button" data-view-component="true" class="ellipsis-expander js-details-target btn"> …
The weekly estimate extrapolated a full-week value from the median cost
per percent, so it never approached the amount already spent. It now adds
the remaining share of that extrapolation to actual spend, which makes
it converge as usage grows and equal spend when the window is exhausted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@InfinityPacer
InfinityPacer merged commit 4c8b63e into main Oct 6, 2026
2 checks passed
@InfinityPacer
InfinityPacer deleted the fix/quota-estimate-converge branch October 6, 2026 19:06
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.

1 participant

0