TASK_PHASE_MVP_DAGI_INTEGRATION_FIX_20251201 A) Agents Layer: - A1: Added gov_level to API and UI (list + profile) - A2: Added dais_identity_id to API and UI - A3: Added home_microdao_id/name/slug for ownership display B) MicroDAO Layer: - B1/B2: Already implemented (agents, rooms, citizens, district badge) C) Nodes Layer: - C1: Node Dashboard already implemented - C2: Created nodes table migration with owner_microdao_id - C3: INSERT NODE1/NODE2 with dao_daarion ownership D) Backend Fixes: - D1: Extended /api/agents/* with DAIS/governance fields - D2/D3: Already implemented Files changed: - services/city-service/repo_city.py - services/city-service/models_city.py - services/city-service/routes_city.py - services/city-service/migrations.py - apps/web/src/lib/types/agents.ts - apps/web/src/lib/agent-dashboard.ts - apps/web/src/app/agents/page.tsx - apps/web/src/components/agent-dashboard/AgentSummaryCard.tsx Reports: - docs/debug/mvp_dagi_integration_fix_report_20251201.md - docs/tasks/TASK_PHASE_MVP_DAGI_INTEGRATION_FIX_20251201.md
90 lines
3.7 KiB
Python
90 lines
3.7 KiB
Python
import asyncpg
|
|
import os
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://postgres:postgres@localhost:5432/daarion")
|
|
|
|
async def run_migrations():
|
|
conn = None
|
|
try:
|
|
conn = await asyncpg.connect(DATABASE_URL)
|
|
|
|
# Add logo_url and banner_url to microdaos table (previous task)
|
|
await conn.execute("""
|
|
ALTER TABLE microdaos
|
|
ADD COLUMN IF NOT EXISTS logo_url TEXT,
|
|
ADD COLUMN IF NOT EXISTS banner_url TEXT;
|
|
""")
|
|
|
|
# Add logo_url and banner_url to city_rooms table (previous task)
|
|
await conn.execute("""
|
|
ALTER TABLE city_rooms
|
|
ADD COLUMN IF NOT EXISTS logo_url TEXT,
|
|
ADD COLUMN IF NOT EXISTS banner_url TEXT;
|
|
""")
|
|
|
|
# NEW: Add crew_team_key to agents table (TASK 044)
|
|
await conn.execute("""
|
|
ALTER TABLE agents
|
|
ADD COLUMN IF NOT EXISTS crew_team_key TEXT;
|
|
""")
|
|
logger.info("Migration: Added crew_team_key to agents table.")
|
|
|
|
# TASK 044: Add room_role, is_public, sort_order to city_rooms table
|
|
await conn.execute("""
|
|
ALTER TABLE city_rooms
|
|
ADD COLUMN IF NOT EXISTS room_role TEXT,
|
|
ADD COLUMN IF NOT EXISTS is_public BOOLEAN DEFAULT TRUE,
|
|
ADD COLUMN IF NOT EXISTS sort_order INTEGER DEFAULT 100;
|
|
""")
|
|
logger.info("Migration: Added room_role, is_public, sort_order to city_rooms table.")
|
|
|
|
# TASK C2: Create nodes table with owner_microdao (replaces node_cache for ontology)
|
|
await conn.execute("""
|
|
CREATE TABLE IF NOT EXISTS nodes (
|
|
id TEXT PRIMARY KEY,
|
|
display_name TEXT NOT NULL,
|
|
hostname TEXT,
|
|
owner_microdao_id TEXT REFERENCES microdaos(id),
|
|
node_type TEXT,
|
|
environment TEXT DEFAULT 'unknown',
|
|
cpu_cores INTEGER,
|
|
ram_gb INTEGER,
|
|
gpu_count INTEGER DEFAULT 0,
|
|
disk_gb INTEGER,
|
|
status TEXT DEFAULT 'unknown',
|
|
guardian_agent_id TEXT,
|
|
steward_agent_id TEXT,
|
|
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ DEFAULT NOW()
|
|
);
|
|
""")
|
|
logger.info("Migration: Created nodes table with owner_microdao.")
|
|
|
|
# TASK C3: Insert NODE1 and NODE2 if not exist
|
|
await conn.execute("""
|
|
INSERT INTO nodes (id, display_name, hostname, owner_microdao_id, node_type, environment, status, guardian_agent_id, steward_agent_id)
|
|
VALUES
|
|
('node-1-hetzner-gex44', 'Hetzner GEX44 Production', '144.76.224.179', 'dao_daarion', 'compute', 'production', 'online', 'monitor-node1', 'node-steward-node1'),
|
|
('node-2-macbook-m4max', 'MacBook Pro M4 Max', '192.168.1.33', 'dao_daarion', 'hybrid', 'development', 'online', 'monitor-node2', 'node-steward-node2')
|
|
ON CONFLICT (id) DO UPDATE SET
|
|
display_name = EXCLUDED.display_name,
|
|
hostname = EXCLUDED.hostname,
|
|
owner_microdao_id = EXCLUDED.owner_microdao_id,
|
|
node_type = EXCLUDED.node_type,
|
|
environment = EXCLUDED.environment,
|
|
guardian_agent_id = EXCLUDED.guardian_agent_id,
|
|
steward_agent_id = EXCLUDED.steward_agent_id,
|
|
updated_at = NOW();
|
|
""")
|
|
logger.info("Migration: Inserted/updated NODE1 and NODE2 in nodes table.")
|
|
|
|
except Exception as e:
|
|
logger.error(f"Error running migrations: {e}")
|
|
raise
|
|
finally:
|
|
if conn:
|
|
await conn.close()
|