Enforce 10j's verified gaps (schema-hardening change): - Migration 00010: partial unique indexes for one default pool and one primary assignment per workspace, plus CHECKs pinning pool/provider/subscription vocabularies and provider lifecycle timestamps. - Workspace creation shares a transactional provisioning function; extension validates its target pool; last-tier deletion of a defaulted ladder is guarded; signup completes plan-less on a broken ladder. - Boot asserts integration slug parity and validates declared config enums; Stripe invoice amounts are range-checked; domain cancellation runs a final evidence probe; rule authoring is additive-only.
30 lines
1.2 KiB
Go
30 lines
1.2 KiB
Go
package integration
|
|
|
|
import "fmt"
|
|
|
|
// AssertSlugMatch enforces design D7 (schema-hardening): every integration
|
|
// declares its slug twice — once from its own Slug() method, once in the
|
|
// Slug field of the manifest its Provider() returns — and nothing but this
|
|
// check enforces the two agree. A mismatch previously registered the
|
|
// provider under one slug while mounting its UI and settings under the
|
|
// other, silently splitting the operator Integrations page into a
|
|
// half-row (registry data, no settings) and a phantom row (settings, no
|
|
// registry data).
|
|
//
|
|
// codeSlug is the integration's Slug() value; manifest is the Manifest
|
|
// returned by that same integration's Provider().ProviderManifest(). Called
|
|
// from cmd/start.go's registry loop, before provider registration, so a
|
|
// mismatch fails boot instead of surfacing later as a UI defect.
|
|
func AssertSlugMatch(codeSlug string, manifest Manifest) error {
|
|
if codeSlug == manifest.Slug {
|
|
return nil
|
|
}
|
|
name := manifest.DisplayName
|
|
if name == "" {
|
|
name = codeSlug
|
|
}
|
|
return fmt.Errorf(
|
|
"integration %q: Slug() returns %q but its provider manifest declares slug %q; the two must match",
|
|
name, codeSlug, manifest.Slug)
|
|
}
|