package ports import ( "context" "time" "github.com/dtoro/oikos/internal/core/domain" ) // Event is a domain occurrence worth publishing (SSE + events table). The // events adapter maps it to the persistence/SSE shapes. type Event struct { Type string // e.g. "execution.completed", "health.changed" Severity string // "info", "warning", "critical" Source string // "api", "mcp", "scheduler", "webhook" EntityID domain.UUID Data map[string]any Ts time.Time } // EventPublisher fans events out to subscribers and persists them. The // events adapter owns the SSE broker, the events table, and the dedicated // LISTEN/NOTIFY connection. type EventPublisher interface { Publish(ctx context.Context, event Event) error } // AuditEntry is an append-only audit-log record. type AuditEntry struct { ActorType string // "agent", "operator", "system" ActorLabel string Action string EntityID domain.UUID Details map[string]any Ts time.Time } // AuditRepository appends audit records and events. Entries are usually // carried inside other repositories' input structs so they commit in the // same transaction (ยง3.6 of the plan); the standalone methods serve // read-path actions that audit without another aggregate write. type AuditRepository interface { AppendAudit(ctx context.Context, entries []AuditEntry) error AppendEvent(ctx context.Context, events []Event) error }