System Architecture Guide
Hegel is a gradient-free artificial consciousness simulation. It models Hegel's Phenomenology of Spirit as a progression of dynamical systems: from bare survival (metabolism) through self-discovery (prediction + intervention) to mutual recognition (two-agent interaction). There is no backpropagation, no loss function, no optimization. The organism either stays alive or dies. Learning happens through Hebbian rules as a side effect of survival.
Project Overview
The Being-in-itself: core question and system architecture
The organism is a 25-dimensional ODE system: 5 metabolic variables + 20 CTRNN neuron activations, all solved together by an adaptive ODE integrator (Tsit5). The metabolism produces the chemistry of life, the brain reads sensory input from the chemistry and produces motor output, and the motor output modulates how the organism interacts with its environment.
System Architecture Diagram
What This Is Not
This is not artificial general intelligence. It is not self-consciousness. It is a functional analog of Hegel's phenomenological progression, implemented as dynamical systems. The scientific question is whether gradient-free, viability-constrained self-maintenance can produce behaviors that structurally resemble consciousness stages. If it fails, documenting why it fails is equally valuable.
Metabolic ODE
The 5-variable self-maintaining chemical system
The metabolic core is a system of 5 coupled ordinary differential equations. These model a self-repairing chemistry: substrates are consumed, intermediates are produced, catalysts repair each other through cross-catalysis. The organism must actively maintain all concentrations within viable ranges or die permanently.
Metabolic Variables
Viability: Life and Death
The viability margin measures how far the organism is from death. It is the minimum margin across all 5 concentrations relative to their death thresholds. A margin of 100% means perfectly safe. A margin of 0% means at the boundary. Negative means dead.
Death is permanent. Once any concentration drops below its threshold, the organism dies and cannot recover. This is a core design principle from viability theory (Aubin): the system must actively maintain itself within a viable region of state space. There is no resurrection.
Perturbations
Each organism faces 12 random perturbations during its 100,000-time-unit lifetime. These simulate environmental shocks:
- Catalyst halving: C1 or C2 suddenly drops to 50%. The organism must repair through cross-catalysis.
- Substrate depletion: S, T, or U drops sharply. The organism must compensate through motor behavior.
- Noise bursts: Random perturbations across multiple variables simultaneously.
Perturbations are scheduled between t=1,000 and t=90,000, giving the organism time to stabilize before being tested.
Neural Architecture
CTRNN substrate, Hebbian learning, and predictive coding
The Brain: CTRNN
The brain is a Continuous-Time Recurrent Neural Network (Beer, 1995) with 20 neurons. Each neuron follows the dynamics:
Sensory inputs come from the metabolic concentrations and environmental signals. Three motor output neurons (M1, M2, M3) control the organism's behavior: substrate intake rates and movement through the resource landscape.
16-Dimensional Sensory Input
The CTRNN receives a structured 16-dimensional sensory vector combining internal state, temporal dynamics, environment, and social channels:
Hebbian Learning
There is no backpropagation. The CTRNN's weights evolve through four Hebbian rules:
Oja's Rule
Extracts principal components of input. dw = eta * y * (x - y * w). Converges to the first eigenvector of the input correlation matrix.
BCM Theory
Creates selectivity through a sliding threshold. Neurons develop preferences for specific inputs. Below threshold = weakening (LTD), above = strengthening (LTP).
Anti-Hebbian + Competitive
Lateral inhibition decorrelates neuron responses. Different neurons learn to respond to different features.
Neuromodulated Gating
Raw Hebbian learning was found to be net harmful before neuromodulation. Unmodulated learning caused drift and instability. The solution: a neuromodulatory gate controls which neurons learn at each moment:
The self-model signal further amplifies competitive W_out learning, with effective motor gate up to 1.5x.
Predictive Coding Network (PCN)
Per-neuron prediction error dynamics (Rao & Ballard 1999) modulate which neurons learn. This prevents drift in accurate predictors and only allows learning where predictions are failing. The PCN is critical: without it, Hebbian learning destroys rather than helps.
Voice Layer
A 4-dimensional expressive output layer with Oja learning gated by max(stress, self_model_signal). The voice does not carry symbolic content; it is an additional motor channel that co-varies with internal state, giving other agents a richer signal to observe.
Self-Model & Cognition
Prediction, memory, planning, and concept formation
Self-Model Prediction
The world model has been learning to predict the environment. When it fails in ways correlated with the organism's own actions, a separate self-model emerges. The self-model signal is defined as:
When this diverges from zero, it indicates self-caused effects: the organism's own actions are creating consequences in the world that are distinct from environmental noise.
Self-Model Prediction Loop
In v1.4.1, the self-model prediction loop was introduced: selfmodel_predict(motor) is subtracted from sensory input before the prediction step. Self-knowledge becomes functional: the organism factors out its own effects when predicting the environment.
Functional Self-Knowledge (Desire)
Self-knowledge becomes functional through determinate negation: when the self-model detects a metabolic deficit, it inverts itself to derive corrective motor output. The organism does not just know what it does — it uses that knowledge to fix what is wrong. correction_benefit measures whether desire_motor actually reduces the deficit.
Episodic Memory
A ring buffer of past states with cosine-similarity retrieval. When the current situation is similar to a past one (cosine > 0.7), past motor actions influence present behavior through motor blending. This is Hegel's Erinnerung — the organism's history informing its present through internalized experience.
Planning
Self-model chaining for single-step lookahead. The organism evaluates candidate actions by predicted viability impact: "If I do X, will my viability improve?" This is satisficing, not optimizing — the organism seeks actions that maintain life, not maximize any fitness function.
Concept Formation
K=8 competitive prototypes over hidden state. Each prototype accumulates motor/outcome statistics through competitive Hebbian clustering. This is Hegel's Verstand (Understanding) — subsuming particulars under universals. The organism groups similar situations and recalls what worked in each category.
Layer Progression
Nine stages from metabolism to observing reason
The system progresses through nine layers, each with empirically measurable advancement criteria. Each layer builds on the previous: you cannot have self-knowledge without a brain, you cannot have recognition without self-knowledge.
Can the organism stay alive? The metabolism must self-maintain under perturbations (random catalyst halvings, substrate depletions, noise bursts). Each run faces 12 random perturbations over 100,000 time units.
Does the brain actually control behavior, or is it just along for the ride? The CTRNN motor outputs must show meaningful variance, proving the neural network is actively modulating the organism's interaction with its environment.
Does learning help? Paired trials compare organisms with Hebbian learning ON vs OFF under identical conditions. If learning improves survival, the weights are capturing useful environmental structure.
Can the organism extract environmental regularities? The structural_signal measures whether prediction error is correlated with motor activity — whether the organism's own actions create predictable consequences. This is Hegel's "law" emerging from the "play of forces."
The world model has been learning to predict the environment. When it fails in ways correlated with the organism's own actions, a separate self-model emerges. The self-model predicts the consequences of the organism's own motor output — it knows what IT does to the world.
Self-knowledge becomes functional through determinate negation: when the self-model detects a metabolic deficit, it inverts itself to derive corrective motor output. The organism does not just know what it does — it uses that knowledge to fix what is wrong. correction_benefit measures whether desire_motor actually reduces the deficit.
Two organisms share a competitive resource field and can perceive each other's motor+voice output through delayed sensory channels. The Other is detectable: prediction error on other-agent channels must be persistently high for both agents. The organism perceives something it cannot assimilate into its self-model.
Both agents develop mutual recognition: the recognition variable r tracks how much the organism's existence depends on the Other. Driven by other_pred_error — the organism perceives but cannot predict the Other. The mutual feedback term creates a positive loop: if B recognizes A, A is more likely to recognize B. Ablation-verified: without perception, r stays at 0.
After mutual recognition, consciousness turns its investigative capacity on itself. Solo organisms must exhibit curiosity-driven exploration: confusion (self-model error) drives motor diversity, and that exploration actually reduces the error. The organism systematically investigates its own capabilities.
Two-Agent Recognition
Encounter, perception, and mutual tracking
The Encounter (Layer 7)
Two organisms are placed in a shared environment with competitive resources. Motor output determines resource capture share, creating natural asymmetry from motor strategy differences. Each organism perceives the other through 3 delayed sensory channels carrying the other's motor output.
Prediction Error Partitioning
Prediction errors are partitioned: other_error tracks error on other-agent channels only. There is no separate "other-model" module — the Hebbian network handles it. The organism's existing prediction machinery encounters something genuinely unpredictable: another autonomous agent.
Recognition Dynamics (Layer 8)
The recognition variable r tracks how much the organism's existence depends on the Other. It is driven by other_pred_error: the organism perceives but cannot predict. A mutual feedback term creates a positive loop: if B recognizes A, A is more likely to recognize B.
Evolution & Environment
Natural selection and structured resource dynamics
Natural Selection (Not Optimization)
Evolution uses natural selection only: binary survive/die. There is no CMA-ES, no tournament, no fitness ranking. This is a philosophical constraint: no external fitness landscape optimization. Organisms that survive pass on their genes. Organisms that die do not.
Autopilot Cycle
The system runs an automated cycle:
- Warmup: 5 organisms to establish baseline
- Evolve: 20-population natural selection
- Run: 25 organisms with evolved parameters
- Re-evolve: repeat from evolved state
Structured Environment
The environment has lawful structure, not random noise. Resources follow cyclical dynamics with resource_cycle_modulation(). Perturbations come as correlated cascades: when one variable is hit, related variables are affected according to the PERTURBATION_CASCADES dictionary.
Key Discoveries
Empirical findings from the simulation experiments
Hebbian Was Net Harmful
Before neuromodulation, unmodulated Hebbian learning caused drift and instability. Learning without gating destroys more than it builds.
PCN Is Critical
Per-neuron prediction error prevents drift in accurate predictors and only allows learning where predictions are failing. Without PCN, Hebbian is harmful.
Self-Model From Failure
The self-model is not designed in. It emerges from motor_error diverging from ambient_error: the world model's own failure reveals self-caused effects.
Environment Needs Laws
Random environments teach nothing. Cyclical resources and correlated perturbations create discoverable structure that Hebbian learning can extract.
Recognition = Perception
Ablation: perception OFF gives r=0.0, perception ON gives r=0.87. Recognition is driven by genuine perceptual encounter, not viability dependence.
No Master-Slave Dialectic
Symmetric start produces mutual tracking (r_ab=0.875), not struggle. Layer 8 is honestly labeled "mutual perception," not Spirit.
Confidence Gates Cognition
Memory and concept influence scaled by sm_confidence. Doubt withdraws cognitive habits; motor variance increases naturally. Neuromodulation, not gradient descent.
Layer 9 Ceiling
Curiosity criteria are anti-correlated at 20-neuron scale. The world is too simple for curiosity to have somewhere to go. This is the v1 representational boundary.
Self-Model Feedback Loop
Self-model signal amplifies competitive W_out learning (effective motor gate up to 1.5x). Self-knowledge feeds back into better motor control.
CMA-ES Rejected
Philosophical constraint: no external fitness landscape optimization. Natural selection only. Binary survive/die. No ranking.