model

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package model emits the same-package descriptor bootstrap used by generated Golem model code. Emission is deliberately in-memory so callers can pass the returned files directly to go/packages through an Overlay.

Index

Constants

View Source
const (
	// DefaultGolemImportPath is the public package imported by generated source.
	DefaultGolemImportPath = "github.com/eleven-am/golem/go/golem"
	// BootstrapFilename is the stable filename used for every emitted package.
	BootstrapFilename = "zz_golem_bootstrap.go"
	// FinalFilename is the manifest-owned descriptor file emitted after typed discovery.
	FinalFilename = "zz_golem_models.gen.go"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	ImportPath  string
	PackageName string
	Path        string
	Source      []byte
}

File is one generated, formatted Go source file.

type FinalStamp

type FinalStamp struct {
	GenerationDigest   string
	GeneratorVersion   string
	TemplateABIVersion string
}

type Manifest

type Manifest struct {
	Symbols []Symbol
}

Manifest is sorted by package, namespace, name, and kind.

type PackageSpec

type PackageSpec struct {
	ImportPath  string
	PackageName string
	Directory   string
}

PackageSpec supplies the Go package information that is intentionally absent from the canonical compiler IR. Directory may be empty when callers only need source; set it when Result.Overlay will be passed to go/packages.

type Request

type Request struct {
	Compilation     ir.CompilationIR
	Packages        []PackageSpec
	GolemImportPath string
	FinalStamp      *FinalStamp
}

Request describes one deterministic bootstrap emission.

type Result

type Result struct {
	Files    []File
	Manifest Manifest
}

Result contains generated files and their stable symbol map.

func Emit

func Emit(request Request) (Result, error)

Emit produces one deterministic same-package bootstrap file per model package. It never writes source to disk.

func (Result) Overlay

func (r Result) Overlay() map[string][]byte

Overlay returns a fresh path-to-source map suitable for packages.Config.

type Symbol

type Symbol struct {
	PackagePath string
	Namespace   string
	Name        string
	Kind        SymbolKind

	ModelID    ir.ModelID
	FieldID    ir.FieldID
	RelationID ir.RelationID
	KeyID      ir.KeyID
	Fields     []ir.FieldID
}

Symbol maps a generated Go symbol back to the canonical stable identifier consumed by later typed interpretation. Namespace is empty for package-level symbols; Name is the member name for namespace fields.

type SymbolKind

type SymbolKind string

SymbolKind classifies a generated public symbol.

const (
	SymbolModelDescriptor SymbolKind = "model_descriptor"
	SymbolNamespace       SymbolKind = "namespace"
	SymbolField           SymbolKind = "field"
	SymbolRelation        SymbolKind = "relation"
	SymbolSelector        SymbolKind = "selector"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL