package semanticreconcile

import (
	"fmt"
	"io/fs"

	rootassets "gitea.maximumdirect.net/eric/notarius/assets"
	"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
)

const (
	ResponseSchemaKey  = llm.ResponseSchemaKey("semantic_reconciliation_llm")
	ResponseSchemaID   = "notarius.generic.semantic_reconciliation.llm"
	ResponseSchemaName = "notarius_semantic_reconciliation_llm_v1"
	SchemaVersion      = "v1"
	SchemaAssetPath    = "schemas/semantic_reconciliation_llm.v1.json"
)

func assetFS() (fs.FS, error) {
	assets, err := fs.Sub(rootassets.FS(), "generic/normalize/deduplication")
	if err != nil {
		return nil, fmt.Errorf("scope semantic reconciliation assets: %w", err)
	}
	return assets, nil
}

// LoadResponseSchema returns the private request-local integer proposal
// contract. It is separate from every durable artifact schema.
func LoadResponseSchema() (llm.ResponseSchema, error) {
	assets, err := assetFS()
	if err != nil {
		return llm.ResponseSchema{}, err
	}
	return llm.LoadResponseSchema(assets, llm.ResponseSchemaDefinition{
		Key:       ResponseSchemaKey,
		ID:        ResponseSchemaID,
		Version:   SchemaVersion,
		Name:      ResponseSchemaName,
		AssetPath: SchemaAssetPath,
	})
}
