pub struct StimulusBatch {
pub session_id: Option<String>,
pub batch_id: u64,
pub timestamp: u64,
pub values: Vec<f32>,
pub valid_mask: Option<Vec<bool>>,
pub metadata: Option<BatchMetadata>,
}Expand description
Canonical wire batch of continuous, domain-neutral runtime stimulus values.
This is the typed replacement for consumers’ ad-hoc stimulus payloads,
such as a flat {"type":"Stimuli","values":[...]} UDP JSON message or
a private ingress packet struct. corpus-ipc owns this schema; consumers
should decode/encode
through IpcMessage::Stimuli instead of a private struct or raw
serde_json::Value field indexing.
§Channel width
values.len() is the channel count. It is not fixed by this crate —
do not encode any particular network’s input width (such as one model’s
current axon count) into this type. Consumers determine width at runtime
from the batch itself.
§Invalid / missing channel semantics
valid_mask, when Some, must be the same length as values.
valid_mask[i] == false means channel i has no valid reading this tick;
the corresponding values[i] is a placeholder (0.0 by convention) and
must not be interpreted as a real zero-valued reading. When
valid_mask is None, every entry in values is valid.
This is a deliberate improvement over ad-hoc formats that silently coerce
missing or non-numeric channels to 0.0
with no way to distinguish “sensor read zero” from “no data this tick.”
Fields are public (matching this crate’s other wire batches, e.g.
SpikeBatch) for direct Rust construction, but deserialization
enforces the valid_mask-length invariant: a JSON/wire payload with a
valid_mask whose length differs from values.len() fails to
deserialize (via StimulusBatch::validate through a TryFrom shadow
type), rather than silently producing an inconsistent instance. Call
Validate::validate explicitly after constructing one directly in
Rust (which bypasses deserialization) to get the same check.
Fields§
§session_id: Option<String>Optional session ID for concurrent experiment isolation.
batch_id: u64Unique batch identifier for correlation.
timestamp: u64Timestamp in nanoseconds (UTC or relative).
values: Vec<f32>Continuous stimulus values. Length is the channel count; not fixed by this crate.
valid_mask: Option<Vec<bool>>Optional per-channel validity mask, same length as values when present.
false marks a channel as invalid/missing for this tick (see type docs).
metadata: Option<BatchMetadata>Optional batch-level metadata.
Trait Implementations§
Source§impl Clone for StimulusBatch
impl Clone for StimulusBatch
Source§impl Debug for StimulusBatch
impl Debug for StimulusBatch
Source§impl Default for StimulusBatch
impl Default for StimulusBatch
Source§impl<'de> Deserialize<'de> for StimulusBatch
impl<'de> Deserialize<'de> for StimulusBatch
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for StimulusBatch
impl PartialEq for StimulusBatch
Source§impl Serialize for StimulusBatch
impl Serialize for StimulusBatch
impl StructuralPartialEq for StimulusBatch
Source§impl Validate for StimulusBatch
impl Validate for StimulusBatch
Source§fn validate_with(&self, limits: ProtocolLimits) -> Result<(), ValidationError>
fn validate_with(&self, limits: ProtocolLimits) -> Result<(), ValidationError>
Source§fn validate(&self) -> Result<(), ValidationError>
fn validate(&self) -> Result<(), ValidationError>
ProtocolLimits::DEFAULT.