ldtc.runtime¶
Runtime: Fixed-interval scheduler.
Lightweight Δt-enforcing scheduler with jitter metrics and optional audit hooks, used by CLI runs and verification harness loops.
See Also
paper/main.tex — Methods: Measurement & Attestation Guardrails.
FixedScheduler
¶
Fixed-interval scheduler.
Enforces a constant sampling interval Δt and invokes a tick callback every period until stopped. Tracks jitter statistics and emits optional audit events through a user-provided hook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
float
|
Target period in seconds (Δt > 0). |
required |
tick_fn
|
Callable[[float], None]
|
Callback invoked each tick with the current |
required |
on_start
|
Optional[Callable[[], None]]
|
Optional hook executed before the worker thread begins. |
None
|
on_stop
|
Optional[Callable[[TickStats], None]]
|
Optional hook executed after stop; receives final |
None
|
audit_hook
|
Optional[Callable[[str, Dict], None]]
|
Optional callable taking |
None
|
Notes
- Jitter metrics are accessible on the
statsattribute. - Thread-safe updates to Δt can be made via
set_dt.
set_dt(new_dt)
¶
Change Δt at runtime.
Thread-safe update of the enforced period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_dt
|
float
|
New period in seconds (Δt > 0). |
required |
Returns:
| Type | Description |
|---|---|
float
|
The previous |
Runtime: Sliding windows and bootstrap indices.
Provides a fixed-length per-channel window and helper to generate circular block-bootstrap indices for CI estimation.
See Also
paper/main.tex — Methods: Measurement & Attestation Guardrails.
SlidingWindow
¶
Fixed-length, per-channel sliding window.
Maintains a deque per channel and exposes a dense matrix view when the window is full. Useful for streaming estimators that require a fixed-size time-by-signal buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capacity
|
int
|
Number of samples to retain per channel. |
required |
channel_order
|
List[str]
|
Ordered list of channel names used for matrix columns. |
required |
Notes
appendinserts a new sample dict; missing keys default to 0.0.get_matrixreturns a(T, N)numpy array inchannel_order.
block_bootstrap_indices(n, block, draws)
¶
Circular block-bootstrap indices for time series.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Length of the time series. |
required |
block
|
int
|
Block length for resampling. |
required |
draws
|
int
|
Number of bootstrap replicates to generate. |
required |
Returns:
| Type | Description |
|---|---|
List[ndarray]
|
List of index arrays (each of length |
List[ndarray]
|
samples with circular wrapping at boundaries. |