Tracks upstream paperclipai/paperclip#6728.
Problem
100% of cost_events rows with billing_type=subscription_included store cost_cents=0 even when usage_json.costUsd is non-zero. As a result agents.spent_monthly_cents is never incremented and any budget gate built on it is silently a no-op.
Why this is priority #1 for Levi
Levi runs primarily on subscription plans (Claude Pro/Max). Every budget-governance feature we port from upstream (per-agent caps, fallback recovery guards, etc.) depends on spent_monthly_cents being a truthful number. Today it is not. Fix this first or all downstream governance work is silently dead.
Files
- Cost-event write site in
packages/server/src/services/heartbeat.* (or current Levi equivalent)
- One-time backfill SQL to populate historical rows from
usage_json.costUsd
Effort
S — fix at one write site + a backfill SQL. Half a day.
Risk
L — correctness fix to a write path. Only failure mode is double-counting; covered by a regression test that asserts cost_cents matches usage_json.costUsd * 100 for new rows.
Levi-specific implementation note
Pair with upstream PR #6740 (recurring_fixed cost events) ONLY if Levi tracks hosting/Claude subscription as a fixed monthly line. Otherwise scope narrowly to the per-event fix to keep the change small.
Acceptance criteria
Surveyed by the Levi planning agent on 2026-05-26.
Tracks upstream paperclipai/paperclip#6728.
Problem
100% of
cost_eventsrows withbilling_type=subscription_includedstorecost_cents=0even whenusage_json.costUsdis non-zero. As a resultagents.spent_monthly_centsis never incremented and any budget gate built on it is silently a no-op.Why this is priority #1 for Levi
Levi runs primarily on subscription plans (Claude Pro/Max). Every budget-governance feature we port from upstream (per-agent caps, fallback recovery guards, etc.) depends on
spent_monthly_centsbeing a truthful number. Today it is not. Fix this first or all downstream governance work is silently dead.Files
packages/server/src/services/heartbeat.*(or current Levi equivalent)usage_json.costUsdEffort
S — fix at one write site + a backfill SQL. Half a day.
Risk
L — correctness fix to a write path. Only failure mode is double-counting; covered by a regression test that asserts
cost_centsmatchesusage_json.costUsd * 100for new rows.Levi-specific implementation note
Pair with upstream PR #6740 (recurring_fixed cost events) ONLY if Levi tracks hosting/Claude subscription as a fixed monthly line. Otherwise scope narrowly to the per-event fix to keep the change small.
Acceptance criteria
usage_json.costUsd > 0writes acost_eventsrow withcost_cents = round(costUsd * 100), regardless ofbilling_typecost_cents=0butusage_json.costUsd>0agents.spent_monthly_centsis observed to advance month-over-month in production after fixSurveyed by the Levi planning agent on 2026-05-26.