litellm/tests/integration/database
joshua-berri 894552205b
feat(spend): report guardrail spend separately in daily activity (#51010)
* feat(spend): report guardrail spend separately in daily activity

Model and key spend in /user/daily/activity/aggregated include the cost of
guardrails like Bedrock guardrails, and nothing in the response says how much.
A customer that bills tenants per key and per model could not get model cost
alone, so tenants that pay AWS for their own guardrails were charged for them
twice

Daily spend rows now carry a guardrail_spend column next to spend, and every
breakdown in the daily activity responses exposes it, so model cost is
spend - guardrail_spend. spend keeps its meaning, so budgets still count
guardrail cost as before

The value comes from the request's cost_breakdown.guardrail_cost, capped at
the row's spend because an allowance discount or a repeat job poll can charge
less than the guardrail cost the breakdown records. The delivery ledger
freezes it into the accounting payload next to accounting_savings, since the
stored payload does not keep cost_breakdown, and the legacy daily queue writes
the same value

The migration only adds the column with a 0 default, so rows written before it
read 0

* fix(spend): count guardrail spend on rows billed without a cost breakdown

A request blocked before the LLM call is billed for its guardrails straight from
guardrail_information, so it carries no cost_breakdown and its guardrail_spend
read 0. Both writers now price guardrail_spend from guardrail_information with
guardrail_information_cost, the same function success and failure rows use to add
guardrail cost to spend

Also fills guardrail_spend in the client usage view built from request logs,
qualifies the field description for rows recorded before it existed, and adds
the lock timeout the migration checks require

* fix(ui): avoid a nested ternary when reading guardrail entries from request logs

---------

Co-authored-by: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com>
2026-11-10 13:02:26 -08:00
..
image test: migrate proxy security, schema migration and MCP legacy tests (#45937) 2026-10-11 16:17:24 -07:00
migrations refactor(proxy)!: drop the unused accounting event tables (#49923) 2026-11-04 20:23:30 -08:00
test_chunked_in_lists.py ci: fail on new unbounded SQL IN lists and add a Prisma chunking helper (#42629) 2026-09-26 13:40:44 -07:00
test_cleanup_transactions.py ci(integration): keep the MCP SDK1 peer on mcp 1.x and autovacuum off the size cleanup test (#47651) 2026-10-21 03:23:30 +00:00
test_global_spend_refresh_writer.py fix(spend): run the MonthlyGlobalSpend refresh on the writer when a read replica is configured (#45699) 2026-10-10 00:49:13 -07:00
test_harness_lifecycle.py test(integration): recognize cached statements in database relay barriers (#50651) 2026-11-09 06:58:46 -08:00
test_managed_file_flat_ids_index.py test(integration): point the scratch upgraded proxy's read replica at the scratch database (#44613) 2026-10-05 23:06:36 +00:00
test_migration_entrypoint.py test(integration): regression tests for July cost tracking, budgeting and spend bugs (#42694) 2026-09-23 09:51:56 -07:00
test_partition_transactions.py test: fix stale and flaky tests across CircleCI, GHA and Buildkite (#45530) 2026-10-09 11:40:14 -07:00
test_prisma_engine_port.py fix(proxy): let the OS assign Prisma engine ports (#50850) 2026-11-10 07:28:55 +00:00
test_prisma_migration_lock.py test(integration): fix four flaky integration tests (#49554) 2026-11-02 09:23:17 -08:00
test_proxy_boot_without_general_settings.py test: move packaging and install checks off CircleCI build_and_test (#45757) 2026-10-10 09:33:51 -07:00
test_proxy_database_lifespan.py refactor(proxy): inject database repositories through per-repository dependencies (#48507) 2026-10-30 22:57:54 +00:00
test_reader_writer_regeneration.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_request_log_indexes_at_boot.py test: update stale MCP call_tool and usage card assertions, add timeout headroom to request-log index boot test (#45523) 2026-10-08 23:44:46 -07:00
test_roi_observed.py feat(roi): measure shipping velocity, quality, and recorded spend (#44426) 2026-10-03 23:07:34 +00:00
test_roi_sync_store.py feat(proxy): add native ROI calculator for gateway spend vs merged PRs (#43669) 2026-09-30 14:16:41 -07:00
test_skill_publication.py feat(skills)!: version published Skills Hub updates (#50152) 2026-11-05 00:19:38 -08:00
test_skill_submissions.py feat(skills): add sortable Skills Hub catalog and publication audit (#50195) 2026-11-06 00:57:33 +00:00
test_spend_lock_order.py feat(accounting)!: make the SpendLogs ledger the default accounting path (#49872) 2026-11-05 09:14:10 -08:00
test_spendlogs_delivery.py fix(accounting): stop delivery metrics from scanning retained receipts on every flush (#50565) 2026-11-07 18:21:32 -08:00
test_spendlogs_ledger_parity.py feat(spend): report guardrail spend separately in daily activity (#51010) 2026-11-10 13:02:26 -08:00
test_transaction_atomicity.py test(integration): add read-replica routing harness to the CircleCI integration suite (#42692) 2026-09-24 00:25:03 -07:00
test_v1_migration_error_logging.py test(integration): hand every harness server a port from one per-worker block (#46761) 2026-10-15 16:56:40 -07:00