package domain import "time" // Approval is a short-TTL signed grant for a gated action. type Approval struct { EntityID UUID SubjectEntityID UUID Action string RiskClass string Kind string Payload map[string]any Status string TokenHash string ExpiresAt time.Time DecidedAt *time.Time DecidedBy UUID CreatedAt time.Time } // Approval statuses. const ( ApprovalPending = "pending" ApprovalApproved = "approved" ApprovalDenied = "denied" ApprovalExpired = "expired" ApprovalRevoked = "revoked" ) // Approval kinds. const ( ApprovalKindExecution = "execution" ApprovalKindPolicyChange = "policy-change" ApprovalKindPatternActivation = "pattern-activation" ) // CheckDef defines a probe (R3-7: probes as data, not code). type CheckDef struct { EntityID UUID TargetID UUID TargetType string Kind string Config map[string]any IntervalS int TimeoutS int Zone string Enabled bool UpdatedAt time.Time } // Check kinds. const ( CheckHTTP = "http" CheckTCP = "tcp" CheckDisk = "disk" CheckCertExpiry = "cert-expiry" CheckDrift = "drift" CheckSSHScript = "ssh-script" ) // EntityStatus is the current health of an entity (R3-6: replaces state_snapshots). type EntityStatus struct { EntityID UUID Health string LastCheckAt *time.Time Details map[string]any UpdatedAt time.Time } // Health values. const ( HealthHealthy = "healthy" HealthDegraded = "degraded" HealthDown = "down" HealthUnknown = "unknown" ) // RiskClass is the four-level safety model. type RiskClass struct { Name string Description string ApprovalRequired string AutonomyAllowed bool } // Risk class names. const ( RiskReadOnly = "read_only" RiskReversibleLow = "reversible_low" RiskConfigMutation = "config_mutation" RiskDestructive = "destructive" ) // ApprovalRule maps (entity_type, action) → risk_class + autonomy. type ApprovalRule struct { ID UUID EntityType string Action string RiskClass string AutonomyLevel string ScopeEntity UUID Version int } // Autonomy levels. const ( AutonomyAuto = "auto" AutonomyEscalate = "escalate" AutonomyNever = "never" )