133 std::vector<std::pair<std::string, double>>
deltas;
193 std::string metric_name,
200 std::string metric_name,
201 std::vector<std::pair<std::string, double>> components,
310 const std::vector<SampleEvent>& captured,
318 const std::vector<SampleEvent>& golden,
320 const std::vector<SampleEvent>& captured,
337 const std::vector<SampleEvent>&
events,
338 std::string_view view_name,
339 std::string_view metric_name,
340 std::string_view component_name =
"value");
346 double epsilon = 1
e-6);
351 double epsilon = 1
e-6);
356double overshoot(
const std::vector<ScalarSample>& samples,
357 double epsilon = 1
e-6);
361 double epsilon = 1
e-6);
383 const std::vector<ScalarSample>& samples,
384 std::size_t window_radius = 3,
385 double epsilon = 1
e-9);
448 explicit InputRecorder(
int sink_id) noexcept : sink_id_(sink_id) {}
476 const std::string& view_id,
477 std::vector<std::pair<std::string, double>> coords);
504 int id() const noexcept {
return id_; }
510 : id_(
id), coord_(coord) {}
525 int precision = 3,
double epsilon = 0.0001);
529 TraceBuilder&
multi(std::string name, std::vector<Component> components,
530 int precision = 3,
double epsilon = 0.0001);
536 std::vector<GeometryProperty> props
541 int precision = 2,
double epsilon = 0.1);
553 std::vector<ScrollProperty> props = {
557 int precision = 2,
double epsilon = 0.1);
575 std::shared_ptr<Spec> spec_;
636 std::
string metric_name,
637 std::vector<
std::pair<
std::
string,
double>> components,
654 Coordinator(const Coordinator&) = delete;
655 Coordinator& operator=(const Coordinator&) = delete;
657 void on_tick(
float dt);
662 std::unique_ptr<State> state_;
Definition frame_clock.hpp:14
Process-wide singleton that owns one FrameClock subscription, holds the active trace set,...
Definition motion.hpp:585
void dispatch_input_event(SampleEvent e)
Stamp e with the bound FrameClock's t/frame and dispatch it to every installed sink.
bool firehose() const noexcept
void publish_internal(std::string view_name, std::string metric_name, std::vector< std::pair< std::string, double > > components, PublishOptions opts)
Called by publish_value / publish_components.
TraceBuilder trace(std::string view_name, TraceOptions opts={})
Start building a trace.
void remove_sink(int sink_id)
static Coordinator & instance()
Process-wide instance. Bound to a FrameClock via bind().
void detach(int trace_id)
Remove a trace by id (called automatically by TraceHandle destruction).
Provenance current_ambient_provenance_internal() const
std::size_t active_trace_count() const noexcept
bool is_bound() const noexcept
bool tracing_enabled() const noexcept
std::size_t emitted_event_count() const noexcept
Cumulative count of SampleEvents dispatched since reset(). For tests.
int add_sink(Sink sink)
Add a sink and return its id (for later removal).
void set_firehose(bool on)
Filter-scope firehose toggle.
void unbind()
Drop the FrameClock subscription. No effect if not bound.
int install_default_log_sink()
Convenience: add the default make_log_sink() and return its id.
void set_tracing_enabled(bool on)
Global tracing toggle. Off by default. When off, on_tick is a no-op.
void reset()
Reset all state (binding, sinks, traces, counters). For tests.
friend class TraceBuilder
Definition motion.hpp:659
void set_ambient_provenance_internal(Provenance p)
Called by set_ambient_provenance / clear_ambient_provenance.
void bind(pulp::view::FrameClock &clock)
Bind the coordinator's single tick subscription to a FrameClock.
Definition motion.hpp:518
std::pair< std::string, ValueSampler > Component
Definition motion.hpp:521
TraceBuilder & multi(std::string name, std::vector< Component > components, int precision=3, double epsilon=0.0001)
Multi-component metric (e.g., a 2D point).
TraceHandle attach()
Register the trace with the coordinator and return an owning handle.
std::function< double()> ValueSampler
Definition motion.hpp:520
TraceBuilder & value(std::string name, ValueSampler sampler, int precision=3, double epsilon=0.0001)
Single-scalar metric. The sampler is invoked once per sampler tick.
friend class Coordinator
Definition motion.hpp:572
TraceBuilder & geometry(std::string name, pulp::view::View &target, std::vector< GeometryProperty > props={GeometryProperty::MinX, GeometryProperty::MinY, GeometryProperty::Width, GeometryProperty::Height}, GeometrySpace space=GeometrySpace::Window, GeometrySource source=GeometrySource::Layout, int precision=2, double epsilon=0.1)
Geometry metric over a target view.
TraceBuilder & with_provenance(Provenance p)
Attach a provenance envelope to the trace.
TraceBuilder & scroll_geometry(std::string name, pulp::view::ScrollView &target, std::vector< ScrollProperty > props={ ScrollProperty::ContentOffsetX, ScrollProperty::ContentOffsetY, ScrollProperty::VisibleRectMinY, ScrollProperty::VisibleRectHeight, }, int precision=2, double epsilon=0.1)
Scroll-geometry metric over a ScrollView.
Definition motion.hpp:491
bool is_attached() const noexcept
Definition motion.hpp:503
void detach()
Remove the trace from its coordinator. Idempotent.
int id() const noexcept
Definition motion.hpp:504
TraceHandle() noexcept=default
friend class TraceBuilder
Definition motion.hpp:508
friend class Coordinator
Definition motion.hpp:507
Definition child_process_manager.hpp:18
GeometrySource
Definition motion.hpp:30
@ Presentation
After paint_all() composition; currently falls back to Layout.
Definition motion.hpp:32
@ Layout
Yoga-computed bounds, ignoring paint-time transforms.
Definition motion.hpp:31
Sink make_log_sink()
Sink that writes one log line per event via pulp::runtime::log_debug.
InputRecorder make_input_recorder(std::string path)
Install a fixture sink at path and enable simulate_* recording.
Sink make_fixture_sink(std::string path)
Sink that appends each SampleEvent as a JSONL line to path.
GeometryProperty
Definition motion.hpp:42
@ MaxY
Definition motion.hpp:43
@ Width
Definition motion.hpp:45
@ MinX
Definition motion.hpp:43
@ MinY
Definition motion.hpp:43
@ MidY
Definition motion.hpp:44
@ MaxX
Definition motion.hpp:43
@ Height
Definition motion.hpp:45
@ MidX
Definition motion.hpp:44
double start_delay_seconds(const std::vector< ScalarSample > &samples, double epsilon=1e-6)
Time from t0 to the first change above epsilon.
constexpr int kFixtureSchemaVersion
Definition motion.hpp:249
int replay_inputs(const std::string &path, View &root_view, FrameClock &frame_clock)
Read a fixture file, find each Input event, resolve view_id from root_view for diagnostics,...
Provenance current_ambient_provenance()
void publish_components(std::string view_name, std::string metric_name, std::vector< std::pair< std::string, double > > components, PublishOptions opts={})
Multi-component publish (e.g., a 2D point or a geometry rect).
void set_ambient_provenance(Provenance p)
int replay_fixture(const std::string &path, const Sink &sink)
Read a fixture file from disk and dispatch each event to sink.
std::vector< ScalarSample > extract_scalar(const std::vector< SampleEvent > &events, std::string_view view_name, std::string_view metric_name, std::string_view component_name="value")
void publish_value(std::string view_name, std::string metric_name, double value, PublishOptions opts={})
Single-component publish.
double final_value(const std::vector< ScalarSample > &samples)
Returns the last sample's value, or NaN when empty.
constexpr int kInvalidFixtureSchemaVersion
Sentinel for a default-constructed / unrecognised fixture header.
Definition motion.hpp:254
double overshoot(const std::vector< ScalarSample > &samples, double epsilon=1e-6)
Overshoot relative to the final value: max excursion beyond the final value's direction from the firs...
std::string format_line(const SampleEvent &e)
Render the canonical [PulpMotion][view][metric] ... line for a sample event.
Sink make_buffer_sink(std::vector< SampleEvent > *buffer)
Sink that appends events to a caller-owned buffer.
FixtureDiff assert_matches(const std::vector< SampleEvent > &golden, const std::vector< SampleEvent > &captured, FixtureMatchOptions opts={})
double frame_jitter_seconds(const std::vector< ScalarSample > &samples)
Standard deviation of inter-sample intervals — proxy for frame-pacing jitter when the sampler is run ...
GeometrySpace
Definition motion.hpp:35
@ Screen
Currently same as ViewGlobal; reserved for screen offset.
Definition motion.hpp:39
@ ViewLocal
Origin at the target view's top-left, in its own frame.
Definition motion.hpp:36
@ ViewGlobal
Root-view coordinate space.
Definition motion.hpp:37
@ Window
Currently same as ViewGlobal; reserved for window origin.
Definition motion.hpp:38
bool input_recording_enabled() noexcept
True while at least one InputRecorder is alive.
void clear_ambient_provenance()
std::vector< SampleEvent > load_fixture(const std::string &path)
Load a fixture file into memory.
FixtureHeader load_fixture_header(const std::string &path)
Load a fixture's header (schema version + policy + duration_scale).
bool is_monotonic(const std::vector< ScalarSample > &samples, double epsilon=1e-6)
Strict monotonicity check with epsilon.
ScrollProperty
Definition motion.hpp:56
@ VisibleRectHeight
Definition motion.hpp:58
@ VisibleRectMinX
Definition motion.hpp:58
@ InsetLeft
Definition motion.hpp:60
@ VisibleRectMinY
Definition motion.hpp:58
@ ContentSizeWidth
Definition motion.hpp:59
@ ContentOffsetY
Definition motion.hpp:57
@ ContentSizeHeight
Definition motion.hpp:59
@ InsetRight
Definition motion.hpp:60
@ ContentOffsetX
Definition motion.hpp:57
@ ScrollableMaxY
Definition motion.hpp:61
@ ScrollableMaxX
Definition motion.hpp:61
@ VisibleRectWidth
Definition motion.hpp:58
@ InsetTop
Definition motion.hpp:60
@ InsetBottom
Definition motion.hpp:60
std::function< void(const SampleEvent &)> Sink
Definition motion.hpp:389
double local_step_outlier_ratio(const std::vector< ScalarSample > &samples, std::size_t window_radius=3, double epsilon=1e-9)
Local-step outlier ratio.
void record_simulated_input(const std::string &input_kind, const std::string &view_id, std::vector< std::pair< std::string, double > > coords)
Process-wide entry point called by View::simulate_* when input recording is active.
double settling_time_seconds(const std::vector< ScalarSample > &samples, double epsilon=1e-6)
Time from first change above epsilon to last change above epsilon.
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
@ path
Definition anchor_strategy.hpp:42
@ value
the widget's primary value (Knob, Fader, RangeSlider, Toggle, ProgressBar)
Definition binding_diagnostics.hpp:19
@ p
Definition input_events.hpp:40
@ e
Definition input_events.hpp:39
@ space
Definition input_events.hpp:58
@ on
Definition accessibility.hpp:132
Definition motion.hpp:282
std::string metric_name
Definition motion.hpp:286
double observed
Definition motion.hpp:289
std::string detail
Definition motion.hpp:288
double expected
Definition motion.hpp:290
std::string component_name
Definition motion.hpp:287
std::string view_name
Definition motion.hpp:285
std::string kind
"missing-event", "extra-event", "component-drift", "timing-drift"
Definition motion.hpp:283
Comparison result from assert_matches.
Definition motion.hpp:281
bool matches() const noexcept
Definition motion.hpp:293
std::vector< Item > differences
Definition motion.hpp:292
Definition motion.hpp:296
double timing_epsilon_seconds
Definition motion.hpp:298
bool require_same_event_count
Definition motion.hpp:299
bool require_matching_policy
When true (default), assert_matches_headers will flag a "policy-mismatch" diff item if the two fixtur...
Definition motion.hpp:305
double component_epsilon
Definition motion.hpp:297
double duration_scale_epsilon
Definition motion.hpp:306
std::string source_file
Optional, e.g. FILE at attach site.
Definition motion.hpp:82
std::string source_kind
"tween" | "css-transition" | "animator-set" | "rAF" | "design-import" | "user" | "publish"
Definition motion.hpp:78
int source_line
Optional, e.g. LINE at attach site.
Definition motion.hpp:83
bool is_set() const noexcept
Definition motion.hpp:85
std::string source_id
Free-form id, e.g.
Definition motion.hpp:80
Definition motion.hpp:181
double epsilon
Definition motion.hpp:183
Provenance provenance
Optional Provenance envelope.
Definition motion.hpp:188
int precision
Definition motion.hpp:182
std::string view_id
Definition motion.hpp:154
double t_seconds
Monotonic FrameClock::time().
Definition motion.hpp:117
std::string view_name
Definition motion.hpp:115
int metric_id
Definition motion.hpp:127
int burst_id
Definition motion.hpp:128
int trace_id
Definition motion.hpp:126
int precision
Definition motion.hpp:119
std::vector< std::pair< std::string, double > > components
Sorted by name.
Definition motion.hpp:132
Kind
Definition motion.hpp:99
@ Input
Recorded View::simulate_* interaction.
Definition motion.hpp:107
@ End
Burst closed (value stabilized). Carries deltas.
Definition motion.hpp:106
@ TraceStarted
Emitted once per trace registration.
Definition motion.hpp:100
@ Baseline
First sample of a metric.
Definition motion.hpp:102
@ Start
Burst opened (value drifted off baseline / last stable).
Definition motion.hpp:104
@ Sample
Value sample within a change burst.
Definition motion.hpp:103
Provenance provenance
Populated on TraceStarted; empty otherwise.
Definition motion.hpp:130
std::string input_kind
Definition motion.hpp:153
std::string metric_name
Definition motion.hpp:116
Kind kind
Definition motion.hpp:114
std::uint64_t frame
Monotonic FrameClock::frame().
Definition motion.hpp:118
std::vector< std::pair< std::string, double > > deltas
End events only.
Definition motion.hpp:133
Flatten a fixture's events into a (time, value) series for one (view, metric, component) triple.
Definition motion.hpp:335
double value
Definition motion.hpp:335
double t
Definition motion.hpp:335
int fps
Definition motion.hpp:67