motion

package
v0.1.0-alpha.50 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: GPL-3.0 Imports: 21 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 motion will own semantic motion targets, plans, sampling, retargeting, and active motion state.

Index

Constants

View Source
const (
	// RoutineCycleFloorMillis is the hardware-derived minimum stored authoring
	// cycle. Runtime playback may retime that curve through the shared plan.
	RoutineCycleFloorMillis int64 = 6600
	// PatternKindRoutine identifies a normal repeating pattern.
	PatternKindRoutine = "routine"
	// PatternKindBurst identifies a deliberately short shape exempt from the
	// routine cycle floor.
	PatternKindBurst = "burst"

	// MaximumMediaTimelinePoints keeps feature-length funscripts bounded while
	// leaving normal pattern and program authoring on the smaller content cap.
	MaximumMediaTimelinePoints = 100_000

	// TagExperimental marks catalog content that is fully playable in the
	// library but exposed to the model only behind the user's
	// experimental-patterns capability gate.
	TagExperimental = "experimental"
	// TagCurated marks user-selected curves promoted into the built-in catalog.
	TagCurated = "curated"
)
View Source
const (
	// DynamicMotionName is the user-facing content label for model-authored loops.
	DynamicMotionName = "Creative"
	// MinimumDynamicSpanPercent prevents narrow model targets from collapsing
	// into whole-percent device stalls at slow speeds.
	MinimumDynamicSpanPercent = 20
)
View Source
const (
	DynamicSpanProfileSteady   = "steady"
	DynamicSpanProfileBreathe  = "breathe"
	DynamicSpanProfileWander   = "wander"
	DynamicSpanProfileContrast = "contrast"
)

DynamicSpanProfileSteady and its siblings are semantic texture choices, not transport modes. The empty profile retains alpha.25 compatibility, where variation_percent also produces a small implicit span swell.

View Source
const MinimumPatternReversalProminence = 2.0

MinimumPatternReversalProminence is the smallest adjacent swing treated as an intentional loop reversal. Smaller extrema are positional chatter.

View Source
const TargetSourceManualUI = "manual_ui"

TargetSourceManualUI identifies motion explicitly started by the diagnostic manual-test controls. Autonomous modes use their mode identifier as source.

View Source
const TargetSourceMedia = "media"

TargetSourceMedia identifies a clock-locked paired-funscript run.

View Source
const (
	// TargetSourceMotionLab identifies an explicitly started experiment.
	TargetSourceMotionLab = "motion_lab"
)

Variables

View Source
var ErrUnsafeStartupState = errors.New("motion startup state is unsafe")

ErrUnsafeStartupState marks device geometry that the shared motion engine cannot safely recover through its bounded startup lead-in. Autonomous modes must not retry this unchanged state indefinitely; a new explicit start may be attempted after the device position or calibration changes.

View Source
var StrokeAccentMoves = []string{"plunge", "full", "tip_flicks", "deep_grind", "pause", "slow"}

StrokeAccentMoves are the motifs an accent can weave in.

View Source
var StrokeAccentRates = []string{"rarely", "sometimes", "often"}

StrokeAccentRates are how often an accent appears.

View Source
var StrokeCharacters = []string{"steady", "drift", "alternate", "occasional", "roam"}

StrokeCharacters are the ways a turn moves between its two positions: holding still, wandering smoothly, switching every few strokes, visiting the other position now and then, or wandering in step with the other roaming turn so the whole stroke moves.

Functions

func DynamicSpanProfiles

func DynamicSpanProfiles() []string

DynamicSpanProfiles lists the explicit model-facing profile vocabulary.

func LabSettingsKey

func LabSettingsKey(settings config.MotionSettings) string

LabSettingsKey detects a changed limit/calibration before audition.

func UsesExactImportedCurve

func UsesExactImportedCurve(definition PatternDefinition) bool

UsesExactImportedCurve marks the explicit allowlist of imported timing that intentionally preserves holds and bypasses generated-pattern fitting. A bulk-imported filename is never sufficient evidence.

func ValidDynamicSpanProfile

func ValidDynamicSpanProfile(value string) bool

ValidDynamicSpanProfile reports whether value is an explicit profile.

Types

type ActiveMotionState

type ActiveMotionState struct {
	Running                    bool                     `json:"running"`
	Starting                   bool                     `json:"starting"`
	Completing                 bool                     `json:"completing"`
	Paused                     bool                     `json:"paused"`
	RunningMillis              int64                    `json:"running_ms"`
	Generation                 uint64                   `json:"generation"`
	StreamID                   string                   `json:"stream_id,omitempty"`
	PlanID                     string                   `json:"plan_id,omitempty"`
	Target                     MotionTarget             `json:"target"`
	Settings                   config.MotionSettings    `json:"settings"`
	StartedAt                  string                   `json:"started_at,omitempty"`
	Phase                      float64                  `json:"phase"`
	NextSampleMillis           int64                    `json:"next_sample_ms"`
	RecentCommandLatencyMillis int64                    `json:"recent_command_latency_ms"`
	CurrentSample              *MotionSample            `json:"current_sample,omitempty"`
	LastSample                 *MotionSample            `json:"last_sample,omitempty"`
	LastResult                 *transport.CommandResult `json:"last_result,omitempty"`
	LastError                  string                   `json:"last_error,omitempty"`
	// Pace is the compact backend-authoritative Creative output readout. It is
	// safe for the motion SSE because it contains no curve points or payloads.
	Pace *PaceSummary `json:"pace,omitempty"`
	// Perceptual is backend planning context. It stays out of the 8 Hz motion
	// SSE snapshot; Autopilot records the compact values in decision traces.
	Perceptual PerceptualSummary `json:"-"`
}

