Skip to content

Usage projection:derive-on-demand vs durable daily aggregates #37

Closed

Description

@DoodleBears

Part of #34
Blocked by: #35, #36

Decision to make

在 #36 验证可查询 usage facts 后,确定 Usage Projection 的计算与持久化边界:

  • 哪些查询可以直接从 DSH SessionEvent / Session Query derive-on-demand;
  • 哪些规模或延迟要求需要 (PersonaBot, day, model, purpose) token buckets 的 durable daily projection;
  • rebuild cursor、schema version、late event、retry/compaction correction 与 price-era recomputation;
  • raw usage facts、derived token aggregate 与按价格表计算出的 cost estimate 三者如何区分。

Locked boundaries

Expected output

Activity

  1. added this to the v1.1 milestone on Sep 18, 2026
  2. changed the title [-]存储与汇总粒度:derive vs 日汇总;json/sqlite(ADR-0005)[/-] [+]Usage projection:derive-on-demand vs durable daily aggregates[/+] on Sep 20, 2026
  3. added
    V1.1Milestone v1.1; mirrors the GitHub milestone
    area:docsDocumentation, research, or planning artifact
    feature:usageUsage and cost attribution
    scope:designDesign decision or UX contract
    and removed
    V1.1Milestone v1.1; mirrors the GitHub milestone
    on Sep 22, 2026
  4. modified the milestones: v1.1, v1.0 on Sep 28, 2026
  5. DoodleBears commented on Sep 28, 2026

    @DoodleBears
    ContributorAuthor

    Resolved 2026-09-29(v1.0):采用 durable daily aggregates。Usage module 在 botharness.db 自持 (bot, day, provider, model, purpose) token 日桶,可从 DSH Session 日志重建;live 增量 + 迟到事件修正;金额不落库(价格 era 重算留 #35 / #39)。bucket 由 assistant/message.usage + assistant/attempt stream usage 经 deriveTurnTokenUsage 折出,sessionProjections.tokenUsage 只做每 Session 对账。实现与 ADR-0005 / #79 修订随 #428。详见 #34 Decisions。

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

    area:docsDocumentation, research, or planning artifactfeature:usageUsage and cost attributionscope:designDesign decision or UX contractwayfinder:grillingWayfinder grilling ticket

    Type

    No type

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions