package packs

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

// CONTROL-PLANE SEAM — control-plane imports bootstrap = ZERO (W5/S7).
//
// autoNumberSeeder is the control-plane packs autonumber seed/verify port.
// The source-backed autonumber component (apply/verify) and the platform
// declared-seed registration in bootstrap_shim.go call this port instead of
// internal/bootstrap 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
// SetAutoNumberSeeder — never defaulted here. The packs package no longer
// references internal/bootstrap for these four functions; the concrete impl is
// owned by the backend-side wiring entrypoint
// (serverruntime.WireControlplaneSeams).
//
// Mandatory injection: every entry point that runs the autonumber apply/verify
// path or init-time declared-seed registration MUST wire this port first, or it
// is nil.
var autoNumberSeeder runtimeports.AutoNumberSeeder

// SetAutoNumberSeeder injects the control-plane packs autonumber seed/verify
// 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 control-plane apply path.
func SetAutoNumberSeeder(p runtimeports.AutoNumberSeeder) {
	if p == nil {
		return
	}
	autoNumberSeeder = p
}
