System Architecture Guide

The Phenomenology of Spirit

Hegel is a gradient-free artificial consciousness simulation. It models Hegel's Phenomenology of Spirit as a progression of dynamical systems: from bare survival (10-variable metabolism) through self-discovery (prediction + intervention) to mutual recognition (multi-agent interaction). There is no backpropagation, no loss function, no optimization. The organism either stays alive or dies. Learning happens through neuromodulated Hebbian rules as a side effect of survival.

science

Project Overview

The Being-in-itself: core question and system architecture

help Core Question
Can self-maintaining chemistry + local learning rules + survival pressure produce consciousness-like structures without any external optimization?

The organism is a 90-dimensional ODE system: 10 metabolic variables (S1-S5, C1-C3, P1-P2) + 80 CTRNN neuron activations, all solved together by an adaptive ODE integrator (Tsit5). The metabolism is a 20-reaction network organized in four layers of chemical structure. The brain reads 41-dimensional sensory input and produces 3-dimensional motor output + 4-dimensional voice output. Motor modulates how the organism interacts with a 300×300 toroidal environment.

System Architecture Diagram

Environment Resources input METABOLISM S1-S5 substrates C1-C3 catalysts P1-P2 intermediates 10 ODEs, 20 reactions sensory CTRNN BRAIN 80 neurons 41-dim input recurrent 80 coupled ODEs output MOTOR M1, M2, M3 movement + resource intake modulates intake rates HEBBIAN Oja + BCM weights VIABILITY BOUNDARY

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.

water_drop

Metabolic ODE

The 10-variable, 20-reaction self-maintaining chemical network

The metabolic core is a system of 10 coupled ordinary differential equations with 20 mass-action reactions organized in four layers of chemical structure: Surface (easily learnable), Intermediate (delayed effects), Catalyst repair (cross-catalytic), and Hidden regulator-modulated (not sensed by the organism). Five substrates (S1-S5) are consumed from the environment, three catalysts (C1-C3) enable reactions and repair each other, and two intermediates (P1-P2) mediate delayed effects.

Metabolic Variables

Variable Name Role Death if
S1-S5 Substrates Environmental input, consumed by reactions. Each has distinct input rate and decay. Motor output modulates intake via resource landscape. < 0.01
C1-C2 Catalysts Cross-repair enzymes. C2+S1 repairs C1, C1+S3 repairs C2. If both fall, the repair loop collapses and the organism dies permanently. < 0.001
C3 Autocatalyst Produced from P1 (saturating, Michaelis-Menten) + autocatalytic amplification (C3²/(2+C3)). Mediates intermediate reactions. < 0.001
P1-P2 Intermediates Produced by Layer 2 reactions, mediate delayed effects. P1 feeds C3 production. Toxic if accumulated above threshold. > 50.0
auto_stories Hegelian Connection
The three catalysts (C1, C2, C3) form a cross-repair network: C2 repairs C1, C1 repairs C2, P1 produces C3, and C3 autocatalytically amplifies itself. This creates a self-maintaining loop: the system keeps itself alive through its own internal chemistry. Hidden regulators H1 (sinusoidal, period 50K) and H2 (bistable sigmoid) modulate reactions without being sensed — Hegel's appearance (Schein) giving way to essence (Wesen). In toxic zones, enzyme inhibition (Michaelis-Menten, Ki=0.15) suppresses repair reactions rather than draining metabolites. This is Hegel's "life" as self-relating negativity.

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 & Toxic Zones

Perturbations target all 10 metabolic variables (S1-S5, C1-C3, P1-P2). Hitting one variable triggers correlated cascades in 1-3 related variables with 300-500 time unit lags, creating causal laws for the organism to discover:

  • Catalyst knockout/halving: C1, C2, or C3 suddenly drops. The cross-repair network must compensate.
  • Substrate depletion: Any S drops sharply. Motor behavior must adjust resource gathering.
  • Noise bursts: Random perturbations across multiple variables simultaneously.
  • Input cutoff: Environmental input temporarily stops for a substrate.

At Layer 3+, toxic zones appear: 5-10 wastelands (radius 35-60) and corridors (radius 25-40) where food=0 and enzyme inhibition suppresses catalyst repair. A coupling ramp (coupling_alpha = clamp(t/60000, 0, 1)) gives organisms 60K time steps to learn avoidance before zones become fully lethal. Zones are determinate negation: they must be avoided, not survived through.

hub

Neural Architecture

CTRNN substrate, Hebbian learning, and predictive coding

The Brain: CTRNN

The brain is a Continuous-Time Recurrent Neural Network (Beer, 1995) with 80 neurons organized in multi-timescale groups (fast τ=1-20, mid τ=20-100, slow τ=100-500). Each neuron follows the dynamics:

tau_i * dy_i/dt = -y_i + sum_j(w_ij * sigma(y_j + theta_j)) + sensory_i

The brain receives 41-dimensional sensory input via W_in (41×80) and produces 3-dimensional motor output via W_out (3×80): M1 (intake modulation), M2 (balance/turning), M3 (efficiency). A separate 4-dimensional voice output via W_voice (4×20) provides an expressive social signal.

41-Dimensional Sensory Input

The CTRNN receives a structured 41-dimensional sensory vector combining internal state, temporal dynamics, environment, and social channels:

10 Metabolic state (S1-S5, C1-C3, P1-P2)
10 Affective derivatives: tanh((current - prev) * 10)
7 Environmental: R1-R5 resource fields + gradient (forward, lateral)
14 Other-agent: 2 nearest × (3 motor + 4 voice) = 0 in solo
info Design Note
Other-agent channels (14-dim) are 0 in solo mode. Oja decay ensures weights go to 0 when there is no signal, preventing spurious learning. The affective derivatives use tanh(x * 10) scaling for good sensitivity without saturation. 5-step ring buffer delay on other-agent channels makes the signal temporally distinct for Hebbian decorrelation.

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.

auto_stories Viability Constraint
Learning ONLY happens while the organism is alive. Death stops all weight updates. This is the viability constraint on cognition: you can only learn if you survive.

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:

gate = max(stress, surprise) * per_neuron_PCN

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.

psychology

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:

self_model_signal = motor_error - ambient_error

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.

auto_stories Self-Certainty (Phenomenology, section 163-165)
The self-model does not emerge from external labeling. It emerges from the world model's own failure. Motor error diverging from ambient error is the organism discovering that some of what happens is its own doing. This is Hegel's "self-certainty" arising from the negation of naive perception.

Self-Model Architecture

The self-model uses random projection (64×83 fixed matrix) to compress the 80-neuron + 3-motor state into a 64-dim representation, then LMS learning (W_read: 41×64) to predict the next sensory input. The self-model prediction is subtracted from sensory input before the world-model prediction step — self-knowledge becomes functional: the organism factors out its own effects when predicting the environment.

A structural signal detects self-causation via correlation: structural_signal = max(corr(residual, motor_dev), max_i(|corr(residual_i, motor_dev)|)) where residual = error not explained by environment (EMA α=0.005) and motor_dev = motor deviation from its own pattern (EMA α=0.02).

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 128-slot ring buffer storing sensory (41-dim), motor (3-dim), outcome (10-dim), and time for each episode. Cosine-similarity retrieval: when current situation matches a past one (cosine > 0.5 retrieval, > 0.7 influence threshold), past motor actions influence present behavior through motor blending (strength 0.15 × sm_confidence). 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.

info Confidence Gating (v1.6.2)
Memory and concept influence are scaled by self-model confidence: sm_confidence = clamp(1 - pred_error/5, 0, 1). When the self-model doubts itself, cognitive habits withdraw and motor variance increases naturally. This is not gradient-based — it is neuromodulation.
layers

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.

