Files
microdao-daarion/migrations/036_node_metrics_extended.sql
Apple bca81dc719 feat: Node Self-Healing, DAGI Audit, Agent Prompts, Infra Invariants
### Backend (city-service)
- Node Registry + Self-Healing API (migration 039)
- Improved get_all_nodes() with robust fallback for node_registry/node_cache
- Agent Prompts Runtime API for DAGI Router integration
- DAGI Router Audit endpoints (phantom/stale detection)
- Node Agents API (Guardian/Steward)
- Node metrics extended (CPU/GPU/RAM/Disk)

### Frontend (apps/web)
- Node Directory with improved error handling
- Node Cabinet with metrics cards
- DAGI Router Card component
- Node Metrics Card component
- useDAGIAudit hook

### Scripts
- check-invariants.py - deploy verification
- node-bootstrap.sh - node self-registration
- node-guardian-loop.py - continuous self-healing
- dagi_agent_audit.py - DAGI audit utility

### Migrations
- 034: Agent prompts seed
- 035: Agent DAGI audit
- 036: Node metrics extended
- 037: Node agents complete
- 038: Agent prompts full coverage
- 039: Node registry self-healing

### Tests
- test_infra_smoke.py
- test_agent_prompts_runtime.py
- test_dagi_router_api.py

### Documentation
- DEPLOY_CHECKLIST_2024_11_30.md
- Multiple TASK_PHASE docs
2025-11-30 13:52:01 -08:00

96 lines
4.3 KiB
SQL

-- Migration 036: Node Metrics Extended
-- Розширення node_cache метриками для Node Cabinet
-- ============================================================================
-- Розширити node_cache полями метрик
-- ============================================================================
-- CPU метрики
ALTER TABLE node_cache ADD COLUMN IF NOT EXISTS cpu_model text;
ALTER TABLE node_cache ADD COLUMN IF NOT EXISTS cpu_cores integer DEFAULT 0;
ALTER TABLE node_cache ADD COLUMN IF NOT EXISTS cpu_usage numeric(5,2) DEFAULT 0;
-- GPU метрики
ALTER TABLE node_cache ADD COLUMN IF NOT EXISTS gpu_model text;
ALTER TABLE node_cache ADD COLUMN IF NOT EXISTS gpu_vram_total integer DEFAULT 0; -- MB
ALTER TABLE node_cache ADD COLUMN IF NOT EXISTS gpu_vram_used integer DEFAULT 0; -- MB
-- RAM метрики
ALTER TABLE node_cache ADD COLUMN IF NOT EXISTS ram_total integer DEFAULT 0; -- MB
ALTER TABLE node_cache ADD COLUMN IF NOT EXISTS ram_used integer DEFAULT 0; -- MB
-- Disk метрики
ALTER TABLE node_cache ADD COLUMN IF NOT EXISTS disk_total integer DEFAULT 0; -- MB
ALTER TABLE node_cache ADD COLUMN IF NOT EXISTS disk_used integer DEFAULT 0; -- MB
-- Agent counts
ALTER TABLE node_cache ADD COLUMN IF NOT EXISTS agent_count_router integer DEFAULT 0;
ALTER TABLE node_cache ADD COLUMN IF NOT EXISTS agent_count_system integer DEFAULT 0;
-- Heartbeat
ALTER TABLE node_cache ADD COLUMN IF NOT EXISTS last_heartbeat timestamptz;
-- DAGI Router URL (для інтеграції)
ALTER TABLE node_cache ADD COLUMN IF NOT EXISTS dagi_router_url text;
-- ============================================================================
-- Оновити існуючі ноди базовими даними
-- ============================================================================
-- NODE1: Hetzner GEX44
UPDATE node_cache SET
cpu_model = 'AMD Ryzen 9 5950X',
cpu_cores = 16,
gpu_model = 'RTX 4090',
gpu_vram_total = 24576, -- 24GB
ram_total = 131072, -- 128GB
disk_total = 3840000, -- ~3.8TB
dagi_router_url = 'http://localhost:9102',
last_heartbeat = NOW()
WHERE node_id = 'node-1-hetzner-gex44';
-- NODE2: MacBook Pro M4 Max
UPDATE node_cache SET
cpu_model = 'Apple M4 Max',
cpu_cores = 16,
gpu_model = 'Apple M4 Max GPU',
gpu_vram_total = 40960, -- 40GB (unified memory)
ram_total = 65536, -- 64GB
disk_total = 1024000, -- 1TB
dagi_router_url = 'http://localhost:9102',
last_heartbeat = NOW()
WHERE node_id = 'node-2-macbook-m4max';
-- ============================================================================
-- Індекси для метрик
-- ============================================================================
CREATE INDEX IF NOT EXISTS idx_node_cache_last_heartbeat
ON node_cache(last_heartbeat DESC);
-- ============================================================================
-- Коментарі
-- ============================================================================
COMMENT ON COLUMN node_cache.cpu_model IS 'CPU model name';
COMMENT ON COLUMN node_cache.cpu_cores IS 'Number of CPU cores';
COMMENT ON COLUMN node_cache.cpu_usage IS 'Current CPU usage percentage (0-100)';
COMMENT ON COLUMN node_cache.gpu_model IS 'GPU model name';
COMMENT ON COLUMN node_cache.gpu_vram_total IS 'Total GPU VRAM in MB';
COMMENT ON COLUMN node_cache.gpu_vram_used IS 'Used GPU VRAM in MB';
COMMENT ON COLUMN node_cache.ram_total IS 'Total RAM in MB';
COMMENT ON COLUMN node_cache.ram_used IS 'Used RAM in MB';
COMMENT ON COLUMN node_cache.disk_total IS 'Total disk space in MB';
COMMENT ON COLUMN node_cache.disk_used IS 'Used disk space in MB';
COMMENT ON COLUMN node_cache.agent_count_router IS 'Number of agents in DAGI Router config';
COMMENT ON COLUMN node_cache.agent_count_system IS 'Number of agents in database (system)';
COMMENT ON COLUMN node_cache.last_heartbeat IS 'Last heartbeat timestamp from node';
COMMENT ON COLUMN node_cache.dagi_router_url IS 'URL of DAGI Router on this node';
-- ============================================================================
-- Результат
-- ============================================================================
SELECT 'Migration 036 completed: Node metrics fields added' AS result;