package layoutbundlekeyv1

const (
	// BundleKeyVersion versions and domain-separates the standalone portable
	// bundle-slot tuple grammar.
	BundleKeyVersion = "nexuscrm.layout-bundle-key/v1"
	// TenantNamespaceIDGrammarVersion names the tenant owner-namespace grammar
	// pinned by BundleKeyVersion. It is not an additional tuple field.
	TenantNamespaceIDGrammarVersion = "nexuscrm.tenant-namespace-id/v1"
	// RequiredBundleKeySetVersion versions and domain-separates the canonical
	// required-slot-set grammar.
	RequiredBundleKeySetVersion = "nexuscrm.required-layout-bundle-key-set/v1"
	// SystemSlotOwnerNamespace is the only valid system owner namespace in v1.
	SystemSlotOwnerNamespace = "io.nexuscrm.system"
	// LocalComponentKeyPrefix separates opaque slot identities from content
	// digests and App component identities.
	LocalComponentKeyPrefix = "key256:"

	// MaxSlotOwnerNamespaceBytes is the complete namespace byte ceiling.
	MaxSlotOwnerNamespaceBytes = 128
	// MaxSlotOwnerNamespaceSegmentBytes is each dot-segment byte ceiling.
	MaxSlotOwnerNamespaceSegmentBytes = 63
	// MaxRequiredBundleKeys is the maximum complete candidate set size.
	MaxRequiredBundleKeys = 100_000
	// MaxCanonicalRequiredBundleKeySetBytes is the canonical set byte ceiling.
	MaxCanonicalRequiredBundleKeySetBytes = 32 << 20
)

// SlotOwnerKind separates App, tenant, and platform-system slot authorities.
type SlotOwnerKind string

const (
	SlotOwnerKindApp    SlotOwnerKind = "app"
	SlotOwnerKindTenant SlotOwnerKind = "tenant"
	SlotOwnerKindSystem SlotOwnerKind = "system"
)

// LocalComponentKey is a separately minted opaque 256-bit slot identity. It
// is intentionally not interchangeable with the string returned by
// appauthority.ComponentID.
type LocalComponentKey string

// BundleKey is the complete portable identity of one stable layout-bundle
// slot. LocalComponentKey is an opaque key256 value, not a content digest.
type BundleKey struct {
	SlotOwnerKind      SlotOwnerKind
	SlotOwnerNamespace string
	LocalComponentKey  LocalComponentKey
}

// RequiredBundleKeySet is one complete Catalog candidate's required slot set.
// Version must equal RequiredBundleKeySetVersion, BundleKeys must be present,
// and input order is not semantic.
type RequiredBundleKeySet struct {
	Version    string
	BundleKeys []BundleKey
}
