Documentation
¶
Overview ¶
Package billsem is a self-contained, test-only reference implementation of component-schema quantity semantics.
It is deliberately independent of production billing code: it imports only the Go standard library and the public pkg/lipsdk/metering DTOs. It exists so that a second, independently written oracle can later falsify the production evaluator. It is not wired into any runtime path.
The solver is deterministic: every map iteration is performed through a sorted key order, so neither Go map ordering nor relationship declaration order influence the result.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidInput = errors.New("billsem: invalid input")
ErrInvalidInput marks genuinely malformed input (for example a schema that fails the public Validate, or an ObsExact state without a value). Semantic quantity problems are reported as classifications, never as errors.
Functions ¶
func SortedKeys ¶
SortedKeys returns map keys in stable sorted order.
Types ¶
type Class ¶
type Class int
Class is the reported classification of one node in one scope. The constants are listed in classification precedence order.
const ( // ClassInactive means there is no evidence anywhere in its complete region. ClassInactive Class = iota // ClassContradicted means lower > upper after the fixed point. ClassContradicted // ClassIncomplete means active but a required member is missing/unavailable. ClassIncomplete // ClassAmbiguous means the node has more than one complete-coverage owner. ClassAmbiguous // ClassRepresented means an exact represented quantity is available. ClassRepresented )
type Evidence ¶
type Evidence struct {
// States maps scope -> canonical component key -> observation state.
States map[string]map[string]ObsState
// Values maps scope -> canonical component key -> exact quantity. It must
// contain an entry for every ObsExact state.
Values map[string]map[string]*big.Rat
}
Evidence carries per-scope observation states and, for ObsExact entries, the reported rational value. Scopes never share evidence.
func NewEvidence ¶
func NewEvidence() Evidence
NewEvidence allocates both maps so callers never have to handle nil maps.
type NodeResult ¶
type NodeResult struct {
Key string
Lower *big.Rat
Upper *big.Rat // nil means +infinity
UpperFinite bool
Class Class
// Represented is non-nil only when Class == ClassRepresented.
Represented *big.Rat
// Absent and Unavailable preserve the observation distinction even though
// both share the [0, +inf) interval.
Absent bool
}
NodeResult is the solved state of one component in one scope.
type ObsState ¶
type ObsState int
ObsState is the exact, three-valued observation state of one component in one reduction scope. The three states are DISTINCT:
- ObsAbsent: the component was not reported. Exact(0) is NOT absent.
- ObsExact: a reported, complete, exact rational quantity.
- ObsUnavailable: reported but not usable/unknown. Never becomes zero.
type ScopeResult ¶
type ScopeResult struct {
Scope string
Nodes map[string]NodeResult
Contradicted []string
Incomplete []string
Ambiguous []string
UnknownIntersection [][2]string
}
ScopeResult is the solved state of one scope. Nodes may be iterated deterministically via SortedKeys.
func Solve ¶
func Solve(schemas []metering.ComponentSchema, ev Evidence) ([]ScopeResult, error)
Solve is the single entry point. It is deterministic and does not mutate its inputs.