package governance import "time" // ServiceTarget is the operator-level 「服务配置」 target: the console endpoints // plus the production knowledge base and its tenant. It exists so the save path // can ask the real endpoint whether the typed values exist, instead of storing // two numbers nobody ever consumed. type ServiceTarget struct { TestBaseURL string ProductionBaseURL string ProductionTenantID string ProductionKnowledgeBaseID string } // Statuses of a whole service-target verification. const ( // ServiceTargetVerified: the endpoint answered and every configured value is // really there. ServiceTargetVerified = "verified" // ServiceTargetMissing: the endpoint answered and the knowledge base (or a // knowledge base of that tenant) is NOT there. Blocking. ServiceTargetMissing = "missing" // ServiceTargetTenantMismatch: the knowledge base exists but belongs to a // different tenant than the configured production ID. Blocking. ServiceTargetTenantMismatch = "tenant_mismatch" // ServiceTargetUnauthorized: the endpoint answered 401/403 — a credential // problem, not proof about the values. Advisory. ServiceTargetUnauthorized = "unauthorized" // ServiceTargetUnreachable: network, timeout or server error. Advisory. ServiceTargetUnreachable = "unreachable" // ServiceTargetCannotVerify: nothing to ask with (no endpoint, no key file, // unusable address). Advisory. ServiceTargetCannotVerify = "cannot_verify" // ServiceTargetNotConfigured: both IDs are empty, so there is nothing to // verify and nothing was. ServiceTargetNotConfigured = "not_configured" ) // Statuses of a single endpoint probe. const ( ServiceEndpointReachable = "reachable" ServiceEndpointUnauthorized = "unauthorized" ServiceEndpointUnavailable = "unavailable" ServiceEndpointNotConfigured = "not_configured" ) // ServiceEndpointStatus is one endpoint's live reachability, as measured during // the save. Both endpoints are probed on every save so the console never claims // 「已配置」without a read behind it. type ServiceEndpointStatus struct { Status string `json:"status"` Message string `json:"message"` } // ServiceTargetVerification is the honest outcome of the real read behind a // 「服务配置」save. Blocked is true only for a definitive negative answer — the // endpoint answered and the knowledge base / tenant is provably absent. A flaky, // unauthorized or unconfigured endpoint only warns: an outage must never stop an // operator from fixing the configuration. type ServiceTargetVerification struct { Status string `json:"status"` Message string `json:"message"` Blocked bool `json:"blocked"` KnowledgeBaseName string `json:"knowledge_base_name,omitempty"` ObservedTenantID string `json:"observed_tenant_id,omitempty"` TestEndpoint ServiceEndpointStatus `json:"test_endpoint"` ProductionEndpoint ServiceEndpointStatus `json:"production_endpoint"` CheckedAt time.Time `json:"checked_at"` }