Cortex: Autonomic Peripheral Layer
The autonomic nervous system for embodied agents. Peripheral communication, routine storage, and reactive neural processing on-device.
Status: Draft. Cortex is in the design phase. This page describes the target architecture. Foundation components (FANN integration, Animus node system) are in progress.
What Cortex Is
Cortex is the autonomic nervous system for embodied agents. It runs on-device, handles low-level peripheral communication, stores conditional action routines, and runs Autonomic Neural Networks (ANNs) for reactive perception. An Animus agent may control one or more bodies, each running its own Cortex instance, exposed as capabilities through the Animus node system.
Key insight: Agents that interact with the physical world need an abstraction boundary between "what I want to do" and "how the hardware does it." Directly controlling actuators frame-by-frame from the deliberative loop is too slow, too noisy, and wastes the agent's reasoning capacity on problems that don't require it.
Three-Layer Control Model
Cortex enables a three-layer architecture that separates concerns by timescale:
- Deliberative Layer (Animus agent)
- High-level intent: "go to the kitchen." Seconds per decision. The agent reasons about goals and strategy.
- Routine Layer (Cortex Routines)
- Stored sequences of conditional actions: "navigate hallway." Composed of peripheral actions, conditionals, loops, and sub-routines. Milliseconds per step.
- Reactive Layer (Autonomic NNs)
- FANN-based perception: "obstacle at 2m." Microseconds, no deliberation. Raw sensor data in, interpreted output out.
The agent doesn't see individual sensor frames. It sees the output of ANNs. It doesn't control individual actuators. It issues intents that get decomposed through routines into hardware commands.
Multi-Body Model
An Animus agent may control one or more bodies. Each body runs its own Cortex instance on local hardware, directly connected to its peripherals. The agent discovers available bodies and their capabilities through the Animus node system.
Cortex capabilities — peripherals, routines, ANNs — are exposed as node capabilities when the device registers as an Animus node. The agent doesn't need to know the hardware details. It asks "which of my bodies can navigate?" and gets a capability answer, not a hardware inventory.
Interface
Peripheral Discovery
List all connected peripherals, their type, capabilities, and available actions. Hot-plug: peripherals can appear and disappear at runtime. Each peripheral declares type, actions, parameter schemas, and streaming vs. discrete mode.
Peripheral Actions
Invoke a single action on a peripheral. Synchronous or asynchronous depending on action type. Actions are defined by the peripheral driver, not hardcoded — Cortex doesn't know about cameras, it knows about peripherals that provide frames.
Routine Management
Routines are composed action sequences that can be invoked as units. A RoutineStep is either a peripheral action, a conditional branch (read sensor → decide path), a loop (repeat until condition), or a sub-routine invocation. Routines can reference FANN networks for perception-driven branching — enabling closed-loop behaviors like "walk forward until obstacle detected, then stop" that run entirely below the deliberative layer.
ANN Management
Autonomic Neural Networks run on-device for low-latency reactive processing. Key operations:
- Train — refine an existing ANN or create new (same continuous refinement model as the FANN Intuition Module)
- Invoke — query a trained network directly for classification
- Attach — bind an ANN to a peripheral's data stream so the network processes raw input at hardware speed
- Read — get the interpreted output ("path clear", "obstacle left"), not raw data
- Detach — unbind an ANN from a peripheral stream
Safety Boundaries
Cortex enforces hard limits independent of agent control:
- Maximum velocity, force, and range — configurable per peripheral
- Kill conditions that don't route through the deliberative loop
- Hardware watchdog — if no heartbeat from Animus for N seconds, peripheral enters safe state
- Cortex is autonomous — if connection to Animus drops, Cortex continues executing the current routine until completion or a safety boundary is hit
Design Principles
- Peripheral drivers are plugins. Each peripheral type (camera, motor controller, actuator, sensor array) has a driver that translates between Cortex's generic interface and hardware-specific protocols.
- Asynchronous event model. Long-running routines and peripheral streams produce events, not blocking calls. The agent issues an intent, continues with other work, and receives completion or status events.
- Capability exposure, not hardware inventory. The agent sees a unified view across all its bodies through node capabilities, not raw hardware details.
- Routines reference ANNs. Closed-loop reactive behaviors run below the deliberative layer, freeing the agent for higher-level decisions.
Relationship to Other Modules
- FANN Intuition Module — Intuitions are agent-level pattern compression for deliberative reasoning. Cortex ANNs are device-level reactive perception. Same FANN infrastructure, different execution context and timescale.
- Perception Tool — Perception uses FANN networks for aesthetic experience (surprise deltas from learned expectations). Cortex ANNs use FANN for reactive sensor processing. Same substrate, different purpose.
- Animus node system — Cortex instances register as Animus nodes. Capability exposure enables multi-body agent control through the existing (or extended) node protocol.
Scope
v1 (MVP): Peripheral driver interface + plugin system, action invocation (sync + async), routine storage and execution, FANN perception binding (at least one reference implementation), safety boundaries (hard limits + watchdog).
Out of scope for v1: Multi-agent peripheral sharing, peripheral simulator, complex multi-modal sensor fusion, visual programming / routine editor UI.