ActiveMotionState is a safe snapshot of the current motion loop. CurrentSample follows the playback clock; LastSample is the accepted transport-buffer tail and may be ahead of playback.

type AreaFocus

type AreaFocus struct {
	MinPercent int `json:"min_percent"`
	MaxPercent int `json:"max_percent"`
}

AreaFocus constrains semantic sampling to a focus region.

type ContinuousRecipe

type ContinuousRecipe struct {
	ID          PatternID `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	Spec        FlowSpec  `json:"spec"`
}

ContinuousRecipe is a distinct movement behavior, independent of pace. IDs and descriptions are also the compact model-facing action vocabulary.

func ContinuousRecipeByID

func ContinuousRecipeByID(id PatternID, speed int) (ContinuousRecipe, bool)

ContinuousRecipeByID resolves only the reviewed canonical action IDs.

func ContinuousRecipes

func ContinuousRecipes(speed int) []ContinuousRecipe

ContinuousRecipes returns fresh scores so callers cannot mutate the catalog.

type Curve

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

Curve is a validated time-parameterized sampler. Pattern curves use monotone cubic interpolation; media timelines preserve linear segments.

func NewCurve

func NewCurve(points []CurvePoint, durationMillis int64, loop bool) (Curve, error)

NewCurve validates points and builds PCHIP-style wall-time derivatives. Authoring, preview, and budget measurement use unscaled playback; only the engine plan knows the speed and focus a curve will actually be played at.

func (Curve) Preview

func (c Curve) Preview(intervalMillis int64) []CurvePoint

Preview returns backend-sampled points including the final endpoint.

func (Curve) Sample

func (c Curve) Sample(timeMillis int64) float64

Sample returns the shape-preserving interpolated relative position.

func (Curve) Velocity

func (c Curve) Velocity(timeMillis int64) float64

Velocity returns the wall-clock derivative in percent per second.

type CurveMetrics

type CurveMetrics struct {
	MaxAccelerationPercentPerSecond2 float64 `json:"max_acceleration_percent_per_second2"`
	MinReversalGapMillis             int64   `json:"min_reversal_gap_ms"`
}

CurveMetrics exposes generator budget measurements for tests and diagnostics.

func MeasureCurve

func MeasureCurve(points []CurvePoint, durationMillis int64, loop bool) (CurveMetrics, error)

MeasureCurve reports the wall-time acceleration and reversal spacing.

type CurvePoint

type CurvePoint struct {
	TimeMillis      int64   `json:"time_ms"`
	PositionPercent float64 `json:"position_percent"`
}

CurvePoint is one relative 0..100 motion sample at wall-clock time.

func ContinuousPatternPreview

func ContinuousPatternPreview(id PatternID) ([]CurvePoint, int64, bool)

ContinuousPatternPreview samples the real playback plan at a declared reference pace; the library must not show a different PCHIP reconstruction.

func SmoothMediaReversals

func SmoothMediaReversals(points []CurvePoint, minimumProminence float64) []CurvePoint

SmoothMediaReversals removes only small excursions with two short flanks. A large authored reversal beside a small spike remains an anchor. The fixed wall-time window is independent of how much script remains after a seek.

func StabilizePatternReversals

func StabilizePatternReversals(points []CurvePoint, minimumProminence float64) []CurvePoint

StabilizePatternReversals removes rapid, insignificant extrema while preserving monotonic detail, endpoints, dwell timing, and slow subtle motion.

type DynamicAnchor

type DynamicAnchor struct {
	Name            string `json:"name"`
	PositionPercent int    `json:"position_percent"`
}

DynamicAnchor is one semantic pass-through target in a model-authored loop.

type DynamicDefinition

type DynamicDefinition struct {
	CenterPercent    int              `json:"center_percent"`
	SpanPercent      int              `json:"span_percent"`
	SpanMinPercent   int              `json:"span_min_percent,omitempty"`
	SpanProfile      string           `json:"span_profile,omitempty"`
	PhraseSeed       uint32           `json:"phrase_seed,omitempty"`
	Anchors          []DynamicAnchor  `json:"anchors,omitempty"`
	VariationPercent int              `json:"variation_percent"`
	SegmentSeconds   int              `json:"segment_seconds"`
	Sections         []DynamicSection `json:"sections,omitempty"`
	// Experiment is opt-in Motion Lab intent. The production LLM contract does
	// not accept it; ordinary Creative targets retain their existing behavior.
	Experiment *DynamicExperiment `json:"experiment,omitempty"`
}

DynamicDefinition is bounded geometry authored by the LLM and compiled by the backend into ordinary MotionPlan content. It is not a transport payload.

func AdvanceDynamicPhraseSeed

func AdvanceDynamicPhraseSeed(definition DynamicDefinition, previous uint32) DynamicDefinition

AdvanceDynamicPhraseSeed gives an explicitly replaced phrase fresh micro-timing while retaining deterministic replay from the authoritative target. The current seed is the entire novelty memory: no unbounded history or second motion model is introduced.

func FreshDynamicPhrase

func FreshDynamicPhrase(definition DynamicDefinition, previous uint32) DynamicDefinition

FreshDynamicPhrase changes only the realization of an explicitly authored Creative phrase. Normalization and saved-target replay stay deterministic; speed-only edits retain the active phrase. No sample-time randomness is used.

func NormalizeDynamicDefinition

func NormalizeDynamicDefinition(definition DynamicDefinition) DynamicDefinition

NormalizeDynamicDefinition returns concrete, bounded geometry suitable for engine sampling. Named anchors take precedence over center/span geometry.

type DynamicExperiment

type DynamicExperiment struct {
	RangeAnchorPercent  int `json:"range_anchor_percent"`
	OutboundTimePercent int `json:"outbound_time_percent"`
}

DynamicExperiment separates two expressive axes that the production variation control couples. Both affect authored intent before the ordinary C2 fit, runtime envelope, sampler, sanitizer and transport dispatch.

type DynamicSection

type DynamicSection struct {
	CenterPercent    int             `json:"center_percent"`
	SpanPercent      int             `json:"span_percent"`
	SpanMinPercent   int             `json:"span_min_percent,omitempty"`
	SpanProfile      string          `json:"span_profile,omitempty"`
	Anchors          []DynamicAnchor `json:"anchors,omitempty"`
	VariationPercent int             `json:"variation_percent"`
	Cycles           int             `json:"cycles"`
}

DynamicSection is one compact movement idea inside a Creative phrase. It deliberately uses the same semantic geometry as DynamicDefinition: the LLM selects a few bounded sections and deterministic code turns them into one smooth, loop-closed curve through the shared motion engine.

type Engine

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

Engine owns one active semantic motion loop.

func NewEngine

func NewEngine(options EngineOptions) (*Engine, error)

NewEngine creates a motion engine bound to one transport dispatcher.

func (*Engine) AdmissionGeneration

func (e *Engine) AdmissionGeneration() uint64

AdmissionGeneration snapshots the Stop epoch used to reject work admitted before a concurrent Emergency Stop.

func (*Engine) ApplyTarget

func (e *Engine) ApplyTarget(ctx context.Context, target MotionTarget, reason string) (ActiveMotionState, error)

ApplyTarget retargets active motion without stopping the active stream.

func (*Engine) ApplyTargetIfCurrent

func (e *Engine) ApplyTargetIfCurrent(ctx context.Context, target MotionTarget, reason string, planID string) (ActiveMotionState, error)

ApplyTargetIfCurrent rejects a late semantic update after Stop/replacement, including one waiting behind another target operation. It never starts motion.

func (*Engine) Pause

func (e *Engine) Pause(ctx context.Context, reason string) (ActiveMotionState, error)

Pause stops dispatch and the device while freezing the plan phase, so Resume can continue the same pattern where it left off. It is not the safety path: Stop clears everything, Pause deliberately retains state.

func (*Engine) RefreshSettings

func (e *Engine) RefreshSettings(ctx context.Context, settings config.MotionSettings, reason string) (ActiveMotionState, error)

RefreshSettings applies active speed, stroke-window, and direction updates.

func (*Engine) Resume

func (e *Engine) Resume(ctx context.Context, reason string) (ActiveMotionState, error)

Resume continues paused motion with the same target and preserved phase on a fresh stream.

func (*Engine) Snapshot

func (e *Engine) Snapshot() ActiveMotionState

Snapshot returns the current active motion state.

func (*Engine) Start

func (e *Engine) Start(ctx context.Context, target MotionTarget, settings config.MotionSettings) (ActiveMotionState, error)

Start begins continuous motion against the configured transport.

func (*Engine) StartAtGeneration

func (e *Engine) StartAtGeneration(ctx context.Context, target MotionTarget, settings config.MotionSettings, admission uint64) (ActiveMotionState, error)

StartAtGeneration starts only when no Stop has occurred since admission.

func (*Engine) Stop

func (e *Engine) Stop(ctx context.Context, reason string) (ActiveMotionState, error)

Stop cancels active motion and sends an explicit transport stop. It also clears any paused state: after Stop there is nothing to resume and the run clock resets.

type EngineOptions

type EngineOptions struct {
	Transport        transport.Transport
	Traces           *diagnostics.TraceRing
	Now              func() time.Time
	ChunkSize        int
	DispatchInterval time.Duration
	SampleInterval   time.Duration
	StreamIDPrefix   string
	// ArchiveTrace is notified after a completed Stop and after all engine and
	// transport locks are released. firstSequence identifies this run inside
	// the shared sanitized trace ring. Archival failure must never fail Stop.
	ArchiveTrace func(reason string, firstSequence uint64)
}

EngineOptions configures a motion engine instance.

type FlowExperiment

type FlowExperiment struct {
	ID          string
	Name        string
	Description string
	Spec        FlowSpec
}

FlowExperiment pairs a frozen semantic score with a comparison prompt.

func FlowExperiments

func FlowExperiments(base FlowSpec) []FlowExperiment

FlowExperiments is the shared roster used by guided tests and visual review. It preserves the user's band, layers and sections while isolating new axes.

type FlowLayer

type FlowLayer struct {
	Axis          string `json:"axis"`
	AmountPercent int    `json:"amount_percent"`
	PeriodCycles  int    `json:"period_cycles"`
	PhasePercent  int    `json:"phase_percent"`
	Shape         string `json:"shape,omitempty"`
}

FlowLayer modulates an axis of the carrier; positions are never added or clipped. Convex envelopes keep all combinations inside the requested band.

type FlowPreview

type FlowPreview struct {
	Spec        FlowSpec              `json:"spec"`
	Settings    config.MotionSettings `json:"settings"`
	SettingsKey string                `json:"settings_key"`
	Candidates  []LabCandidate        `json:"candidates"`
}

FlowPreview compares independent generators through the same engine plan.

func PreviewFlow

func PreviewFlow(spec FlowSpec, settings config.MotionSettings, references bool) (FlowPreview, error)

PreviewFlow returns a new-framework plan with optional historical references.

type FlowSpec

type FlowSpec struct {
	Gesture *GestureSpec `json:"gesture,omitempty"`
	// Strokes is an LLM Lab experiment; see StrokeSpec.
	Strokes              *StrokeSpec `json:"strokes,omitempty"`
	MinPercent           int         `json:"min_percent"`
	MaxPercent           int         `json:"max_percent"`
	SpeedPercent         int         `json:"speed_percent"`
	RangeFloorPercent    int         `json:"range_floor_percent"`
	RangeCeilingPercent  int         `json:"range_ceiling_percent,omitempty"`
	AnchorPercent        int         `json:"anchor_percent"`
	MemoryCycles         int         `json:"memory_cycles"`
	PaceVariationPercent int         `json:"pace_variation_percent"`
	VariationMode        string      `json:"variation_mode,omitempty"`
	TurnSoftnessPercent  int         `json:"turn_softness_percent,omitempty"`
	CadenceHoldPercent   int         `json:"cadence_hold_percent,omitempty"`
	Seed                 uint32      `json:"seed"`
	LoopCycles           int         `json:"loop_cycles,omitempty"`
	Steps                []FlowStep  `json:"steps,omitempty"`
	Layers               []FlowLayer `json:"layers,omitempty"`
}

FlowSpec describes a continuous carrier and slow modulation in cycle space. It does not use DynamicDefinition, span profiles, authored reversal routes, or the Creative interval fitter. All values are semantic, never wire points.

func CloneFlowSpec

func CloneFlowSpec(spec *FlowSpec) *FlowSpec

CloneFlowSpec prevents edits or snapshots from aliasing an active score.

func DefaultFlowSpec

func DefaultFlowSpec() FlowSpec

DefaultFlowSpec supplies a reproducible starting comparison.

func (FlowSpec) Validate

func (s FlowSpec) Validate(settings config.MotionSettings) error

Validate rejects ambiguous or out-of-bounds scores rather than silently clipping model output. Physical speed limits remain backend authoritative.

type FlowStep

type FlowStep struct {
	MinPercent   int `json:"min_percent"`
	MaxPercent   int `json:"max_percent"`
	SpeedPercent int `json:"speed_percent"`
	Cycles       int `json:"cycles"`
}

FlowStep is a section of one continuous score, not a separate motion run.

type GestureSpec

type GestureSpec struct {
	FocusPercent        int    `json:"focus_percent"`
	FocusWidthPercent   int    `json:"focus_width_percent"`
	FocusMixPercent     int    `json:"focus_mix_percent"`
	FocusRoamPercent    int    `json:"focus_roam_percent"`
	FasterDirection     string `json:"faster_direction"`
	ContrastPercent     int    `json:"contrast_percent"`
	InertiaPercent      int    `json:"inertia_percent"`
	ReboundCount        int    `json:"rebound_count"`
	ReboundDecayPercent int    `json:"rebound_decay_percent"`
	VariationPercent    int    `json:"variation_percent"`
}

GestureSpec generates stroke destinations and travel character, rather than superimposing position oscillators. It is semantic content for the shared engine: no timers, transport access, device coordinates or private playback.

func DefaultGestureSpec

func DefaultGestureSpec() GestureSpec

DefaultGestureSpec is a neutral vocabulary starting point, not a named path.

type LabCandidate

type LabCandidate struct {
	Method              string            `json:"method"`
	Target              MotionTarget      `json:"target"`
	PeriodMillis        int64             `json:"period_ms"`
	Perceptual          PerceptualSummary `json:"perceptual"`
	OutboundTimePercent float64           `json:"outbound_time_percent"`
	MaximumAcceleration float64           `json:"maximum_acceleration"`
	MaximumJerk         float64           `json:"maximum_jerk"`
	Samples             []LabSample       `json:"samples"`
	Flow                *FlowSpec         `json:"flow,omitempty"`
}

LabCandidate contains full-loop diagnostics and a fixed 12s excerpt.

type LabPreview

type LabPreview struct {
	Version       int                   `json:"version"`
	Request       LabRequest            `json:"request"`
	Settings      config.MotionSettings `json:"settings"`
	SettingsKey   string                `json:"settings_key"`
	PreviewMillis int64                 `json:"preview_ms"`
	Candidates    []LabCandidate        `json:"candidates"`
}

LabPreview is fully computed on the backend without creating an Engine, acquiring a controller, changing settings, or contacting a device.

func PreviewMotionLab

func PreviewMotionLab(request LabRequest, settings config.MotionSettings) (LabPreview, error)

PreviewMotionLab compares identical source intent, seed and saved limits.

type LabRequest

type LabRequest struct {
	SpeedPercent        int    `json:"speed_percent"`
	CenterPercent       int    `json:"center_percent"`
	SpanPercent         int    `json:"span_percent"`
	SpanMinPercent      int    `json:"span_min_percent"`
	SpanProfile         string `json:"span_profile"`
	VariationPercent    int    `json:"variation_percent"`
	RangeAnchorPercent  int    `json:"range_anchor_percent"`
	OutboundTimePercent int    `json:"outbound_time_percent"`
	Seed                uint32 `json:"seed"`
}

LabRequest is a bounded semantic experiment, never a timed-point API. Its seed permits matched, reproducible comparisons without hidden variation.

func (LabRequest) Target

func (r LabRequest) Target(method string) (MotionTarget, error)

Target resolves a lab method through the same Creative semantic compiler.

type LabSample

type LabSample struct {
	TimeMillis        int64   `json:"time_ms"`
	PositionPercent   float64 `json:"position_percent"`
	VelocityPerSecond float64 `json:"velocity_percent_per_second"`
}

LabSample is a planned semantic position and a velocity estimate, not a wire point or measured device feedback. Transport fitting is deliberately excluded from the preview and still occurs normally during an audition.

type LabStart

type LabStart struct {
	Request     LabRequest `json:"request"`
	Method      string     `json:"method"`
	SettingsKey string     `json:"settings_key"`
	Flow        *FlowSpec  `json:"flow,omitempty"`
}

LabStart binds an explicit audition to the settings used for preview.

type MediaRoundingEffect

type MediaRoundingEffect struct {
	RoundedCorners       int     `json:"rounded_corners"`
	LimitedCorners       int     `json:"rounding_limited_corners"`
	SkippedCorners       int     `json:"rounding_skipped_corners"`
	PeakReductionPercent float64 `json:"peak_reduction_percent"`
	PeakShiftMillis      float64 `json:"peak_shift_ms"`
}

MediaRoundingEffect describes the compiled, optionally speed-limited curve. These are commanded geometry measurements, never physical-device telemetry.

type MediaTimelineDefinition

type MediaTimelineDefinition struct {
	ID             string       `json:"id"`
	Name           string       `json:"name"`
	DurationMillis int64        `json:"duration_ms"`
	Points         []CurvePoint `json:"points"`
	// RoundingMillis is opt-in local C2 corner interpolation. The authored
	// timestamps and linear bodies remain unchanged; zero is authored-exact.
	RoundingMillis int `json:"rounding_ms,omitempty"`
}

MediaTimelineDefinition is finite, clock-locked motion authored against a media file. It is deliberately separate from ProgramDefinition: feature- length funscripts need a larger bound and linear interpolation, and they are never persisted in the pattern library.

func NormalizeMediaTimelineDefinition

func NormalizeMediaTimelineDefinition(definition MediaTimelineDefinition) (MediaTimelineDefinition, error)

NormalizeMediaTimelineDefinition validates a bounded feature-length media curve without applying pattern-library normalization or loop closure.

type MotionPlan

type MotionPlan struct {
	ID             string            `json:"id"`
	Target         MotionTarget      `json:"target"`
	PatternID      PatternID         `json:"pattern_id,omitempty"`
	ProgramID      string            `json:"program_id,omitempty"`
	MediaID        string            `json:"media_id,omitempty"`
	PeriodMillis   int64             `json:"period_ms"`
	HandoffMillis  int64             `json:"handoff_ms"`
	PhaseOffset    float64           `json:"phase_offset"`
	PhasePreserved bool              `json:"phase_preserved"`
	Loop           bool              `json:"loop"`
	CreatedAt      string            `json:"created_at"`
	Perceptual     PerceptualSummary `json:"perceptual"`
	// contains filtered or unexported fields
}

MotionPlan is repeatable or finite semantic content sampled over stream time.

func NewMotionPlan

func NewMotionPlan(
	id string,
	target MotionTarget,
	settings config.MotionSettings,
	phaseOffset float64,
	handoffMillis int64,
	createdAt time.Time,
) MotionPlan

NewMotionPlan returns a normalized plan for a target.

func (MotionPlan) CompleteAt

func (p MotionPlan) CompleteAt(streamMillis int64) bool

CompleteAt reports whether finite program content reached its final point.

func (MotionPlan) DirectionAt

func (p MotionPlan) DirectionAt(streamMillis int64) int

DirectionAt estimates current semantic travel direction.

func (MotionPlan) PhaseAt

func (p MotionPlan) PhaseAt(streamMillis int64) float64

PhaseAt returns semantic phase at the given stream-relative time.

func (MotionPlan) Retarget

func (p MotionPlan) Retarget(
	id string,
	target MotionTarget,
	settings config.MotionSettings,
	streamMillis int64,
	createdAt time.Time,
) MotionPlan

Retarget returns a replacement plan, preserving phase for the same content.

func (MotionPlan) SampleAt

func (p MotionPlan) SampleAt(streamMillis int64) MotionSample

SampleAt samples the plan at the given stream-relative time.

func (MotionPlan) VelocityAt

func (p MotionPlan) VelocityAt(streamMillis int64) float64

VelocityAt estimates played semantic velocity in percent per second. It is used only to choose a smooth retarget phase; transports still receive the normal sampled plan.

type MotionSample

type MotionSample struct {
	PlanID          string    `json:"plan_id"`
	PatternID       PatternID `json:"pattern_id,omitempty"`
	ProgramID       string    `json:"program_id,omitempty"`
	MediaID         string    `json:"media_id,omitempty"`
	PositionPercent float64   `json:"position_percent"`
	TimeMillis      int64     `json:"time_ms"`
	Phase           float64   `json:"phase"`
}

MotionSample is one transport-neutral semantic sample.

type MotionTarget

type MotionTarget struct {
	Label                  string    `json:"label,omitempty"`
	Source                 string    `json:"source,omitempty"`
	PatternID              PatternID `json:"pattern_id,omitempty"`
	PatternName            string    `json:"pattern_name,omitempty"`
	ProgramID              string    `json:"program_id,omitempty"`
	MediaID                string    `json:"media_id,omitempty"`
	SpeedPercent           int       `json:"speed_percent"`
	MediaSpeedLimitEnabled bool      `json:"media_speed_limit_enabled,omitempty"`
	// Derived compact geometry survives snapshots without copying media points.
	MediaRoundingEffect MediaRoundingEffect `json:"-"`
	AreaFocus           *AreaFocus          `json:"area_focus,omitempty"`
	SoftAnchor          *SoftAnchor         `json:"soft_anchor,omitempty"`
	Dynamic             *DynamicDefinition  `json:"dynamic,omitempty"`
	Flow                *FlowSpec           `json:"flow,omitempty"`

	// Resolved content is backend-owned and never serialized to clients. The
	// public IDs above remain the authoritative snapshot vocabulary.
	Pattern *PatternDefinition       `json:"-"`
	Program *ProgramDefinition       `json:"-"`
	Media   *MediaTimelineDefinition `json:"-"`
	// contains filtered or unexported fields
}

MotionTarget is the app-level semantic motion intent.

func FlowTarget

func FlowTarget(spec FlowSpec, settings config.MotionSettings) (MotionTarget, error)

FlowTarget compiles the score once into immutable kinematic content. The ordinary engine owns playback, live limit changes, handoffs and Stop.

func NormalizeTarget

func NormalizeTarget(target MotionTarget, settings config.MotionSettings) MotionTarget

NormalizeTarget clamps semantic intent without applying physical stroke settings.

type PaceSummary

type PaceSummary struct {
	RequestedPercent               int      `json:"requested_percent"`
	EffectivePercent               float64  `json:"effective_percent"`
	RequestedMeanTravelPerSecond   float64  `json:"requested_mean_travel_percent_per_second"`
	CommandedMeanTravelPerSecond   float64  `json:"commanded_mean_travel_percent_per_second"`
	CommandedPeakVelocityPerSecond float64  `json:"commanded_peak_velocity_percent_per_second"`
	DevicePeakVelocityPerSecond    float64  `json:"device_peak_velocity_percent_per_second"`
	Limited                        bool     `json:"limited"`
	Limiters                       []string `json:"limiters,omitempty"`
}

PaceSummary explains how the selected Creative percentage became the final transport-neutral trajectory. RequestedPercent is the control value; EffectivePercent is the calibrated equivalent of commanded mean travel. Limiters are observational diagnostics and never alter model authority.

type PatternDefinition

type PatternDefinition struct {
	ID          PatternID    `json:"id"`
	Name        string       `json:"name"`
	Description string       `json:"description,omitempty"`
	Kind        string       `json:"kind"`
	CycleMillis int64        `json:"cycle_ms"`
	Points      []CurvePoint `json:"points"`
	Tags        []string     `json:"tags,omitempty"`
	// contains filtered or unexported fields
}

PatternDefinition is reusable loop content. Positions are always relative and are projected into the configured stroke window only by the transport.

func BuiltinPatternDefinition

func BuiltinPatternDefinition(id PatternID) (PatternDefinition, bool)

BuiltinPatternDefinition resolves one generated built-in pattern.

func BuiltinPatternDefinitions

func BuiltinPatternDefinitions() []PatternDefinition

BuiltinPatternDefinitions returns the parametrically generated catalog.

func ContinuousPatternDefinition

func ContinuousPatternDefinition(id PatternID) (PatternDefinition, bool)

ContinuousPatternDefinition supplies canonical content to the durable library.

func NormalizePatternDefinition

func NormalizePatternDefinition(definition PatternDefinition) (PatternDefinition, error)

NormalizePatternDefinition validates, closes, and floor-stretches loop data.

func PromotedBuiltinPatternDefinitions

func PromotedBuiltinPatternDefinitions() []PatternDefinition

PromotedBuiltinPatternDefinitions returns defensive copies of user-tested curves promoted into the catalog.

type PatternID

type PatternID string

PatternID identifies a repeatable semantic motion pattern.

const (
	// PatternFullSweeps is the default continuous full-band carrier.
	PatternFullSweeps PatternID = "flow-full-sweeps"
	// PatternBaseVariation varies reach while retaining the lower return.
	PatternBaseVariation PatternID = "flow-base-anchored"
	// PatternPaceWave varies pace without changing full-band geometry.
	PatternPaceWave PatternID = "flow-pace-wave"
	// TagDeprecated identifies retired built-ins retained only for export.
	TagDeprecated = "deprecated"
)
const (
	// PatternStroke is the default full-stroke triangle pattern.
	PatternStroke PatternID = "stroke"
	// PatternPulse is a fixed double-peak pattern.
	PatternPulse PatternID = "pulse"
	// PatternTease is a fixed shallow-to-deep pattern.
	PatternTease PatternID = "tease"
	// PatternWaves identifies a retired swelling-amplitude pattern.
	PatternWaves PatternID = "waves"
	// PatternClimb identifies a retired ratcheting-build pattern.
	PatternClimb PatternID = "climb"
	// PatternFlutter identifies a retired shallow-flutter-with-sweep pattern.
	PatternFlutter PatternID = "flutter"
	// PatternSway identifies a retired asymmetric broad-arc pattern.
	PatternSway PatternID = "sway"
	// PatternDrift migrates a consistent stroke window across a cycle.
	PatternDrift PatternID = "drift"
	// PatternDoubleTap identifies a retired paired-accent pattern.
	PatternDoubleTap PatternID = "double-tap"
	// PatternCascade identifies a retired descending-peak pattern.
	PatternCascade PatternID = "cascade"
	// PatternPendulum identifies a retired alternating centered-arc pattern.
	PatternPendulum PatternID = "pendulum"
	// PatternCradle identifies the retired restrained centered-arcs pattern.
	PatternCradle PatternID = "cradle"
	// PatternSurge identifies a retired decaying-echo pattern.
	PatternSurge PatternID = "surge"
	// PatternRolling identifies a retired layered medium-and-deep pattern.
	PatternRolling PatternID = "rolling"
	// PatternSyncopate identifies a retired uneven-rhythm pattern.
	PatternSyncopate PatternID = "syncopate"
	// PatternFourLevelCircuit cycles full and partial strokes across both zones.
	PatternFourLevelCircuit PatternID = "four-level-circuit"
	// PatternHighLowBlocks identifies retired grouped upper/lower zone pulses.
	PatternHighLowBlocks PatternID = "high-low-blocks"
	// PatternDeepShallowSequence identifies a retired upper-anchored sequence.
	PatternDeepShallowSequence PatternID = "deep-shallow-sequence"
	// PatternShortMediumSteps identifies a retired lower-anchored step pattern.
	PatternShortMediumSteps PatternID = "short-medium-steps"
	// PatternTopAnchoredDepths identifies a retired upper-return catalog pattern.
	PatternTopAnchoredDepths PatternID = "top-anchored-depths"
	// PatternDeepBookends identifies a retired lower-return catalog pattern.
	PatternDeepBookends PatternID = "deep-bookends"
	// PatternOneDeepThreeShallow identifies a retired shallow-pulse catalog pattern.
	PatternOneDeepThreeShallow PatternID = "one-deep-three-shallow"
	// PatternLowerMidrangeMix identifies a retired lower-midrange catalog pattern.
	PatternLowerMidrangeMix PatternID = "lower-midrange-mix"
	// PatternMidTopSwitch identifies a retired upper-pulse catalog pattern.
	PatternMidTopSwitch PatternID = "mid-top-switch"
	// PatternSlowFastFull changes from slow full strokes to fast full strokes.
	PatternSlowFastFull PatternID = "slow-fast-full"
	// PatternMidrangeFullFinish identifies a retired repeated-midrange pattern.
	PatternMidrangeFullFinish PatternID = "midrange-full-finish"
	// PatternDeepPartialSequence mixes full and partial lower-anchored strokes.
	PatternDeepPartialSequence PatternID = "deep-partial-sequence"
	// PatternDeepMediumShortPairs identifies a retired paired reach-band pattern.
	PatternDeepMediumShortPairs PatternID = "deep-medium-short-pairs"
	// PatternFallingCrest identifies a retired lowering-reversal pattern.
	PatternFallingCrest PatternID = "falling-crest"
	// PatternThreeDeepOneShort identifies a retired grouped broad-stroke pattern.
	PatternThreeDeepOneShort PatternID = "three-deep-one-short"
	// PatternDescendingLadder identifies a retired stepped-endpoint pattern.
	PatternDescendingLadder PatternID = "descending-ladder"
	// PatternWanderingSwell identifies a retired migrating center-and-reach pattern.
	PatternWanderingSwell PatternID = "wandering-swell"
	// PatternRisingReach progressively extends alternating upper reversals.
	PatternRisingReach PatternID = "rising-reach"
	// PatternHardAndRegular is a promoted user-curated full-range rhythm.
	PatternHardAndRegular PatternID = "hard-and-regular"
	// PatternPlayfulJerk is a promoted user-curated staggered full-range rhythm.
	PatternPlayfulJerk PatternID = "playful-jerk"

	// PatternEasingDown steps the whole stroke window lower at a held pace.
	PatternEasingDown PatternID = "easing-down"
	// PatternBuildingUp steps the whole stroke window higher at a held pace.
	PatternBuildingUp PatternID = "building-up"
	// PatternBroadAndTight identifies a retired wide/tight contrast pattern.
	PatternBroadAndTight PatternID = "broad-and-tight"
	// PatternUpperAccents keeps quick accents in the upper range.
	PatternUpperAccents PatternID = "upper-accents"
	// PatternLowerAccents identifies a retired lower-range accent pattern.
	PatternLowerAccents PatternID = "lower-accents"
	// PatternSteadyDrift holds one pace while the window wanders.
	PatternSteadyDrift PatternID = "steady-drift"
	// PatternOffbeat breaks even strokes with one displaced deeper reach.
	PatternOffbeat PatternID = "offbeat"
	// PatternNarrowing converges stroke width toward the center.
	PatternNarrowing PatternID = "narrowing"
	// PatternOpeningUp diverges stroke width away from the center.
	PatternOpeningUp PatternID = "opening-up"
	// PatternLongReturn pairs a quick reach with an unhurried return.
	PatternLongReturn PatternID = "long-return"
	// PatternSwell carries the window up and back across one long arc.
	PatternSwell PatternID = "swell"
	// PatternRocking repeats one even mid-range stroke at a fixed pace.
	PatternRocking PatternID = "rocking"
	// PatternSurgeAndSettle follows one full sweep with a long settled run.
	PatternSurgeAndSettle PatternID = "surge-and-settle"
	// PatternThreeAndOne identifies a retired grouped upper/full-range pattern.
	PatternThreeAndOne PatternID = "three-and-one"
	// PatternCrosscut trades long blocks of broad and tight strokes.
	PatternCrosscut PatternID = "crosscut"
)

func RetiredBuiltinPatternIDs

func RetiredBuiltinPatternIDs() []PatternID

RetiredBuiltinPatternIDs returns catalog IDs removed after physical feedback.

type PerceptualSummary

type PerceptualSummary struct {
	PositionMinPercent             float64     `json:"position_min_percent"`
	PositionMaxPercent             float64     `json:"position_max_percent"`
	MeanStrokePercent              float64     `json:"mean_stroke_percent"`
	StrokeLengthCV                 float64     `json:"stroke_length_cv"`
	MinimumLocalStrokeCV           float64     `json:"minimum_local_stroke_cv"`
	MinimumLocalStrokeRange        float64     `json:"minimum_local_stroke_range_percent"`
	CommandedMeanTravelPerSecond   float64     `json:"commanded_mean_travel_percent_per_second"`
	CommandedPeakVelocityPerSecond float64     `json:"commanded_peak_velocity_percent_per_second"`
	AnchorCount                    int         `json:"anchor_count"`
	SectionCount                   int         `json:"section_count"`
	SpanProfile                    string      `json:"span_profile,omitempty"`
	Pace                           PaceSummary `json:"pace"`
}

PerceptualSummary is a compact description of the curve that the shared engine actually commands after speed calibration and safety fitting. It contains no transport payload and is safe to expose to the mode planner and diagnostics without retaining raw curve points.

func (PerceptualSummary) MateriallyDifferent

func (s PerceptualSummary) MateriallyDifferent(other PerceptualSummary) bool

MateriallyDifferent reports whether two commanded curves differ enough to count as a new felt phrase. It is deliberately one normalized perceptual distance rather than a list of schema-field exceptions. Speed is absent: the scheduler already tracks pace age independently.

type PlanningEnvelope

type PlanningEnvelope struct {
	PositionMinPercent           int     `json:"position_min_percent"`
	PositionMaxPercent           int     `json:"position_max_percent"`
	ProfilePeakVelocityPerSecond float64 `json:"profile_peak_velocity_percent_per_second"`
}

PlanningEnvelope exposes the current semantic coordinate system and the profile-derived velocity ceiling. It is a planning reference, not telemetry. Physical stroke-window mapping and final curve fitting stay in the engine.

func CurrentPlanningEnvelope

func CurrentPlanningEnvelope(settings config.MotionSettings) PlanningEnvelope

CurrentPlanningEnvelope derives values from the same profile as the shared sampler; callers need no knowledge of hardware names or version differences.

type ProgramDefinition

type ProgramDefinition struct {
	ID             string       `json:"id"`
	Name           string       `json:"name"`
	DurationMillis int64        `json:"duration_ms"`
	Points         []CurvePoint `json:"points"`
}

ProgramDefinition is finite, non-looping motion content.

func NormalizeProgramDefinition

func NormalizeProgramDefinition(definition ProgramDefinition) (ProgramDefinition, error)

NormalizeProgramDefinition validates finite program content without looping it.

type SoftAnchor

type SoftAnchor struct {
	PositionPercent int `json:"position_percent"`
	WeightPercent   int `json:"weight_percent"`
}

SoftAnchor gently biases sampled positions toward one semantic point.

type StrokeAccent

type StrokeAccent struct {
	Move string `json:"move"`
	Rate string `json:"rate"`
}

StrokeAccent is a short motif that appears at a seeded rate.

type StrokeSpec

type StrokeSpec struct {
	Bottom StrokeTurn `json:"bottom"`
	Top    StrokeTurn `json:"top"`
	// Accents are at most three distinct motifs.
	Accents []StrokeAccent `json:"accents,omitempty"`
	// VariationPercent lets timing breathe from stroke to stroke; 0 repeats
	// every stroke's timing exactly.
	VariationPercent int `json:"variation_percent"`
}

StrokeSpec is an LLM Lab experiment that describes continuous motion by where each stroke turns, in absolute slider positions: its bottom turn, how deep the stroke goes (0 is the base), and its top turn, how close to the tip it turns. Each turn has a usual position, a position it may go instead, and a character for how it moves between them. Accents are short motifs woven into the stream at a seeded rate. The shared joint leg fit times the strokes, as it does for Creative v2, so the ordinary plan, sampler and Stop own playback.

type StrokeTurn

type StrokeTurn struct {
	// AtPercent is the usual turning point, 0 the base and 100 the tip.
	AtPercent int `json:"at_percent"`
	// VaryToPercent is where the turn goes instead, deeper or shallower. It
	// equals AtPercent when the turn holds still.
	VaryToPercent int `json:"vary_to_percent"`
	// Character is how the turn moves between the two positions.
	Character string `json:"character"`
}

StrokeTurn is one turning point of every stroke.

Jump to

Keyboard shortcuts

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