package packs

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

// CONTROL-PLANE SEAM — control-plane imports bootstrap = ZERO (W5/S7).
//
// fieldProvenanceInitializer is the packs package's field-provenance init port.
// RegisterRuntimeMetadataForPacks / RegisterL0RuntimeMetadata 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 SetFieldProvenanceInitializer — 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 a register call site MUST
// wire this port first, or it is nil.
var fieldProvenanceInitializer runtimeports.FieldProvenanceInitializer

// SetFieldProvenanceInitializer injects the packs field-provenance init 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 runtime-metadata register path.
func SetFieldProvenanceInitializer(p runtimeports.FieldProvenanceInitializer) {
	if p == nil {
		return
	}
	fieldProvenanceInitializer = p
}
