feat(foundation): FOUNDATION_UPDATE implementation

## Documentation (20 files)
- DAARION Ontology Core v1 (Agent → MicroDAO → Node → District)
- User Onboarding & Identity Layer (DAIS)
- Data Model UPDATE, Event Catalog, Governance & Permissions
- Rooms Layer, City/MicroDAO/Agents/Nodes Interface Architecture
- Helper files: ontology-summary, lifecycles, event-schemas

## Database Migration (027)
- DAIS tables: dais_identities, dais_emails, dais_wallets, dais_keys
- agent_assignments table for Assignment Layer
- rooms table for Rooms Layer
- event_outbox for NATS event delivery
- New enums: agent_role, microdao_type, node_kind, node_status, etc.
- Updated agents, microdaos, nodes tables with ontology fields

## Backend
- DAIS service & routes (/api/v1/dais/*)
- Assignment service & routes (/api/v1/assignments/*)
- Domain types for DAIS and Ontology

## Frontend
- Ontology types (Agent, MicroDAO, Node, DAIS, Assignments)
- API clients for DAIS and Assignments
- UI components: DaisProfileCard, AssignmentsPanel, OntologyBadge

Non-breaking update - all existing functionality preserved.
This commit is contained in:
Apple
2025-11-29 15:24:38 -08:00
parent deeaf26b0b
commit 7b91c8e83c
43 changed files with 5733 additions and 47 deletions

View File

@@ -0,0 +1,93 @@
/**
* DAIS - DAARION Autonomous Identity System
* Based on: docs/foundation/DAARION_Identity_And_Access_Draft_v1.md
*/
// Trust levels for DAIS identity
export type DaisTrustLevel = 'guest' | 'agent' | 'verified' | 'orchestrator' | 'operator';
// DAIS Identity
export interface DaisIdentity {
id: string;
did: string; // format: did:daarion:<uuid>
defaultEmail?: string;
defaultWallet?: string;
matrixHandle?: string; // format: @<agent_id>:matrix.daarion.city
trustLevel: DaisTrustLevel;
metadata: Record<string, unknown>;
createdAt: Date;
updatedAt: Date;
}
// DAIS Email identity
export interface DaisEmail {
id: string;
daisId: string;
email: string;
verified: boolean;
verifiedAt?: Date;
createdAt: Date;
}
// DAIS Wallet identity
export interface DaisWallet {
id: string;
daisId: string;
walletAddress: string;
network: 'evm' | 'ton' | 'solana';
verified: boolean;
verifiedAt?: Date;
createdAt: Date;
}
// DAIS Key types
export type DaisKeyType = 'ed25519' | 'x25519' | 'secp256k1';
// DAIS Public Key
export interface DaisKey {
id: string;
daisId: string;
keyType: DaisKeyType;
publicKey: string;
createdAt: Date;
revokedAt?: Date;
}
// Full DAIS profile with all identities
export interface DaisProfile {
identity: DaisIdentity;
emails: DaisEmail[];
wallets: DaisWallet[];
keys: DaisKey[];
}
// Create DAIS identity request
export interface CreateDaisRequest {
email?: string;
walletAddress?: string;
network?: 'evm' | 'ton' | 'solana';
}
// Verify email request
export interface VerifyEmailRequest {
daisId: string;
email: string;
otp: string;
}
// Connect wallet request (SIWE)
export interface ConnectWalletRequest {
daisId: string;
walletAddress: string;
network: 'evm' | 'ton' | 'solana';
signature: string;
message: string;
}
// DAIS creation result
export interface DaisCreationResult {
identity: DaisIdentity;
agentId: string;
matrixHandle: string;
}

View File

@@ -0,0 +1,285 @@
/**
* DAARION Ontology Types
* Based on: docs/foundation/DAARION_Ontology_Core_v1.md
*
* Core hierarchy: Agent → MicroDAO → Node → District
*/
// ============================================================================
// AGENT
// ============================================================================
export type AgentRole = 'regular' | 'orchestrator';
export type ServiceScope = 'microdao' | 'district' | 'city';
export interface Agent {
id: string;
daisIdentityId?: string;
homeMicrodaoId: string; // Required by ontology
homeNodeId?: string;
role: AgentRole;
serviceScope?: ServiceScope;
// Existing fields
name: string;
kind: string;
isOrchestrator: boolean;
isPublic: boolean;
visibilityScope?: string;
primaryMicrodaoId?: string;
nodeId?: string;
metadata: Record<string, unknown>;
createdAt: Date;
updatedAt: Date;
}
export type AgentType =
| 'personal' // User's personal agent
| 'service' // Service/infrastructure agent
| 'core-city' // DAARION108 - citywide agents
| 'orchestrator'; // Can create MicroDAO
// ============================================================================
// MICRODAO
// ============================================================================
export type MicrodaoType = 'root' | 'standard' | 'district';
export interface Microdao {
id: string;
slug: string;
name: string;
description?: string;
type: MicrodaoType;
primaryOrchestratorAgentId: string; // Required by ontology
parentMicrodaoId?: string; // For districts
walletAddress?: string;
// Existing fields
ownerAgentId?: string;
orchestratorAgentId?: string;
isPlatform: boolean;
isActive: boolean;
isPublic: boolean;
district?: string;
metadata: Record<string, unknown>;
createdAt: Date;
updatedAt: Date;
}
// ============================================================================
// NODE
// ============================================================================
export type NodeKind =
| 'smartphone'
| 'laptop'
| 'edge'
| 'datacenter'
| 'iot'
| 'gpu-cluster';
export type NodeStatus =
| 'provisioning'
| 'active'
| 'draining'
| 'retired';
export interface NodeCapabilities {
cpu?: string;
ram?: string;
gpu?: {
name: string;
vram?: string;
unified_memory_gb?: number;
};
network?: {
up: string;
down: string;
};
sensors?: string[];
modules?: Array<{
id: string;
status: string;
port?: number;
}>;
}
export interface Node {
id: string;
nodeId: string;
name: string;
microdaoId: string; // Required by ontology
kind: NodeKind;
status: NodeStatus;
capabilities: NodeCapabilities;
lastHeartbeat?: Date;
// Existing fields
gpu?: Record<string, unknown>;
modules?: Array<Record<string, unknown>>;
roles?: string[];
version?: string;
metadata: Record<string, unknown>;
createdAt: Date;
updatedAt: Date;
}
// ============================================================================
// DISTRICT (MicroDAO with type='district')
// ============================================================================
export interface District extends Microdao {
type: 'district';
childMicrodaos: Microdao[];
nodePool: Node[];
}
// ============================================================================
// AGENT ASSIGNMENT
// ============================================================================
export type AssignmentScope = 'microdao' | 'district' | 'city';
export type AssignmentRole = 'advisor' | 'security' | 'mentor' | 'ops' | 'core-team' | 'member';
export interface AgentAssignment {
id: string;
agentId: string;
targetMicrodaoId: string;
scope: AssignmentScope;
role: AssignmentRole;
startTs: Date;
endTs?: Date;
metadata: Record<string, unknown>;
createdAt: Date;
}
export interface CreateAssignmentRequest {
agentId: string;
targetMicrodaoId: string;
scope: AssignmentScope;
role: AssignmentRole;
metadata?: Record<string, unknown>;
}
export interface EndAssignmentRequest {
assignmentId: string;
endTs?: Date;
}
// ============================================================================
// ROOMS LAYER
// ============================================================================
export type RoomType =
| 'city-room'
| 'dao-room'
| 'front-room'
| 'agent-room'
| 'event-room'
| 'district-room';
export type RoomVisibility =
| 'private'
| 'members'
| 'public-city'
| 'public-global';
export type SpaceScope = 'city' | 'microdao' | 'district';
export interface Room {
id: string;
ownerType: 'city' | 'microdao' | 'district' | 'agent';
ownerId: string;
type: RoomType;
spaceScope: SpaceScope;
visibility: RoomVisibility;
name: string;
description?: string;
matrixRoomId?: string;
isPortal: boolean;
portalTargetMicrodaoId?: string;
mapX?: number;
mapY?: number;
zone?: string;
meshId?: string;
primaryAgentId?: string;
teamAgentIds?: string[];
metadata: Record<string, unknown>;
createdAt: Date;
updatedAt: Date;
}
// ============================================================================
// EVENTS (for NATS)
// ============================================================================
export interface DomainEvent {
eventId: string;
timestamp: string; // ISO8601
version: string;
subject: string;
payload: Record<string, unknown>;
}
export interface AgentPromotedEvent extends DomainEvent {
subject: 'dagion.agent.promoted_to_orchestrator';
payload: {
agentId: string;
timestamp: string;
};
}
export interface MicrodaoCreatedEvent extends DomainEvent {
subject: 'dagion.microdao.created';
payload: {
microdaoId: string;
primaryOrchestratorAgentId: string;
type: MicrodaoType;
parentMicrodaoId?: string;
timestamp: string;
};
}
export interface NodeRegisteredEvent extends DomainEvent {
subject: 'dagion.node.registered';
payload: {
nodeId: string;
microdaoId: string;
nodeKind: NodeKind;
capabilities: NodeCapabilities;
timestamp: string;
};
}
export interface MicrodaoPromotedToDistrictEvent extends DomainEvent {
subject: 'dagion.microdao.promoted_to_district';
payload: {
microdaoId: string;
promotedByAgentId: string;
parentMicrodaoId?: string;
timestamp: string;
};
}
export interface AssignmentCreatedEvent extends DomainEvent {
subject: 'dagion.agent.assignment_created';
payload: {
assignmentId: string;
agentId: string;
targetMicrodaoId: string;
scope: AssignmentScope;
role: string;
timestamp: string;
};
}
export interface AssignmentEndedEvent extends DomainEvent {
subject: 'dagion.agent.assignment_ended';
payload: {
assignmentId: string;
agentId: string;
timestamp: string;
};
}