attention

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: GPL-3.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package attention owns core-only eligibility, arbitration, and explanations.

Index

Constants

View Source
const (
	StateVersion    = 1
	MaxStateEntries = 2048
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AcknowledgementState

type AcknowledgementState struct {
	Identity   StateIdentity `json:"identity"`
	ObservedAt time.Time     `json:"observed_at"`
	TouchedAt  time.Time     `json:"touched_at"`
}

type Decision

type Decision struct {
	Candidate   *presentation.Candidate
	Evaluations []Evaluation
}

func Select

func Select(records []observation.Record, resolve Resolver, history presentation.History, now time.Time) Decision

Select applies mode eligibility before delegating deterministic ordering and anti-flap mechanics to presentation.Select.

type DeliveryOutcome

type DeliveryOutcome string
const (
	OutcomeDrawn               DeliveryOutcome = "drawn"
	OutcomeCleared             DeliveryOutcome = "cleared"
	OutcomeUnchanged           DeliveryOutcome = "unchanged"
	OutcomeFirmwareSuppressed  DeliveryOutcome = "firmware_suppressed_409"
	OutcomeDeviceUnavailable   DeliveryOutcome = "device_unavailable"
	OutcomeAssetMissing        DeliveryOutcome = "asset_missing"
	OutcomeInvalidPresentation DeliveryOutcome = "invalid_presentation"
)

type Evaluation

type Evaluation struct {
	ObservationID string               `json:"observation_id"`
	PluginID      string               `json:"plugin_id"`
	InstanceID    string               `json:"instance_id"`
	Channel       string               `json:"channel"`
	Policy        presentation.Policy  `json:"policy,omitempty"`
	Disposition   protocol.Disposition `json:"disposition"`
	Impact        protocol.Impact      `json:"impact"`
	Band          presentation.Band    `json:"band,omitempty"`
	ReasonCode    string               `json:"reason_code"`
	Reason        Reason               `json:"reason"`
	EvaluatedAt   time.Time            `json:"evaluated_at"`
	CooldownUntil time.Time            `json:"cooldown_until,omitempty"`
	NextDue       time.Time            `json:"next_due,omitempty"`
}

Evaluation is safe to expose through status and persist in decision history.

type LastShownState

type LastShownState struct {
	Identity StateIdentity `json:"identity"`
	ShownAt  time.Time     `json:"shown_at"`
}

type Reason

type Reason string

Reason is a stable, non-sensitive explanation for one evaluation.

const (
	ReasonSelected                  Reason = "selected"
	ReasonDisabled                  Reason = "disabled"
	ReasonAssetsPending             Reason = "assets_pending"
	ReasonStale                     Reason = "stale"
	ReasonExpired                   Reason = "expired"
	ReasonResolved                  Reason = "resolved"
	ReasonNotActionableForAttention Reason = "not_actionable_for_attention"
	ReasonNotRelevant               Reason = "not_relevant"
	ReasonNotDue                    Reason = "not_due"
	ReasonAcknowledged              Reason = "acknowledged"
	ReasonCooldownUntil             Reason = "cooldown_until"
	ReasonHeldByCurrent             Reason = "held_by_current"
	ReasonLowerBand                 Reason = "lower_band"
	ReasonLowerImpact               Reason = "lower_impact"
	ReasonFairnessWait              Reason = "fairness_wait"
	ReasonForegroundInactive        Reason = "foreground_inactive"
	ReasonBlockedByAtomicExecution  Reason = "blocked_by_atomic_execution"
)

type Recorder

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

Recorder keeps bounded in-memory decisions and a rotated local JSONL ledger.

func NewRecorder

func NewRecorder(path string, capacity int, maxBytes int64, retained int) (*Recorder, error)

func (*Recorder) Append

func (r *Recorder) Append(trace Trace) error

func (*Recorder) Close

func (r *Recorder) Close() error

func (*Recorder) Explain

func (r *Recorder) Explain(observationID string) (Evaluation, bool)

func (*Recorder) History

func (r *Recorder) History(limit int, since time.Time) []Trace

func (*Recorder) Snapshot

func (r *Recorder) Snapshot() (Trace, bool)

func (*Recorder) Status

func (r *Recorder) Status() RecorderStatus

type RecorderPhase

type RecorderPhase string
const (
	RecorderUnavailable RecorderPhase = "unavailable"
	RecorderHealthy     RecorderPhase = "healthy"
	RecorderDegraded    RecorderPhase = "degraded"
)

type RecorderStatus

type RecorderStatus struct {
	Phase         RecorderPhase `json:"phase"`
	LastErrorCode string        `json:"last_error_code,omitempty"`
	LastErrorAt   time.Time     `json:"last_error_at,omitempty"`
	LastSuccessAt time.Time     `json:"last_success_at,omitempty"`
	LastTraceAt   time.Time     `json:"last_trace_at,omitempty"`
	LastSequence  uint64        `json:"last_sequence"`
}

RecorderStatus exposes recorder freshness without leaking paths or raw I/O errors.

type Resolver

type Resolver func(observation.Record) (Rule, bool)

type Rule

type Rule struct {
	Enabled                  bool
	AssetsReady              bool
	Policy                   presentation.Policy
	DevicePriority           int
	HoldMS                   int
	CooldownMS               int
	RequiresAck              bool
	Acknowledged             bool
	Foreground               bool
	RotationIntervalMS       int
	RotationJitterPercent    int
	BlockedByAtomicExecution bool
}

Rule is core-owned configuration and runtime state for one observation.

type StateDocument

type StateDocument struct {
	Version          int                    `json:"version"`
	Acknowledgements []AcknowledgementState `json:"acknowledgements"`
	LastShown        []LastShownState       `json:"last_shown"`
}

type StateError

type StateError struct {
	Code string
	Err  error
}

func (*StateError) Error

func (e *StateError) Error() string

func (*StateError) Unwrap

func (e *StateError) Unwrap() error

type StateIdentity

type StateIdentity struct {
	PluginID   string `json:"plugin_id"`
	InstanceID string `json:"instance_id"`
	Generation uint64 `json:"generation"`
	Channel    string `json:"channel"`
	Key        string `json:"key"`
}

func (StateIdentity) Validate

func (i StateIdentity) Validate() error

type StateStore

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

func NewStateStore

func NewStateStore(path string) *StateStore

func (*StateStore) Load

func (s *StateStore) Load() (StateDocument, error)

func (*StateStore) Save

func (s *StateStore) Save(document StateDocument) (localstate.CommitOutcome, error)

func (*StateStore) Status

func (s *StateStore) Status() StateStoreStatus

type StateStoreStatus

type StateStoreStatus struct {
	Phase         string    `json:"phase"`
	LastErrorCode string    `json:"last_error_code,omitempty"`
	LastReadAt    time.Time `json:"last_read_at,omitempty"`
	LastWriteAt   time.Time `json:"last_write_at,omitempty"`
	Failures      uint64    `json:"failures"`
}

type Trace

type Trace struct {
	Sequence    uint64          `json:"sequence"`
	At          time.Time       `json:"at"`
	SelectedID  string          `json:"selected_id,omitempty"`
	Outcome     DeliveryOutcome `json:"outcome,omitempty"`
	Evaluations []Evaluation    `json:"evaluations"`
}

Jump to

Keyboard shortcuts

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