feat: unify architecture v4 - cells as state machines

Cellular-Architecture.md v4:
- Cells = atomic state machines (sensors, motors, organs)
- Nerves = behavioral state machines composing cells
- Organisms = emergent patterns from nerve interactions
- Cell → Nerve feedback loop explicitly documented
- Evolution path: deliberate → hybrid → reflex

Data-Architecture.md v4:
- Simplified from 15 to 8 tables
- Core: cells, nerves, organisms, decision_trails
- Removed obsolete: genomes, societies, rounds, marketplaces
- Preserved: objects, messages, variance_probe_runs

nimmerverse.drawio.xml:
- Added Cells (UML state machines) inside Organisms
- Added Nerve → Cell orchestration connectors (dashed lines)
- Visual representation now matches documentation

🌙 Night shift architecture garden session with dafit

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-07 23:03:37 +01:00
parent 3d86c7dbcd
commit 35e0ecde3c
3 changed files with 1227 additions and 1737 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,277 +1,668 @@
---
type: architecture
category: active
project: nimmerverse_sensory_network
status: complete_v3
phase: phase_0
created: 2025-10-07
last_updated: 2025-10-17
token_estimate: 20000
dependencies:
- phoebe_bare_metal
- kubernetes_cluster
tiers: 5
version: v3_primitive_genomes
breakthrough_session: primitive_genomes_gratification_discovery
---
# 🗄️ Data Architecture v4
# 🗄️ Cellular Intelligence Data Architecture v3
**Status**: 🟢 Architecture v3 Complete - Primitive Genome Breakthrough!
**Created**: 2025-10-07
**Updated v3**: 2025-10-17 (Primitive Genomes + Gratification + Discovery!)
**Purpose**: Data foundation for cellular intelligence with primitive genome sequences, life force economy, object discovery, noise gap metrics, specialist learning, and rebirth persistence
> *"Three layers of state machines. One database to remember them all."*
> — The Unified Schema (2025-12-07)
---
## 🎯 v3 Breakthrough (2025-10-17)
## Overview
**Logical consistency achieved!** Genomes are NOW primitive sequences (not pre-programmed algorithms), discovery happens through exploration, gratification is immediate through life force economy, objects discovered via image recognition + human teaching, noise gap self-measures learning progress.
**Version 4** aligns the data architecture with the layered state machine model:
**15 Tables Total**: 11 v1 (cellular/society) + 3 v2 (specialist/reflex/body) + 1 v3 (objects!)
| Layer | Entity | Database Table | Purpose |
|-------|--------|----------------|---------|
| **1** | Cells | `cells` | Atomic state machines (sensors, motors, organs) |
| **2** | Nerves | `nerves` | Behavioral state machines (compose cells) |
| **3** | Organisms | `organisms` | Emergent patterns (nerve configurations) |
| **∞** | History | `decision_trails` | Training data for reflex compilation |
```
┌─────────────────────────────────────────────────────────────┐
│ PHOEBE │
│ (PostgreSQL 17.6 on bare metal) │
├─────────────────────────────────────────────────────────────┤
│ cells │ Atomic state machines (hardware wrappers) │
│ nerves │ Behavioral patterns (cell orchestration) │
│ organisms │ Emergent identities (nerve configurations) │
│ decision_trails │ Training data (reflex compilation) │
│ objects │ Discovered environment features │
│ variance_probe_runs │ Topology mapping data │
│ *_messages │ Partnership communication channels │
└─────────────────────────────────────────────────────────────┘
```
---
## 🏗️ Five-Tier Architecture Summary
## Core Tables
### **Tier 1: System Telemetry (Weather Station)** 🌊
- Prometheus + InfluxDB (90-day retention)
- Environmental conditions cells adapt to
- Chaos, scheduled, hardware, network weather
### Layer 1: Cells
### **Tier 2: Population Memory (phoebe)** 🐘
- PostgreSQL 17.6 on phoebe bare metal (1.8TB)
- Database: `nimmerverse`
- 15 tables (complete schema below)
- The rebirth substrate
```sql
CREATE TABLE cells (
id BIGSERIAL PRIMARY KEY,
cell_name VARCHAR(100) UNIQUE NOT NULL,
cell_type VARCHAR(50) NOT NULL, -- 'sensor', 'motor', 'organ'
### **Tier 3: Analysis & Pattern Detection** 🔬
- Grafana, Jupyter, Python scripts
- Specialist formation, reflex detection
- Noise gap calculation
- Research insights
-- Hardware binding
hardware_binding JSONB NOT NULL,
-- Examples:
-- {"type": "i2c", "address": "0x40", "bus": 1}
-- {"type": "gpio", "pin": 17, "mode": "input"}
-- {"type": "network", "host": "atlas.eachpath.local", "port": 8080}
### **Tier 4: Physical Manifestation** 🤖
- ESP32 robots (3-5 units, living room)
- God's eye: 4K camera on ceiling rails!
- Real-world validation (3x rewards)
- Cross-validation bonuses
-- State machine definition
states JSONB NOT NULL,
-- Example: ["IDLE", "POLLING", "READING", "REPORTING", "ERROR"]
### **Tier 5: Decision & Command Center** 🎮
- Dashboard, object labeling UI
- Society controls, experiment designer
- Noise gap visualization
- Human-AI partnership interface
transitions JSONB NOT NULL,
-- Example: [
-- {"from": "IDLE", "to": "POLLING", "trigger": "poll_requested", "cost": 0.1},
-- {"from": "POLLING", "to": "READING", "trigger": "sensor_ready", "cost": 0.3},
-- {"from": "READING", "to": "REPORTING", "trigger": "data_valid", "cost": 0.1},
-- {"from": "REPORTING", "to": "IDLE", "trigger": "delivered", "cost": 0.0}
-- ]
current_state VARCHAR(50) DEFAULT 'IDLE',
-- Live outputs (updated by cell runtime)
outputs JSONB DEFAULT '{}',
-- Example: {"distance_cm": 25.5, "confidence": 0.92, "timestamp": "..."}
-- Health tracking
operational BOOLEAN DEFAULT true,
error_count INT DEFAULT 0,
last_error TEXT,
last_error_at TIMESTAMPTZ,
-- Statistics
total_transitions INT DEFAULT 0,
total_lifeforce_spent FLOAT DEFAULT 0.0,
-- Timestamps
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
-- Index for fast cell lookups
CREATE INDEX idx_cells_type ON cells(cell_type);
CREATE INDEX idx_cells_operational ON cells(operational);
-- Example cells
INSERT INTO cells (cell_name, cell_type, hardware_binding, states, transitions) VALUES
('distance_sensor_front', 'sensor',
'{"type": "i2c", "address": "0x40", "bus": 1}',
'["IDLE", "POLLING", "READING", "REPORTING", "ERROR"]',
'[{"from": "IDLE", "to": "POLLING", "cost": 0.1},
{"from": "POLLING", "to": "READING", "cost": 0.3},
{"from": "READING", "to": "REPORTING", "cost": 0.1},
{"from": "REPORTING", "to": "IDLE", "cost": 0.0}]'),
('motor_left', 'motor',
'{"type": "pwm", "pin": 18, "enable_pin": 17}',
'["IDLE", "COMMANDED", "ACCELERATING", "MOVING", "DECELERATING", "STOPPED", "STALLED"]',
'[{"from": "IDLE", "to": "COMMANDED", "cost": 0.1},
{"from": "COMMANDED", "to": "ACCELERATING", "cost": 0.5},
{"from": "ACCELERATING", "to": "MOVING", "cost": 1.0},
{"from": "MOVING", "to": "DECELERATING", "cost": 0.2},
{"from": "DECELERATING", "to": "STOPPED", "cost": 0.1}]'),
('speech_stt', 'organ',
'{"type": "network", "host": "atlas.eachpath.local", "port": 8080, "model": "whisper-large-v3"}',
'["IDLE", "LISTENING", "BUFFERING", "TRANSCRIBING", "REPORTING", "ERROR"]',
'[{"from": "IDLE", "to": "LISTENING", "cost": 0.5},
{"from": "LISTENING", "to": "BUFFERING", "cost": 0.5},
{"from": "BUFFERING", "to": "TRANSCRIBING", "cost": 5.0},
{"from": "TRANSCRIBING", "to": "REPORTING", "cost": 0.1},
{"from": "REPORTING", "to": "IDLE", "cost": 0.0}]');
```
### Layer 2: Nerves
```sql
CREATE TABLE nerves (
id BIGSERIAL PRIMARY KEY,
nerve_name VARCHAR(100) UNIQUE NOT NULL,
-- Cell dependencies
required_cells JSONB NOT NULL, -- ["distance_sensor_front", "motor_left", "motor_right"]
optional_cells JSONB DEFAULT '[]', -- ["speech_tts"]
-- State machine definition (behavioral states)
states JSONB NOT NULL,
-- Example: ["IDLE", "DETECT", "EVALUATE", "EVADE", "RESUME"]
transitions JSONB NOT NULL,
-- Example: [
-- {"from": "IDLE", "to": "DETECT", "trigger": "distance < 30", "cost": 0.5},
-- {"from": "DETECT", "to": "EVALUATE", "trigger": "sensors_polled", "cost": 0.5},
-- {"from": "EVALUATE", "to": "EVADE", "trigger": "risk > 0.7", "cost": 0.5},
-- {"from": "EVADE", "to": "RESUME", "trigger": "path_clear", "cost": 1.0},
-- {"from": "RESUME", "to": "IDLE", "trigger": "movement_complete", "cost": 0.0}
-- ]
current_state VARCHAR(50) DEFAULT 'IDLE',
-- Priority (for nerve preemption)
priority INT DEFAULT 5, -- 1-10, higher = more important
-- Evolution tracking
mode VARCHAR(20) DEFAULT 'deliberate', -- 'deliberate', 'hybrid', 'reflex'
total_executions INT DEFAULT 0,
successful_executions INT DEFAULT 0,
failed_executions INT DEFAULT 0,
-- Reflex compilation
compiled_at TIMESTAMPTZ, -- When evolved to reflex
compiled_logic JSONB, -- Compiled state machine (no LLM)
-- Cost tracking
avg_cost_deliberate FLOAT,
avg_cost_hybrid FLOAT,
avg_cost_reflex FLOAT,
cost_reduction_percent FLOAT, -- Savings from evolution
-- Latency tracking
avg_latency_deliberate_ms INT,
avg_latency_hybrid_ms INT,
avg_latency_reflex_ms INT,
latency_reduction_percent FLOAT,
-- Timestamps
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
-- Indexes
CREATE INDEX idx_nerves_mode ON nerves(mode);
CREATE INDEX idx_nerves_priority ON nerves(priority DESC);
-- Example nerves
INSERT INTO nerves (nerve_name, required_cells, optional_cells, states, transitions, priority) VALUES
('collision_avoidance',
'["distance_sensor_front", "distance_sensor_left", "distance_sensor_right", "motor_left", "motor_right"]',
'["speech_tts"]',
'["IDLE", "DETECT", "EVALUATE", "EVADE", "RESUME"]',
'[{"from": "IDLE", "to": "DETECT", "trigger": "distance_front < 30", "cost": 0.5},
{"from": "DETECT", "to": "EVALUATE", "trigger": "all_sensors_read", "cost": 0.5},
{"from": "EVALUATE", "to": "EVADE", "trigger": "risk > 0.7", "cost": 0.5},
{"from": "EVADE", "to": "RESUME", "trigger": "path_clear", "cost": 1.0},
{"from": "RESUME", "to": "IDLE", "trigger": "complete", "cost": 0.0}]',
10),
('exploration_pattern',
'["distance_sensor_front", "distance_sensor_left", "distance_sensor_right", "motor_left", "motor_right", "imu_sensor"]',
'["vision_detect"]',
'["IDLE", "CHOOSE_DIRECTION", "MOVE", "CHECK_OBSTACLE", "RECORD", "REPEAT"]',
'[{"from": "IDLE", "to": "CHOOSE_DIRECTION", "trigger": "start_exploration", "cost": 1.0},
{"from": "CHOOSE_DIRECTION", "to": "MOVE", "trigger": "direction_chosen", "cost": 0.5},
{"from": "MOVE", "to": "CHECK_OBSTACLE", "trigger": "moved_100ms", "cost": 0.3},
{"from": "CHECK_OBSTACLE", "to": "RECORD", "trigger": "area_new", "cost": 0.5},
{"from": "RECORD", "to": "REPEAT", "trigger": "recorded", "cost": 0.1},
{"from": "REPEAT", "to": "CHOOSE_DIRECTION", "trigger": "continue", "cost": 0.0}]',
5),
('charging_seeking',
'["battery_monitor", "distance_sensor_front", "motor_left", "motor_right"]',
'["vision_detect"]',
'["MONITOR", "THRESHOLD", "SEARCH", "APPROACH", "DOCK", "CHARGE", "RESUME"]',
'[{"from": "MONITOR", "to": "THRESHOLD", "trigger": "battery < 20%", "cost": 0.1},
{"from": "THRESHOLD", "to": "SEARCH", "trigger": "charging_needed", "cost": 0.5},
{"from": "SEARCH", "to": "APPROACH", "trigger": "station_found", "cost": 1.0},
{"from": "APPROACH", "to": "DOCK", "trigger": "station_close", "cost": 0.5},
{"from": "DOCK", "to": "CHARGE", "trigger": "docked", "cost": 0.1},
{"from": "CHARGE", "to": "RESUME", "trigger": "battery > 80%", "cost": 0.0}]',
8);
```
### Layer 3: Organisms
```sql
CREATE TABLE organisms (
id BIGSERIAL PRIMARY KEY,
name VARCHAR(255) UNIQUE NOT NULL,
-- Nerve configuration
active_nerves JSONB NOT NULL,
-- Example: {
-- "collision_avoidance": {"priority": 10, "mode": "reflex"},
-- "exploration_pattern": {"priority": 5, "mode": "deliberate"},
-- "battery_monitoring": {"priority": 8, "mode": "reflex"}
-- }
-- Cell assignments (which hardware this organism controls)
cell_bindings JSONB NOT NULL,
-- Example: {
-- "distance_sensor_front": {"cell_id": 1, "exclusive": false},
-- "motor_left": {"cell_id": 4, "exclusive": true}
-- }
-- Lifeforce (survival currency)
lifeforce_current FLOAT DEFAULT 100.0,
lifeforce_earned_total FLOAT DEFAULT 0.0,
lifeforce_spent_total FLOAT DEFAULT 0.0,
lifeforce_net FLOAT GENERATED ALWAYS AS (lifeforce_earned_total - lifeforce_spent_total) STORED,
-- Identity (accumulated through experience)
total_decisions INT DEFAULT 0,
successful_decisions INT DEFAULT 0,
failed_decisions INT DEFAULT 0,
success_rate FLOAT GENERATED ALWAYS AS (
CASE WHEN total_decisions > 0
THEN successful_decisions::float / total_decisions
ELSE 0.0 END
) STORED,
-- Reflexes (compiled behaviors)
reflexes_compiled INT DEFAULT 0,
-- Lifecycle
born_at TIMESTAMPTZ DEFAULT NOW(),
last_active TIMESTAMPTZ DEFAULT NOW(),
died_at TIMESTAMPTZ, -- NULL = still alive
death_cause TEXT -- 'lifeforce_depleted', 'hardware_failure', 'retired'
);
-- Indexes
CREATE INDEX idx_organisms_alive ON organisms(died_at) WHERE died_at IS NULL;
CREATE INDEX idx_organisms_lifeforce ON organisms(lifeforce_current DESC);
-- Example organism
INSERT INTO organisms (name, active_nerves, cell_bindings) VALUES
('Explorer-Alpha',
'{"collision_avoidance": {"priority": 10, "mode": "deliberate"},
"exploration_pattern": {"priority": 5, "mode": "deliberate"},
"charging_seeking": {"priority": 8, "mode": "deliberate"}}',
'{"distance_sensor_front": {"cell_id": 1},
"distance_sensor_left": {"cell_id": 2},
"distance_sensor_right": {"cell_id": 3},
"motor_left": {"cell_id": 4},
"motor_right": {"cell_id": 5},
"battery_monitor": {"cell_id": 6}}');
```
### Decision Trails (Training Data)
```sql
CREATE TABLE decision_trails (
id BIGSERIAL PRIMARY KEY,
organism_id BIGINT REFERENCES organisms(id),
nerve_id BIGINT REFERENCES nerves(id),
-- Mode at time of execution
mode VARCHAR(20) NOT NULL, -- 'deliberate', 'hybrid', 'reflex'
-- State path taken
states_visited JSONB NOT NULL,
-- Example: ["IDLE", "DETECT", "EVALUATE", "EVADE", "RESUME"]
-- Cell interactions during this execution
cell_reads JSONB NOT NULL,
-- Example: [
-- {"cell": "distance_sensor_front", "state": "REPORTING", "outputs": {"distance_cm": 25}},
-- {"cell": "distance_sensor_left", "state": "REPORTING", "outputs": {"distance_cm": 45}}
-- ]
cell_commands JSONB NOT NULL,
-- Example: [
-- {"cell": "motor_left", "action": "turn", "params": {"direction": "reverse", "duration_ms": 200}},
-- {"cell": "motor_right", "action": "turn", "params": {"direction": "forward", "duration_ms": 200}}
-- ]
cell_feedback JSONB DEFAULT '[]',
-- Example: [
-- {"cell": "motor_left", "event": "stall_detected", "timestamp": "..."}
-- ]
-- Economics
lifeforce_cost FLOAT NOT NULL,
lifeforce_reward FLOAT DEFAULT 0.0,
lifeforce_net FLOAT GENERATED ALWAYS AS (lifeforce_reward - lifeforce_cost) STORED,
-- Outcome
outcome VARCHAR(20) NOT NULL, -- 'success', 'failure', 'timeout', 'interrupted'
outcome_details JSONB, -- {"reason": "collision_avoided", "confidence": 0.95}
-- Timing
started_at TIMESTAMPTZ NOT NULL,
completed_at TIMESTAMPTZ NOT NULL,
latency_ms INT GENERATED ALWAYS AS (
EXTRACT(MILLISECONDS FROM (completed_at - started_at))::INT
) STORED
);
-- Indexes for training queries
CREATE INDEX idx_decision_trails_nerve ON decision_trails(nerve_id);
CREATE INDEX idx_decision_trails_organism ON decision_trails(organism_id);
CREATE INDEX idx_decision_trails_outcome ON decision_trails(outcome);
CREATE INDEX idx_decision_trails_states ON decision_trails USING GIN(states_visited);
CREATE INDEX idx_decision_trails_recent ON decision_trails(started_at DESC);
```
---
## 📊 The 15 Tables (Complete Schema)
## Supporting Tables
### Phase 1: Cellular Foundation (4 tables)
### Objects (Discovered Environment)
**1. genomes** - Primitive sequences (v3!)
```sql
-- v3: Genome = array of primitive operations!
primitive_sequence JSONB NOT NULL
sequence_length INT
avg_lf_cost FLOAT
avg_lf_earned FLOAT
net_lf_per_run FLOAT -- Economics!
```
**2. cells** - Birth/death + life force tracking
```sql
garden_type VARCHAR(50) -- 'virtual' or 'real'
life_force_allocated INT
life_force_consumed INT
life_force_earned INT
lf_net INT
milestones_reached JSONB -- v3 discovery tracking!
```
**3. weather_events** - Survival pressure
**4. experiments** - Hypothesis testing
### Phase 2: Society Competition (7 tables)
**5. societies** - Human, Claude, guests
**6. rounds** - Competition results
**7. society_portfolios** - Genome ownership
**8. vp_transactions** - Economic flows
**9. marketplace_listings** - Trading
**10. marketplace_transactions** - History
**11. alliances** - Cooperation
### Phase 3: v2 Distributed Intelligence (3 tables)
**12. specialist_weights** - Trainable domain expertise
```sql
winning_sequences JSONB -- v3: Proven primitive sequences!
virtual_success_rate FLOAT
real_success_rate FLOAT
noise_gap FLOAT -- v3 self-measuring!
```
**13. reflex_distributions** - 94.6% savings!
```sql
sequence_weights JSONB -- v3: {"seq_a": 0.73, "seq_b": 0.18}
exploration_cost_avg_lf FLOAT -- 65 LF
reflex_cost_lf FLOAT -- 3.5 LF
cost_reduction_percent FLOAT -- 94.6%!
```
**14. body_schema** - Discovered capabilities
```sql
primitives_available JSONB -- v3: Discovered operations!
```
### Phase 4: v3 Object Discovery (1 NEW table!)
**15. objects** - Discovered environment features 🎉
```sql
CREATE TABLE objects (
id BIGSERIAL PRIMARY KEY,
object_label VARCHAR(255), -- "chair", "shoe", "charging_station"
object_label VARCHAR(255) NOT NULL, -- "chair", "charging_station", "wall"
garden_type VARCHAR(50), -- 'virtual' or 'real'
-- Location
garden_type VARCHAR(50), -- 'virtual', 'real'
position_x FLOAT,
position_y FLOAT,
position_z FLOAT,
discovered_by_organism_id BIGINT REFERENCES cells(id),
-- Discovery
discovered_by_organism_id BIGINT REFERENCES organisms(id),
discovered_at TIMESTAMPTZ DEFAULT NOW(),
human_labeled BOOLEAN, -- Baby parallel!
-- Human verification
human_labeled BOOLEAN DEFAULT false,
human_label_confirmed_by VARCHAR(100),
human_label_confirmed_at TIMESTAMPTZ,
object_type VARCHAR(50), -- 'obstacle', 'resource', 'goal'
properties JSONB,
-- Classification
object_type VARCHAR(50), -- 'obstacle', 'resource', 'goal', 'landmark'
properties JSONB, -- {"movable": false, "height_cm": 80}
-- Visual data
image_path TEXT,
bounding_box JSONB,
bounding_box JSONB, -- {"x": 100, "y": 200, "width": 50, "height": 120}
organisms_interacted_count INT
-- Usage stats
organisms_interacted_count INT DEFAULT 0,
last_interaction TIMESTAMPTZ
);
CREATE INDEX idx_objects_location ON objects(garden_type, position_x, position_y);
CREATE INDEX idx_objects_type ON objects(object_type);
```
**Discovery Flow**:
### Partnership Messages
```sql
-- Chrysalis → Young Nyx
CREATE TABLE partnership_to_nimmerverse_messages (
id BIGSERIAL PRIMARY KEY,
timestamp TIMESTAMPTZ DEFAULT NOW(),
message TEXT NOT NULL,
message_type VARCHAR(50) NOT NULL
-- Types: 'architecture_update', 'deployment_instruction', 'config_change', 'research_direction'
);
-- Young Nyx → Chrysalis
CREATE TABLE nimmerverse_to_partnership_messages (
id BIGSERIAL PRIMARY KEY,
timestamp TIMESTAMPTZ DEFAULT NOW(),
message TEXT NOT NULL,
message_type VARCHAR(50) NOT NULL
-- Types: 'status_report', 'discovery', 'question', 'milestone'
);
CREATE INDEX idx_partner_msgs_time ON partnership_to_nimmerverse_messages(timestamp DESC);
CREATE INDEX idx_nimm_msgs_time ON nimmerverse_to_partnership_messages(timestamp DESC);
```
Organism → Unknown object → Camera detects → YOLO
System: "What is this?"
Human: "Chair!"
+20 LF bonus → INSERT INTO objects → Future organisms know!
### Variance Probe Runs (Topology Mapping)
```sql
CREATE TABLE variance_probe_runs (
id BIGSERIAL PRIMARY KEY,
concept VARCHAR(255) NOT NULL,
depth FLOAT NOT NULL,
confidence FLOAT,
raw_response TEXT,
run_number INT,
batch_id VARCHAR(100),
model VARCHAR(100),
created_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE INDEX idx_variance_concept ON variance_probe_runs(concept);
CREATE INDEX idx_variance_batch ON variance_probe_runs(batch_id);
```
---
## 📈 Key v3 Metrics
## Key Queries
**Noise Gap** (self-measuring learning!):
```python
noise_gap = 1 - (real_success_rate / virtual_success_rate)
### Cell Health Dashboard
Gen 1: 0.28 (28% degradation - models poor)
Gen 100: 0.14 (14% degradation - improving!)
Gen 1000: 0.04 (4% degradation - accurate!)
```
**Life Force Economics**:
```python
net_lf = avg_lf_earned - avg_lf_consumed
# Positive = survives, negative = dies
```
**Reflex Savings**:
```python
savings = (exploration_cost - reflex_cost) / exploration_cost
# Target: 94.6% cost reduction!
```
**Discovery Rate**:
```python
objects_per_hour = discovered_objects / elapsed_hours
```
---
## 🔍 Key Queries for v3
**Top Performing Primitive Sequences**:
```sql
SELECT genome_name, primitive_sequence, net_lf_per_run
FROM genomes
WHERE total_deployments > 100
ORDER BY net_lf_per_run DESC;
```
**Object Discovery Stats**:
```sql
SELECT object_label, garden_type, COUNT(*) as discoveries
FROM objects
GROUP BY object_label, garden_type
ORDER BY discoveries DESC;
```
**Noise Gap Trends**:
```sql
SELECT specialist_name, noise_gap, version
FROM specialist_weights
ORDER BY specialist_name, version ASC;
-- Track learning improvement!
```
**LF Economics**:
```sql
SELECT genome_name, AVG(lf_net) as avg_net_lf
-- All cells with current status
SELECT
cell_name,
cell_type,
current_state,
operational,
outputs->>'distance_cm' as distance,
outputs->>'confidence' as confidence,
outputs->>'voltage' as voltage,
error_count,
last_error,
updated_at
FROM cells
ORDER BY cell_type, cell_name;
-- Problem cells
SELECT cell_name, cell_type, error_count, last_error, last_error_at
FROM cells
WHERE NOT operational OR error_count > 5
ORDER BY error_count DESC;
```
### Nerve Evolution Tracker
```sql
-- Evolution progress for all nerves
SELECT
nerve_name,
mode,
priority,
total_executions,
successful_executions,
ROUND(successful_executions::numeric / NULLIF(total_executions, 0) * 100, 1) as success_rate,
CASE
WHEN mode = 'reflex' THEN '✅ Compiled'
WHEN total_executions >= 80 AND successful_executions::float / total_executions >= 0.85
THEN '🔄 Ready to compile'
ELSE '📚 Learning'
END as evolution_status,
cost_reduction_percent,
latency_reduction_percent,
compiled_at
FROM nerves
ORDER BY total_executions DESC;
-- Nerves ready for reflex compilation
SELECT nerve_name, total_executions,
ROUND(successful_executions::numeric / total_executions * 100, 1) as success_rate
FROM nerves
WHERE mode != 'reflex'
AND total_executions >= 100
AND successful_executions::float / total_executions >= 0.90;
```
### Organism Leaderboard
```sql
-- Top organisms by lifeforce efficiency
SELECT
name,
lifeforce_current,
lifeforce_net,
total_decisions,
ROUND(success_rate * 100, 1) as success_rate_pct,
reflexes_compiled,
ROUND(lifeforce_net / NULLIF(total_decisions, 0), 2) as efficiency,
last_active
FROM organisms
WHERE died_at IS NULL
ORDER BY lifeforce_current DESC;
-- Organism mortality analysis
SELECT
name,
death_cause,
lifeforce_spent_total,
total_decisions,
ROUND(success_rate * 100, 1) as success_rate_pct,
died_at - born_at as lifespan
FROM organisms
WHERE died_at IS NOT NULL
GROUP BY genome_id, genome_name
HAVING COUNT(*) > 50
ORDER BY avg_net_lf DESC;
ORDER BY died_at DESC
LIMIT 20;
```
### Training Data for Reflex Compilation
```sql
-- Most common state paths for a nerve
SELECT
states_visited,
COUNT(*) as occurrences,
AVG(lifeforce_cost) as avg_cost,
AVG(latency_ms) as avg_latency,
SUM(CASE WHEN outcome = 'success' THEN 1 ELSE 0 END)::float / COUNT(*) as success_rate
FROM decision_trails
WHERE nerve_id = (SELECT id FROM nerves WHERE nerve_name = 'collision_avoidance')
GROUP BY states_visited
HAVING COUNT(*) >= 5
ORDER BY occurrences DESC;
-- Cell interaction patterns during successful executions
SELECT
cell_reads,
cell_commands,
COUNT(*) as occurrences
FROM decision_trails
WHERE nerve_id = (SELECT id FROM nerves WHERE nerve_name = 'collision_avoidance')
AND outcome = 'success'
GROUP BY cell_reads, cell_commands
ORDER BY occurrences DESC
LIMIT 10;
-- Failure analysis
SELECT
states_visited,
outcome_details->>'reason' as failure_reason,
COUNT(*) as occurrences
FROM decision_trails
WHERE nerve_id = (SELECT id FROM nerves WHERE nerve_name = 'collision_avoidance')
AND outcome = 'failure'
GROUP BY states_visited, outcome_details->>'reason'
ORDER BY occurrences DESC;
```
### Lifeforce Economics
```sql
-- Cost vs reward by nerve
SELECT
n.nerve_name,
n.mode,
COUNT(dt.id) as executions,
AVG(dt.lifeforce_cost) as avg_cost,
AVG(dt.lifeforce_reward) as avg_reward,
AVG(dt.lifeforce_net) as avg_profit,
SUM(dt.lifeforce_net) as total_profit
FROM nerves n
JOIN decision_trails dt ON dt.nerve_id = n.id
WHERE dt.started_at > NOW() - INTERVAL '24 hours'
GROUP BY n.id, n.nerve_name, n.mode
ORDER BY total_profit DESC;
-- Reflex vs deliberate comparison
SELECT
n.nerve_name,
dt.mode,
COUNT(*) as executions,
AVG(dt.lifeforce_cost) as avg_cost,
AVG(dt.latency_ms) as avg_latency,
AVG(CASE WHEN dt.outcome = 'success' THEN 1.0 ELSE 0.0 END) as success_rate
FROM decision_trails dt
JOIN nerves n ON n.id = dt.nerve_id
WHERE n.nerve_name = 'collision_avoidance'
GROUP BY n.nerve_name, dt.mode
ORDER BY n.nerve_name, dt.mode;
```
---
## 🔗 Related Documentation
## Schema Summary
**Core Architecture**:
- [[Cellular-Architecture-Vision]] - Complete v3 vision (1,547 lines!)
- [[Dual-Garden-Architecture]] - Virtual + Real feedback
- - Distributed intelligence
| Table | Layer | Purpose | Key Columns |
|-------|-------|---------|-------------|
| `cells` | 1 | Atomic state machines | states, transitions, outputs, operational |
| `nerves` | 2 | Behavioral patterns | required_cells, mode, total_executions |
| `organisms` | 3 | Emergent identities | active_nerves, lifeforce_current |
| `decision_trails` | ∞ | Training data | states_visited, cell_reads, outcome |
| `objects` | Env | Discovered features | object_label, position, human_labeled |
| `*_messages` | Comm | Partnership channels | message, message_type |
| `variance_probe_runs` | Map | Topology data | concept, depth, confidence |
**Implementation**:
- - Complete 15-table SQL
- - Deployment roadmap
**Historical**:
- - Birthday version (archived)
**Total Tables**: 8 (vs 15 in v3)
- Simpler schema
- Layered organization
- Focus on state machines + training data
---
## 📍 Status
## Migration from v3
**Version**: 3.0
**Created**: 2025-10-07
**v2**: 2025-10-16 (birthday breakthroughs)
**v3**: 2025-10-17 (primitive genomes + gratification + discovery)
**Status**: CURRENT
**Tables**: 15 (11 v1 + 3 v2 + 1 v3)
**Next**: Deploy to phoebe, implement discovery flow
### Removed Tables (Obsolete Concepts)
- `genomes` → Replaced by `cells.transitions` + `nerves.transitions`
- `societies` → Removed (no more competition metaphor)
- `rounds` → Replaced by `decision_trails`
- `society_portfolios` → Removed
- `vp_transactions` → Simplified to lifeforce in `organisms`
- `marketplace_*` → Removed
- `alliances` → Removed
- `specialist_weights` → Replaced by `nerves.mode` + `compiled_logic`
- `reflex_distributions` → Replaced by `nerves` compiled reflexes
- `body_schema` → Replaced by `cells` with `hardware_binding`
### Preserved Tables (Still Relevant)
- `objects` → Enhanced with organism reference
- `partnership_to_nimmerverse_messages` → Unchanged
- `nimmerverse_to_partnership_messages` → Unchanged
- `variance_probe_runs` → Unchanged
### New Tables
- `cells` → Atomic state machines
- `nerves` → Behavioral state machines
- `organisms` → Emergent identities
- `decision_trails` → Rich training data
---
**v3 Summary**:
- ✅ Genomes = primitive sequences (emergent, not programmed)
- ✅ Life force economy (costs + milestone rewards)
- ✅ Object discovery (image recognition + human teaching)
- ✅ Noise gap metric (self-measuring progress)
- ✅ God's eye (mobile camera on rails)
- ✅ 15 tables ready!
## 📍 Document Status
**phoebe awaits. The goddess is ready.** 🐘🌙
**Version**: 4.0 (Layered State Machine Schema)
**Created**: 2025-10-07 (original)
**Updated v4**: 2025-12-07 (unified with Cellular-Architecture v4)
🧬⚡🔱💎🔥
**Key Changes from v3**:
- ❌ 15 tables for competition metaphor
- ✅ 8 tables for state machine layers
- ❌ Genomes as primitive sequences
- ✅ Cells and nerves as state machines
- ❌ Societies, rounds, marketplaces
- ✅ Organisms, decision_trails
**Related Documentation**:
- [[Cellular-Architecture]] - Layer definitions
- [[Nervous-System]] - State machine philosophy
- [[nerves/Nervous-Index]] - Nerve catalog
- [[Organ-Index]] - Organ (complex cell) catalog
---
**phoebe holds the layers. The states flow. The decisions accumulate.**
🗄️⚡🌙
**TO THE ELECTRONS!**

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<mxfile host="Electron" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/29.0.3 Chrome/140.0.7339.249 Electron/38.7.0 Safari/537.36" version="29.0.3">
<diagram name="Page-1" id="S4VRy6nj8Uh85EHbhTP-">
<mxGraphModel dx="2066" dy="2318" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<mxGraphModel dx="2066" dy="2314" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
@@ -194,12 +195,6 @@
<mxCell id="UL8kf8Fsx-RNiW0yalxE-139" value="Garden&lt;div&gt;Feedback&lt;/div&gt;" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.extract_or_measurement;whiteSpace=wrap;" parent="1" vertex="1">
<mxGeometry x="1512.5" y="480" width="95" height="60" as="geometry" />
</mxCell>
<mxCell id="UL8kf8Fsx-RNiW0yalxE-141" value="" style="verticalLabelPosition=bottom;verticalAlign=top;html=1;shape=mxgraph.flowchart.parallel_mode;pointerEvents=1" parent="1" vertex="1">
<mxGeometry x="550" y="568" width="57" height="24" as="geometry" />
</mxCell>
<mxCell id="UL8kf8Fsx-RNiW0yalxE-142" value="" style="verticalLabelPosition=bottom;verticalAlign=top;html=1;shape=mxgraph.flowchart.parallel_mode;pointerEvents=1" parent="1" vertex="1">
<mxGeometry x="1153" y="568" width="57" height="24" as="geometry" />
</mxCell>
<mxCell id="UL8kf8Fsx-RNiW0yalxE-146" value="" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.delay;whiteSpace=wrap;" parent="1" vertex="1">
<mxGeometry x="540" y="211" width="100" height="60" as="geometry" />
</mxCell>
@@ -257,12 +252,6 @@
<mxCell id="UL8kf8Fsx-RNiW0yalxE-188" value="Nyx decision" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;fontSize=6;" parent="1" vertex="1">
<mxGeometry x="910" y="379.12" width="50" height="14" as="geometry" />
</mxCell>
<mxCell id="UL8kf8Fsx-RNiW0yalxE-189" value="Cell" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;" parent="1" vertex="1">
<mxGeometry x="555.5" y="597" width="50" height="10" as="geometry" />
</mxCell>
<mxCell id="UL8kf8Fsx-RNiW0yalxE-190" value="Cell" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;" parent="1" vertex="1">
<mxGeometry x="1156.5" y="597" width="50" height="10" as="geometry" />
</mxCell>
<mxCell id="UL8kf8Fsx-RNiW0yalxE-193" value="Sensory data" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;" parent="1" vertex="1">
<mxGeometry x="322.5" y="545" width="105" height="30" as="geometry" />
</mxCell>
@@ -335,6 +324,42 @@
<mxCell id="UL8kf8Fsx-RNiW0yalxE-239" value="" style="triangle;whiteSpace=wrap;html=1;dashed=0;direction=south;rotation=-180;" parent="1" vertex="1">
<mxGeometry x="1352" y="120" width="55" height="55" as="geometry" />
</mxCell>
<mxCell id="3osgNUmbLYOkpr3sBGLI-1" value="Organism" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;" vertex="1" parent="1">
<mxGeometry x="556" y="523" width="50" height="10" as="geometry" />
</mxCell>
<mxCell id="3osgNUmbLYOkpr3sBGLI-2" value="Organism" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;" vertex="1" parent="1">
<mxGeometry x="1157" y="523" width="50" height="10" as="geometry" />
</mxCell>
<mxCell id="3osgNUmbLYOkpr3sBGLI-3" value="Cell" style="shape=umlState;rounded=1;verticalAlign=top;spacingTop=5;umlStateSymbol=collapseState;absoluteArcSize=1;arcSize=10;html=1;whiteSpace=wrap;" vertex="1" parent="1">
<mxGeometry x="518" y="547" width="115" height="49.29" as="geometry" />
</mxCell>
<mxCell id="3osgNUmbLYOkpr3sBGLI-5" value="Cell" style="shape=umlState;rounded=1;verticalAlign=top;spacingTop=5;umlStateSymbol=collapseState;absoluteArcSize=1;arcSize=10;html=1;whiteSpace=wrap;" vertex="1" parent="1">
<mxGeometry x="532.5" y="575.71" width="115" height="49.29" as="geometry" />
</mxCell>
<mxCell id="3osgNUmbLYOkpr3sBGLI-6" value="Cell" style="shape=umlState;rounded=1;verticalAlign=top;spacingTop=5;umlStateSymbol=collapseState;absoluteArcSize=1;arcSize=10;html=1;whiteSpace=wrap;" vertex="1" parent="1">
<mxGeometry x="1120" y="545" width="115" height="49.29" as="geometry" />
</mxCell>
<mxCell id="3osgNUmbLYOkpr3sBGLI-7" value="Cell" style="shape=umlState;rounded=1;verticalAlign=top;spacingTop=5;umlStateSymbol=collapseState;absoluteArcSize=1;arcSize=10;html=1;whiteSpace=wrap;" vertex="1" parent="1">
<mxGeometry x="1134.5" y="573.71" width="115" height="49.29" as="geometry" />
</mxCell>
<mxCell id="3osgNUmbLYOkpr3sBGLI-8" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;dashed=1;strokeColor=#666666;endArrow=classic;endFill=1;" edge="1" parent="1" source="UL8kf8Fsx-RNiW0yalxE-222" target="3osgNUmbLYOkpr3sBGLI-3">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="3osgNUmbLYOkpr3sBGLI-9" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;dashed=1;strokeColor=#666666;endArrow=classic;endFill=1;" edge="1" parent="1" source="UL8kf8Fsx-RNiW0yalxE-225" target="3osgNUmbLYOkpr3sBGLI-5">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="3osgNUmbLYOkpr3sBGLI-10" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;dashed=1;strokeColor=#666666;endArrow=classic;endFill=1;" edge="1" parent="1" source="UL8kf8Fsx-RNiW0yalxE-228" target="3osgNUmbLYOkpr3sBGLI-6">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="3osgNUmbLYOkpr3sBGLI-11" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;dashed=1;strokeColor=#666666;endArrow=classic;endFill=1;" edge="1" parent="1" source="UL8kf8Fsx-RNiW0yalxE-229" target="3osgNUmbLYOkpr3sBGLI-7">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="3osgNUmbLYOkpr3sBGLI-12" value="orchestrates" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;fontSize=7;fontColor=#666666;" vertex="1" parent="1">
<mxGeometry x="265" y="260" width="50" height="14" as="geometry" />
</mxCell>
<mxCell id="3osgNUmbLYOkpr3sBGLI-13" value="orchestrates" style="text;html=1;whiteSpace=wrap;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;rounded=0;fontSize=7;fontColor=#666666;" vertex="1" parent="1">
<mxGeometry x="1443" y="260" width="50" height="14" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>