8000 fix(quota): ignore stale quota readings for 0.9.6 by InfinityPacer · Pull Request #33 · InfinityPacer/meterleaf · GitHub
[go: up one dir, main page]

Skip to content

fix(quota): ignore stale quota readings for 0.9.6 - #33

Merged
InfinityPacer merged 2 commits into
mainfrom
fix/quota-stale-readings
Oct 6, 2026
Merged

InfinityPacer merged 2 commits into
mainfrom
fix/quota-stale-readings

Conversation

@InfinityPacer
Copy link
Copy Markdown
Owner

问题

首页七天额度预估会突然跌到几十美元,例如已用 43%、本周期已花 $599.93 时预估只显示 $21.04。

同时开着多个 Claude Code 会话时,各会话会写入自己较早看到的额度,使同一周期内的百分比暂时回落 1 到 5 个点。旧算法把任何回落都当作上游重新计数,丢掉此前全部观测,只用回落后几分钟的消费外推整周额度。每个周期会出现 6 到 10 次,每次让预估在数小时内跌到几美元至几百美元。重置时间带毫秒抖动的快照也会被拆成单独周期。

周期初期还有系统性偏低。上游百分比四舍五入为整数,刚显示 1% 时实际约 0.5%,粗估在 1%、2%、3% 时分别低估约 45%、22%、14%。

改动

  • 同一周期内的小幅回落按过时读数忽略,进度与预估保持此前最高值。回落至少 5 个百分点且不高于此前最高值一半时才重新起算,换套餐的隔离逻辑不变。
  • 重置时间按整分钟归组。
  • 紧接 k-1 之后首次出现的整数 k 按 k-0.5 计算,粗估与多段估算都适用,重新起算后的区间不校正。
  • 更新 docs/reporting.md 预估说明与 CHANGELOG,版本 0.9.6。

验证

  • 用生产数据三个七天周期的额度快照与逐请求费用回放 quotaView。截图时刻预估由 $21 变为 $1,360;此前每次回落后的 $6 至 $500 全部消失,曲线平滑。本周期 1% 至 7% 的预估由 776、1095、1202、1275、1312、1392 变为 1553、1565、1529、1475、1466、1445,与后期 1,360 至 1,500 一致。
  • 新增 5 个回归测试,其中 4 个在旧实现上失败。bun test tests 437 通过,bun run typecheck、bun run build、Prettier 与 git diff --check 通过。

🤖 Generated with Claude Code

InfinityPacer and others added 2 commits October 7, 2026 02:42
…imates

Several Claude Code sessions write their own last-seen quota, so the
seven-day percent briefly drops by 1-5 points within a cycle. Each drop
was treated as an upstream reset, collapsing the weekly estimate to a
tiny recent segment (e.g. $21 instead of ~$1,360). Small drops are now
ignored, millisecond reset jitter stays in one cycle, and first arrivals
of rounded integer percents count as k-0.5 so early estimates are not
biased low.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@InfinityPacer
InfinityPacer merged commit 9b34ed5 into main Oct 6, 2026
2 checks passed
@InfinityPacer
InfinityPacer deleted the fix/quota-stale-readings branch October 6, 2026 18:49
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