发布

  • [OPIK-6873] [BE][FE] Token-native AI Spend on the cc.billing schema (#7037)

    frostbyte_neo 发布于 2026-06-12 12:48:59 +00:00

    • [OPIK-6873] [BE][FE] Token-native AI Spend on the cc.billing schema

    Rebuild the AI Spend pipeline on the plugin's cc.billing metadata block:
    per-LLM-call positional cache-tier attribution where plain SUM is exact
    against API usage. The backend ships only tokens (per-tier columns on
    lanes, summary, and users); all dollar amounts are computed in the FE
    from a hardcoded Claude rate table, so every figure on the dashboard is
    consistent with the same token counts.

    • BE: 10 input lanes (incl. unattributed), lane tier columns and items
      (kind/count/definition/usage) read from cc.billing fixed JSON paths;
      output lanes derived from cc.billing.lanes.output.items; tier-token
      summary; users leaderboard ranked by total_tokens
    • BE: queries/mapping ported into the AiSpendQueryBuilder / AiSpendMapper
      / AiSpendDAO structure from the review refactor
    • FE: claudePricing rate table + useSavingsPricer; lane cards, Sankey,
      breakdown panel (stacked definition/usage bars), KPI cards, leaderboard
      and recommendations all priced FE-side from tier tokens
    • Pricing overrides: add claude-fable-5 model entries

    Co-Authored-By: Claude Fable 5 noreply@anthropic.com

    • [OPIK-6873] [BE][FE] Address review: typed lanes extract, SQL out of api layer, ST templates
    • Composition tokens now parses cc.billing.lanes once per row via a single
      typed JSONExtract Tuple instead of 50 JSONExtractInt paths (~17x less CPU
      at 1M traces, byte-for-byte identical results)
    • SpendLane/OutputLane no longer carry ClickHouse expressions; predicates and
      label expressions moved to AiSpendQueryBuilder EnumMaps
    • Queries assembled via StringTemplate variable binding instead of positional
      String.formatted; drops the < escaping and keeps SQL construction (incl.
      the users ORDER BY tiebreaker) in the builder
    • Rename est_saving_tokens -> estimated_savings_tokens, aligned with
      total_savings_tokens
    • Input-lane breakdown subtitle restored from the lane description
    • Breakdown ships tier sums + model so the FE prices lane totals; lane panel
      shows cost, orders user-prompt size buckets, local-dev AiSpendProvider

    Co-Authored-By: Claude Fable 5 noreply@anthropic.com

    • [OPIK-6873] [BE][FE] Price breakdown rows, lane-aware count units, definition-split gating
    • Lane breakdown rows show cost (per-item tier sums shipped through the
      envelope and priced FE-side); exact tokens stay in the tooltip
    • Lanes declare a singular item-count unit (prompt/file/call/load/block);
      lanes whose counts are structurally 0 hide the column and header segment,
      counts pluralize correctly and carry a tooltip explaining that counts are
      window events while tokens include replay of earlier context
    • Definition/usage stacked bar only renders for lanes with the definition
      concept (FE lane registry flag)
    • Lane hover card overflow figure uses the entity count, not item_count
      (which now means total events)

    Co-Authored-By: Claude Fable 5 noreply@anthropic.com

    • fix(ai-spend): add goToCostIntelligence to development AiSpendProvider stand-in

    Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com


    Co-authored-by: Claude Fable 5 noreply@anthropic.com
    Co-authored-by: andrii.dudar andriid@comet.com

    下载附件