billingcompose

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 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 (*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

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 (*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

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

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

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 (*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

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

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

Tariff resolves immutable generic material by its stable ID/version. The returned body is a deep copy; callers cannot mutate replay behavior.

type SnapshotRefFuncs

type SnapshotRefFuncs struct {
	CustomerPricingRef func(context.Context, lipapi.Call) billing.VersionRef
	ChargePolicyRef    func(context.Context, lipapi.Call) billing.VersionRef
	OperatorRateRef    func(context.Context, string, string) billing.VersionRef
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL