Documentation
¶
Overview ¶
Package control owns device execution independently of HTTP, CLI and agents.
Index ¶
- Constants
- Variables
- func CheckSequenceDevice(input sequence.Sequence, state DeviceState) error
- func NewSequenceJobID() (string, error)
- func SequenceRequiredCapabilities(input sequence.Sequence) []string
- func ValidDeviceSerial(serial string) bool
- func ValidSequenceJobID(id string) bool
- func ValidateCapabilityCatalog(c CapabilityCatalog) error
- func ValidatePreviewResult(r PreviewResult, inputKind string, serial *string) error
- type Backend
- type CapabilityCatalog
- type ConnectionEvent
- type DeviceInfo
- type DeviceState
- type Driver
- type Effect
- type EffectLimits
- type Engine
- func (e *Engine) Cancel(ctx context.Context, id string) (Job, error)
- func (e *Engine) CancelFrame(ctx context.Context, id string) (FrameJob, error)
- func (e *Engine) CancelPatternRequest(ctx context.Context, serial string, input ReceiptRequest, ...) (PatternJobEnvelope, error)
- func (e *Engine) CancelSequence(ctx context.Context, id string) (SequenceJob, error)
- func (e *Engine) CancelSequenceForDevice(ctx context.Context, id, serial string) (SequenceJob, error)
- func (e *Engine) Close(ctx context.Context) error
- func (e *Engine) Device(serial string) (DeviceState, error)
- func (e *Engine) Devices() []DeviceState
- func (e *Engine) Done() <-chan struct{}
- func (e *Engine) DroppedEvents() uint64
- func (e *Engine) Events() <-chan ConnectionEvent
- func (e *Engine) FrameJob(id string) (FrameJob, error)
- func (e *Engine) FrameRequest(serial, requestID, expectedDaemonInstanceID string) (FrameJob, error)
- func (e *Engine) InspectNative(ctx context.Context, serial string, request nativeinspection.Request) (nativeinspection.Result, error)
- func (e *Engine) Instance() InstanceInfo
- func (e *Engine) Job(id string) (Job, error)
- func (e *Engine) PatternRequest(serial string, input ReceiptRequest, ref patternidentity.Ref) (PatternJobEnvelope, error)
- func (e *Engine) Request(serial, requestID, expectedDaemonInstanceID string) (Job, error)
- func (e *Engine) SequenceJob(id string) (SequenceJob, error)
- func (e *Engine) SequenceJobLimits() (int, time.Duration)
- func (e *Engine) Start(ctx context.Context) error
- func (e *Engine) Submit(ctx context.Context, serial string, program Program, policy string) (Job, error)
- func (e *Engine) SubmitFrameWithReceipt(ctx context.Context, serial string, program FrameProgram, policy string, ...) (FrameReceiptResult, error)
- func (e *Engine) SubmitPatternWithReceipt(ctx context.Context, serial string, ref patternidentity.Ref, policy string, ...) (PatternReceiptResult, error)
- func (e *Engine) SubmitRoutedSequence(ctx context.Context, requestedSerial, id string, fingerprint [32]byte, ...) (SequenceJob, bool, error)
- func (e *Engine) SubmitSequence(ctx context.Context, serial, id string, fingerprint [32]byte, ...) (SequenceJob, bool, error)
- func (e *Engine) SubmitWithReceipt(ctx context.Context, serial string, program Program, policy string, ...) (ReceiptResult, error)
- func (e *Engine) TransportMetrics() []TransportMetric
- type Frame
- type FrameExecutionAvailability
- type FrameJob
- type FramePreview
- type FrameProgram
- type FrameReceiptResult
- type FrameService
- type FrameTarget
- type IdempotencyInfo
- type InstanceInfo
- type Job
- type NativeInspectionBackend
- type NativeInspectionService
- type Observation
- type Options
- type PatternExecution
- type PatternJobEnvelope
- type PatternReceiptResult
- type PatternResolveError
- type PatternResolveErrorKind
- type PatternResolver
- type PatternService
- type PreviewDevice
- type PreviewResult
- type PreviewValidation
- type Program
- type ProgramLimits
- type ReceiptRequest
- type ReceiptResult
- type ReceiptService
- type ResolvedPattern
- type SequenceJob
- type SequenceRoute
- type SequenceService
- type Service
- type Step
- type TransportMetric
Constants ¶
const ( FrameExecutorCapability = "frame-program-experimental-v1" MaxFrameProgramFrames = 1024 MaxFrameProgramRepeat = 10000 MaxFrameProgramExecutedFrames = 1024 MaxFrameProgramTargetWrites = 2050 // two initial + two per executed frame MaxFrameProgramTargets = 2 MinFrameIntervalMS = 50 MaxFrameIntervalMS = 600000 MaxFrameFadeMS = 600000 FrameFadeQuantumMS = 10 FrameWriteSpacingMS = 10 FrameUpdateAllowanceMS = 10 MaxFrameProgramBytes = 1 << 20 MaxFrameNominalDurationMS = int64(86400000) )
const ( MaxProgramSteps = 1024 MaxProgramRepeat = 10000 MaxFadeMS = 600000 FadeQuantumMS = 10 MaxHoldMS = 3600000 MaxNominalDurationMS int64 = 86400000 StepOverheadMS = 10 MinPulsePeriodMS = 60 MaxPulsePeriodMS = 1200000 MaxRequestBytes = 1 << 20 )
const CompileContract = "nb1-program-effect/v1"
CompileContract identifies the unchanged Program/Effect semantics shared by execution and software preview. It is not a hardware conformance claim.
const FrameContract = "nb1-frame-program/experimental-v1"
FrameContract is an experimental authoring contract with an opt-in FrameService executor. The legacy Service and its capability catalog remain unchanged. Physical qualification precedes any stable contract release.
const (
SequenceJobRetention = 30 * time.Minute
)
Variables ¶
var ( ErrRequestConflict = errors.New("request id has a different accepted payload") ErrInstanceChanged = errors.New("daemon instance changed") ErrRequestExpired = errors.New("request expired; original outcome may be unknown") ErrReceiptCapacity = errors.New("request receipt capacity exhausted") ErrRequestNotFound = errors.New("request receipt not found") )
var ( ErrSequenceJobConflict = errors.New("sequence job ID has a different accepted payload") ErrSequenceCapability = errors.New("sequence device capability missing") ErrSequenceJobTarget = errors.New("expected serial does not match the accepted Job target") )
Functions ¶
func CheckSequenceDevice ¶
func CheckSequenceDevice(input sequence.Sequence, state DeviceState) error
CheckSequenceDevice checks the cached connection and profile. Admission and native execution still belong to the device worker.
func NewSequenceJobID ¶
NewSequenceJobID returns j_ followed by ten Crockford Base32 characters.
func SequenceRequiredCapabilities ¶
SequenceRequiredCapabilities describes the existing execution path selected by a normalized sequence.
func ValidDeviceSerial ¶
func ValidSequenceJobID ¶
func ValidateCapabilityCatalog ¶
func ValidateCapabilityCatalog(c CapabilityCatalog) error
func ValidatePreviewResult ¶
func ValidatePreviewResult(r PreviewResult, inputKind string, serial *string) error
ValidatePreviewResult checks a received v1 result, not the truth of remote hardware claims. The known compiler contract, arithmetic, canonical Program and requested snapshot identity must agree before a client reports success.
Types ¶
type Backend ¶
type Backend interface {
Info() DeviceInfo
Set(Step) error
Read() (Observation, error)
Stop(mode string) error
Close()
}
Backend is used by exactly one device worker. Stop must stop autonomous pattern/tickle before applying off or freezing the currently observed RGB. Calls are synchronous: a request deadline cannot promise to cancel native I/O.
type CapabilityCatalog ¶
type CapabilityCatalog struct {
SchemaVersion int `json:"schema_version"`
APIVersion string `json:"api_version"`
CompileContract string `json:"compile_contract"`
SupportedInputs []string `json:"supported_inputs"`
Effects []string `json:"effects"`
Policies []string `json:"policies"`
ColorModel string `json:"color_model"`
LEDSelectors []int `json:"led_selectors"`
PreviewPath string `json:"preview_path"`
PatternLibrary bool `json:"pattern_library"`
HardwarePatternUpload bool `json:"hardware_pattern_upload"`
ProgramLimits ProgramLimits `json:"program_limits"`
EffectLimits EffectLimits `json:"effect_limits"`
MaxRequestBytes int `json:"max_request_bytes"`
}
func Capabilities ¶
func Capabilities() CapabilityCatalog
Capabilities describes software compilation. Configured device snapshots separately describe enabled backend capabilities; this performs no I/O.
type ConnectionEvent ¶
type ConnectionEvent struct {
Sequence uint64 `json:"sequence"`
Time time.Time `json:"time"`
Serial string `json:"serial"`
Connection string `json:"connection"`
Path string `json:"path"`
Error string `json:"error"`
}
ConnectionEvent is a transition in connection state or device path. Sequence is global to an Engine and increases even when a full buffer drops an event. Error is the state's last error at this transition, not a retry-by-retry log.
type DeviceInfo ¶
type DeviceState ¶
type DeviceState struct {
DeviceInfo
Connection string `json:"connection"`
ActiveJob string `json:"active_job,omitempty"`
QueueDepth int `json:"queue_depth"`
Desired *Step `json:"desired,omitempty"`
Observed *Observation `json:"observed,omitempty"`
LastError string `json:"last_error,omitempty"`
}
type Effect ¶
type Effect struct {
Kind string `json:"kind"`
Color string `json:"color"`
LED int `json:"led"`
FadeMS *int `json:"fade_ms,omitempty"`
Cycles *int `json:"cycles,omitempty"`
PeriodMS *int `json:"period_ms,omitempty"`
OnFinish *string `json:"on_finish,omitempty"`
}
Effect is a finite, high-level request compiled into an ordinary Program. Optional pointers distinguish omitted defaults from explicitly invalid zero values or fields belonging to another effect kind. JSON entry points must independently reject explicit null and unknown fields.
type EffectLimits ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) CancelFrame ¶
func (*Engine) CancelPatternRequest ¶
func (e *Engine) CancelPatternRequest(ctx context.Context, serial string, input ReceiptRequest, ref patternidentity.Ref, knownID string) (PatternJobEnvelope, error)
CancelPatternRequest binds source and original receipt under the same lock as cancellation. A known ID is an additional check, never a replacement ticket.
func (*Engine) CancelSequence ¶
func (*Engine) CancelSequenceForDevice ¶ added in v0.1.3
func (e *Engine) CancelSequenceForDevice(ctx context.Context, id, serial string) (SequenceJob, error)
CancelSequenceForDevice checks the accepted serial under the same lock that requests cancellation. The guard is independent of the current device route.
func (*Engine) Close ¶
A deadline stops waiting, not the native operation. The worker keeps its handle and ownership lease until native I/O and cleanup really finish.
func (*Engine) Devices ¶
func (e *Engine) Devices() []DeviceState
func (*Engine) DroppedEvents ¶
DroppedEvents counts transitions discarded because the event buffer was full. It does not count failures in a consumer's downstream log writer.
func (*Engine) Events ¶
func (e *Engine) Events() <-chan ConnectionEvent
Events returns one bounded, best-effort stream, intended for one consumer. Native workers never wait for its reader. It closes after all workers finish, including Close called before Start. Multiple readers share rather than broadcast events; use Device/Devices for a current authoritative snapshot.
func (*Engine) FrameRequest ¶
func (*Engine) InspectNative ¶
func (e *Engine) InspectNative(ctx context.Context, serial string, request nativeinspection.Request) (nativeinspection.Result, error)
InspectNative reserves an idle existing worker for one bounded native read. Busy rejection never replaces, queues or cancels a control job. A canceled caller cannot interrupt an in-flight native operation: admission remains reserved until the worker really returns. Available results retain their original error, including partial reads and typed native causes.
func (*Engine) Instance ¶
func (e *Engine) Instance() InstanceInfo
Instance supplies an optional receipt prefix without reserving cache space. Its identity changes on Engine creation, not on device disconnect/recovery.
func (*Engine) PatternRequest ¶
func (e *Engine) PatternRequest(serial string, input ReceiptRequest, ref patternidentity.Ref) (PatternJobEnvelope, error)
PatternRequest resolves only the original in-memory receipt. Store failures, ordinary history eviction and runtime closure cannot strip its provenance.
func (*Engine) Request ¶
Request resolves an accepted submission even after ordinary history eviction or Engine shutdown. An absent expired key cannot reveal its original outcome.
func (*Engine) SequenceJob ¶
func (e *Engine) SequenceJob(id string) (SequenceJob, error)
func (*Engine) SequenceJobLimits ¶
SequenceJobLimits reports this daemon's startup policy, not a guaranteed deduplication interval. Capacity eviction and restart can remove records sooner.
func (*Engine) SubmitFrameWithReceipt ¶
func (e *Engine) SubmitFrameWithReceipt(ctx context.Context, serial string, program FrameProgram, policy string, input ReceiptRequest) (FrameReceiptResult, error)
func (*Engine) SubmitPatternWithReceipt ¶
func (e *Engine) SubmitPatternWithReceipt(ctx context.Context, serial string, ref patternidentity.Ref, policy string, input ReceiptRequest, resolve PatternResolver) (PatternReceiptResult, error)
SubmitPatternWithReceipt preserves a verified source identity at the same linearization point as its receipt and worker queue publication. No old Submit is called, and no side table or in-flight reservation is created.
func (*Engine) SubmitRoutedSequence ¶ added in v0.1.3
func (e *Engine) SubmitRoutedSequence(ctx context.Context, requestedSerial, id string, fingerprint [32]byte, prepare func() (sequence.Sequence, SequenceRoute, error)) (SequenceJob, bool, error)
SubmitRoutedSequence checks the original request identity before resolving mutable trigger bindings or choosing a device from the current daemon state. An empty requested serial denotes an implicit target, never a wildcard ID. An explicit request serial is authoritative over the prepared routing hint.
func (*Engine) SubmitSequence ¶
func (e *Engine) SubmitSequence(ctx context.Context, serial, id string, fingerprint [32]byte, prepare func() (sequence.Sequence, error)) (SequenceJob, bool, error)
SubmitSequence resolves a new intent outside the engine mutex. An already accepted ID is checked on both sides of that work, even if resolution failed.
func (*Engine) SubmitWithReceipt ¶
func (e *Engine) SubmitWithReceipt(ctx context.Context, serial string, program Program, policy string, input ReceiptRequest) (ReceiptResult, error)
SubmitWithReceipt atomically deduplicates logical job admission in this Engine. It is in-memory only and never retries a failed or cancelled program.
func (*Engine) TransportMetrics ¶
func (e *Engine) TransportMetrics() []TransportMetric
type Frame ¶
type Frame struct {
Targets []FrameTarget `json:"targets"`
FadeMS int `json:"fade_ms"`
IntervalMS int `json:"interval_ms"`
}
Frame describes overlapping device fades followed by one host interval. The executor must wait only the remainder of IntervalMS after writes, not FadeMS separately for each target. Device qualification remains separate from these host-side scheduling semantics.
type FrameExecutionAvailability ¶
type FrameExecutionAvailability struct {
Available bool `json:"available"`
Reason string `json:"reason"`
}
FrameExecutionAvailability prevents a pure preview from claiming a working frame executor or any physical device qualification.
func FrameExecutionForDevice ¶
func FrameExecutionForDevice(state *DeviceState) FrameExecutionAvailability
FrameExecutionForDevice checks cached facts only. It neither probes hardware nor proves optical performance, admission, or a particular daemon's support.
type FrameJob ¶
type FrameJob struct {
ID string `json:"id"`
Device string `json:"device"`
Status string `json:"status"`
Program FrameProgram `json:"program"`
CompletedFrames int `json:"completed_frames"`
TotalFrames int `json:"total_frames"`
CompletedTargetWrites int `json:"completed_target_writes"`
PlannedTargetWrites int `json:"planned_target_writes"`
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
Error string `json:"error,omitempty"`
}
type FramePreview ¶
type FramePreview struct {
Contract string `json:"contract"`
Program FrameProgram `json:"program"`
TotalFrames int `json:"total_frames"`
StoredTargetWrites int `json:"stored_target_writes"`
PlannedTargetWrites int `json:"planned_target_writes"`
CycleDurationMS int64 `json:"cycle_duration_ms"`
NominalInitialMS int64 `json:"nominal_initial_ms"`
NominalTailMS int64 `json:"nominal_tail_ms"`
NominalDurationMS int64 `json:"nominal_duration_ms"`
TimingBasis string `json:"timing_basis"`
RequiredCapabilities []string `json:"required_capabilities"`
Execution FrameExecutionAvailability `json:"execution"`
}
func PreviewFrameProgram ¶
func PreviewFrameProgram(input FrameProgram) (FramePreview, error)
PreviewFrameProgram describes a validated experimental schedule only. It does not select an Engine or device, so execution availability remains unchecked. Actual tail waiting must use last native Set return times, not this nominal arithmetic. Native I/O, timer lateness, readback and cleanup add wall time.
type FrameProgram ¶
type FrameProgram struct {
Contract string `json:"contract"`
Initial []FrameTarget `json:"initial"`
Frames []Frame `json:"frames"`
Repeat int `json:"repeat"`
OnFinish string `json:"on_finish"`
}
FrameProgram is distinct from the unchanged sequential Program contract. Initial zero-time targets apply once; Repeat repeats Frames only. The final device fade must settle before OnFinish; native I/O is not included in nominal preview duration and cannot be cancelled by a host timer.
func DecodeFrameProgram ¶
func DecodeFrameProgram(data []byte) (FrameProgram, error)
DecodeFrameProgram accepts one strict JSON description and returns a fresh normalized copy. It performs no I/O and is not registered with any transport.
func NormalizeFrameProgram ¶
func NormalizeFrameProgram(input FrameProgram) (FrameProgram, error)
NormalizeFrameProgram validates and deeply copies a pure experimental frame description. It never discovers devices, enables capabilities or submits work.
type FrameReceiptResult ¶
type FrameService ¶
type FrameService interface {
Instance() InstanceInfo
SubmitFrameWithReceipt(context.Context, string, FrameProgram, string, ReceiptRequest) (FrameReceiptResult, error)
FrameJob(string) (FrameJob, error)
CancelFrame(context.Context, string) (FrameJob, error)
FrameRequest(string, string, string) (FrameJob, error)
}
FrameService is opt-in. Existing Service and ReceiptService stay unchanged.
type FrameTarget ¶
FrameTarget is an exact raw RGB target for one physical LED. Ordered targets would be sent sequentially; this type does not promise an atomic USB write.
type IdempotencyInfo ¶
type IdempotencyInfo struct {
Supported bool `json:"supported"`
RequestIDPrefix string `json:"request_id_prefix"`
AcceptUntilUptimeMS int64 `json:"accept_until_uptime_ms"`
MaxAcceptWindowMS int64 `json:"max_accept_window_ms"`
ReceiptRetentionMS int64 `json:"receipt_retention_ms"`
MaxEntries int `json:"max_entries"`
MaxRetainedSteps int `json:"max_retained_steps"`
}
Deadlines are monotonic Engine uptime milliseconds, not wall-clock dates. Append 32 random lowercase hexadecimal characters to RequestIDPrefix.
type InstanceInfo ¶
type InstanceInfo struct {
DaemonInstanceID string `json:"daemon_instance_id"`
Idempotency IdempotencyInfo `json:"idempotency"`
}
type Job ¶
type Job struct {
ID string `json:"id"`
Device string `json:"device"`
Status string `json:"status"`
Program Program `json:"program"`
CompletedSteps int `json:"completed_steps"`
TotalSteps int `json:"total_steps"`
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
Error string `json:"error,omitempty"`
}
type NativeInspectionBackend ¶
type NativeInspectionBackend interface {
InspectNative(context.Context, nativeinspection.Request) (nativeinspection.Result, error)
}
NativeInspectionBackend is optional. The existing Backend stays compatible with non-native implementations and test doubles. Only the worker invokes it.
type NativeInspectionService ¶
type NativeInspectionService interface {
InspectNative(context.Context, string, nativeinspection.Request) (nativeinspection.Result, error)
}
NativeInspectionService adds live native reads without changing Service or creating a control Job, receipt, device handle or persistent library record.
type Observation ¶
type Options ¶
type Options struct {
// TerminalJobLimit and TerminalJobTTL bound the v1 Job identity cache.
// Zero selects defaults; active Jobs never consume terminal capacity.
TerminalJobLimit int
TerminalJobTTL time.Duration
Serials []string
QueueSize int
PollInterval time.Duration
MaxHistory int
// Default off for daemon shutdown; direct commands may release a completed
// stable state with hold. Interrupted active jobs always clean up with off.
ShutdownMode string
// ReadOnly permits monitoring without freezing or changing device output.
ReadOnly bool
}
type PatternExecution ¶
type PatternExecution struct {
Kind string
Program *Program
FrameProgram *FrameProgram
}
PatternExecution is a closed typed union of already frozen execution data. Its outer contract is derived from Kind. It carries no source verification, Ref, arbitrary JSON, device capability or permission to admit a job.
func ValidatePatternExecution ¶
func ValidatePatternExecution(input PatternExecution) (PatternExecution, error)
ValidatePatternExecution returns a deep copy only if the input is already fully normalized. It rejects defaults or RGB changes rather than changing the execution under an existing source identity. All original budgets apply.
func (PatternExecution) CanonicalJSON ¶
func (input PatternExecution) CanonicalJSON() ([]byte, error)
CanonicalJSON encodes only the validated, closed ASCII/integer subset. Every object layer is a map with fixed keys, so encoding/json's lexical map order matches P1 canonical bytes. No generic parser, floats or struct field-order assumptions are used. Zero fields and array order are preserved.
func (PatternExecution) Digest ¶
func (input PatternExecution) Digest() (string, error)
Digest always recomputes the fixed execution-domain hash from validated canonical bytes; it never accepts a caller-provided digest as proof.
func (PatternExecution) VerifyDigest ¶
func (input PatternExecution) VerifyDigest(expected string) error
VerifyDigest compares the exact expected digest after recomputing it. A mismatch is rejected, never repaired. Neither match nor validation proves that an author Action compiled into this data; the P1 adapter owns that check.
type PatternJobEnvelope ¶
type PatternJobEnvelope struct {
PatternRef patternidentity.Ref `json:"pattern_ref"`
ExecutionDigest string `json:"execution_digest"`
JobKind string `json:"job_kind"`
ProgramJob *Job `json:"-"`
FrameJob *FrameJob `json:"-"`
}
PatternJobEnvelope adds provenance outside the unchanged Job/FrameJob wire shape. Exactly the selected typed snapshot is present; callers cannot submit this envelope as arbitrary execution input.
func (PatternJobEnvelope) MarshalJSON ¶
func (e PatternJobEnvelope) MarshalJSON() ([]byte, error)
type PatternReceiptResult ¶
type PatternReceiptResult struct {
Job PatternJobEnvelope `json:"job"`
Replayed bool `json:"replayed"`
DaemonInstanceID string `json:"daemon_instance_id"`
}
type PatternResolveError ¶
type PatternResolveError struct {
Kind PatternResolveErrorKind
Err error
}
PatternResolveError preserves the diagnostic and an explicit classification. Only a whitelisted availability failure can yield to a concurrently accepted, exactly matching receipt. Unknown errors and all integrity failures fail closed. Adapters must classify unsafe/corrupt data before any underlying I/O cause.
func (*PatternResolveError) Error ¶
func (e *PatternResolveError) Error() string
func (*PatternResolveError) Unwrap ¶
func (e *PatternResolveError) Unwrap() error
type PatternResolveErrorKind ¶
type PatternResolveErrorKind string
const ( PatternResolveAvailability PatternResolveErrorKind = "availability" PatternResolveIntegrity PatternResolveErrorKind = "integrity" PatternResolveUnsupported PatternResolveErrorKind = "unsupported" PatternResolveConfiguration PatternResolveErrorKind = "configuration" PatternResolveUnknown PatternResolveErrorKind = "unknown" )
type PatternResolver ¶
type PatternResolver func(context.Context, patternidentity.Ref) (ResolvedPattern, error)
PatternResolver runs at most once per Submit call, and only after a receipt miss. It runs outside Engine.mu and must release its storage transaction before returning. An accepted receipt is independent of this callback thereafter.
type PatternService ¶
type PatternService interface {
Instance() InstanceInfo
SubmitPatternWithReceipt(context.Context, string, patternidentity.Ref, string, ReceiptRequest, PatternResolver) (PatternReceiptResult, error)
PatternRequest(string, ReceiptRequest, patternidentity.Ref) (PatternJobEnvelope, error)
CancelPatternRequest(context.Context, string, ReceiptRequest, patternidentity.Ref, string) (PatternJobEnvelope, error)
}
PatternService is opt-in; old interfaces and bare Job schemas stay unchanged. Query and cancel require the original receipt and never depend on storage.
type PreviewDevice ¶
type PreviewResult ¶
type PreviewResult struct {
SchemaVersion int `json:"schema_version"`
CompileContract string `json:"compile_contract"`
InputKind string `json:"input_kind"`
Program Program `json:"program"`
NominalDurationMS int64 `json:"nominal_duration_ms"`
TotalSteps int `json:"total_steps"`
RequiredCapabilities []string `json:"required_capabilities"`
Validation PreviewValidation `json:"validation"`
Device *PreviewDevice `json:"device,omitempty"`
}
func Preview ¶
func Preview(program *Program, effect *Effect) (PreviewResult, error)
Preview shares the actual compiler and normalizer with job execution. It neither discovers devices nor creates jobs, receipts or ownership leases.
func WithDeviceSnapshot ¶
func WithDeviceSnapshot(result PreviewResult, serial string, snapshot *DeviceState) PreviewResult
WithDeviceSnapshot checks advertised names only, not hardware execution or admission. Offline/unknown snapshots cannot establish support. No I/O occurs.
type PreviewValidation ¶
type Program ¶
type Program struct {
Steps []Step `json:"steps"`
Repeat int `json:"repeat"`
OnFinish string `json:"on_finish"`
}
func CompileEffect ¶
CompileEffect is the authoritative high-level compiler. Its result is an ordinary normalized Program: queueing, receipts, execution and cleanup retain their existing semantics. This function performs no I/O or device discovery. Pulse periods include the executor's three 10ms update allowances per cycle; native I/O and preflight/finish cleanup add time beyond that nominal period.
type ProgramLimits ¶
type ProgramLimits struct {
MaxSteps int `json:"max_steps"`
MaxRepeat int `json:"max_repeat"`
MaxFadeMS int `json:"max_fade_ms"`
FadeQuantumMS int `json:"fade_quantum_ms"`
MaxHoldMS int `json:"max_hold_ms"`
MaxNominalDurationMS int64 `json:"max_nominal_duration_ms"`
StepOverheadMS int `json:"step_overhead_ms"`
}
type ReceiptRequest ¶
type ReceiptRequest struct {
RequestID string `json:"request_id"`
ExpectedDaemonInstanceID string `json:"expected_daemon_instance_id"`
}
ReceiptRequest binds one logical submission to one Engine instance. Both fields are required by SubmitWithReceipt; unkeyed callers keep using Submit.
type ReceiptResult ¶
type ReceiptResult struct {
Job Job `json:"job"`
Replayed bool `json:"replayed"`
DaemonInstanceID string `json:"daemon_instance_id"`
}
ReceiptResult returns the original job's current snapshot, including terminal failure/cancellation. Replayed never means the program was executed again.
type ReceiptService ¶
type ReceiptService interface {
Service
Instance() InstanceInfo
SubmitWithReceipt(context.Context, string, Program, string, ReceiptRequest) (ReceiptResult, error)
Request(serial, requestID, expectedDaemonInstanceID string) (Job, error)
}
ReceiptService is an optional extension. The original Service remains compatible with existing callers, adapters and test doubles.
type ResolvedPattern ¶
type ResolvedPattern struct {
Ref patternidentity.Ref
Execution PatternExecution
ExecutionDigest string
}
ResolvedPattern is supplied only by a trusted, full source/recipe verifier. The Engine independently validates Ref, frozen execution and its digest, but cannot reconstruct an author's source from this bounded admission input.
type SequenceJob ¶
type SequenceJob struct {
ID string `json:"id"`
Serial string `json:"serial"`
TargetSource string `json:"target_source,omitempty"`
Status string `json:"status"`
CompletedSteps int `json:"completed_steps"`
TotalSteps int `json:"total_steps"`
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
Error string `json:"error,omitempty"`
}
SequenceJob is the current status of an accepted v1 job. TotalSteps counts repeated steps; initialization and final cleanup do not count as steps.
type SequenceRoute ¶ added in v0.1.3
SequenceRoute describes the resolved request or binding, before checking the live worker states. Only a configured default may opt into substitution.
type SequenceService ¶
type SequenceService interface {
SubmitSequence(ctx context.Context, serial, id string, fingerprint [32]byte, prepare func() (sequence.Sequence, error)) (SequenceJob, bool, error)
SequenceJob(id string) (SequenceJob, error)
CancelSequence(ctx context.Context, id string) (SequenceJob, error)
}
SequenceService is the v1 execution interface. The fingerprint identifies the original request, while prepare resolves its execution input.
type Service ¶
type Service interface {
Devices() []DeviceState
Device(serial string) (DeviceState, error)
Submit(ctx context.Context, serial string, program Program, policy string) (Job, error)
Job(id string) (Job, error)
Cancel(ctx context.Context, id string) (Job, error)
}
Service is the common interface used by HTTP and local clients. Cancel only becomes terminal after the worker has confirmed hardware cleanup.
type Step ¶
type Step struct {
LED int `json:"led"`
Color string `json:"color"`
FadeMS int `json:"fade_ms"`
HoldMS int `json:"hold_ms"`
}
Durations are host-side milliseconds. Observed colors are raw device RGB; this initial executor sends exact RGB with no implicit gamma conversion.
type TransportMetric ¶
type TransportMetric struct {
Serial string `json:"serial"`
Operation string `json:"operation"`
Calls uint64 `json:"calls"`
Attempts uint64 `json:"attempts"`
Retries uint64 `json:"retries"`
Failures uint64 `json:"failures"`
LastError string `json:"last_error,omitempty"`
}
TransportMetric is an optional driver's cumulative transport-counter snapshot. Calls counts SDK operations, Attempts includes the initial call, Retries counts additional attempts, and Failures counts terminally failed operations. LastError is historical: the operation may since have recovered. Drivers expose Metrics() []TransportMetric without changing Backend/Service.
Source Files
¶
- effects.go
- engine.go
- events.go
- frame_decode.go
- frame_execute.go
- frame_normalize.go
- frame_preview.go
- frame_receipts.go
- frame_record.go
- frame_schedule.go
- frame_service.go
- frame_types.go
- metrics.go
- native_inspection.go
- pattern_execution.go
- pattern_receipts.go
- pattern_record.go
- pattern_service.go
- preview.go
- receipt_types.go
- receipts.go
- sequence_execution.go
- sequence_jobs.go
- sequence_routing.go
- transport_scope.go
- types.go