Documentation
¶
Overview ¶
Package metering implements immutable metering checkpoint capture and fact drafting for dual-plane economics. Public DTOs live in pkg/lipsdk/metering; durable journal stores are Phase 5.
Index ¶
- Constants
- Variables
- func ObservePreparedInput(ctx context.Context, summary PreparedInputSummary)
- func ObservePreparedInputCall(ctx context.Context, call lipapi.Call, method string)
- func PreparedInputObservationEnabled(ctx context.Context) bool
- func ProjectWorkloadIdentity(f lipmetering.Fact, auxiliaryRole string) (corebilling.WorkloadIdentity, error)
- func WithPreparedInputObserver(ctx context.Context, observer PreparedInputObserver) context.Context
- type AccountWindowObservationPage
- type AccountWindowProjection
- type AccountWindowProjectionPage
- type AccountWindowQuery
- type AccountWindowStore
- type BoundaryAccumulator
- func (a *BoundaryAccumulator) MarkAccepted(accepted bool)
- func (a *BoundaryAccumulator) MarkAttempted()
- func (a *BoundaryAccumulator) Observations(identity ObservationIdentity) []lipsdkmetering.Observation
- func (a *BoundaryAccumulator) ObserveCustomerEvent(event lipapi.Event, media ...MediaSummary)
- func (a *BoundaryAccumulator) ObservePreparedInput(summary PreparedInputSummary)
- func (a *BoundaryAccumulator) ObserveProviderEvent(event lipapi.Event, media ...MediaSummary)
- func (a *BoundaryAccumulator) PrepareCall(call lipapi.Call)
- func (a *BoundaryAccumulator) PreparePayloadBytes(bytes int64)
- func (a *BoundaryAccumulator) Snapshot() BoundarySnapshot
- type BoundaryConfig
- type BoundarySnapshot
- type ClosedBLegReader
- type EconomicObservationSink
- type LateEconomicAppender
- type LateEconomicAppenderConfig
- type LateEconomicEvidence
- type LateEconomicEvidenceKind
- type LateEconomicIdentity
- type MediaKind
- type MediaSummary
- type ObservationIdentity
- type ObservationResolver
- type OutputSnapshot
- type PreparedInputObserver
- type PreparedInputSnapshot
- type PreparedInputSummary
- type PreparedInputSummaryBuilder
- func (b *PreparedInputSummaryBuilder) AddMedia(media MediaSummary)
- func (b *PreparedInputSummaryBuilder) AddText(text string)
- func (b *PreparedInputSummaryBuilder) AddTextBytes(bytes int64)
- func (b *PreparedInputSummaryBuilder) Build() PreparedInputSummary
- func (b *PreparedInputSummaryBuilder) SetPayloadBytes(bytes int64)
- type ProviderDebitSnapshot
- type ProviderEvidenceBinder
- type ProviderEvidenceBuffer
- func (b *ProviderEvidenceBuffer) Add(draft ProviderEvidenceDraft)
- func (b *ProviderEvidenceBuffer) AddUsageEvent(ev lipapi.Event, mapping string)
- func (b *ProviderEvidenceBuffer) BindEconomicEvidence(identity ObservationIdentity)
- func (b *ProviderEvidenceBuffer) DrainEconomicObservations() []lipsdkmetering.Observation
- type ProviderEvidenceDraft
Constants ¶
const ( // BoundaryMappingRef identifies the provider-neutral local boundary mapping. BoundaryMappingRef = "lip.local.boundary.v1" // DefaultBoundaryMaxTextBytes limits text accounting without retaining text. DefaultBoundaryMaxTextBytes = 64 * 1024 // DefaultBoundaryMaxMediaEntries limits media property entries per plane. DefaultBoundaryMaxMediaEntries = 128 )
Variables ¶
var ( // ErrLateEconomicAppend classifies failures at the post-execution economic // append seam. It never represents a request/attempt reopen failure because // this seam has no lifecycle mutation capability. ErrLateEconomicAppend = errors.New("metering: late economic append rejected") // ErrLateEconomicSinkCapability identifies a sink that cannot guarantee one // transaction commits both the observation and its economic-work trigger. // A plain observation sink, including an observation-only atomic sink, is // intentionally insufficient for late evidence. ErrLateEconomicSinkCapability = errors.New("metering: late economic sink lacks atomic economic outbox capability") // ErrLateEconomicStoreMismatch prevents a caller from using a journal or // billing store belonging to another isolation namespace. ErrLateEconomicStoreMismatch = errors.New("metering: late economic store mismatch") // ErrLateEconomicLineageMismatch prevents attribution to a different // BillingCallID, B-leg, attempt sequence, or resolved correction scope. ErrLateEconomicLineageMismatch = errors.New("metering: late economic lineage mismatch") // ErrLateEconomicAuthorityMismatch prevents a provider/account authority // from being changed while referring to an immutable closed B-leg. ErrLateEconomicAuthorityMismatch = errors.New("metering: late economic authority mismatch") // ErrLateEconomicProvenanceMismatch prevents a late producer from using a // provenance tuple that does not match its declared evidence kind. ErrLateEconomicProvenanceMismatch = errors.New("metering: late economic provenance mismatch") // ErrLateEconomicLegNotClosed means the durable current-record checkpoint is // not yet closed. Late append is intentionally not an alternate terminal // handoff path. ErrLateEconomicLegNotClosed = errors.New("metering: late economic B-leg is not closed") )
var ( // ErrProviderDebitIncomplete is returned when no complete authoritative // request debit can be established (for example estimated/absent evidence, // an unresolved correction, or a pending supersession). The returned // snapshot retains the diagnostic aggregate but must not be posted or // converted to money by a caller. ErrProviderDebitIncomplete = errors.New("metering: provider debit incomplete") // ErrProviderDebitIdentityConflict is the typed reducer spelling of the // canonical replay conflict. A changed payload under one source revision is // never accepted as a second debit. ErrProviderDebitIdentityConflict = aggregate.ErrIdentityConflict )
Functions ¶
func ObservePreparedInput ¶
func ObservePreparedInput(ctx context.Context, summary PreparedInputSummary)
ObservePreparedInput invokes an attached callback, if any.
func ObservePreparedInputCall ¶
ObservePreparedInputCall computes the bounded canonical estimate only when a request-scoped observer is attached. This keeps ordinary accounting-off adapters free of media-summary allocations while retaining the same neutral callback seam for enabled capture.
func PreparedInputObservationEnabled ¶
PreparedInputObservationEnabled reports whether a final-boundary observer is attached. Adapter summary builders use it to keep disabled accounting free of payload-sized traversal or temporary summary allocations.
func ProjectWorkloadIdentity ¶
func ProjectWorkloadIdentity(f lipmetering.Fact, auxiliaryRole string) (corebilling.WorkloadIdentity, error)
ProjectWorkloadIdentity maps trusted auxiliary lineage onto the same bounded billing identity used by normal terminal/report records. The fact itself remains the existing metering contract: lifecycle and safe scope correlation carry classification, while the role is supplied from trusted lineage.
func WithPreparedInputObserver ¶
func WithPreparedInputObserver(ctx context.Context, observer PreparedInputObserver) context.Context
WithPreparedInputObserver attaches a request-scoped prepared-input callback.
Types ¶
type AccountWindowObservationPage ¶
type AccountWindowObservationPage struct {
Observations []lipsdkmetering.Observation
NextCursor string
}
AccountWindowObservationPage is a bounded immutable history page.
type AccountWindowProjection ¶
type AccountWindowProjection struct {
Subject lipsdkmetering.SubjectRef
Measures []lipsdkmetering.Measure
ObservedAt time.Time
ReceivedAt time.Time
ObservationRefs []lipsdkmetering.ObservationRef
}
AccountWindowProjection is a deterministic current or as-of view for one complete provider account/pool/window/reset identity. Measures are merged by component key as present-field gauges: an omitted or unavailable field never erases a previously known field. ObservationRefs retain the immutable source revisions used by this view. No measure is additive and no monetary charge can be represented by this projection.
func ProjectAccountWindows ¶
func ProjectAccountWindows(observations []lipsdkmetering.Observation, asOf time.Time) ([]AccountWindowProjection, error)
ProjectAccountWindows reduces account-window gauge observations into deterministic reset-scoped projections. It accepts observations in any arrival order and removes exact source-event replays before reducing. A conflicting payload for one immutable identity is rejected by the shared replay boundary.
func (AccountWindowProjection) IdentityKey ¶
func (p AccountWindowProjection) IdentityKey() string
IdentityKey returns the complete reset-scoped subject identity used for deterministic projection ordering and pagination. It intentionally excludes request/call lineage: any such association is informational on an account-window observation, never a separate gauge subject.
type AccountWindowProjectionPage ¶
type AccountWindowProjectionPage struct {
Projections []AccountWindowProjection
NextCursor string
}
AccountWindowProjectionPage contains one projection per matching reset epoch. Distinct pools, windows and reset epochs are never combined.
type AccountWindowQuery ¶
type AccountWindowQuery struct {
StoreID string
TenantID string
ProviderAccountKey string
PoolID string
WindowID string
ResetAt *time.Time
AsOf time.Time
Limit int
Cursor string
}
AccountWindowQuery identifies a provider allowance-window query. The provider account is mandatory: an account-window query without that bound would scan unrelated supplier accounts. Pool, window and reset are optional refinements; AsOf is an effective observed-at bound, not a receipt-time bound.
type AccountWindowStore ¶
type AccountWindowStore interface {
ListAccountWindowObservations(context.Context, AccountWindowQuery) (AccountWindowObservationPage, error)
ProjectAccountWindows(context.Context, AccountWindowQuery) (AccountWindowProjectionPage, error)
}
AccountWindowStore is the domain query contract implemented by the durable journal adapter. The contract carries only context and immutable DTOs; SQL transaction types remain in infrastructure.
type BoundaryAccumulator ¶
type BoundaryAccumulator struct {
// contains filtered or unexported fields
}
BoundaryAccumulator owns one attempt's bounded local boundary state.
func NewBoundaryAccumulator ¶
func NewBoundaryAccumulator(config ...BoundaryConfig) *BoundaryAccumulator
NewBoundaryAccumulator creates bounded in-memory observation state.
func (*BoundaryAccumulator) MarkAccepted ¶
func (a *BoundaryAccumulator) MarkAccepted(accepted bool)
MarkAccepted records an observed backend-open result.
func (*BoundaryAccumulator) MarkAttempted ¶
func (a *BoundaryAccumulator) MarkAttempted()
MarkAttempted records that backend opening crossed the local attempt boundary.
func (*BoundaryAccumulator) Observations ¶
func (a *BoundaryAccumulator) Observations(identity ObservationIdentity) []lipsdkmetering.Observation
Observations snapshots and converts local state into V2 envelopes without I/O.
func (*BoundaryAccumulator) ObserveCustomerEvent ¶
func (a *BoundaryAccumulator) ObserveCustomerEvent(event lipapi.Event, media ...MediaSummary)
ObserveCustomerEvent captures the post-projection customer-egress plane.
func (*BoundaryAccumulator) ObservePreparedInput ¶
func (a *BoundaryAccumulator) ObservePreparedInput(summary PreparedInputSummary)
ObservePreparedInput replaces the canonical fallback with an adapter's final provider-bound summary. It never imports provider count evidence.
func (*BoundaryAccumulator) ObserveProviderEvent ¶
func (a *BoundaryAccumulator) ObserveProviderEvent(event lipapi.Event, media ...MediaSummary)
ObserveProviderEvent captures provider-origin content before projection. Adapters may provide bounded post-decode media properties explicitly.
func (*BoundaryAccumulator) PrepareCall ¶
func (a *BoundaryAccumulator) PrepareCall(call lipapi.Call)
PrepareCall records a bounded canonical fallback before adapter opening.
func (*BoundaryAccumulator) PreparePayloadBytes ¶
func (a *BoundaryAccumulator) PreparePayloadBytes(bytes int64)
PreparePayloadBytes records a wire-only payload-byte fallback. A negative length remains absent rather than being converted to a false observed zero.
func (*BoundaryAccumulator) Snapshot ¶
func (a *BoundaryAccumulator) Snapshot() BoundarySnapshot
Snapshot returns a deep copy of mutable media slices.
type BoundaryConfig ¶
BoundaryConfig bounds local observation capture. Zero values select defaults.
type BoundarySnapshot ¶
type BoundarySnapshot struct {
Input PreparedInputSnapshot
ProviderOutput OutputSnapshot
CustomerOutput OutputSnapshot
}
BoundarySnapshot is an immutable copy of all local boundary planes.
func (BoundarySnapshot) Observations ¶
func (s BoundarySnapshot) Observations(identity ObservationIdentity) []lipsdkmetering.Observation
Observations converts the three local boundary planes into durable V2 envelopes. The conversion is deliberately pure: it does not call a recorder, journal, provider, or rating implementation.
type ClosedBLegReader ¶
type ClosedBLegReader interface {
GetCallLegUsage(context.Context, string) (corebilling.CallLegUsageRecord, error)
}
ClosedBLegReader resolves the immutable terminal usage record. The reader has no append or allocation method by design, which keeps this seam unable to reopen execution or manufacture a replacement B-leg.
type EconomicObservationSink ¶
type EconomicObservationSink interface {
sdkmetering.ObservationSink
AppendEconomicObservationWithOutbox(context.Context, sdkmetering.Observation) error
}
EconomicObservationSink is the consumer-owned late-economics capability. AppendEconomicObservationWithOutbox must commit the immutable observation and its required economic-work trigger in one durable transaction, preserve the journal's exact replay/ambiguity semantics, and return the same result for an exact retry. A sink implementing only ObservationSink or AtomicObservationSink does not satisfy this contract.
type LateEconomicAppender ¶
type LateEconomicAppender struct {
// contains filtered or unexported fields
}
LateEconomicAppender is the production append seam for provider finalizer, statement and correction evidence after execution closure.
func NewLateEconomicAppender ¶
func NewLateEconomicAppender(config LateEconomicAppenderConfig) (*LateEconomicAppender, error)
NewLateEconomicAppender constructs a late evidence appender with explicit ownership ports. It returns a concrete type so composition remains visible.
func (*LateEconomicAppender) AppendLateEconomicEvidence ¶
func (a *LateEconomicAppender) AppendLateEconomicEvidence(ctx context.Context, evidence LateEconomicEvidence) error
AppendLateEconomicEvidence validates a closed B-leg identity and appends one immutable observation. The only mutation available after the closed-record read is the observation sink; no terminal usage record, stream, attempt, or B-leg allocator is reachable from this method.
type LateEconomicAppenderConfig ¶
type LateEconomicAppenderConfig struct {
StoreID string
Legs ClosedBLegReader
// Sink remains compatibility-typed for composition boundaries; the
// constructor rejects it unless its dynamic implementation exposes the
// consumer-owned EconomicObservationSink capability.
Sink sdkmetering.ObservationSink
Resolver ObservationResolver
}
LateEconomicAppenderConfig wires the two read/append ports needed by the post-terminal economic path. StoreID is explicit so the appender cannot infer isolation from an untrusted observation.
type LateEconomicEvidence ¶
type LateEconomicEvidence struct {
Kind LateEconomicEvidenceKind
Identity LateEconomicIdentity
Observation sdkmetering.Observation
}
LateEconomicEvidence is a complete, already-normalized V2 observation plus the trusted closed B-leg identity supplied by the caller. It deliberately contains no terminal sink, attempt allocator, or stream handle.
type LateEconomicEvidenceKind ¶
type LateEconomicEvidenceKind string
LateEconomicEvidenceKind identifies the authenticated producer of an observation appended after execution closure. The kind is checked against the V2 provenance tuple so a provider response cannot be relabelled as a statement (or vice versa) at this boundary.
const ( LateEconomicProviderFinalizer LateEconomicEvidenceKind = "provider_finalizer" LateEconomicStatement LateEconomicEvidenceKind = "statement" LateEconomicCorrection LateEconomicEvidenceKind = "correction" )
type LateEconomicIdentity ¶
type LateEconomicIdentity struct {
StoreID string
BillingCallID corebilling.BillingCallID
ALegID string
BLegID string
AttemptID string
AttemptSeq uint64
ProviderID string
ProviderAccountKey string
ProviderRequestID string
ProviderChargeID string
}
LateEconomicIdentity is the immutable identity that a late observation must echo. ProviderID is the closed record's provider authority; the remaining fields are the trusted B-leg/economic lineage carried by the observation.
type MediaKind ¶
type MediaKind string
MediaKind identifies a provider-neutral media shape at a boundary.
type MediaSummary ¶
type MediaSummary struct {
Kind MediaKind
Count int64
Bytes int64
BytesPresent bool
DurationMillis int64
DurationPresent bool
Frames int64
FramesPresent bool
Pages int64
PagesPresent bool
WidthPixels int64
WidthPresent bool
HeightPixels int64
HeightPresent bool
MIME string
}
MediaSummary is a bounded media property summary. It never contains raw media; presence flags distinguish an observed zero from an unknown value.
type ObservationIdentity ¶
type ObservationIdentity struct {
StoreID string
RequestID string
CallID string
BillingCallID string
ALegID string
BLegID string
AttemptID string
AttemptSeq uint64
Scope scope.PrincipalScopeView
ObservedAt time.Time
ReceivedAt time.Time
}
ObservationIdentity is trusted request/B-leg lineage supplied by runtime. Missing StoreID or BLegID suppresses observations instead of inventing scope.
type ObservationResolver ¶
type ObservationResolver interface {
GetObservation(context.Context, string, uint64) (sdkmetering.Observation, error)
}
ObservationResolver resolves exact immutable predecessors for corrections. A correction cannot be accepted merely because its reference is syntactically valid; the predecessor must be present and hash-identical in the same store.
type OutputSnapshot ¶
type OutputSnapshot struct {
TextBytes int64
TextBytesPresent bool
TextTokens int64
TextTokensPresent bool
TextTokensEstimated bool
TextTruncated bool
Media []MediaSummary
MediaTruncated bool
Truncated bool
}
OutputSnapshot contains bounded provider-origin or customer-egress data.
type PreparedInputObserver ¶
type PreparedInputObserver func(PreparedInputSummary)
PreparedInputObserver is the adapter-to-core final-boundary callback.
type PreparedInputSnapshot ¶
type PreparedInputSnapshot struct {
Prepared bool
Attempted bool
Accepted bool
AcceptedKnown bool
AdapterProvided bool
TextBytes int64
TextBytesPresent bool
PayloadBytes int64
PayloadBytesPresent bool
TextTokens int64
TextTokensPresent bool
TextTokensEstimated bool
TextTruncated bool
Media []MediaSummary
MediaTruncated bool
Truncated bool
MethodRef string
}
PreparedInputSnapshot records the final input and its backend-open lifecycle.
type PreparedInputSummary ¶
type PreparedInputSummary struct {
TextBytes int64
TextBytesPresent bool
PayloadBytes int64
PayloadBytesPresent bool
TextTokens int64
TextTokensPresent bool
TextTokensEstimated bool
Media []MediaSummary
TextTruncated bool
MediaTruncated bool
Truncated bool
MethodRef string
}
PreparedInputSummary describes the final provider-bound representation. Adapters report it after payload rewrites/transforms through the observer.
func PreparedInputSummaryFromCall ¶
func PreparedInputSummaryFromCall(call lipapi.Call) PreparedInputSummary
PreparedInputSummaryFromCall returns the bounded canonical fallback summary.
func SummaryFromCall ¶
func SummaryFromCall(call lipapi.Call) PreparedInputSummary
SummaryFromCall is a concise compatibility alias for adapter integrations.
type PreparedInputSummaryBuilder ¶
type PreparedInputSummaryBuilder struct {
// contains filtered or unexported fields
}
PreparedInputSummaryBuilder is a bounded adapter-side builder for the final provider representation. It accepts properties without retaining payload bytes; adapters can therefore inspect SDK params directly without marshaling or cloning the request body solely for accounting.
func NewPreparedInputSummaryBuilder ¶
func NewPreparedInputSummaryBuilder(method string) PreparedInputSummaryBuilder
NewPreparedInputSummaryBuilder starts a bounded summary with the adapter's method reference. The returned value is intentionally stack-friendly.
func (*PreparedInputSummaryBuilder) AddMedia ¶
func (b *PreparedInputSummaryBuilder) AddMedia(media MediaSummary)
AddMedia records one bounded provider-bound media property set.
func (*PreparedInputSummaryBuilder) AddText ¶
func (b *PreparedInputSummaryBuilder) AddText(text string)
AddText records text bytes from the provider-bound representation.
func (*PreparedInputSummaryBuilder) AddTextBytes ¶
func (b *PreparedInputSummaryBuilder) AddTextBytes(bytes int64)
AddTextBytes records a bounded text-byte property without retaining text.
func (*PreparedInputSummaryBuilder) Build ¶
func (b *PreparedInputSummaryBuilder) Build() PreparedInputSummary
Build returns a bounded summary with an ownership-safe media slice.
func (*PreparedInputSummaryBuilder) SetPayloadBytes ¶
func (b *PreparedInputSummaryBuilder) SetPayloadBytes(bytes int64)
SetPayloadBytes records a bounded payload metadata value when the adapter already knows it. It never requires constructing a payload copy.
type ProviderDebitSnapshot ¶
type ProviderDebitSnapshot struct {
Measures []aggregate.ReducedMeasure
Observations []sdkmetering.Observation
Complete bool
Replayed int
}
ProviderDebitSnapshot is a deterministic nonmonetary reduction of typed provider unit debits. Measures retain the complete account/pool/window and request/BillingCallID/B-leg scope from aggregate.SnapshotV2. Reduction has no customer balance, currency, or journal-posting fields by design.
func ReduceProviderDebitObservations ¶
func ReduceProviderDebitObservations(observations []sdkmetering.Observation) (ProviderDebitSnapshot, error)
ReduceProviderDebitObservations reduces only canonical provider-debit observations read back from the durable V2 journal. Account-window observations and other provider evidence are rejected rather than inferred into this request-debit plane.
func ReduceProviderDebits ¶
func ReduceProviderDebits(debits []sdkmetering.ProviderDebit) (ProviderDebitSnapshot, error)
ReduceProviderDebits validates typed evidence, projects it to the canonical V2 observation journal and applies the existing replay/supersession reducer. A gauge, request association without a debit, estimate, or partial record therefore cannot enter this function as a payable quantity.
type ProviderEvidenceBinder ¶
type ProviderEvidenceBinder interface {
BindEconomicEvidence(ObservationIdentity)
}
ProviderEvidenceBinder is implemented by an in-process provider stream that captured provider-shaped usage before the runtime assigned the trusted request/B-leg identity. The binding is deliberately one-way: provider data cannot choose its store, call, or B-leg subject.
type ProviderEvidenceBuffer ¶
type ProviderEvidenceBuffer struct {
// contains filtered or unexported fields
}
ProviderEvidenceBuffer retains bounded, immutable provider drafts until the executor binds the concrete B-leg. It deduplicates exact replay of one source payload while preserving changed payloads as revisions.
func NewProviderEvidenceBuffer ¶
func NewProviderEvidenceBuffer() *ProviderEvidenceBuffer
NewProviderEvidenceBuffer creates a stream-local provider evidence buffer.
func (*ProviderEvidenceBuffer) Add ¶
func (b *ProviderEvidenceBuffer) Add(draft ProviderEvidenceDraft)
Add appends one provider-owned draft. Exact replay under the same source key is ignored; changed content is retained and receives a buffer-assigned revision. A draft that supplies its own source Revision or Sequence is rejected as an unsupported ordering identity (see the field docs).
func (*ProviderEvidenceBuffer) AddUsageEvent ¶
func (b *ProviderEvidenceBuffer) AddUsageEvent(ev lipapi.Event, mapping string)
AddUsageEvent maps the six legacy token counters and a genuine provider monetary field into a V2 draft. Family adapters call this after parsing their own wire schema; no provider-specific interpretation occurs here.
func (*ProviderEvidenceBuffer) BindEconomicEvidence ¶
func (b *ProviderEvidenceBuffer) BindEconomicEvidence(identity ObservationIdentity)
BindEconomicEvidence supplies only trusted runtime lineage. Binding may be called once after Open; subsequent calls replace no already-drained data.
func (*ProviderEvidenceBuffer) DrainEconomicObservations ¶
func (b *ProviderEvidenceBuffer) DrainEconomicObservations() []lipsdkmetering.Observation
DrainEconomicObservations returns only valid, strictly B-leg-owned V2 observations. An unbound stream returns no evidence rather than inventing a store or attaching provider quantities to a logical request.
type ProviderEvidenceDraft ¶
type ProviderEvidenceDraft struct {
SourceEventKey string
// Revision is a host-assigned observation revision. A caller/provider
// supplied source revision is NOT a supported capability: Add rejects any
// non-zero Revision as an explicit unsupported-ordering-identity loss and
// never drains the payload as provider evidence. This is an enforceable
// boundary, not a TODO: the SDK observation cannot carry source-vs-host
// revision provenance, so a late older explicit revision would be
// observationally identical to a valid cumulative/delta update and could
// duplicate a charge. The buffer assigns the revision instead.
Revision uint64
StreamID string
// Sequence is a host-assigned lifetime receipt ordinal. A caller/provider
// supplied non-zero Sequence is part of the same unsupported ordering
// identity and is rejected at Add with the same loss disposition; the buffer
// assigns the sequence.
Sequence uint64
Origin string
Acquisition string
Authority string
Perspective lipsdkmetering.EconomicPerspective
Boundary lipsdkmetering.Boundary
Lifecycle lipsdkmetering.LifecycleScope
Semantics string
ProviderAccountKey string
ProviderRequestID string
ProviderChargeID string
Measures []lipsdkmetering.Measure
Charges []lipsdkmetering.ReportedCharge
Supersedes []lipsdkmetering.ObservationRef
Evidence []lipsdkmetering.SafeEvidenceField
ObservedAt time.Time
ReceivedAt time.Time
Coverage string
CoverageReason string
}
ProviderEvidenceDraft is the provider-neutral portion of one provider observation. Provider adapters own construction of measures, charges and safe evidence; this type only makes the runtime identity boundary explicit. A draft cannot be drained as V2 until a trusted B-leg binding is supplied.
func ProviderUsageEvent ¶
func ProviderUsageEvent(ev lipapi.Event, mapping, sourceKey string) ProviderEvidenceDraft
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package aggregate applies metering fact kinds onto a stream aggregate without mutating journal history (requirements 3.2, 3.3, 3.5, 13.6).
|
Package aggregate applies metering fact kinds onto a stream aggregate without mutating journal history (requirements 3.2, 3.3, 3.5, 13.6). |
|
Package ledgercompat projects neutral metering facts onto the legacy token ledger record.
|
Package ledgercompat projects neutral metering facts onto the legacy token ledger record. |
|
Package normalize maps provider-family fields onto neutral V2 metering measures.
|
Package normalize maps provider-family fields onto neutral V2 metering measures. |
|
Package plane holds pure dual-plane usage projection helpers used by runtime metering and settlement without importing the executor.
|
Package plane holds pure dual-plane usage projection helpers used by runtime metering and settlement without importing the executor. |
|
Package reconcile exposes bounded journal reconciliation helpers over a metering Querier (requirements 13.6, 13.7, 14.5, 15.3).
|
Package reconcile exposes bounded journal reconciliation helpers over a metering Querier (requirements 13.6, 13.7, 14.5, 15.3). |
|
Package replay provides the source-event replay boundary shared by metering reducers.
|
Package replay provides the source-event replay boundary shared by metering reducers. |