1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//! The nervous system (feature `nerve`): the layer between sensors, small fast models, the
//! large slow model (the brain, an LLM) and actuators.
//!
//! Not a server that loads models and answers requests, but what moves signals between
//! them: overwhelmingly light, so that the models are the only cost. Most signals must
//! never reach the brain. The mechanisms are a neuron's:
//!
//! - **Receptors** ([`receptor`]) extract a small [`Feature`] from the world and stamp an
//! [`Urgency`]; the raw input stays a lazily shared [`Payload`].
//! - **Habituation**, **thresholds** and **refractory periods** ([`Mechanisms`]) live in
//! every neuron's gate: a repeated feature attenuates before it propagates and recovers
//! with time; weak signals cost nothing; a neuron that just fired ignores the next burst.
//! - **Reflex pathways** are direct calls on the firing thread, with no queue and no
//! scheduler: microseconds from stimulus to effector.
//! - **Deliberative pathways** queue to a worker that sums a window of signals into one
//! firing of the [`Brain`] (temporal summation).
//! - **Timing selects the pathway**: a pathway whose measured p99 does not fit in the
//! signal's remaining deadline is not eligible; among the eligible, the heaviest weight
//! wins. No classifier decides "is this urgent".
//! - **Effectors** ([`effector`]) act on the world (a webhook, a command, a file, a
//! response) with their own local loops: retry, circuit breaker, rate limit, refractory
//! period. The brain is never in a retry loop.
//!
//! ```no_run
//! use std::time::Duration;
//! use furnace::nerve::{
//! effector, receptor, Fabric, Firing, FnNeuron, Habituation, Mechanisms, Summation,
//! };
//!
//! let mut fabric = Fabric::builder();
//! // POST /events: a 64-bit sketch of the body is the feature; repeats habituate here
//! let events = fabric.receptor(
//! receptor::Http::new("events", "/events"),
//! Mechanisms::NONE
//! .threshold(0.3)
//! .habituation(Habituation::new(Duration::from_secs(30))),
//! );
//! // A reflex: in process, no blocking; urgent lines become commands at once
//! let classify = fabric.neuron(
//! FnNeuron::reflex("classify", |signal, _cx| {
//! if signal.payload.as_text().is_some_and(|t| t.contains("ALERT")) {
//! Firing::one(signal.command("alert", serde_json::json!({"text": "alert"})))
//! } else {
//! Firing::one(signal)
//! }
//! }),
//! Mechanisms::NONE,
//! );
//! let alert = fabric.neuron(
//! effector::Effector::new(effector::Webhook::new("alert", "http://127.0.0.1:9000/hook")),
//! Mechanisms::NONE.refractory(Duration::from_millis(100)),
//! );
//! fabric.reflex(events, classify, 1.0);
//! fabric.reflex(classify, alert, 1.0);
//! // ... and a deliberative pathway from `classify` to a Brain, with Summation::default()
//! let _ = Summation::default();
//! let fabric = fabric.build();
//! # let _ = fabric;
//! ```
//!
//! See [docs/NERVE.md](https://github.com/Gilfeather/furnace/blob/main/docs/NERVE.md) for
//! the concepts, the demo and the measurements.
pub
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;