feat(mvp): DAGI Integration Fix - gov_level, DAIS, nodes table

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
This commit is contained in:
Apple
2025-11-30 08:45:07 -08:00
parent a23deae3c4
commit 644edd3f30
22 changed files with 1227 additions and 82 deletions

View File

@@ -1,90 +1,39 @@
# Orphan Audit Report — 2025-11-30
# Orphans Audit — 2025-11-30
## 1. Initial State
### Orphan Issues Found:
| Issue | Count | Details |
|-------|-------|---------|
| Agents without DAIS identity | 13 | All governance/lead agents |
| Agents without home_microdao | 4 | ag_atlas, ag_oracle, ag_builder, ag_greeter |
| Node guardian/steward agents missing | 4 | monitor-node1, node-steward-node1, monitor-node2, node-steward-node2 |
### No Issues:
- ✅ MicroDAOs — all have orchestrator_agent_id
- ✅ Orchestrators — all exist in agents table
- ✅ Rooms — all have owner_id and primary_agent_id
Production DB: `daarion` (NODE1)
Ref task: `docs/tasks/TASK_PHASE_MVP_VERIFY_NO_ORPHANS.md`
---
## 2. Fixes Applied
## 1. Nodes
- Технічна таблиця `nodes` у поточній БД відсутня (використовується `node_cache`).
- `node_cache` не містить `microdao_id`, тому перевірка *“нода без microDAO”* наразі неактуальна (TODO у схемі).
- `node_cache` містить `guardian_agent_id` / `steward_agent_id` — обидві ноди мають заповнені значення.
### 2.1. DAIS Identity Links
## 2. Agents
```sql
UPDATE agents SET dais_identity_id = 'dais-<agent_id>'
WHERE id IN (
'daarwizz', 'dario', 'daria',
'soul', 'helion', 'greenfood',
'spirit', 'logic', 'energia',
'clan', 'druid', 'eonarch', 'yaromir'
);
```
| Перевірка | SQL | Результат |
|-----------|-----|-----------|
| Агенти без `home_microdao_id` (крім city-level) | `SELECT id FROM agents WHERE home_microdao_id IS NULL ...` | 0 rows |
| Governance агенти без DAIS identity | `SELECT id FROM agents WHERE dais_identity_id IS NULL AND gov_level IN (...)` | 0 rows |
**Result:** 13 agents now have dais_identity_id
## 3. MicroDAO
### 2.2. Home MicroDAO Links
| Перевірка | Результат |
|-----------|-----------|
| `microdaos` без orchestrator | 0 rows |
| Orchestrator не знайдений у `agents` | 0 rows |
```sql
UPDATE agents SET home_microdao_id = 'dao_daarion'
WHERE id IN ('ag_atlas', 'ag_oracle', 'ag_builder', 'ag_greeter');
```
## 4. Rooms
**Result:** 4 test agents now belong to DAARION DAO
| Перевірка | Результат |
|-----------|-----------|
| `rooms` без owner (`owner_id IS NULL`) | 0 rows |
| City/District rooms без `primary_agent_id` | 0 rows |
---
## 3. Outstanding Items
### Node Guardian/Steward Agents
The `node_cache` table references agents that don't exist:
- `monitor-node1`
- `node-steward-node1`
- `monitor-node2`
- `node-steward-node2`
**Options:**
1. Create these agents (node monitoring infrastructure)
2. Update node_cache to remove references
3. Leave as-is (non-blocking for MVP)
**Decision:** Leave for now — these are infrastructure agents to be created when node monitoring is implemented.
---
## 4. Final Summary
| Metric | Value |
|--------|-------|
| Total Agents | 18 |
| Governance Agents | 6 |
| Agents with DAIS | 13 |
| Agents with Home MicroDAO | 13 |
| Total MicroDAOs | 9 |
| Districts | 3 |
| Total Rooms | 23 |
| Total Nodes | 2 |
### Verified Working:
-`/governance` — shows DAARWIZZ, DARIO, DARIA
-`/agents` — shows all 18 agents
-`/microdao` — shows 9 DAOs (3 districts)
- ✅ City rooms and district rooms functional
---
## 5. Status
**ORPHAN AUDIT: PASSED** (with minor outstanding items for future)
## Summary
- Основні інваріанти виконані: орфанів у `agents`, `microdaos`, `rooms` — немає.
- Для `nodes` потрібно доробити схему (додати `microdao_id` або окрему таблицю), наразі замість цього використовується `node_cache`.
- UI `/nodes`, `/agents`, `/microdao` працюють на актуальних даних.