This repository was archived by the owner on May 26, 2026. It is now read-only.
KR-SNAPSHOT-EXPAND-COST-FIELDS — schema v3 cost-ladder spend/pool#169
Merged
rafe-walker merged 1 commit intoMay 24, 2026
Merged
Conversation
…end/pool fields
* Bump snapshot schema_version 2 → 3.
* Add `spent_to_date_usd` + `credit_pool_usd` to `cost_ladder` section.
- When the cost-state holder is wired, fields flow from
`holder.current.spent_to_date_usd` and `holder.current.credit_pool_usd`.
- When the holder is unavailable: `spent_to_date_usd` degrades to
`"unknown"` (no observed-state env); `credit_pool_usd` falls back to
`KORA_CREDIT_POOL_USD` env (fail-soft, $200 default per
`reference-anthropic-sdk-billing-split`).
- Holder wins over env when both are present — the holder figure is
what the cost rungs compute against, so the snapshot must agree.
* Wire `cost_ladder.model_default` to KR-HAIKU-ROUTER's
`DEFAULT_HAIKU_MODEL` constant (resolves PR #157's `"unknown"`
placeholder). Router import fail degrades back to `"unknown"`.
* Tests cover: schema bump, env override (truthy / malformed / zero /
negative), holder-wins-over-env, model-default resolution,
router-import degrade, and holder-current-raises full degrade.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 24, 2026
rafe-walker
added a commit
that referenced
this pull request
May 24, 2026
…n holdouts (#174) 4-of-4 dashboard hero fields snapshot-driven on warm cache. Verified at DashboardPage.tsx:1270-1345 — loadInitial does NOT call api.getOperationalState / getCurrentAlerts / getCostState / getHealthRollup with fresh snapshot. PR #162 anti-projection tests FLIPPED (not deleted): test_dashboard_does_not_project_*_from_snapshot → test_dashboard_projects_*_from_snapshot with null-return + per-field fallback pins. New pins: badge surfaces N-of-M hero count + DASHBOARD_HERO_FIELD_COUNT===4 literal regression guard. K-DG drift caught + fixed: SnapshotResponse TS type was stale — missing cost_ladder.spent_to_date_usd + credit_pool_usd (#169) + the entire daemon_health section (#170). Added; required before projection helpers could compile. Per-card retry buttons + forceFullLiveRefresh still fan out by design (operator-triggered force paths). 19/19 tests pass, tsc + vite build clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bumps the daemon snapshot to schema_version 3 with two new
cost_ladderfields and a resolvedmodel_default:cost_ladder.spent_to_date_usd—holder.current.spent_to_date_usdwhen wired, else"unknown".cost_ladder.credit_pool_usd—holder.current.credit_pool_usdwhen wired, elseKORA_CREDIT_POOL_USDenv (default $200 perreference-anthropic-sdk-billing-split).cost_ladder.model_default— now readsDEFAULT_HAIKU_MODELfrom KR-HAIKU-ROUTER (feat(kora): KR-HAIKU-ROUTER — default-Haiku with earned Opus escalation (Lock R3-3) #165). Resolves PR feat(kora): KR-CHEAP-PRE-WARMED-SNAPSHOT — daemon state every 5 min at zero LLM cost #157's"unknown"placeholder.Bucket spec:
17_cc_bucket_prompts/KR-SNAPSHOT-EXPAND-COST-FIELDS_spent_credit_pool.md.Env vars
KORA_CREDIT_POOL_USD200.00DEFAULT_CREDIT_POOL_USD.Populated vs degraded fields
cost_ladderfieldNone.currentraisescurrent_tierholder.active_rung().name(e.g.WARN_75)"unknown""unknown"monthly_budget_pct_usedholder.current_pct_used() * 100rounded 2dpNoneNonemodel_defaultDEFAULT_HAIKU_MODEL(or"unknown"if router import fails)DEFAULT_HAIKU_MODELDEFAULT_HAIKU_MODELspent_to_date_usdholder.current.spent_to_date_usdrounded 6dp"unknown""unknown"credit_pool_usdholder.current.credit_pool_usdrounded 2dp (wins over env)KORA_CREDIT_POOL_USDor $200 defaultKORA_CREDIT_POOL_USDor $200 defaultHolder wins over env for
credit_pool_usd— rungs compute against the holder figure, so the snapshot must agree.CC#2 follow-on recommendation
PR #164 (
CostCardBody) currently pulls cost figures from/api/cost-telemetrydirectly. With snapshot v3 surfacingspent_to_date_usd+credit_pool_usdfrom a single 5-min-cron'd file, CC#2 can shift to readingdaemon_snapshot.jsoninstead:The cron cadence is 5-min so the displayed value will lag by up to 5 min — acceptable for a cockpit panel, but CC#2 should keep
/api/cost-telemetryas the live source for any pre-decision read.Test plan
tests/kora_cli/snapshot/test_state_snapshot.py— 47 tests pass (schema bump, shape, env override truthy / malformed / zero, holder-wins-over-env, model-default router-resolved, router-import degrade, holder-current-raises full degrade)ruff checkclean on changed files🤖 Generated with Claude Code