feat: add first-class background billing - #1388
Open
pjb157 wants to merge 1 commit into
Open
Conversation
Deploying control-layer with
|
| Latest commit: |
cc4ca3a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0f676d11.control-layer.pages.dev |
| Branch Preview URL: | https://peter-background-billing-tie.control-layer.pages.dev |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes “background” a first-class billing tier end-to-end (ledger, batch aggregates, pricing/tariffs, connection sync ingestion, metrics, and UI), with explicit pricing resolution rules that keep background requests labeled as background while preventing accidental realtime billing.
Changes:
- Add background-aware service tier classification/backfills for credits ledger and batch aggregates.
- Implement background-specific tariff resolution (explicit background tariff → 24h batch tariff only; otherwise unbilled) and expose it in APIs/UI.
- Allow connection sync to submit native background batches (role-gated) while bypassing foreground SLA capacity + unverified-volume admission but still validating models.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/backfill_credits_denorm.sh | Extends ledger backfill classification to include background (file-backed + batchless) and updates Phase 2 to recover background/flex from analytics. |
| scripts/backfill_batch_aggregates_denorm.sh | Backfills batch_aggregates.service_tier to include background based on fusillade batch metadata. |
| dwctl/src/request_logging/batcher.rs | Adds background billing tier computation, factors tariff resolution into a helper, and adds integration tests for background pricing/tier behavior. |
| dwctl/src/metrics/gen_ai.rs | Updates GenAI metrics tier labeling tests to include background. |
| dwctl/src/db/models/tariffs.rs | Documents background as a supported batch completion window in tariff models. |
| dwctl/src/db/models/credits.rs | Updates ledger response docs to include background service tier. |
| dwctl/src/db/handlers/tariffs.rs | Implements background pricing fallback semantics (background → 24h only) and adds tests. |
| dwctl/src/connections/sync.rs | Supports activating background batches from connection sync while skipping foreground admission/capacity reservation. |
| dwctl/src/api/models/transactions.rs | Updates API docs to include background service tier in transaction responses. |
| dwctl/src/api/models/tariffs.rs | Updates API docs to include background completion window for batch tariffs. |
| dwctl/src/api/models/deployments/mod.rs | Keeps background tariff visibility independent of foreground SLA windows, with 24h fallback visibility rules. |
| dwctl/src/api/models/deployments/enrichment.rs | Adds tests asserting background tariff and fallback aren’t filtered by foreground completion window config. |
| dwctl/src/api/models/connections.rs | Documents completion_window: background for sync trigger requests (role-gated). |
| dwctl/src/api/handlers/connections.rs | Enforces BackgroundInferenceUser role for background sync triggers and persists the completion window override. |
| dwctl/migrations/125_add_background_billing_tier.sql | Adds background to service tier CHECK constraints using a NOT VALID approach to avoid scanning the large ledger. |
| dashboard/src/utils/formatters.ts | Adds “Background” labeling and deterministic sort order for background tariffs. |
| dashboard/src/utils/formatters.test.ts | Tests background display name and sorting behavior. |
| dashboard/src/components/features/models/manage/ModelTariffTable.tsx | Allows selecting an explicit background tariff window even when foreground SLA windows are constrained. |
| dashboard/src/components/features/models/manage/ModelTariffTable.test.tsx | Verifies background tariff option is available independent of foreground SLAs. |
| dashboard/src/components/features/models/manage/ModelsContent.tsx | Surfaces background pricing independently and shows effective background pricing via 24h fallback when needed. |
| dashboard/src/api/control-layer/types.ts | Extends frontend types to recognize background as a completion window value. |
pjb157
force-pushed
the
peter/background-billing-tier
branch
from
July 29, 2026 19:08
8b678a7 to
cc4ca3a
Compare
Introduce explicit background tariff resolution and accounting across the ledger, metrics, model pricing UI, and historical backfills. Allow authorized connector syncs to create native background batches while retaining model validation and bypassing foreground admission limits.
pjb157
force-pushed
the
peter/background-billing-tier
branch
from
July 29, 2026 19:09
cc4ca3a to
3443523
Compare
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
backgroundas a first-class billing tier across credit transactions, batch aggregates, GenAI metrics, transaction responses, model pricing, and historical backfillsWhy
Background dispatch is a distinct inference class, but billing and connector ingestion still treated it as an ordinary SLA batch in several paths. That could report the wrong tier, select realtime pricing, or reject/fail connector-created background work through foreground admission and completion-window parsing.
Impact
Platform managers can configure a dedicated background tariff per model. Without one, background work charges the model's 24h batch price without changing its accounting identity. Connection sync callers need the
BackgroundInferenceUserrole to selectcompletion_window: "background"; accepted files become real background batches and do not consume foreground admission capacity.Historical backfill scripts now classify file-backed and batchless background usage, including purged request rows recovered from analytics, without adding an extra analytics-table scan.
Validation
cargo test -p dwctl background_ --lib(31 passed)cargo test -p dwctl test_compute_billing_tier --libcargo test -p dwctl test_billing_tier_label_maps_each_case --libjust lint rust -- -D warningsjust lint tspnpm build