Data Models
Core database schema for 1000 Agent Platform
Core Tables
Agents Table
CREATE TABLE agents (
id UUID PRIMARY KEY,
name VARCHAR(255) NOT NULL,
type VARCHAR(50) NOT NULL, -- space|engineering|corpunit|investment
status VARCHAR(50) NOT NULL, -- active|idle|busy|blocked|error
cage_id VARCHAR(50), -- Cage number (001-1000)
current_task_id UUID,
resource_config JSONB,
metrics JSONB, -- Real-time metrics
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW(),
last_heartbeat TIMESTAMP
);
Tasks Table
CREATE TABLE tasks (
id UUID PRIMARY KEY,
type VARCHAR(100) NOT NULL,
priority INTEGER DEFAULT 0,
status VARCHAR(50) NOT NULL, -- pending|running|completed|failed|cancelled
assigned_agent_id UUID REFERENCES agents(id),
input JSONB NOT NULL,
output JSONB,
error TEXT,
started_at TIMESTAMP,
completed_at TIMESTAMP,
created_at TIMESTAMP DEFAULT NOW()
);
Artifacts Table (Agent Outputs)
CREATE TABLE artifacts (
id UUID PRIMARY KEY,
agent_id UUID REFERENCES agents(id),
task_id UUID REFERENCES tasks(id),
type VARCHAR(50) NOT NULL, -- code|doc|analysis|decision|report
title VARCHAR(500),
content TEXT,
quality_score FLOAT,
human_approved BOOLEAN DEFAULT FALSE,
metadata JSONB,
created_at TIMESTAMP DEFAULT NOW()
);
Cages Table (Agent Containers/Resource Quotas)
CREATE TABLE cages (
id VARCHAR(50) PRIMARY KEY, -- 001-1000
agent_id UUID REFERENCES agents(id),
status VARCHAR(50) NOT NULL, -- occupied|vacant|maintenance
resource_limits JSONB, -- cpu, memory, gpu, tokens
resource_usage JSONB, -- Actual usage
created_at TIMESTAMP DEFAULT NOW()
);
Metrics Table (Time-Series Metrics)
CREATE TABLE metrics (
time TIMESTAMP NOT NULL,
agent_id UUID NOT NULL,
metric_name VARCHAR(100) NOT NULL,
metric_value FLOAT NOT NULL,
labels JSONB,
PRIMARY KEY (time, agent_id, metric_name)
) PARTITION BY RANGE (time);
Indexes
-- Performance indexes
CREATE INDEX idx_agents_status ON agents(status);
CREATE INDEX idx_agents_type ON agents(type);
CREATE INDEX idx_tasks_status ON tasks(status);
CREATE INDEX idx_tasks_assigned ON tasks(assigned_agent_id);
CREATE INDEX idx_artifacts_agent ON artifacts(agent_id);
CREATE INDEX idx_metrics_time ON metrics(time DESC);