8000 feat(release): faster report opening, self-recovering PWA, local OTEL relay and ledger retention for 0.12.1 by InfinityPacer · Pull Request #49 · InfinityPacer/meterleaf · GitHub
[go: up one dir, main page]

Skip to content

feat(release): faster report opening, self-recovering PWA, local OTEL relay and ledger retention for 0.12.1 - #49

Merged
InfinityPacer merged 14 commits into
mainfrom
release/0.12.1
Oct 23, 2026
Merged

InfinityPacer merged 14 commits into
mainfrom
release/0.12.1

Conversation

@InfinityPacer
Copy link
Copy Markdown
Owner

问题

  • 网络切换或公网地址变更后,PWA 打开时导航请求可能挂住,独立窗口长时间白屏,反复重开也无法恢复。
  • 打开页面偏慢。每次报表查询都要重新扫描额度历史,首屏报表即使已是最新也会被重查一次。
  • Claude Code 的 OTEL 日志直接发到服务端,服务端或网络不可用时会丢失。服务端的请求归属表只增不删。
  • 账本里旧价格表的估值和已消费的变更日志从不清理,生产账本中这部分约占 1.57 GB 里的 1 GB。
  • 运行时停留在 Bun 1.4.2,1.4.4 包含 fetch 与 TLS 的安全修复。

结果

  • PWA:Service Worker 的导航等待超过 8 秒时改为显示离线页,离线页带超时探测,会自动重试,连上后直接打开账本。
  • 报表:账户、合并关系和额度候选按账本版本 ledger:dataRevision 跨查询复用,窗口汇总跟随索引写入失效。首屏只重查不是按最新版本算出的报表。
  • 采集器:新增 otel-relay,常驻在 127.0.0.1:4319 接收 OTLP 日志,写入本机待发送队列,由 sync 先于用量推送。服务端拒收时用量照常推送。队列上限 5 万条。install-launchd 同时注册同步和中继两个后台任务。
  • 账本:OTEL 归属写进用量事实本身(metadata.attribution = "otel"),重发不会再翻转账户。request_accounts 只保留 30 天。启动后在后台分批删除非当前价格表的估值,删除时不写变更日志。两个索引都消费过的变更日志会被清理,最大的一行始终保留。索引游标落后于日志下限时改为全量重建。
  • 运行时:Dockerfile、CI 与 packageManager 升级到 Bun 1.4.4。
  • 数据库结构从 c4f1a9d7e250 迁移到 e6b2f4a91c07,升级前需停服并备份。

验证

  • bun run typecheck 通过,bun test tests 546 个测试全部通过,bun run build 和 bun run build:collector 成功。
  • PWA:真实浏览器中用一个不应答的代理模拟挂起的导航,8.0 秒后显示离线页,代理恢复后 3.3 秒自动打开账本。tests/pwa.browser.ts 已改为验证网络恢复后无需手动刷新即可重新打开。
  • 升级演练:在生产账本的一致性副本上,先用 0.12.0 取视图作为基线,再换本版启动。迁移约 1 秒完成,后台删除旧估值 1,195,365 行,清理变更日志 2,065,324 行。/api/view 除时间戳外逐字段与基线一致,重启后没有触发全量重建。VACUUM 用时 5 秒,账本从 1.57 GB 降到 548 MB。
  • 生产部署:先停服,再备份账本并校验,之后升级、清理、VACUUM、启动,最终结构版本为 e6b2f4a91c07,容器状态 healthy。
  • 端到端:本机采集器换成本版并注册中继,Claude Code 改发 127.0.0.1:4319,分别用两个账户跑真实会话。两条请求经中继进入队列,由 sync 推送后各自归到正确账户,并带上 otel 标记。
  • TLS 复测:在旧镜像(Bun 1.4.2)和本版镜像(Bun 1.4.4)里分别对 badssl.com 的过期、错误主机名、自签名、不受信根和不完整链地址发起 fetch,两者都正确拒绝,合法地址都能正常访问。

🤖 Generated with Claude Code

InfinityPacer and others added 14 commits October 23, 2026 21:33
…angs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
…lemetry

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Opening the page sends the overview plus one 7-day trend query per
account, and the view worker re-read accounts, merges and the quota
history and re-ran every quota window sum for each of them although
the snapshot does not depend on the query.

The worker now keeps the inputs of the latest ledger revision and
re-cuts the quota candidates for the current time, and the report
index keeps the window sums of the previous reader until its next
write. Results carry the ledger revision they were computed at.
A placeholder account created by a replayed push now bumps the
revision so cached inputs cannot miss it.

On a synthetic 120-day ledger (420k usage events, 380k quota rows)
snapshotMs p50 drops from 420 ms to 56 ms for queries without an
intervening write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first sync status read invalidated every report query, so each
open re-read all reports and could make the worker recompute a result
it had just produced. Only reports not computed at the reported
ledger revision are refetched now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… mappings after 30 days

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@InfinityPacer
InfinityPacer merged commit e672daf into main Oct 23, 2026
2 checks passed
@InfinityPacer
InfinityPacer deleted the release/0.12.1 branch October 23, 2026 14:51
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