package tenantoverlay

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

// CONTROL-PLANE SEAM — control-plane imports bootstrap = ZERO (W5/S7).
//
// These vars invert tenantoverlay's behavioral dependency on internal/bootstrap
// for the AutoNumberSeeder (SeedAutoNumberCounters) and SchemaProvisioner
// (ReconcileTableColumns) port functions: pack.go calls the port vars instead of
// bootstrap directly. tenantoverlay no longer references internal/bootstrap; the
// concrete impls are constructed and injected at the composition roots
// (pkg/serverruntime via WireControlplaneSeams, internal/setupcmd, CP test
// wiring) via the setters below — never defaulted here.
//
// Mandatory injection: every entry point that runs the tenant-overlay apply path
// MUST wire both ports first, or they are nil.
var autoNumberSeeder cruntimeports.AutoNumberSeeder

// SetAutoNumberSeeder injects the concrete AutoNumberSeeder at init time (composition root only).
func SetAutoNumberSeeder(p cruntimeports.AutoNumberSeeder) {
	if p == nil {
		return
	}
	autoNumberSeeder = p
}

var schemaProvisioner dbruntimeports.SchemaProvisioner

// SetSchemaProvisioner injects the concrete SchemaProvisioner at init time (composition root only).
func SetSchemaProvisioner(p dbruntimeports.SchemaProvisioner) {
	if p == nil {
		return
	}
	schemaProvisioner = p
}
