Documentation
¶
Overview ¶
Package invariant registers invariant checks, matching runtime-diagnostics/invariants. Development checks enforce event ordering, turn/step pairing, tool pairing, and goal CAS revisions before invalid state reaches persistence. Violations identify the owning package. Production can disable checks with SetEnabled(false).
Initialize a Registry and register checks per package; Run collects all failures. Errors use the prefix INVARIANT [pkgName] for diagnosis.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetEnabled ¶
func SetEnabled(on bool)
SetEnabled globally enables or disables checks; production can disable them at startup.
Types ¶
type Checker ¶
type Checker func() error
Checker returns nil on success or an error for a violation.
type InvariantError ¶
type InvariantError struct {
// Pkg is the registered owner, such as pkg/session.
Pkg string
// Msg describes the violation.
Msg string
}
InvariantError describes a violation and its owning package.
func (*InvariantError) Error ¶
func (e *InvariantError) Error() string
Error includes the owning package for diagnosis.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry groups invariant checkers by package.
func (*Registry) Ledger ¶
Ledger returns violations in registration order for auditing and assertions.
func (*Registry) MustSatisfy ¶
func (r *Registry) MustSatisfy()
MustSatisfy panics on any violation as a development assertion. It becomes a no-op when checks are disabled.