observability

package
v0.1.0-rc.1 Latest Latest
Warning

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

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

Documentation

Overview

Package observability provides the content-free diagnostics seam for the compaction-continuity feature. It records bounded statuses and measurements only; queue depth, token usage, cost and accounting remain owned by the scheduler and billing observability surfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoundedID

func BoundedID(value string) string

BoundedID keeps a non-secret enum or rule identifier safe for a direct Sink implementation. Correlation values should use HashID instead.

func HashID

func HashID(value string) string

HashID creates the only correlation representation accepted by the recorder. It is useful for transaction/job IDs without exposing their raw values to diagnostics.

Types

type Func

type Func func(Observation)

Func adapts a function to Sink and is convenient for deterministic tests.

func (Func) Observe

func (f Func) Observe(sample Observation)

type Nop

type Nop struct{}

Nop is the default sink. It keeps the feature's observability calls explicit without introducing global state when metrics are not composed.

func (Nop) Observe

func (Nop) Observe(Observation)

type Observation

type Observation struct {
	Stage           Stage
	Outcome         Outcome
	Evidence        string
	RuleID          string
	Phase           string
	CorrelationHash string
	Revision        uint64
	SizeBytes       int
	FactCount       int
	Duration        time.Duration
	Count           uint64
}

Observation is deliberately content-free. CorrelationHash must be produced with HashID; raw BranchKey, prompt, output and capsule fields have no place in this contract. Count is a positive delta and the other measurements are bounded by the recorder.

type Outcome

type Outcome string

Outcome identifies a finite feature outcome. Errors are intentionally represented by statuses rather than error text.

const (
	OutcomeObserved       Outcome = "observed"
	OutcomeCandidate      Outcome = "candidate"
	OutcomeCommitted      Outcome = "committed"
	OutcomeSkipped        Outcome = "skipped"
	OutcomeMatched        Outcome = "matched"
	OutcomeUnmatched      Outcome = "unmatched"
	OutcomeEligible       Outcome = "eligible"
	OutcomeIneligible     Outcome = "ineligible"
	OutcomeCreated        Outcome = "created"
	OutcomeBound          Outcome = "bound"
	OutcomeExpired        Outcome = "expired"
	OutcomeSubmitted      Outcome = "submitted"
	OutcomeCoalesced      Outcome = "coalesced"
	OutcomeSaturated      Outcome = "saturated"
	OutcomeCanceled       Outcome = "canceled"
	OutcomeCompleted      Outcome = "completed"
	OutcomeFailed         Outcome = "failed"
	OutcomeDenied         Outcome = "denied"
	OutcomeInvalid        Outcome = "invalid"
	OutcomeStale          Outcome = "stale"
	OutcomeConflict       Outcome = "conflict"
	OutcomeDigestMismatch Outcome = "digest_mismatch"
	OutcomeTimeout        Outcome = "timeout"
	OutcomeRollback       Outcome = "rollback"
	OutcomePanic          Outcome = "panic"
	OutcomeRestored       Outcome = "restored"
	OutcomePending        Outcome = "pending"
	OutcomeReleased       Outcome = "released"
	OutcomeOpaque         Outcome = "opaque"
	OutcomeRejected       Outcome = "rejected"
)

type Recorder

type Recorder struct {
	// contains filtered or unexported fields
}

Recorder aggregates observations into a bounded set of content-free series. It is suitable for deterministic tests and small in-process diagnostics; production metric adapters may implement Sink directly.

func NewRecorder

func NewRecorder(maxSeries int) *Recorder

NewRecorder creates a bounded recorder. Non-positive bounds use 64 series.

func (*Recorder) Observe

func (r *Recorder) Observe(sample Observation)

Observe records one bounded sample. Invalid dimensions are normalized to unknown values and never cause an error or callback failure.

func (*Recorder) Snapshot

func (r *Recorder) Snapshot() []Observation

Snapshot returns a deterministic copy of the currently retained series.

type Sink

type Sink interface {
	Observe(Observation)
}

Sink consumes feature-local content-free observations. Implementations must be non-blocking or bounded; callers isolate sink failures from primary flow.

type Stage

type Stage string

Stage identifies one feature-local lifecycle seam. The finite vocabulary is intentional: adding a provider/model/branch value here would make metrics cardinality and privacy depend on request content.

const (
	StagePreview       Stage = "preview"
	StageEvent         Stage = "event"
	StageCarrier       Stage = "carrier"
	StageEligibility   Stage = "eligibility"
	StagePreviewIntent Stage = "preview_intent"
	StageJob           Stage = "job"
	StageCapsule       Stage = "capsule"
	StageBarrier       Stage = "barrier"
	StageAugmentation  Stage = "augmentation"
	StageReinjection   Stage = "reinjection"
	StageWatermark     Stage = "watermark"
	StageCallback      Stage = "callback"
)

Jump to

Keyboard shortcuts

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