package controlplane

import (
	"github.com/pingcap-inc/nexuscrm-contract/pkg/runtimeports"
)

// CONTROL-PLANE SEAM — control-plane imports bootstrap = ZERO (W5/S7).
//
// fieldProvenanceInitializer is the control-plane's field-provenance init port.
// The apply paths (operations_tenant_apply.go) 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, CP test wiring) via
// SetFieldProvenanceInitializer — never defaulted here. The control-plane 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 apply-tenant MUST wire this
// port before calling it, or it is nil.
var fieldProvenanceInitializer runtimeports.FieldProvenanceInitializer

// SetFieldProvenanceInitializer injects the control-plane field-provenance
// init port. Intended for the composition roots (pkg/serverruntime via
// WireControlplaneSeams, internal/setupcmd, CP test wiring), which construct
// the bootstrap implementation and inject it here so the concrete dependency is
// owned by the composition root rather than the control-plane apply path.
func SetFieldProvenanceInitializer(p runtimeports.FieldProvenanceInitializer) {
	if p == nil {
		return
	}
	fieldProvenanceInitializer = p
}
