-
Notifications
You must be signed in to change notification settings - Fork 0
Tick Loop
Raul Montoya Cardenas edited this page Jul 29, 2026
·
2 revisions

Generated with Grok Build: Grok 4.5 · xAI Imagine (/imagine)
Core orchestration in src/daemon.rs (run_tick + BrainstemDaemon::run).
tick_duration = 1e9 ns / tick_rate_hz
MissedTickBehavior::Skip
Invalid tick_rate_hz (0 or > 1_000_000) aborts run() with an error.
-
Ingress —
source.next_ingress()-
Ok(Some(packet))→ use packet -
Ok(None)→ empty stimuli packet, still step -
Err→ warn and return early (no step/emit this tick)
-
-
Decode —
decode_inputs(packet, &mut stimuli)- Copy min(len) floats into channel buffer; zero-fill remainder
- Modulators: if
Someandlen >= 4, map toNeuroModulators { dopamine, cortisol, acetylcholine, tempo, aux_dopamine: 0 } - Else
NeuroModulators::default()
-
Network —
network.step(stimuli, &modulators)- On error: log and return early
-
Encode spikes — map neuron indices →
SpikeEvent { channel: u16, time, strength: 1.0 }- Shared wall-clock millis truncated into
u32fortime - Drop IDs that do not fit
u16(warn)
- Shared wall-clock millis truncated into
-
Emit —
sink.emit(spike_buf, now)even if empty (stable per-tick cadence for consumers/tests)
On Ctrl+C:
- Break loop
backend.sink.flush()backend.source.shutdown()- Return
Ok(())
run_tick_for_test is pub(crate) under #[cfg(test)] so unit tests drive one tick without exposing run_tick publicly.
Last updated: July 28, 2026
Updated by: Grok Build: Grok 4.5
Package tip reference: 8176c58 (main)