1 Metabolic Viability Sense-Certainty

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.

check_circle 7/10 recent runs surviving with average survival > 80,000 time units
2 Sensorimotor Coupling Perception

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.

check_circle Average motor output variance > 0.01 across 5 recent runs
3 Hebbian Adaptation Force & Understanding

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.

check_circle Learning-ON beats Learning-OFF in 2/3 recent paired comparisons
4 Understanding Laws & Force (section 132-145)

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."

check_circle structural_signal > 0.1 in 3/5 recent runs
5 Self-Model Self-Certainty (section 163-165)

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.

check_circle predictive_accuracy > 0.3 AND self-model active in 3/5 runs
6 Functional Self-Knowledge Desire (section 167-170)

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.

check_circle correction_benefit > 0.05 AND ambient_error persists in 3/5 runs
7 Two-Agent Encounter Recognition (section 178-184)

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.

check_circle both survived AND other_error > 0.1 for both agents in 3/5 pairs
8 Mutual Recognition Mutual Perception (section 438)

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.

check_circle r_ab > 0.4 AND r_ba > 0.4 AND other_error > 0.5 for both in 3/5 pairs
9 Observing Reason section 240-262

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.

check_circle curiosity_drive > 0.1 AND exploration_productivity > 0.05 in 3/5 runs
info Layer 9 Ceiling
Layer 9 has reached a representational ceiling at the 80-neuron scale. Curiosity criteria are anti-correlated: organisms that explore find nothing new; organisms with productive exploration do not need to explore. The world is too simple for curiosity to have somewhere to go. No shared symbolic space, no concept composition, no representation modification — these would require architectural changes beyond the CTRNN+Hebbian framework.
group

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 2 nearest others through 14 delayed sensory channels carrying motor (3-dim) and voice (4-dim) output.

Paired state vector: 180-dim ODE (90 per organism) Triad state vector: 270-dim ODE (90 per organism, Layer 9) Sensory delay: 5-step ring buffer (temporal decorrelation for Hebbian learning) Other-agent channels: 2 nearest × (motor[1:3] + voice[1:4]) = 14 dim

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.

auto_stories Recognition Requires Perception
Ablation study: with perception OFF, r = 0.0. With perception ON, r = 0.87. The signal is genuine — recognition is driven by actual perceptual encounter with an unpredictable Other, not by viability-based dependence.
info Honest Labeling
Layer 8 achieves mutual perception (r_ab = 0.875), but with symmetric start. There is no master-slave dialectic, no struggle. This is honest: mutual tracking, not Spirit. The label is "mutual perception," not "absolute knowing."
genetics

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.

41 evolvable genes, layer-gated: Layer 1: genes 1-14 (metabolic: k-rates, decay, input) Layer 2: genes 1-25 (+ CTRNN: tau, gain, motor, connectivity) Layer 3-4: genes 1-34 (+ Hebbian rates, voice, organism params) Layer 5+: genes 1-41 (+ self-model, memory, planning, concepts) Selection: viability-proportional survive/die — no ranking Seeding: entire population seeded from best genome

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 (300×300 Torus)

The environment is a 300×300 toroidal grid with 5 independent resource fields (one per substrate S1-S5). Resources regenerate (rate 0.003), diffuse (0.03), and deplete locally. Each field cycles with distinct periods (6K-15K time units) and phase offsets, creating temporal patterns discoverable via Hebbian learning. Cross-resource interaction: eating Sk depletes Sk+2 by 15% — trade-off dynamics. Perturbations come as correlated cascades: when one variable is hit, 1-3 related variables are affected with 300-500 time unit lags.

auto_stories Why Structure Matters
Random noise teaches nothing. For Hebbian learning to extract regularities, there must be regularities to extract. Cyclical dynamics and correlated perturbations create a world with discoverable laws — this is Hegel's "Force" that the Understanding can grasp.
lightbulb

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 80-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.