reconcile

package
v1.7.33 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package reconcile prices events that were stored without a cost.

budgetclaw stores an event whose model the pricing table does not know rather than discarding it (see db.InsertUnpriced). Those rows keep their full token counts, so once the table learns the model the spend can be recovered from the rows themselves. This package is what does that, automatically, with no user action.

It depends on both db and pricing, which is why it is its own package: db stays free of any pricing dependency, and pricing stays free of any storage dependency. The caller wires the two together.

The pass is safe to run from several places at once. Every update is guarded so a second run, or a racing process, prices nothing twice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Repriced  int
	Recovered float64
	Models    []string
	Remaining int
}

Result reports what a pass did. Repriced is the number of events that gained a cost; Recovered is the dollar total those events added. Remaining counts rows still unpriceable, which is a legitimate steady state (a retired model with no interval covering an old event).

func Run

func Run(ctx context.Context, store *db.DB, force bool) (Result, error)

Run prices whatever it can of the unpriced backlog.

It is cheap to call unconditionally. The healthy case costs one indexed existence probe and returns immediately, so callers can run it at startup without thinking about it.

force skips the watermark check. Use it when the effective pricing table may have changed in a way the tag does not capture, or when the user explicitly asked for a repair pass.

func (Result) Any

func (r Result) Any() bool

Any reports whether the pass changed anything worth telling the user.

func (Result) Summary

func (r Result) Summary() string

Summary renders a one-line, user-facing description of a pass that changed something. Returns "" when nothing was repriced, so callers can print it unconditionally.

Jump to

Keyboard shortcuts

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