Skip to main content

Crate costroid_focus

Crate costroid_focus 

Source
Expand description

FOCUS 1.3 Cost and Usage export primitives for Costroid.

As of Milestone 6a, FocusRecord carries the full FOCUS 1.3 Cost and Usage column set so the official validator’s conditional dependency checks resolve. Columns Costroid cannot derive from local data are emitted null where the spec permits; the few that a not-null cascade forces are populated with the spec-correct categorical value or, for billing-source identifiers with no local value, a clearly-non-billing placeholder (documented as a deviation).

Numeric columns serialize as genuine numbers in JSON and as decimal-pointed values in CSV (so the validator’s DECIMAL/DOUBLE/FLOAT type checks pass even when every value in a column is whole).

As of Milestone 6b, pricing is represented per token: PricingUnit = "tokens", PricingQuantity is the token count, and the unit-price columns are per-token rates (the per-1M catalog rate ÷ 1_000_000). Cost is unchanged — cost = tokens × rate is invariant — only the representation changed. On rows with no priced SKU (SkuPriceId null), FOCUS 1.3 requires ConsumedQuantity / PricingQuantity / PricingUnit / PricingCategory to be null, so they are; the raw token count still travels on the always-populated x_ConsumedTokens custom column for the aggregation engine. One genuine validator-ruleset defect remains documented (the ListCost/ContractedCost = unit-price × quantity check, which the validator evaluates in zero-tolerance float64 even though Costroid’s decimal arithmetic is exact); see scripts/focus_known_failures.txt.

Structs§

FocusExportEnvelope
FocusRecord
A FOCUS 1.3 Cost and Usage charge row.
UnpricedUsage

Enums§

FocusAccessPath
FocusError
TokenType

Constants§

BILLING_ACCOUNT_ID_LOCAL
Placeholder BillingAccountId. FOCUS requires BillingAccountId to be non-null, but Costroid is a local estimator with no billing-account identity. This obviously-non-billing sentinel is a documented deviation; Costroid never fabricates realistic-looking account identifiers.
BILLING_ACCOUNT_NAME_LOCAL
Placeholder BillingAccountName, paired with BILLING_ACCOUNT_ID_LOCAL.
BILLING_ACCOUNT_TYPE_LOCAL
Placeholder BillingAccountType. FOCUS forces this non-null whenever BillingAccountId is non-null; since our account id is itself a placeholder, the type is too (documented deviation).
CHARGE_CATEGORY_USAGE
CHARGE_FREQUENCY_USAGE_BASED
DEFAULT_BILLING_CURRENCY
FOCUS_VERSION
PRICING_CATEGORY_STANDARD
PRICING_STATUS_MISSING_PRICE
PRICING_UNIT_TOKENS
FOCUS PricingUnit / ConsumedUnit for per-token AI usage. Singular count unit (no numeric multiplier) so it conforms to the FOCUS UnitFormat.
SERVICE_CATEGORY_AI
SERVICE_SUBCATEGORY_GENERATIVE_AI
Valid FOCUS ServiceSubcategory paired with ServiceCategory = "AI and Machine Learning". Costroid’s three providers are LLM coding tools, so this is the correct classification — not a deviation.

Functions§

to_csv_string
to_json_string

Type Aliases§

FocusTimestamp