Documentation
¶
Index ¶
- Variables
- func ComposeMaintenanceAccounting(store billing.AuthoritativeBilling, ...) (billing.ProviderMaintenanceUsageObserver, error)
- func NewCallRatingResolver(catalog *SnapshotCatalog) (billing.CallRatingResolver, error)
- func NewProviderCostResolver(catalog *SnapshotCatalog, currency string) (billing.ProviderCostResolver, error)
- func PrincipalSessionIdentity(refs SnapshotRefFuncs) runtime.BillingIdentity
- type CustomerRatingSnapshots
- type DurableMaintenanceObserver
- type JoinRatingResolver
- func (r *JoinRatingResolver) Rate(ctx context.Context, input economics.PostUsageRatingInput) (economics.Valuation, error)
- func (r *JoinRatingResolver) ResolveCallRating(_ context.Context, complete billing.CompleteCall, ...) (billing.CallRatingResult, error)
- func (r *JoinRatingResolver) ResolveCallRatingForOwner(_ context.Context, complete billing.CompleteCall, ...) (billing.CallRatingResult, error)
- type ProviderCostJoinResolver
- type SnapshotCatalog
- func (c *SnapshotCatalog) ChargePolicyRef(_ context.Context, _ lipapi.Call) billing.VersionRef
- func (c *SnapshotCatalog) CustomerPricingRef(_ context.Context, _ lipapi.Call) billing.VersionRef
- func (c *SnapshotCatalog) CustomerRatingSnapshots(call billing.CallUsageRecord, legs []billing.CallLegUsageRecord) (CustomerRatingSnapshots, error)
- func (c *SnapshotCatalog) DefaultTariff(ctx context.Context) (economics.TariffSnapshot, error)
- func (c *SnapshotCatalog) HasDefaults() bool
- func (c *SnapshotCatalog) OperatorCostSelectionPolicy(ref billing.VersionRef) (billing.OperatorCostSelectionPolicy, error)
- func (c *SnapshotCatalog) OperatorRate(ref billing.VersionRef) (billing.OperatorRateSnapshot, error)
- func (c *SnapshotCatalog) OperatorRateRef(_ context.Context, backend, model string) billing.VersionRef
- func (c *SnapshotCatalog) Policy(ctx context.Context, _ lipapi.Call) (billing.ChargePolicy, error)
- func (c *SnapshotCatalog) PutOperatorCostSelectionPolicy(policy billing.OperatorCostSelectionPolicy) error
- func (c *SnapshotCatalog) PutOperatorRate(snapshot billing.OperatorRateSnapshot) error
- func (c *SnapshotCatalog) PutPolicy(snapshot billing.ChargePolicy) error
- func (c *SnapshotCatalog) PutPricing(snapshot billing.PricingSnapshot) error
- func (c *SnapshotCatalog) PutPricingWithSchemas(snapshot billing.PricingSnapshot, schemas []metering.ComponentSchema) error
- func (c *SnapshotCatalog) PutPricingWithSupportAdvisory(snapshot billing.PricingSnapshot, schemas []metering.ComponentSchema, ...) error
- func (c *SnapshotCatalog) PutTariff(snapshot economics.TariffSnapshot) error
- func (c *SnapshotCatalog) ResolveTariff(ctx context.Context, ref billing.VersionRef) (economics.TariffSnapshot, error)
- func (c *SnapshotCatalog) RoutePricing(ctx context.Context, backend, model string) (billing.PricingSnapshot, error)
- func (c *SnapshotCatalog) RouteTariff(ctx context.Context, backend, model string) (economics.TariffSnapshot, error)
- func (c *SnapshotCatalog) SetDefaults(CustomerPricing, ChargePolicy billing.VersionRef) error
- func (c *SnapshotCatalog) SetOperatorRateBinding(backend, model string, ref billing.VersionRef) error
- func (c *SnapshotCatalog) SetRoutePricing(backend, model string, ref billing.VersionRef) error
- func (c *SnapshotCatalog) Snapshot(ctx context.Context) (economics.Snapshot[economics.RatingCatalogView], error)
- func (c *SnapshotCatalog) Tariff(ref billing.VersionRef) (economics.TariffSnapshot, error)
- type SnapshotRefFuncs
Constants ¶
This section is empty.
Variables ¶
var ( ErrSnapshotImmutable = errors.New("billingcompose: published snapshot is immutable") ErrSnapshotNotFound = errors.New("billingcompose: snapshot not found") ErrPolicyPricingMismatch = errors.New("billingcompose: charge policy pricing ref does not match customer pricing") ErrBindingImmutable = errors.New("billingcompose: route binding is immutable") )
Functions ¶
func ComposeMaintenanceAccounting ¶
func ComposeMaintenanceAccounting(store billing.AuthoritativeBilling, injected billing.ProviderMaintenanceUsageObserver) (billing.ProviderMaintenanceUsageObserver, error)
func NewCallRatingResolver ¶
func NewCallRatingResolver(catalog *SnapshotCatalog) (billing.CallRatingResolver, error)
func NewProviderCostResolver ¶
func NewProviderCostResolver(catalog *SnapshotCatalog, currency string) (billing.ProviderCostResolver, error)
func PrincipalSessionIdentity ¶
func PrincipalSessionIdentity(refs SnapshotRefFuncs) runtime.BillingIdentity
Types ¶
type CustomerRatingSnapshots ¶
type CustomerRatingSnapshots struct {
DefaultPricing billing.PricingSnapshot
Policy billing.ChargePolicy
ModelPricing []billing.ModelCustomerPricing
// DefaultTariff and ModelTariffs are the frozen component-rating material
// corresponding to the scalar cards above. They are additive so existing
// scalar callers continue to resolve exactly as before.
DefaultTariff economics.TariffSnapshot
ModelTariffs []billing.ModelCustomerTariff
}
CustomerRatingSnapshots is the complete immutable input set customer rating resolves for one call. It deliberately carries no OperatorRateSnapshot values: customer settlement must never depend on provider-cost readiness.
type DurableMaintenanceObserver ¶
type DurableMaintenanceObserver struct {
// contains filtered or unexported fields
}
DurableMaintenanceObserver delivers maintenance usage to the authoritative provider-billable store. The store owns idempotency and durable persistence.
func NewDurableMaintenanceObserver ¶
func NewDurableMaintenanceObserver(store billing.ProviderMaintenanceUsageStore) *DurableMaintenanceObserver
func (*DurableMaintenanceObserver) ObserveProviderMaintenance ¶
func (o *DurableMaintenanceObserver) ObserveProviderMaintenance(ctx context.Context, usage billing.ProviderMaintenanceUsage) error
type JoinRatingResolver ¶
type JoinRatingResolver struct {
// contains filtered or unexported fields
}
func (*JoinRatingResolver) Rate ¶
func (r *JoinRatingResolver) Rate(ctx context.Context, input economics.PostUsageRatingInput) (economics.Valuation, error)
Rate resolves and freezes the accepted tariff before invoking the billing domain's post-usage evaluator. The resolver is intentionally separate from ResolveCallRating: legacy scalar call settlement remains compatible while component E/Q/P valuation uses the immutable tariff path.
func (*JoinRatingResolver) ResolveCallRating ¶
func (r *JoinRatingResolver) ResolveCallRating(_ context.Context, complete billing.CompleteCall, exposure billing.CallExposure) (billing.CallRatingResult, error)
func (*JoinRatingResolver) ResolveCallRatingForOwner ¶
func (r *JoinRatingResolver) ResolveCallRatingForOwner(_ context.Context, complete billing.CompleteCall, exposure billing.CallExposure, owner string) (billing.CallRatingResult, error)
ResolveCallRatingForOwner is the production owner-aware customer-rating port (Phase 18 blocker 1). The durable B1 pin owner selects V1 drain vs V2 component semantics inside billing.RateCall: V2-owned work rates exclusively from canonical V2 component quantities (legacy tariffs as explicitly mapped component material where supported) and fails closed before money when V2 evidence is missing or unsupported. The scalar live engine is unreachable for V2 owner/token and new live V2 calls. The complete bound valuation (subject/scope, currency, amount, result identity) is enforced before returning so a scalar wearing an ID cannot leave this boundary.
type ProviderCostJoinResolver ¶
type ProviderCostJoinResolver struct {
// contains filtered or unexported fields
}
func (*ProviderCostJoinResolver) ResolveProviderCost ¶
func (r *ProviderCostJoinResolver) ResolveProviderCost(_ context.Context, leg billing.CallLegUsageRecord) (billing.OperatorCostResult, error)
type SnapshotCatalog ¶
type SnapshotCatalog struct {
// contains filtered or unexported fields
}
func NewSnapshotCatalog ¶
func NewSnapshotCatalog() *SnapshotCatalog
func (*SnapshotCatalog) ChargePolicyRef ¶
func (c *SnapshotCatalog) ChargePolicyRef(_ context.Context, _ lipapi.Call) billing.VersionRef
func (*SnapshotCatalog) CustomerPricingRef ¶
func (c *SnapshotCatalog) CustomerPricingRef(_ context.Context, _ lipapi.Call) billing.VersionRef
func (*SnapshotCatalog) CustomerRatingSnapshots ¶
func (c *SnapshotCatalog) CustomerRatingSnapshots(call billing.CallUsageRecord, legs []billing.CallLegUsageRecord) (CustomerRatingSnapshots, error)
CustomerRatingSnapshots resolves customer pricing/policy/model cards only. It never looks up, validates, or loads operator-rate snapshots, so missing, invalid, stale, or unreconciled provider-cost data cannot block customer settlement or leave operational exposure open (requirements 5.1-5.6).
The model cards mirror what admission quotes: a route/model override binds a versioned immutable pricing body; a route without an override keeps the configured default card. When any override exists for the call and an override body is missing this fails closed rather than substituting an unrelated model price.
func (*SnapshotCatalog) DefaultTariff ¶
func (c *SnapshotCatalog) DefaultTariff(ctx context.Context) (economics.TariffSnapshot, error)
DefaultTariff resolves the configured default component tariff. It is used for direct provider-reported P valuations, whose amount does not depend on local tariff arithmetic but still needs a stable evaluator instance.
func (*SnapshotCatalog) HasDefaults ¶
func (c *SnapshotCatalog) HasDefaults() bool
func (*SnapshotCatalog) OperatorCostSelectionPolicy ¶
func (c *SnapshotCatalog) OperatorCostSelectionPolicy(ref billing.VersionRef) (billing.OperatorCostSelectionPolicy, error)
OperatorCostSelectionPolicy returns the frozen policy for ref, or ErrSnapshotNotFound. The returned value is caller-owned.
func (*SnapshotCatalog) OperatorRate ¶
func (c *SnapshotCatalog) OperatorRate(ref billing.VersionRef) (billing.OperatorRateSnapshot, error)
OperatorRate returns a historical V1 operator-rate body for replay only (Task 18.2). No live production money path calls it after the Task 18.1 scalar-fallback retirement; V2 provider-quantity valuation owns estimates. Operator migration: query historical bodies for audit, never for live rating.
func (*SnapshotCatalog) OperatorRateRef ¶
func (c *SnapshotCatalog) OperatorRateRef(_ context.Context, backend, model string) billing.VersionRef
func (*SnapshotCatalog) Policy ¶
func (c *SnapshotCatalog) Policy(ctx context.Context, _ lipapi.Call) (billing.ChargePolicy, error)
func (*SnapshotCatalog) PutOperatorCostSelectionPolicy ¶
func (c *SnapshotCatalog) PutOperatorCostSelectionPolicy(policy billing.OperatorCostSelectionPolicy) error
PutOperatorCostSelectionPolicy freezes one versioned operator cost selection policy in the catalog. Exact replay is idempotent; a changed payload under an existing identity is rejected.
func (*SnapshotCatalog) PutOperatorRate ¶
func (c *SnapshotCatalog) PutOperatorRate(snapshot billing.OperatorRateSnapshot) error
PutOperatorRate publishes a historical V1 operator-rate body (Migration Strategy step 8, Task 18.2). Live scalar fallback is retired: no production money path reads these bodies for estimates. Retained for historical replay and OperatorRateRef lineage. Operator migration: do not publish new rates for live rating; V2 tariffs own estimates.
func (*SnapshotCatalog) PutPolicy ¶
func (c *SnapshotCatalog) PutPolicy(snapshot billing.ChargePolicy) error
func (*SnapshotCatalog) PutPricing ¶
func (c *SnapshotCatalog) PutPricing(snapshot billing.PricingSnapshot) error
func (*SnapshotCatalog) PutPricingWithSchemas ¶
func (c *SnapshotCatalog) PutPricingWithSchemas(snapshot billing.PricingSnapshot, schemas []metering.ComponentSchema) error
PutPricingWithSchemas atomically publishes a scalar pricing card and the matching opt-in schema-bearing tariff, so a frozen default or route tariff is reachable through the public catalog. Schemas are caller-supplied and never inferred; empty schemas is exactly PutPricing.
func (*SnapshotCatalog) PutPricingWithSupportAdvisory ¶
func (c *SnapshotCatalog) PutPricingWithSupportAdvisory(snapshot billing.PricingSnapshot, schemas []metering.ComponentSchema, version string) error
PutPricingWithSupportAdvisory atomically publishes a scalar pricing card and its matching frozen advisory tariff. The version is validated by the SDK tariff contract before either catalog entry becomes visible.
func (*SnapshotCatalog) PutTariff ¶
func (c *SnapshotCatalog) PutTariff(snapshot economics.TariffSnapshot) error
PutTariff publishes a generic immutable tariff alongside the legacy scalar catalog. The identity is the VersionRef portion of the rating snapshot; content and rater identity remain part of the immutable body.
func (*SnapshotCatalog) ResolveTariff ¶
func (c *SnapshotCatalog) ResolveTariff(ctx context.Context, ref billing.VersionRef) (economics.TariffSnapshot, error)
ResolveTariff is the context-aware catalog port used by post-usage workers. Context cancellation is checked before resolving immutable local material.
func (*SnapshotCatalog) RoutePricing ¶
func (c *SnapshotCatalog) RoutePricing(ctx context.Context, backend, model string) (billing.PricingSnapshot, error)
func (*SnapshotCatalog) RouteTariff ¶
func (c *SnapshotCatalog) RouteTariff(ctx context.Context, backend, model string) (economics.TariffSnapshot, error)
RouteTariff resolves the generic tariff bound to a route, or the configured default when no route override exists.
func (*SnapshotCatalog) SetDefaults ¶
func (c *SnapshotCatalog) SetDefaults(CustomerPricing, ChargePolicy billing.VersionRef) error
func (*SnapshotCatalog) SetOperatorRateBinding ¶
func (c *SnapshotCatalog) SetOperatorRateBinding(backend, model string, ref billing.VersionRef) error
SetOperatorRateBinding binds a historical V1 operator-rate ref for OperatorRateRef lineage stamping (Task 18.2). Live money never resolves rate bodies through this binding; V2 tariffs own estimates. Retained so sealed B-legs keep explicit historical refs.
func (*SnapshotCatalog) SetRoutePricing ¶
func (c *SnapshotCatalog) SetRoutePricing(backend, model string, ref billing.VersionRef) error
func (*SnapshotCatalog) Snapshot ¶
func (c *SnapshotCatalog) Snapshot(ctx context.Context) (economics.Snapshot[economics.RatingCatalogView], error)
Snapshot implements the public rating source for the configured default card. Refresh still belongs to the host snapshot controller; this method only exposes a stable, content-addressable source view.
func (*SnapshotCatalog) Tariff ¶
func (c *SnapshotCatalog) Tariff(ref billing.VersionRef) (economics.TariffSnapshot, error)
Tariff resolves immutable generic material by its stable ID/version. The returned body is a deep copy; callers cannot mutate replay behavior.