package records

import (
	"log"

	"github.com/nexuscrm/kernel/pkg/schema"
	"github.com/nexuscrm/kernel/pkg/schemacatalog"
)

// managedTableDefinitions returns the platform-managed system table
// definitions sourced from the kernel schema catalog.
//
// It is a thin records-local adapter over the error-returning
// schemacatalog.ManagedTableDefinitions(): the kernel home returns
// (defs, error), whereas every records call site historically consumed the
// fail-fast bootstrap.GetManagedTableDefinitions() shape (a bare slice that
// terminated the process on a parse/guard error). Wrapping the error in a
// log.Fatalf here preserves that exact fail-fast contract with zero signature
// ripple at the call sites — the parse never fails with the shipped embedded
// JSON, so the fatal branch is a defensive invariant, not a live path.
func managedTableDefinitions() []schema.TableDefinition {
	defs, err := schemacatalog.ManagedTableDefinitions()
	if err != nil {
		log.Fatalf("managed table definitions: %v", err)
	}
	return defs
}
