Documentation
¶
Overview ¶
Package transcribe owns authored source parsing, canonical component assembly, component-graph SQL resource traversal, and generated package production. Typed per-source SQL expansion belongs to package sql.
Index ¶
- Constants
- Variables
- type CompileError
- type Compiler
- type ContractOptions
- type ContractTypeOverrides
- type CurrentBinding
- type Diagnostic
- type Discovery
- type GeneratedPackage
- type GeneratedProject
- type GenerationOptions
- type GenerationRequest
- type Generator
- type GoExecution
- type GoHandlerOptions
- type HandlerOptions
- type HandlerTarget
- type HookOptions
- type Options
- type PackageCompilation
- type Position
- type ProjectComponent
- type ProjectGeneration
- type ProjectManifest
- type ProjectMigrationComponent
- type ProjectMigrationReport
- type ProjectRoute
- type Request
- type Result
- type RuntimeContract
- type SchemaInspection
- type Severity
- type Source
- type SourceMap
- type Span
- type ValidationReport
- type Validator
- type VeltyHandlerOptions
- type WriteOperation
Constants ¶
const ( WritePost = handlerast.OperationPost WritePut = handlerast.OperationPut WritePatch = handlerast.OperationPatch )
Variables ¶
var ErrNilSource = errors.New("transcribe: nil source")
Functions ¶
This section is empty.
Types ¶
type CompileError ¶
type CompileError struct {
Cause error
Diagnostics []*Diagnostic
}
CompileError carries compiler diagnostics while preserving the parser error for errors.Is/errors.As classification.
func (*CompileError) Error ¶
func (e *CompileError) Error() string
func (*CompileError) Unwrap ¶
func (e *CompileError) Unwrap() error
type Compiler ¶
type Compiler struct{}
Compiler is the single authored-source orchestration entrypoint. Its body is intentionally narrow while the original preprocess and plan stages are ported behind this stable boundary.
func NewCompiler ¶
func NewCompiler() *Compiler
func (*Compiler) RuntimeContracts ¶
func (c *Compiler) RuntimeContracts(ctx context.Context, rootDir string, source *Source) (*RuntimeContract, error)
RuntimeContracts compiles authored DQL and materializes generated input and output reflect types for an ephemeral reader execution. rootDir must be a module root so #package destination authority is resolved consistently with ordinary transcription.
func (*Compiler) Transcribe ¶
Transcribe compiles one authored source under normalized options, emits its package artifacts, and loads the generated package.
type ContractOptions ¶
type ContractOptions string
ContractOptions controls contract ownership for one transcription.
const ( ContractsAuto ContractOptions = "auto" ContractsGenerated ContractOptions = "generated" ContractsLinked ContractOptions = "linked" )
type ContractTypeOverrides ¶
ContractTypeOverrides records only type names explicitly authored by DQL. Package-inherited settings are intentionally excluded so ownership decisions never need to infer provenance from equal strings.
type CurrentBinding ¶
type CurrentBinding = handlercompiler.CurrentBinding
type Diagnostic ¶
type Diagnostic struct {
Code string `json:"code"`
Severity Severity `json:"severity"`
Message string `json:"message"`
Hint string `json:"hint,omitempty"`
Path string `json:"path,omitempty"`
Span Span `json:"span"`
}
Diagnostic is transcribe compile feedback. It remains outside canonical spec because source spans and compiler hints are pipeline products.
func (*Diagnostic) Error ¶
func (d *Diagnostic) Error() string
func (*Diagnostic) IsError ¶
func (d *Diagnostic) IsError() bool
type Discovery ¶
type Discovery struct {
Const *constant.Values
// Workspace fixes source selection to a Go build when supplied.
Workspace *xmodule.Workspace
BaseDir string
ModuleDirs []string
Include []string
// TypeInclude loads package-level type authority without selecting those
// packages for component discovery or resource loading.
TypeInclude []string
Exclude []string
Connector string
Types *typecatalog.Catalog
ColumnRefiner *column.Refiner
// Registry is trusted compiled package authority. Selected source descriptors
// retain linked types so lifecycle methods and typed factories remain executable.
Registry *x.Registry
// Holders are build-linked component declarations for the packages selected
// by Include. They supply concrete Go contracts and factories without init
// registration; source scanning remains the discovery authority.
Holders []any
// RequireLinked rejects source-declared component holders that were not
// selected by the host's default-import package. Runtime hosts enable it;
// authoring/transcription may intentionally inspect unlinked source.
RequireLinked bool
}
Discovery compiles authored component sources selected by module-qualified package patterns into one canonical project. It is the local-filesystem frontend corresponding to the original transcribe command's source loop.
func (*Discovery) Compile ¶
func (d *Discovery) Compile(ctx context.Context) (*ProjectGeneration, error)
Compile discovers and compiles each component source exactly once. Plain SQL files without a route directive are resources rather than components and are ignored; every other compile failure is returned with its source path.
func (*Discovery) CompileSource ¶
CompileSource compiles one in-memory authored source with the same configured workspace/import authority used by Discovery. It is intended for bounded MCP authoring surfaces where clients may provide source text but not filesystem roots, compiler options, schema refiners, or package selections.
type GeneratedPackage ¶
type GeneratedPackage struct {
Result *gen.Result
Package *smodel.Package
Types *typecatalog.Catalog
}
GeneratedPackage holds transcribed package artifacts for package bootstrap.
type GeneratedProject ¶
type GeneratedProject struct {
Manifest *ProjectManifest
Components []*GeneratedPackage
}
type GenerationOptions ¶
type GenerationOptions struct {
Operation string
Language HandlerTarget
}
GenerationOptions opts a configured authoring target into the high-level Generator path. Source and Destination remain owned by Request so operator configuration has one source/destination owner.
func (GenerationOptions) Enabled ¶
func (o GenerationOptions) Enabled() bool
func (GenerationOptions) Normalize ¶
func (o GenerationOptions) Normalize() (GenerationOptions, error)
type GenerationRequest ¶
type Generator ¶
type Generator struct {
Operation string
Language HandlerTarget
EphemeralOwnership bool
GenerationPolicy gen.GenerationPolicy
}
Generator derives request contracts and mutation state before lowering a canonical handler. Transcribe remains the lower-level authored-contract path. Destination is only the project root; DQL and package metadata own artifacts.
func (Generator) Generate ¶
func (g Generator) Generate(ctx context.Context, request GenerationRequest) (*GeneratedPackage, error)
type GoExecution ¶
type GoExecution string
GoExecution selects generated orchestration without changing the Go target or the canonical invocation engine. Direct preserves authored control flow.
const ( GoExecutionDirect GoExecution = "direct" GoExecutionMutation GoExecution = "mutation" )
type GoHandlerOptions ¶
type GoHandlerOptions struct {
Execution GoExecution
Factory string
Handler string
Destination string
}
type HandlerOptions ¶
type HandlerOptions struct {
Target HandlerTarget
Operation WriteOperation
Input string
Output string
RootView string
Current string
Currents []CurrentBinding
Table string
Key string
Hooks HookOptions
Go GoHandlerOptions
Velty VeltyHandlerOptions
}
HandlerOptions selects one generated product over the canonical handler plan. It never selects behavior from an HTTP method.
type HandlerTarget ¶
type HandlerTarget string
HandlerTarget selects a generated handler target. The zero value preserves package, supplied, or authored handler authority.
const ( HandlerNone HandlerTarget = "none" HandlerVelty HandlerTarget = "velty" HandlerGo HandlerTarget = "go" )
type HookOptions ¶
HookOptions opts into a create-once user-owned file. Direct Go execution scaffolds input/output lifecycle methods; mutation execution scaffolds typed EntityHooks for roles without an authored hook declaration.
type Options ¶
type Options struct {
Contracts ContractOptions
Handler HandlerOptions
}
Options contains target-independent transcription choices.
type PackageCompilation ¶
type PackageCompilation struct {
Source *Source
Component *bootstrap.RouteSource
InputType reflect.Type
OutputType reflect.Type
Types *typecatalog.Catalog
Options Options
}
PackageCompilation joins an explicitly selected package component with an authored DQL source. Package tags establish the base contract; DQL overlays that contract through Compiler's canonical load stage.
func (*PackageCompilation) Compile ¶
func (c *PackageCompilation) Compile(ctx context.Context) (*Result, error)
Compile registers linked contract types under package authority and compiles the DQL source with package metadata as its canonical base.
func (*PackageCompilation) Transcribe ¶
func (c *PackageCompilation) Transcribe(ctx context.Context, rootDir string) (*GeneratedPackage, error)
Transcribe compiles package/DQL authority under normalized options and emits only products selected by the resulting canonical ownership decisions.
type ProjectComponent ¶
type ProjectComponent struct {
Key spec.Key `json:"key"`
Source string `json:"source,omitempty"`
Package string `json:"package"`
OutputType string `json:"outputType,omitempty"`
OutputOrigin typecatalog.TypeOrigin `json:"outputOrigin,omitempty"`
IR string `json:"ir"`
Diagnostics string `json:"diagnostics"`
Artifacts []string `json:"artifacts"`
Routes []ProjectRoute `json:"routes,omitempty"`
Dependencies []string `json:"dependencies,omitempty"`
}
type ProjectGeneration ¶
type ProjectGeneration struct {
Components []*Result
// Resources is the staged named authority shared by all component sources.
Resources *resource.Store
}
ProjectGeneration persists a coherent project from already compiled canonical components. Compilation remains owned by Compiler and PackageCompilation; this type owns only cross-component validation and project-level output.
func (*ProjectGeneration) Generate ¶
func (g *ProjectGeneration) Generate(ctx context.Context, rootDir string) (*GeneratedProject, error)
type ProjectManifest ¶
type ProjectManifest struct {
Version int `json:"version"`
Components []ProjectComponent `json:"components"`
Dependencies []string `json:"dependencies,omitempty"`
Analysis ProjectMigrationReport `json:"analysis"`
}
type ProjectMigrationReport ¶
type ProjectMigrationReport struct {
Components []ProjectMigrationComponent `json:"components"`
}
type ProjectRoute ¶
type Request ¶
type Request struct {
Component *bootstrap.RouteSource
InputType reflect.Type
OutputType reflect.Type
Source *Source
Destination string
Options Options
Generation GenerationOptions
}
Request is the sole public authored-source-to-package transcription request.
func (Request) GeneratorRequest ¶
func (r Request) GeneratorRequest() (Generator, GenerationRequest, error)
func (Request) NormalizeGeneration ¶
type Result ¶
type Result struct {
Source *Source
Component *spec.Component
PreparedSQL string
Statements statement.Statements
SourceMap *SourceMap
TypeContext *typecatalog.ResolutionContext
TypeResolver *typecatalog.Resolver
TypeAuthority typecatalog.Authority
Declarations gen.Declarations
Contracts gen.ContractReferences
Views gen.ViewReferences
ViewBindings gen.ViewBindings
GeneratedTypes []gen.GeneratedTypeReference
GoHandler *gen.GoHandlerAsset
VeltyHandler *gen.VeltyHandlerAsset
ContractTypeOverrides ContractTypeOverrides
Diagnostics []*Diagnostic
}
Result is the compile-time product passed to later plan, type-resolution, generation, and persistence stages. Runtime artifacts are intentionally not part of this model.
type RuntimeContract ¶
type RuntimeContract struct {
Result *Result
Component *spec.Component
InputType reflect.Type
OutputType reflect.Type
Resources *resource.Store
Types *typecatalog.Catalog
Plan *gen.Plan
}
RuntimeContract is the dynamic-reader contract compiled from DQL without emitting or loading a persistent generated Go package.
type SchemaInspection ¶
type SchemaInspection struct {
Component string `json:"component"`
View string `json:"view"`
Connector string `json:"connector"`
Table string `json:"table,omitempty"`
Completed []string `json:"completed"`
}
SchemaInspection records guaranteed stages of successful compiler refinement. It is not validation of a runtime payload or of every SQL template branch.
type Source ¶
type Source struct {
Const *constant.Values
Scope string
Name string
Path string
Text string
Connector string
// Resources is the Bindly-owned resource authority shared by source
// expansion, column discovery, and generated-package planning.
Resources *resource.Store
Docs xdocs.Service
Types *typecatalog.Catalog
// ColumnRefiner explicitly enables compile-time SQLX column discovery.
// A nil refiner keeps ordinary transcription DB-free.
ColumnRefiner *column.Refiner
// PackageComponent is optional package-authority canonical metadata used as
// the base for DQL+package transcription. Authored DQL overlays this graph;
// ordinary package-only bootstrap does not enter transcribe.
PackageComponent *spec.Component
LinkedInputType reflect.Type
LinkedOutputType reflect.Type
LinkedHandler func() (rhandler.TypedHandler, error)
// GoHandler is an explicitly accepted custom handler source asset. It is
// generation input only; canonical metadata retains just its handler name.
GoHandler *gen.GoHandlerAsset
// VeltyHandler optionally supplies an accepted template asset. When absent,
// explicit DQL service programs are transcribed into the same artifact.
// Runtime state and capabilities remain owned by runtime/handler/velty.
VeltyHandler *gen.VeltyHandlerAsset
}
Source is the transcribe-owned authored source/config model used to assemble canonical components and generated package artifacts for package bootstrap.
type SourceMap ¶
type SourceMap struct {
// contains filtered or unexported fields
}
SourceMap maps offsets in preprocessed SQL or Velty text back to authored DQL. This is ported from the newer original shape preprocessor.
func (*SourceMap) Remap ¶
func (m *SourceMap) Remap(diagnostics []*Diagnostic)
type ValidationReport ¶
type ValidationReport struct {
Valid bool `json:"valid"`
Components []string `json:"components"`
Completed []string `json:"completed"`
Skipped []string `json:"skipped"`
Diagnostics []*Diagnostic `json:"diagnostics,omitempty"`
Schema []SchemaInspection `json:"schema,omitempty"`
}
type Validator ¶
type Validator struct {
Const *constant.Values
BaseDir string
ModuleDirs []string
Include []string
Exclude []string
// ColumnRefiner explicitly enables database discovery through the existing
// compiler owner. Nil keeps validation static. Connections remain caller-owned.
ColumnRefiner *column.Refiner
Connector string
}
Validator is the non-persisting authoring validation entry point for CLI and developer tooling. It reuses discovery and generation planning; it never registers components or executes application code.
type VeltyHandlerOptions ¶
type WriteOperation ¶
type WriteOperation = handlerast.Operation
Source Files
¶
- compiler.go
- constants.go
- contracts.go
- declarations.go
- description.go
- diagnostic.go
- discover.go
- discovery_imports.go
- discovery_input.go
- discovery_package.go
- discovery_source.go
- doc.go
- generator.go
- handler.go
- handler_generation.go
- handler_generation_contract.go
- handler_generation_current.go
- handler_generation_current_carrier.go
- handler_generation_entities.go
- handler_generation_hooks.go
- handler_generation_index_groups.go
- handler_generation_indexes.go
- handler_generation_late.go
- handler_generation_markers.go
- handler_generation_mutation.go
- handler_generation_mutation_scaffold.go
- handler_generation_program.go
- load.go
- load_contract.go
- load_settings.go
- options.go
- output_relations.go
- package_authority.go
- package_compile.go
- package_views.go
- project.go
- project_components.go
- project_manifest_editor.go
- project_path.go
- project_persist.go
- read_plan.go
- resources.go
- runtime_contract.go
- source_map.go
- source_model.go
- transcribe.go
- validation.go
- validation_schema.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package column refines canonical view columns during explicit transcription.
|
Package column refines canonical view columns during explicit transcription. |
|
Package compile lowers prepared DQL into normalized transcribe plans.
|
Package compile lowers prepared DQL into normalized transcribe plans. |
|
Package dql implements focused DQL syntax parsing for the transcribe pipeline.
|
Package dql implements focused DQL syntax parsing for the transcribe pipeline. |
|
statement
Package statement segments preprocessed DQL into top-level SQL and Velty operations.
|
Package statement segments preprocessed DQL into top-level SQL and Velty operations. |
|
Package generate emits Go package artifacts from resolved transcribe products and type authority.
|
Package generate emits Go package artifacts from resolved transcribe products and type authority. |
|
handler
|
|
|
ast
Package ast defines the target-neutral semantic tree used to generate Go and Velty handlers.
|
Package ast defines the target-neutral semantic tree used to generate Go and Velty handlers. |
|
compiler
Package compiler validates canonical component metadata and produces the target-neutral handler AST.
|
Package compiler validates canonical component metadata and produces the target-neutral handler AST. |
|
golang
Package golang lowers semantic handler transcription plans into Go AST.
|
Package golang lowers semantic handler transcription plans into Go AST. |
|
velty
Package velty lowers target-neutral handler transcription plans into Velty.
|
Package velty lowers target-neutral handler transcription plans into Velty. |