presentation

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: GPL-3.0 Imports: 9 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 presentation defines BUSY Bar-specific plugin output and selection policy.

Index

Constants

View Source
const (
	PolicyAttention    = "attention"
	PolicyInteractive  = "interactive"
	PolicyWhenRelevant = "when_relevant"
	PolicyRotation     = "rotation"
)

Variables

View Source
var ErrInvalidPresentation = errors.New("invalid BUSY Bar presentation")

ErrInvalidPresentation identifies a deterministic presentation that cannot be represented by the supported BUSY Bar API.

Functions

func CompareBand

func CompareBand(left, right Band) int

CompareBand compares daemon-owned semantic priority.

func CompareImpact

func CompareImpact(left, right protocol.Impact) int

CompareImpact compares the exact four provider impact levels.

func CompileAudio

func CompileAudio(applicationName string, cue ResolvedAudioCue) (busylib.PlayAudio, error)

CompileAudio performs the pure resolved-cue to busylib translation.

func CompileBusyTimer

func CompileBusyTimer(theme string) error

CompileBusyTimer validates the firmware theme field through the authoritative busylib boundary without reading or mutating device state.

func CompileScene

func CompileScene(applicationName string, priority int, scene ResolvedScene) (busylib.DisplayElements, error)

CompileScene performs the pure public-DSL to busylib translation used at publication and again at the device boundary. It never performs device I/O.

func ValidateObservation

func ValidateObservation(pluginID string, observation protocol.Observation, resolver AssetCompilerResolver) error

ValidateObservation compiles every device-bound part of an observation without I/O. A successful return means the observation is representable by the supported busylib contract at publication time.

Types

type AssetCompilerResolver

type AssetCompilerResolver interface {
	ResolveScene(string, Scene) (ResolvedScene, error)
	ResolveAudioCue(string, AudioCue) (ResolvedAudioCue, error)
}

AssetCompilerResolver resolves authenticated package IDs and validated stock basenames without exposing physical paths to plugins.

type AudioCue

type AudioCue = protocol.AudioCue

type Band

type Band string

Band is the daemon-derived semantic priority of one eligible candidate. Plugins choose neither the band nor its ordering.

const (
	BandCriticalActionable Band = "critical_actionable"
	BandInteractive        Band = "interactive"
	BandActionable         Band = "actionable"
	BandRelevant           Band = "relevant"
	BandRotation           Band = "rotation"
)

func BandFor

func BandFor(policy Policy, impact protocol.Impact) Band

BandFor returns the only semantic band valid for an eligible policy and impact pair. Attention eligibility is established before candidate creation.

type Candidate

type Candidate struct {
	PluginID          string                          `json:"plugin_id"`
	InstanceID        string                          `json:"instance_id"`
	Channel           string                          `json:"channel"`
	Key               string                          `json:"key"`
	Revision          uint64                          `json:"revision"`
	Generation        uint64                          `json:"generation"`
	Policy            Policy                          `json:"policy"`
	Band              Band                            `json:"band"`
	Impact            protocol.Impact                 `json:"impact"`
	AdmissionSequence uint64                          `json:"admission_sequence"`
	Reason            string                          `json:"reason,omitempty"`
	CreatedAt         time.Time                       `json:"created_at"`
	UpdatedAt         time.Time                       `json:"updated_at"`
	ExpiresAt         time.Time                       `json:"expires_at,omitempty"`
	HoldMS            int                             `json:"hold_ms,omitempty"`
	CooldownMS        int                             `json:"cooldown_ms,omitempty"`
	RequiresAck       bool                            `json:"requires_ack,omitempty"`
	Acknowledged      bool                            `json:"acknowledged,omitempty"`
	DevicePriority    int                             `json:"device_priority,omitempty"`
	Scene             Scene                           `json:"scene,omitempty"`
	BusyTimer         *protocol.BusyTimerPresentation `json:"busy_timer,omitempty"`
	AudioCue          *protocol.AudioCue              `json:"audio_cue,omitempty"`
}

Candidate is one plugin channel's current display offer.

func (Candidate) Cooldown

func (c Candidate) Cooldown() time.Duration

Cooldown returns the configured or policy-default repeat cooldown.

func (Candidate) EffectiveDevicePriority

func (c Candidate) EffectiveDevicePriority() int

EffectiveDevicePriority returns a validated policy default when no override exists.

func (Candidate) Eligible

func (c Candidate) Eligible(now time.Time) bool

Eligible reports whether the candidate can participate at now.

func (Candidate) Hold

func (c Candidate) Hold() time.Duration

Hold returns the configured or policy-default minimum readable hold.

func (Candidate) ID

func (c Candidate) ID() string

ID returns the stable host-side identity used for replacement and history.

func (Candidate) Identity

func (c Candidate) Identity() Identity

func (Candidate) Validate

func (c Candidate) Validate() error

Validate rejects malformed or unsafe candidate data before it reaches arbitration.

type Decision

type Decision struct {
	Candidate *Candidate
}

Decision describes the current winner. A nil candidate means bsbctl should clear.

func Select

func Select(candidates []Candidate, history History, now time.Time) Decision

Select deterministically chooses one eligible candidate.

type Element

type Element = protocol.Element

Element is the unresolved public plugin element.

type History

type History struct {
	CurrentID    string
	CurrentSince time.Time
	LastShown    map[string]time.Time
}

History is the minimum state required to enforce holds, cooldowns, and fairness.

type Identity

type Identity struct {
	PluginID   string
	InstanceID string
	Channel    string
	Key        string
}

Identity is the comparable internal key for one plugin observation.

func (Identity) String

func (i Identity) String() string

type Policy

type Policy = string

Policy determines when a candidate may participate in display arbitration.

type PolicyConfig

type PolicyConfig struct {
	Policy                string `json:"policy"`
	DevicePriority        int    `json:"device_priority,omitempty"`
	HoldMS                int    `json:"hold_ms,omitempty"`
	CooldownMS            int    `json:"cooldown_ms,omitempty"`
	RequiresAck           bool   `json:"requires_ack,omitempty"`
	ActivationInput       string `json:"activation_input,omitempty"`
	ActivationAction      string `json:"activation_action,omitempty"`
	RotationIntervalMS    int    `json:"rotation_interval_ms,omitempty"`
	RotationJitterPercent int    `json:"rotation_jitter_percent,omitempty"`
}

PolicyConfig is daemon-owned arbitration policy for one plugin channel. It is never sent to a plugin process.

type ResolvedAudioCue

type ResolvedAudioCue struct {
	AudioCue
	Path string `json:"path,omitempty"`
}

func ResolveAudioCue

func ResolveAudioCue(cue AudioCue) ResolvedAudioCue

type ResolvedElement

type ResolvedElement struct {
	Element
	Path string `json:"path,omitempty"`
}

ResolvedElement is a host-owned element whose logical asset may have been translated to a device path. Path never crosses the plugin wire boundary.

type ResolvedScene

type ResolvedScene struct {
	Elements []ResolvedElement `json:"elements"`
}

ResolvedScene is the host-owned form consumed by the device gateway.

func ResolveScene

func ResolveScene(scene Scene) ResolvedScene

ResolveScene copies a public scene into the host-owned resolved form.

type Scene

type Scene = protocol.Scene

Scene is an unresolved public plugin scene.

Jump to

Keyboard shortcuts

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