DEV Community

yuer
yuer

Posted on

Time Is Not an Index: Time Semantics and Windowed State for Quant Operators in Rust

Why Quant Operators Need Explicit Time Semantics

Document Statement

This is not a Rust tutorial.

This is the third article in the Rust Quant Operator series, focused on making time a first-class semantic constraint in operator execution.

All code exists solely to validate definitions.

Author

yuer
Author of EDCA OS
Proposer of controllable AI standards

Engineering repository:
https://github.com/yuer-dsl

Contact: lipxtk@gmail.com

  1. Why time cannot remain an index

Once operators carry state, a critical question arises:

In what order does state evolve?

Most implementations implicitly rely on:

row index

array position

arrival order

These break down under:

out-of-order data

replay and recomputation

mixed batch and step execution

multi-source alignment

Index is not time. It is only storage order.

  1. Core definition: Time Semantics

In this document, Time Semantics is defined as:

An external semantic coordinate that constrains operator execution order and state evolution.

Key properties:

time is not generated by operators

time is not equivalent to index

time governs when, not how, computation occurs

  1. TimeIndex: minimal time abstraction

Rather than covering full event-time complexity, this document introduces a minimal abstraction:

pub trait TimeIndex: Ord + Clone {}

A TimeIndex is:

comparable

externally provided

not required to be continuous

  1. Binding state evolution to time

With time semantics introduced:

State evolution must be constrained by time ordering.

This makes time misordering an explicit, detectable issue.

  1. WindowedState model (v0.1)

A WindowedState is defined as:

A state entity responsible only for data within a bounded time interval.

Minimal interface:

pub trait WindowedState {
fn advance(&mut self, time: Time);
fn apply(&mut self, value: T);
fn reset(&mut self);
}

This document defines semantics, not strategies.

  1. Minimal time-aware example pub struct SimpleWindow { sum: f64, }

impl WindowedState for SimpleWindow {
fn advance(&mut self, _time: u64) {}

fn apply(&mut self, value: f64) {
    self.sum += value;
}

fn reset(&mut self) {
    self.sum = 0.0;
}
Enter fullscreen mode Exit fullscreen mode

}

This demonstrates that:

state updates depend on when execution occurs.

Top comments (0)