package tools import "strings" const EnvSendMessageProductionEnabled = "ISPHERE_SEND_PRODUCTION_ENABLED" type SendMessageGatePolicy struct { ProductionAllowed bool ReasonCode string ReasonMessage string EvidenceGatePass bool ConnectorConfigured bool } func LoadSendMessageGatePolicy(env map[string]string, evidenceGatePass bool, connectorConfigured bool) SendMessageGatePolicy { policy := SendMessageGatePolicy{ EvidenceGatePass: evidenceGatePass, ConnectorConfigured: connectorConfigured, } if !sendMessageProductionEnabled(env) { policy.ReasonCode = "send_disabled_by_default" policy.ReasonMessage = "production send is disabled by default; set ISPHERE_SEND_PRODUCTION_ENABLED=1 only after the evidence and connector gates pass" return policy } if !evidenceGatePass { policy.ReasonCode = "send_evidence_missing" policy.ReasonMessage = "production send is blocked until dynamic observation, idempotency audit, and one approved sandbox send gate pass" return policy } if !connectorConfigured { policy.ReasonCode = "send_connector_missing" policy.ReasonMessage = "production send is blocked because no validated send connector is configured" return policy } policy.ProductionAllowed = true policy.ReasonCode = "send_gate_passed" policy.ReasonMessage = "production send gate passed" return policy } func sendMessageProductionEnabled(env map[string]string) bool { if env == nil { return false } value := strings.TrimSpace(strings.ToLower(env[EnvSendMessageProductionEnabled])) return value == "1" || value == "true" || value == "yes" }