package packs

import (
	"github.com/nexuscrm/db/pkg/runtimeports"
)

// CONTROL-PLANE SEAM — control-plane imports bootstrap = ZERO (W5/S7).
//
// schemaProvisioner is the packs package's physical schema / DDL / reconcile
// port. The source-backed repair / object-spec / platform-core / live-oracle
// paths call this port instead of the internal/bootstrap functions directly, so
// the behavioral dependency is inverted: the concrete implementation is
// constructed and injected at the composition roots (pkg/serverruntime,
// internal/setupcmd, packs test wiring) via SetSchemaProvisioner — never
// defaulted here. The packs package no longer references internal/bootstrap; the
// concrete impl is owned by the backend-side wiring entrypoint
// (serverruntime.WireControlplaneSeams).
//
// Mandatory injection: every entry point that runs the repair/apply path MUST
// wire this port first, or it is nil.
//
// controlplane imports this packs package, so packs cannot reuse the
// controlplane seam (that would be an import cycle); it carries its own copy of
// the port var and setter, mirroring the field-provenance seam.
var schemaProvisioner runtimeports.SchemaProvisioner

// SetSchemaProvisioner injects the packs schema-provisioner port. Intended for
// the composition roots (pkg/serverruntime via WireControlplaneSeams,
// internal/setupcmd, packs test wiring), which construct the bootstrap
// implementation and inject it here so the concrete dependency is owned by the
// composition root rather than the packs apply path.
func SetSchemaProvisioner(p runtimeports.SchemaProvisioner) {
	if p == nil {
		return
	}
	schemaProvisioner = p
}
