backend

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 39 Imported by: 0

Documentation

Overview

Copyright (c) 2026 Tarek Wasfy

Copyright (c) 2026 Tarek Wasfy Code generated by cmd/uast-emission-recipes; DO NOT EDIT. Source: exact M_EO emission-contract factorization.

Copyright (c) 2026 Tarek Wasfy Code generated from the checked-in direct-UAST renderer catalog; DO NOT EDIT.

Copyright (c) 2026 Tarek Wasfy

Index

Constants

View Source
const (
	SemanticSEVersion           = SemanticSPVersion
	SemanticReadableExtension   = ".se"
	SemanticCompressedExtension = ".spz"
	SemanticLegacyExtension     = ".sp"
	SemanticLegacyCompressedExt = ".spz"
)

Semantic transport extensions. .se is the current name for the readable SemanticProgram format; .sp and .spz remain wire-compatible legacy aliases.

View Source
const ExactCallResolutionCapability = "call.resolution.exact.v1"
View Source
const ExactSignatureCapability = "function.signature.exact.v1"
View Source
const SemanticDocumentSchema = "r2many.semantic-program"

SemanticDocument is the stable interchange format for SemanticProgram. It intentionally contains no Canonical R text and can therefore move between a source frontend, a route decoder and every target backend without R carrying semantic state. The source-specific parser remains an adapter at the edge.

View Source
const SemanticDocumentVersion = 1
View Source
const SemanticSPVersion = 1
View Source
const SemanticTraceSchemaVersion = "uast-semantic-trace/v1"

Variables

View Source
var Languages = []Language{
	{"go", "Go", ".go", "//"},
	{"rust", "Rust", ".rs", "//"},
	{"cpp", "C++", ".cpp", "//"},
	{"c", "C", ".c", "//"},
	{"python", "Python", ".py", "#"},
	{"zig", "Zig", ".zig", "//"},
	{"julia", "Julia", ".jl", "#"},
	{"nim", "Nim", ".nim", "#"},
	{"csharp", "C#", ".cs", "//"},
	{"java", "Java", ".java", "//"},
	{"kotlin", "Kotlin", ".kt", "//"},
	{"swift", "Swift", ".swift", "//"},
}
View Source
var PrimitiveMatrix = []PrimitiveSpec{}/* 702 elements not displayed */
View Source
var StructuredFieldCoverage = map[string][]string{
	"CONTAINER":              {"node kind", "child", "operand", "type", "binding", "allocation size"},
	"ITERATION":              {"node kind", "iterable", "binding", "child", "control/body reference", "filter/condition"},
	"CLOSURE_FUNCTION_VALUE": {"node kind", "parameter", "capture", "binding", "child", "control/body reference"},
	"INDEX_SLICE":            {"node kind", "operand", "index", "slice bounds", "binding"},
}

StructuredFieldCoverage is the exact field basis used by the four shared extractor families. A missing cell is diagnostic evidence, never a request to reconstruct source spelling.

Functions

func ApplyAutomaticSemanticRepairClosure added in v1.2.1

func ApplyAutomaticSemanticRepairClosure(u *UniversalASTDocument)

ApplyAutomaticSemanticRepairClosure is the generated-rule kernel selected by the V6 residual synthesizer. The rules are pure relation completions: they preserve existing nodes and only expose already-proved operands through the canonical syntax roles required by the existing executor.

func ApplySemanticClosure added in v1.2.1

func ApplySemanticClosure(u *UniversalASTDocument) error

ApplySemanticClosure validates and records the derived closure on the same canonical document consumed by the generic executor. It never creates a second semantic representation and it never infers meaning from source text.

func ApplyUniversalTruthClosure added in v1.2.1

func ApplyUniversalTruthClosure(u *UniversalASTDocument)

ApplyUniversalTruthClosure applies only presence implications that are already witnessed by canonical syntax relations. It never invents a value, binding, type, target, or operand identity: an explicit child relation is merely exposed through the existing data.operand relation used by the executor. The rule is language and target neutral and therefore belongs in the existing UAST enrichment pass rather than in a second semantic system.

func BackendCapabilities

func BackendCapabilities(name string) []string

func DependencyGap added in v1.2.1

func DependencyGap(closure SemanticClosureMatrix) int

func EmitSemantic

func EmitSemantic(target string, p *SemanticProgram) (string, error)

func EmitSemanticCompatibility added in v1.2.8

func EmitSemanticCompatibility(target string, p *SemanticProgram) (string, error)

EmitSemanticCompatibility is the explicit document-level fallback used by the source-to-target pipeline after strict native and matrix-lowered projections have been exhausted. It still consumes the canonical UAST; compatibility rendering never reparses source text or invokes a legacy frontend.

func EmitSemanticDirect added in v1.1.1

func EmitSemanticDirect(target string, p *SemanticProgram) (string, error)

EmitSemanticDirect is used by the intermediate-route planner. It shares the canonical semantic/UAST construction with EmitSemantic but asks the projector for a strict native result, so a route can be attempted before compatibility runtime output is considered.

func EmitSemanticPreserveOriginal added in v1.2.1

func EmitSemanticPreserveOriginal(target string, p *SemanticProgram) (string, error)

EmitSemanticPreserveOriginal is the explicit same-language surface-plane mode. The ordinary EmitSemantic path still regenerates canonical target source from UAST, while callers that request PRESERVE_ORIGINAL can return the verified original bytes without making source text part of semantics.

func EmpiricalPy2ManyPrimitive added in v1.1.1

func EmpiricalPy2ManyPrimitive(astNode string) (string, bool)

EmpiricalPy2ManyPrimitive returns the canonical primitive for a known AST operation. Unknown operations remain unavailable and are handled by the normal compatibility path.

func EnrichUniversalAST added in v1.0.5

func EnrichUniversalAST(u *UniversalASTDocument) error

EnrichUniversalAST is the shared, UAST-only semantic enrichment pass. It materializes only facts that follow from schema crosswalks and explicit syntax roles; frontend-specific parsers and SemanticDocument are absent.

func EquivalentSemanticObservations

func EquivalentSemanticObservations(a, b SemanticObservation) bool

func ExactSemanticShapeIDs added in v1.2.1

func ExactSemanticShapeIDs() []string

ExactSemanticShapeIDs exposes the source-independent shapes to matrix consumers. Target executability is deliberately evaluated separately.

func FindDirectResiduals added in v1.2.1

func FindDirectResiduals(u *UniversalASTDocument, target string) ([]int, error)

FindDirectResiduals returns node IDs whose canonical semantic operation is not covered by the target's direct plane. It is a conservative worklist: a node is never rewritten merely because a rule exists in the registry.

func FormatSemanticSE added in v1.2.9

func FormatSemanticSE(data []byte) ([]byte, error)

func FormatSemanticSP added in v1.2.8

func FormatSemanticSP(data []byte) ([]byte, error)

FormatSemanticSP canonicalizes an SP document through SemanticProgram.

func FormatSemanticSPZ added in v1.2.8

func FormatSemanticSPZ(data []byte) ([]byte, error)

func FrontendInputUsesSemanticLift added in v1.2.8

func FrontendInputUsesSemanticLift(kind FrontendInputKind) bool

FrontendInputUsesSemanticLift identifies non-source inputs that must pass through the existing binary/assembly semantic lift before UAST projection.

func GenericAtomicKernel added in v1.2.1

func GenericAtomicKernel(primitive string) (string, bool)

GenericAtomicKernel returns an existing productive kernel binding only when the canonical operation has a language-neutral UAST consumer. Callers must not infer a binding from a diagnostic or primitive name alone.

func HasBackend

func HasBackend(name string) bool

func HasFrontend

func HasFrontend(name string) bool

func IntermediateRouteCandidates added in v1.2.1

func IntermediateRouteCandidates(source, target string) []string

IntermediateRouteCandidates returns only matrix-proven, cycle-free bridge targets. The generated table is compiled into the binary; no CSV parsing is performed on the transpilation hot path.

func LinkRequiredRuntime added in v1.2.8

func LinkRequiredRuntime(program *SemanticProgram, target string) error

func LowerSemanticToNative added in v1.2.8

func LowerSemanticToNative(program *SemanticProgram, target string) (*SemanticProgram, NativeClosure, error)

func LowerSourceWithDiagnostics added in v1.2.8

func LowerSourceWithDiagnostics(language, filename, source string, mode DiagnosticMode) (*SemanticProgram, *DiagnosticContext, error)

LowerSourceWithDiagnostics runs the same productive frontend selection as LowerSource while exposing a separate, transient diagnostic context. In strict mode it is equivalent to LowerSource. In saturating mode a failed frontend call is recorded as structured diagnostic data, but no placeholder is returned as a SemanticProgram and no recovery value is accepted by the production path.

func MatrixFrontendLanguages added in v1.0.5

func MatrixFrontendLanguages() []string

MatrixFrontendLanguages exposes every language currently backed by the matrix grammar extractor. Each uses the same typed-event contract.

func MissingStructuredFields added in v1.0.6

func MissingStructuredFields(input StructuredConstructInput) []string

func ModuleStoreRoot added in v1.2.9

func ModuleStoreRoot() (string, error)

ModuleStoreRoot exposes the platform-resolved store location without exposing any machine-specific user path in the API.

func NeedsParentheses added in v1.0.5

func NeedsParentheses(parent, child TargetOperatorSpec, role string) bool

NeedsParentheses is target-neutral: TargetSpec supplies precedence and associativity while the algorithm uses only operand role.

func NewTranspileFailure added in v1.2.1

func NewTranspileFailure(class FailureClass, stage, source, target string, cause error) error

NewTranspileFailure wraps an internal cause without making the raw message part of routing or classification. The cause remains available to diagnostics and tests via errors.Unwrap/As.

func NormalizeLanguage

func NormalizeLanguage(name string) string

func OpenSFPCQuery added in v1.2.9

func OpenSFPCQuery(data []byte, maxBytes int) (*SFPCQuery, SFPCVerificationResult)

func PhaseGap added in v1.2.1

func PhaseGap(closure SemanticClosureMatrix) int

PhaseGap and DependencyGap are intentionally derived from the populated closure axes. The current compiler evidence has no required-but-absent cells, so these remain zero without hard-coding a success result.

func PrimitiveFamilyForContract added in v1.2.8

func PrimitiveFamilyForContract(id string) (string, bool)

PrimitiveFamilyForContract returns the exact residual quotient family for a contract id. It is shared by reports and the productive rule binder.

func PrimitiveTargetCapability added in v1.2.1

func PrimitiveTargetCapability(target, primitive string) (kernel string, direct bool)

PrimitiveTargetCapability is the read-only target contract used by reports and the final closure replay. It delegates to the same capability matrix used by the productive lowering path, so a report cannot claim support from a second, hand-maintained table.

func PrimitiveTargetEmitterEvidence added in v1.2.1

func PrimitiveTargetEmitterEvidence(target, primitive string) (kernel, emitter string, exists, guardCompatible, representationCompatible, reachable bool)

PrimitiveTargetEmitterEvidence derives target support from the productive UAST renderer/template contracts. It intentionally does not consult the older capability plane: that plane describes semantic preservation, while this contract answers whether the shared target emitter can render the kernel's structural form.

func Run

func Run(src string) (string, error)

func RunSemantic

func RunSemantic(program *SemanticProgram) (string, error)

RunSemantic executes the semantic tree directly. It is used for IR round-trip equivalence checks and never reconstructs source text.

func RuntimeSource

func RuntimeSource(target string) (string, error)

RuntimeSource returns the actual support code embedded in generated programs. It does not contain a compiler or an external language installation.

func SaturateFrontendFacts added in v1.2.8

func SaturateFrontendFacts(f FrontendSemanticFacts, ctx *DiagnosticContext) (successful, holes int)

SaturateFrontendFacts validates independent structured nodes while keeping the canonical builder untouched. Nodes that cannot be decoded become transient diagnostic failures; valid siblings remain countable.

func SemanticEquivalenceLibrary added in v1.2.1

func SemanticEquivalenceLibrary() (map[string][]GeneratedLoweringRecipe, error)

SemanticEquivalenceLibrary is a read-only view of exact alternatives. It is intentionally represented with existing recipe values rather than a second semantic IR.

func StructuredInputFields added in v1.0.6

func StructuredInputFields(input StructuredConstructInput) map[string]bool

func SupportsCapability

func SupportsCapability(caps []string, capability string) bool

func SyntaxFailureSignature added in v1.0.6

func SyntaxFailureSignature(diagnostic string) string

SyntaxFailureSignature groups actual target diagnostics into the stable matrix vocabulary. It does not infer a cause; unrecognised diagnostics are preserved as "other" for review.

func Transpile

func Transpile(target, src string) (string, error)

func TranspileFrom

func TranspileFrom(source, target, src string) (string, error)

TranspileFrom retains argument-evaluation semantics when the canonical syntax originated in an eager source language rather than R.

func TypeConversionFingerprint added in v1.2.1

func TypeConversionFingerprint(t SemanticType) string

TypeConversionFingerprint provides a stable key for matrix/report joins.

func UASTTargetProjectionCapabilities added in v1.0.5

func UASTTargetProjectionCapabilities() (map[string]map[string]PreservationMode, error)

UASTTargetProjectionCapabilities folds the exact structure decisions back to the historical 13×73 class matrix. A class is only marked supported when all members are supported; the per-structure matrix above is used for actual executable capability decisions and never loses a proved member.

func UASTTargetStructureProjectionCapabilities added in v1.0.5

func UASTTargetStructureProjectionCapabilities() (map[string]map[string]PreservationMode, error)

UASTTargetStructureProjectionCapabilities is the exact target-side availability of every structure contract. It is derived from declarative TargetSpec forms and the generated template quotient, never from a guess based on a target-language name. It remains structure-granular because an execution-equivalent projection class can contain multiple syntax forms.

func UniversalLower added in v1.2.1

func UniversalLower(original *UniversalASTDocument, target string) (*UniversalASTDocument, LoweringTrace, error)

UniversalLower applies a bounded fixed-point worklist to a private UAST clone. Every rewrite is validated before the next iteration and a graph fingerprint prevents cycles. The original document is never mutated.

func ValidateFrontendFacts added in v1.2.8

func ValidateFrontendFacts(f FrontendSemanticFacts) (int, error)

ValidateFrontendFacts is the fail-closed counterpart to the diagnostic walk. It never returns a transient hole as a successful semantic result.

func ValidateSemanticContracts added in v1.2.8

func ValidateSemanticContracts(program *SemanticProgram) error

ValidateSemanticContracts is stricter than schema validation: it runs the executable UAST validator and rejects contract forms that have no consumer.

func ValidateSemanticProgram added in v1.0.5

func ValidateSemanticProgram(p *SemanticProgram) error

ValidateSemanticProgram checks the live tree and recomputes its evidence. Mutating Body without updating its relations cannot bypass JSON validation.

func VerifySemanticModule added in v1.2.9

func VerifySemanticModule(m *SemanticModule) error

func WalkSemanticDocument

func WalkSemanticDocument(doc *SemanticDocument, visitor SemanticVisitor) error

func WriteExternalPrimitiveProofReport added in v1.2.1

func WriteExternalPrimitiveProofReport(out string) (int, error)

WriteExternalPrimitiveProofReport proves a conservative subset of the external EXACT_CODE rows against existing canonical frontend/UAST shapes.

func WriteFailureSaturationReport added in v1.2.8

func WriteFailureSaturationReport(out string, ctx *DiagnosticContext) error

WriteFailureSaturationReport materializes the diagnostic plane as stable CSV/JSON files. It consumes only structured failures already recorded by a frontend; it never reparses source text or promotes holes into UAST nodes.

func WriteReductionArtifacts added in v1.2.8

func WriteReductionArtifacts(out string, reductions map[string]ReductionResult, originals map[string]SemanticFailure) error

WriteReductionArtifacts writes the transient reduction evidence in the layout consumed by the saturation reports. The original and minimal failures remain diagnostic JSON; the reduced tree is intentionally not passed to any canonical UAST builder.

func WriteSemanticTrace added in v1.2.1

func WriteSemanticTrace(path string, parseSuccess bool, u *UniversalASTDocument, route SemanticTraceRoute) error

WriteSemanticTrace writes atomically when path is non-empty. A nil UAST is a valid parse/UAST failure sidecar and is intentionally not an error.

func WriteUASTMatrixEngineInputs added in v1.0.5

func WriteUASTMatrixEngineInputs(dir string) error

WriteUASTMatrixEngineInputs adapts existing, checked-in UAST matrices to the offline uast-matrix-engine contract. It performs no closure, matrix product, readiness selection, or preservation selection. Those operations belong to the external engine. In particular, language facet evidence is already an exact quotient class in the source matrix, so it is emitted as a stable evidence feature rather than being expanded back into guessed source rows.

Types

type Arg

type Arg struct {
	Name    string
	Value   Expr
	Missing bool
}

type ArtifactKind added in v1.2.9

type ArtifactKind string
const (
	SourceModule           ArtifactKind = "SOURCE_MODULE"
	SemanticModuleArtifact ArtifactKind = "SEMANTIC_MODULE"
	AssemblyModule         ArtifactKind = "ASSEMBLY_MODULE"
	BinaryModule           ArtifactKind = "BINARY_MODULE"
	NativeExternal         ArtifactKind = "NATIVE_EXTERNAL"
)

type AssignStmt

type AssignStmt struct {
	Name, Op string
	Value    Expr
}

type BackendSpec

type BackendSpec struct {
	ID           string
	Aliases      []string
	Capabilities []string
	Dialects     []string
}

func Backends

func Backends() []BackendSpec

type BinaryExpr

type BinaryExpr struct {
	Op   string
	L, R Expr
}

type BlockStmt

type BlockStmt struct{ List []Stmt }

type BreakStmt

type BreakStmt struct{}

type CallExpr

type CallExpr struct {
	Fun        Expr
	Args       []Arg
	Eager      bool // explicit call boundary, including decoded R force wrappers
	Resolution *SemanticCallResolution
}

type CanonicalPrimitiveWitness added in v1.2.1

type CanonicalPrimitiveWitness struct {
	Primitive string
	Kernel    string
	Program   *SemanticProgram
}

CanonicalPrimitiveWitness is a generated, target-neutral UAST witness for a semantic primitive family. It deliberately starts below the source frontend: it exists to validate Primitive × Target backend cells which do not yet have a source-language occurrence. The resulting document is built by the normal SemanticProgram -> Canonical UAST projection and is then consumed by the unchanged primitive compiler, legalizer and emitters.

For parameterized evidence entries the witness proves the selected generic kernel and its operand wiring. It never claims that a VM/ISA spelling is a distinct source-language operation.

func BuildCanonicalPrimitiveWitness added in v1.2.1

func BuildCanonicalPrimitiveWitness(primitive string) (CanonicalPrimitiveWitness, error)

BuildCanonicalPrimitiveWitness constructs the smallest executable canonical UAST shape for the already-registered primitive kernel. It is intentionally data-driven through GenericAtomicKernel; no source or target language selects a special path here.

type CapabilityMatrix added in v1.0.5

type CapabilityMatrix struct {
	Features    []string              `json:"features"`
	Targets     []string              `json:"targets"`
	Native      matrixir.SparseMatrix `json:"native"`
	Lowering    matrixir.SparseMatrix `json:"lowering"`
	Emulated    matrixir.SparseMatrix `json:"emulated"`
	Unsupported matrixir.SparseMatrix `json:"unsupported"`
}

CapabilityMatrix is feature x target. Status planes are mutually exclusive; Unsupported is explicit so unknown features cannot look like supported zeros.

func SemanticCapabilityMatrix added in v1.0.5

func SemanticCapabilityMatrix(extra []string) CapabilityMatrix

func (CapabilityMatrix) RejectedTargets added in v1.0.5

func (m CapabilityMatrix) RejectedTargets(requirements []string) (matrixir.SparseMatrix, error)

RejectedTargets computes requirements^T * unsupported. A positive entry is the count of unavailable requirements for that target, not a quality score.

type CapabilityResult

type CapabilityResult struct {
	Feature string           `json:"feature"`
	Backend string           `json:"backend"`
	Status  CapabilityStatus `json:"status"`
	Reason  string           `json:"reason,omitempty"`
}

CapabilityResult is a backend contract, not a success prediction. The caller can display it before emitting and refuse any non-exact policy.

func BackendCapability

func BackendCapability(feature, backend string) CapabilityResult

type CapabilityStatus

type CapabilityStatus string
const (
	CapabilityNative      CapabilityStatus = "native"
	CapabilityLowering    CapabilityStatus = "lowering"
	CapabilityEmulated    CapabilityStatus = "emulated"
	CapabilityUnsupported CapabilityStatus = "unsupported"
)

type CompileInputKind added in v1.2.1

type CompileInputKind string

CompileInputKind identifies the representation supplied to the common compiler API. Source is currently the fully productive frontend; the other values are explicit capability contracts so callers cannot accidentally treat binary data as UTF-8 source.

const (
	CompileInputSource     CompileInputKind = "source"
	CompileInputAssembly   CompileInputKind = "assembly"
	CompileInputMachine    CompileInputKind = "machine_code"
	CompileInputObject     CompileInputKind = "object"
	CompileInputExecutable CompileInputKind = "executable"
)

type CompileOptions added in v1.2.1

type CompileOptions struct {
	InputKind       CompileInputKind
	SourceLanguage  string
	SourceArch      string
	SourceOS        string
	SourceABI       string
	SourceAsmSyntax string
	TargetArch      string
	TargetOS        string
	ABI             string
	OutputKind      CompileOutputKind
	TargetLanguage  string
	EntryPoint      string
	ViaAssembly     bool
	BaseAddress     uint64
}

type CompileOutputKind added in v1.2.1

type CompileOutputKind string
const (
	CompileSource      CompileOutputKind = "source"
	CompileAssembly    CompileOutputKind = "assembly"
	CompileMachineCode CompileOutputKind = "machine_code"
	CompileObject      CompileOutputKind = "object"
	CompileExecutable  CompileOutputKind = "executable"
)

type CompileResult added in v1.2.1

type CompileResult struct {
	Bytes               []byte
	Text                string
	OutputKind          CompileOutputKind
	InstructionCount    int
	AppliedRecipes      []string
	AllocatedLiveRanges int
}

func CompileBinaryInput added in v1.2.1

func CompileBinaryInput(data []byte, opts CompileOptions) (CompileResult, error)

func CompileMachine added in v1.2.1

func CompileMachine(p *SemanticProgram, opts CompileOptions) (CompileResult, error)

CompileMachine consumes the existing canonical document. Architecture/OS/ABI are independent options. Unsupported semantic nodes produce an error before any bytes are returned.

func EmitNativeExecutable added in v1.2.8

func EmitNativeExecutable(program *SemanticProgram, target string, entry string) (CompileResult, error)

type CompilerFrontendEvidence added in v1.2.1

type CompilerFrontendEvidence struct {
	ID, Language, Compiler, Stage, SourceArea, Representation string
	Features, Relations                                       []string
	Phase, EvidenceClass, Guidance, SourceURL                 string
}

type CompilerSourceEvidence added in v1.2.1

type CompilerSourceEvidence struct{ Language, Compiler, Repository, Area, URL, LicensePolicy string }

CompilerSourceEvidence records provenance and licence constraints for facts. It is deliberately metadata only; no third-party implementation is shipped.

type ContractGapClosureReport added in v1.2.1

type ContractGapClosureReport struct {
	InitialGaps                   int            `json:"initial_contract_gaps"`
	RecoveredExactContracts       []string       `json:"recovered_exact_contracts"`
	NewDerivedPrimitives          []string       `json:"new_derived_primitives"`
	NewGeneratedRecipes           []string       `json:"new_generated_recipes"`
	NewRecoveredExactRules        []string       `json:"new_recovered_exact_rules"`
	NewParameterizedAtomic        []string       `json:"new_parameterized_atomic_primitives"`
	TrueAtomicResidual            []string       `json:"true_atomic_residual_primitives"`
	RuntimeOnly                   []string       `json:"runtime_only_reclassifications"`
	TargetTerminal                []string       `json:"target_terminal_reclassifications"`
	ValidationOnly                []string       `json:"validation_only_reclassifications"`
	Aliases                       []string       `json:"aliases"`
	RemainingInsufficientEvidence []string       `json:"remaining_insufficient_evidence"`
	FinalContractGaps             []string       `json:"final_contract_gaps"`
	TotalGeneratedRecipes         int            `json:"total_generated_recipes"`
	TotalClosureReachableRules    int            `json:"total_closure_reachable_rules"`
	TotalExecutorReachableRules   int            `json:"total_executor_reachable_rules"`
	GenericAtomicKernelClasses    []string       `json:"generic_atomic_kernel_classes"`
	MinimalMissingAtomicBasis     []string       `json:"minimal_missing_atomic_basis"`
	BasisHash                     string         `json:"basis_hash"`
	ImplementationGraphRows       int            `json:"implementation_graph_rows"`
	RecoveredEquivalenceRules     int            `json:"recovered_equivalence_rules"`
	AtomicResidualCount           int            `json:"atomic_residual_count"`
	ProductiveFamilyContracts     int            `json:"productive_family_contracts"`
	ValidationOnlyFamilyContracts int            `json:"validation_only_family_contracts"`
	UnresolvedFamilyContracts     int            `json:"unresolved_family_contracts"`
	FamilyCounts                  map[string]int `json:"family_counts,omitempty"`
}

ContractGapClosureReport records the evidence-based resolution of every contract gap. A gap without an exact repository proof is deliberately kept as INSUFFICIENT_EVIDENCE instead of being mislabeled as executable.

func WriteContractGapClosureReport added in v1.2.1

func WriteContractGapClosureReport(out string) (*ContractGapClosureReport, error)

type DetectionResult added in v1.2.9

type DetectionResult struct {
	Kind       ArtifactKind   `json:"kind"`
	Language   string         `json:"language,omitempty"`
	Confidence string         `json:"confidence"`
	Scores     map[string]int `json:"scores"`
	Languages  []string       `json:"languages,omitempty"`
	Mixed      bool           `json:"mixed,omitempty"`
}

func DetectArtifact added in v1.2.9

func DetectArtifact(path string) DetectionResult

type DiagnosticContext added in v1.2.8

type DiagnosticContext struct {
	Mode     DiagnosticMode
	Failures []SemanticFailure
	// Holes are transient placeholders used only while saturating a
	// diagnostic walk. They must never be handed to a canonical builder.
	Holes         []DiagnosticHole
	RewriteProofs []RewriteProofRecord
}

func NewDiagnosticContext added in v1.2.8

func NewDiagnosticContext(mode DiagnosticMode) *DiagnosticContext

func (*DiagnosticContext) FailuresByFamily added in v1.2.8

func (c *DiagnosticContext) FailuresByFamily() map[string][]SemanticFailure

func (*DiagnosticContext) Record added in v1.2.8

Record returns an error in strict mode and records a transient failure in saturation mode. The caller may then continue only when its structural synchronisation condition is true.

func (*DiagnosticContext) RecordRewriteProof added in v1.2.8

func (c *DiagnosticContext) RecordRewriteProof(original RewriteState, proof RewriteProof)

RecordRewriteProof stores only bounded closure evidence. The proof is diagnostic data and is never interpreted as a canonical program node.

func (*DiagnosticContext) Summary added in v1.2.8

func (c *DiagnosticContext) Summary() SaturationSummary

func (*DiagnosticContext) SummaryJSON added in v1.2.8

func (c *DiagnosticContext) SummaryJSON() ([]byte, error)

type DiagnosticHole added in v1.2.8

type DiagnosticHole struct {
	FailureID     string `json:"failure_id"`
	Stage         string `json:"stage"`
	NodeKind      string `json:"node_kind,omitempty"`
	SemanticRole  string `json:"semantic_role,omitempty"`
	SourceStart   int    `json:"source_start,omitempty"`
	SourceEnd     int    `json:"source_end,omitempty"`
	RecoveryClass string `json:"recovery_class"`
}

DiagnosticHole is a transient recovery marker. It belongs exclusively to the diagnostic plane and is never serialized into UniversalASTDocument or accepted by the production executor.

type DiagnosticMode added in v1.2.8

type DiagnosticMode string
const (
	DiagnosticStrict   DiagnosticMode = "STRICT"
	DiagnosticSaturate DiagnosticMode = "SATURATE"
)

type DirectLoweringAnalysis added in v1.0.5

type DirectLoweringAnalysis struct {
	Schema              string                      `json:"schema"`
	Rows                []DirectLoweringRequirement `json:"rows"`
	AtomicObligations   []string                    `json:"atomic_obligations"`
	MissingVectors      map[string][]string         `json:"missing_vectors"`
	Classes             map[string][]string         `json:"classes"`
	Primitives          []string                    `json:"primitives"`
	ConnectedComponents int                         `json:"connected_components"`
	DataOnlyPrimitives  int                         `json:"data_only_primitives"`
	NewHandlerClasses   int                         `json:"new_handler_classes"`
}

func WriteDirectLoweringAnalysis added in v1.0.5

func WriteDirectLoweringAnalysis(out, candidateCSV string) (DirectLoweringAnalysis, error)

type DirectLoweringContract added in v1.0.5

type DirectLoweringContract struct {
	Target          string
	ProjectionClass string
	Primitive       string
	Handler         string
	RecipeIDs       []string
	TemplateID      string
	ProofStatus     string
}

DirectLoweringContract is a checked product-path registration. It stores no program data and is deliberately narrower than a projection form: a target may use the generic syntax recipe only after the named native semantic handler and its proof gate are registered.

func DirectLoweringContractFor added in v1.0.5

func DirectLoweringContractFor(target, projectionClass string) (DirectLoweringContract, bool)

type DirectLoweringRequirement added in v1.0.5

type DirectLoweringRequirement struct {
	CandidateID, Target, ProjectionClass string
	UASF                                 []string
	Required, Existing, Missing          []string
	Classification                       string
}

DirectLoweringRequirement is one row of M_CO. It describes only registry contracts and existing emission machinery; it is not a program IR.

type DirectLoweringStatus added in v1.2.9

type DirectLoweringStatus string
const (
	DirectOK                DirectLoweringStatus = "DIRECT_OK"
	NeedsSelectiveExpansion DirectLoweringStatus = "NEEDS_SELECTIVE_EXPANSION"
	NeedsFullFallback       DirectLoweringStatus = "NEEDS_FULL_FALLBACK"
)

func CanDirectLower added in v1.2.9

func CanDirectLower(source SemanticSource, nodeID int) DirectLoweringStatus

CanDirectLower conservatively gates future direct native operations. An operation is never guessed: until a grammar/native proof is registered it requests the complete classic path.

type Doc added in v1.0.5

type Doc interface {
	// contains filtered or unexported methods
}

Doc is a syntax-only, ephemeral rendering tree. It contains no types, symbols, UAST nodes, or semantic meaning.

func EmitNativeDocument added in v1.0.5

func EmitNativeDocument(spec TargetSpec, source string) (Doc, error)

EmitNativeDocument is the central DIRECT document boundary. The semantic projector has already lowered every UAST node through the native target renderer; this final recipe carries the resulting syntax document through the same NativeEmitterContract without reintroducing a runtime or a second semantic representation. Keeping this operation here makes it impossible for a DIRECT projection to bypass the native emitter dispatch point.

func EmitNativeExecution added in v1.0.5

func EmitNativeExecution(spec TargetSpec, recipe EmissionRecipe, template TargetSyntaxTemplateCell, input NativeEmissionInput) (Doc, error)

EmitNativeExecution is the single data-driven native emission entry point. It composes an existing emission recipe with an existing target template and TargetSpec. No target×primitive dispatch or runtime helper is introduced.

func ExecuteEmissionRecipe added in v1.0.5

func ExecuteEmissionRecipe(recipe EmissionRecipe, input EmissionRecipeInput, spec TargetSpec) (Doc, error)

ExecuteEmissionRecipe builds only a layout Doc. It never selects a semantic lowering, resolves symbols, or interprets a source language. An empty role remains empty; the executor never invents a child or a target token.

func ExecuteTargetSyntaxTemplate added in v1.0.5

func ExecuteTargetSyntaxTemplate(recipe EmissionRecipe, template TargetSyntaxTemplateCell, spec TargetSpec, input EmissionRecipeInput) (Doc, error)

ExecuteTargetSyntaxTemplate applies only an already-registered template and delegates all layout to the three generic emission handlers. It cannot turn a missing target template into source text.

func NativeDeclarationEmitter added in v1.0.5

func NativeDeclarationEmitter(spec TargetSpec, recipe EmissionRecipe, template TargetSyntaxTemplateCell, input NativeEmissionInput) (Doc, error)

func NativeEmitterCapabilityDoc added in v1.0.5

func NativeEmitterCapabilityDoc(target, capability string, spec TargetSpec, body Doc) (Doc, error)

NativeEmitterCapabilityDoc provides the shared backend representation for the three previously runtime-terminal capabilities. It is layout-only and contains no UAST or program semantics.

func NativeExpressionEmitter added in v1.0.5

func NativeExpressionEmitter(spec TargetSpec, recipe EmissionRecipe, template TargetSyntaxTemplateCell, input NativeEmissionInput) (Doc, error)

NativeExpressionEmitter, NativeStatementEmitter and NativeDeclarationEmitter are deliberately thin category wrappers around the same generic emitter. Their category is selected by the already registered projection form, never by a target-specific switch.

func NativeStatementEmitter added in v1.0.5

func NativeStatementEmitter(spec TargetSpec, recipe EmissionRecipe, template TargetSyntaxTemplateCell, input NativeEmissionInput) (Doc, error)

type DocConcat added in v1.0.5

type DocConcat struct{ Parts []Doc }

type DocHardLine added in v1.0.5

type DocHardLine struct{}

type DocIndent added in v1.0.5

type DocIndent struct {
	By   string
	Body Doc
}

type DocText added in v1.0.5

type DocText struct{ Text string }

type EmissionContractAnalysis added in v1.0.5

type EmissionContractAnalysis struct {
	Contracts   []string
	Operations  []string
	Combinators []ProjectionObligationPrimitive
}

EmissionContractAnalysis is the syntax-only M_EO factorization. Atomic operations are the already validated projection obligations; no semantic datum or UAST node is copied into this registry.

func UniversalEmissionContractAnalysis added in v1.0.5

func UniversalEmissionContractAnalysis() (EmissionContractAnalysis, error)

func WriteEmissionContractAnalysis added in v1.0.5

func WriteEmissionContractAnalysis(dir string) (EmissionContractAnalysis, error)

type EmissionHandlerClass added in v1.0.5

type EmissionHandlerClass string

EmissionHandlerClass groups atomic matrix operations by identical syntax-only execution behavior. It is deliberately independent of UASF, source language, structural kind, and target identity.

type EmissionRecipe added in v1.0.5

type EmissionRecipe struct {
	ID         string
	Archetypes []string
	Operations []EmissionRecipeOperation
}

EmissionRecipe is an ephemeral syntax plan. It holds no program facts: nodes, types, symbols and relations remain in UniversalASTDocument.

func GeneratedEmissionRecipeForPrimitive added in v1.0.5

func GeneratedEmissionRecipeForPrimitive(id string) (EmissionRecipe, bool, error)

GeneratedEmissionRecipeForPrimitive is used by the direct projector's preflight to verify that every residual syntax contract has a compiled layout plan. It does not upgrade target preservation modes by itself.

type EmissionRecipeChild added in v1.0.5

type EmissionRecipeChild struct {
	Role    string
	Ordinal int
	Doc     Doc
}

EmissionRecipeChild preserves the proven syntax.child role and ordinal while holding only an already-rendered ephemeral Doc.

type EmissionRecipeInput added in v1.0.5

type EmissionRecipeInput struct {
	NodeID   int
	Children []EmissionRecipeChild
}

EmissionRecipeInput adapts a single canonical UAST node to the generic executor. It intentionally excludes all semantic values except the node ID for diagnostics; children are passed as already-rendered syntax fragments.

type EmissionRecipeOperation added in v1.0.5

type EmissionRecipeOperation struct {
	Atomic  string
	Handler EmissionHandlerClass
	Slot    string
}

EmissionRecipeOperation is one generated entry of M_EO. Atomic is retained verbatim so its matrix provenance can be checked before any Doc is built.

type EmissionRecipeRegistry added in v1.0.5

type EmissionRecipeRegistry struct {
	Recipes        map[string]EmissionRecipe
	HandlerClasses []EmissionHandlerClass
}

EmissionRecipeRegistry is the cached result of compiling the generated data. Recipes are built once per process and execution is O(recipe length).

func UniversalEmissionRecipeRegistry added in v1.0.5

func UniversalEmissionRecipeRegistry() (EmissionRecipeRegistry, error)

UniversalEmissionRecipeRegistry returns the build-cached generated recipes.

type EmpiricalLoweringContract added in v1.1.1

type EmpiricalLoweringContract struct {
	Target       string
	ASTNode      string
	Primitive    string
	UASTContract string
}

EmpiricalLoweringContract describes a target-independent UAST operation observed in py2many's emitters. It is deliberately a contract table, not a second IR or a parser.

type ExecutionPrimitiveMatrixAnalysis added in v1.0.5

type ExecutionPrimitiveMatrixAnalysis struct {
	Schema                                                                                         string `json:"schema"`
	Targets, ProjectionClasses, Primitives                                                         []string
	E                                                                                              matrixir.SparseMatrix `json:"e"`
	R, S, SDirect, SClosed, M                                                                      matrixir.SparseMatrix
	Direct                                                                                         map[string]map[string]bool `json:"direct"`
	NativeSupportCells, DerivedSupportCells, ClosedSupportCells                                    int
	MissingCells, SemanticMissingCells, DirectCells, ExistingDirectCells, ReconstructedDirectCells int
	Contradictions                                                                                 []string `json:"contradictions"`
	UnknownSupportCells                                                                            int      `json:"unknown_support_cells"`
	ResidualClasses                                                                                int      `json:"residual_classes"`
	SolveObligations                                                                               int      `json:"solve_obligations"`
	NativeProven                                                                                   int      `json:"native_proven"`
	NativeImpossible                                                                               int      `json:"native_impossible"`
	Conflicts                                                                                      int      `json:"conflicts"`
	InsufficientProof                                                                              int      `json:"insufficient_proof"`
	ExecutableWitnessBefore                                                                        int      `json:"executable_witness_before"`
	RuntimeFallbackOnly                                                                            int      `json:"runtime_fallback_only"`
	MissingRegistryEdges                                                                           int      `json:"missing_registry_edges"`
	MissingDispatchEdges                                                                           int      `json:"missing_dispatch_edges"`
	MissingRecipeBindings                                                                          int      `json:"missing_recipe_bindings"`
	MissingRendererBindings                                                                        int      `json:"missing_renderer_bindings"`
	MissingHandlerBehaviors                                                                        int      `json:"missing_handler_behaviors"`
}

ExecutionPrimitiveMatrixAnalysis is the canonical R/S/M quotient. It is a registry/report plane only: R comes from structure execution contracts and S only from already proven DIRECT UAST paths.

func UniversalExecutionPrimitiveMatrixAnalysis added in v1.0.5

func UniversalExecutionPrimitiveMatrixAnalysis() (ExecutionPrimitiveMatrixAnalysis, error)

func WriteExecutionPrimitiveMatrixAnalysis added in v1.0.5

func WriteExecutionPrimitiveMatrixAnalysis(out string) (ExecutionPrimitiveMatrixAnalysis, error)

type Expr

type Expr interface {
	// contains filtered or unexported methods
}

type ExprStmt

type ExprStmt struct{ X Expr }

type ExternalPrimitiveCrosswalkReport added in v1.2.1

type ExternalPrimitiveCrosswalkReport struct {
	InitialInsufficientEvidence int      `json:"initial_insufficient_evidence"`
	ExternalEvidenceRows        int      `json:"external_evidence_rows"`
	ExactCodeEvidenceRows       int      `json:"exact_code_evidence_rows"`
	CodeEvidenceRows            int      `json:"code_evidence_rows"`
	DocCandidateRows            int      `json:"doc_candidate_rows"`
	GapRowsWithExternalMatch    int      `json:"gap_rows_with_external_match"`
	GapRowsPromotedExact        int      `json:"gap_rows_promoted_exact"`
	NewDerivedPrimitives        int      `json:"new_derived_primitives"`
	NewGeneratedRecipes         int      `json:"new_generated_recipes"`
	NewParameterizedMappings    int      `json:"new_parameterized_kernel_mappings"`
	NewTargetTerminalProofs     int      `json:"new_target_terminal_proofs"`
	TransitivelyClosedGaps      int      `json:"transitively_closed_gaps"`
	RemainingInsufficient       int      `json:"remaining_insufficient_evidence"`
	TotalGeneratedRecipes       int      `json:"total_generated_recipes"`
	TotalClosureRules           int      `json:"total_closure_reachable_rules"`
	TotalExecutorRules          int      `json:"total_executor_reachable_rules"`
	ExternalGapClosureRate      float64  `json:"external_gap_closure_rate"`
	Promoted                    []string `json:"promoted_exact_contracts"`
	Remaining                   []string `json:"remaining_contracts"`
	EvidenceSHA256              string   `json:"evidence_sha256"`
}

func WriteExternalPrimitiveCrosswalkReport added in v1.2.1

func WriteExternalPrimitiveCrosswalkReport(out string) (*ExternalPrimitiveCrosswalkReport, error)

WriteExternalPrimitiveCrosswalkReport crosswalks the embedded workbook against the existing contract-gap and primitive registries.

type FailureClass added in v1.2.1

type FailureClass string

FailureClass is the stable, machine-readable classification exposed at the public transpilation boundary. Internal parser/compiler text is retained only as Cause and never used to choose a route.

const (
	FailureSourceSyntax        FailureClass = "SOURCE_SYNTAX_ERROR"
	FailureFrontendParse       FailureClass = "FRONTEND_PARSE_BUG"
	FailureFrontendSemantic    FailureClass = "FRONTEND_SEMANTIC_GAP"
	FailureLegacyParserEscape  FailureClass = "LEGACY_PARSER_ESCAPE"
	FailureLegacyBackendEscape FailureClass = "LEGACY_BACKEND_ESCAPE"
	FailureUASTValidation      FailureClass = "UAST_VALIDATION_FAILED"
	FailureDirectUnavailable   FailureClass = "DIRECT_NATIVE_UNAVAILABLE"
	FailureLowering            FailureClass = "LOWERING_INVALID_UAST"
	FailureIntermediate        FailureClass = "INTERMEDIATE_ROUTE_FAILED"
	FailureRuntime             FailureClass = "RUNTIME_ROUTE_FAILED"
	FailureRuntimeDisabled     FailureClass = "RUNTIME_DISABLED"
	FailureTargetEmit          FailureClass = "TARGET_RENDER_FAILED"
	FailureTargetReparse       FailureClass = "TARGET_REPARSE_FAILED"
	FailureRegexParserEscape   FailureClass = "REGEX_PARSER_ESCAPE"
	FailureTextParserEscape    FailureClass = "TEXT_PARSER_ESCAPE"
	FailurePostFrontendReparse FailureClass = "POST_FRONTEND_REPARSE_ESCAPE"
	FailureInternal            FailureClass = "INTERNAL_BUG"
	FailureUnknown             FailureClass = "UNKNOWN_FAILURE"
)

func FailureClassOf added in v1.2.1

func FailureClassOf(err error) FailureClass

type ForStmt

type ForStmt struct {
	Name string
	Seq  Expr
	Body Stmt
}

type FrontendClosureReport added in v1.2.1

type FrontendClosureReport struct {
	Languages []string
	Forms     []string
	Features  []string
	Patterns  []string
	// ParserAccept is the independently inventoried source-parser axis.
	// Accept is retained as a compatibility alias for callers that consumed
	// the older closure report.
	ParserAccept                  matrixir.SparseMatrix
	ParserEvidence                []FrontendParserFormEvidence
	SourceToMatrixIR              matrixir.SparseMatrix `json:"source_to_matrixir"`
	MatrixIRForms                 []string              `json:"matrixir_forms"`
	PerLanguage                   []FrontendLanguageClosure
	OldAxisForms                  []string
	OldGenericMatrixIRAxis        int  `json:"old_generic_matrixir_form_axis"`
	SourceParserFormUnion         int  `json:"true_source_parser_form_union"`
	SourceParserLanguageFormCells int  `json:"true_source_parser_language_form_cells"`
	SourceParserGapInitial        int  `json:"source_parser_gap_initial"`
	SourceParserGapFinal          int  `json:"source_parser_gap_final"`
	SilentSourceParserDrop        int  `json:"silent_source_parser_drop"`
	InvalidParserEvidenceRows     int  `json:"invalid_parser_evidence_rows"`
	IdenticalLanguageAxisWarning  bool `json:"identical_language_axis_warning"`

	Accept           matrixir.SparseMatrix // Language x Form
	Accounted        matrixir.SparseMatrix // Language x Form
	Required         matrixir.SparseMatrix // Form x Feature
	Have             matrixir.SparseMatrix // Form x Feature
	RelationRequired matrixir.SparseMatrix // Form x Pattern
	RelationHave     matrixir.SparseMatrix // Form x Pattern
	Phase            matrixir.SparseMatrix // Language x phase
	Dependency       matrixir.SparseMatrix // Language x dependency class

	NodeGap, SemanticGap, RelationGap, PhaseGap, DependencyGap  int
	Families                                                    []string
	NodeGapInitial, NodeGapFinal                                int
	LanguageSpecificPreserved, UnknownSemanticForms             int
	UnownedSurface                                              int
	StructuralComplete, SemanticComplete, CrossLanguageEmitSafe bool
	OldAxisComplete                                             bool
}

func FrontendClosureMatrices added in v1.2.1

func FrontendClosureMatrices() (FrontendClosureReport, error)

FrontendClosureMatrices derives source-parser acceptance from checked-in grammar/node evidence, then joins it to the existing canonical matrices. A missing evidence row remains unknown rather than being treated as false.

type FrontendConstructMatrixEntry added in v1.2.1

type FrontendConstructMatrixEntry struct {
	Construct           string   `json:"construct"`
	UASTStructure       string   `json:"uast_structure"`
	UASTKind            string   `json:"uast_kind"`
	ExecutionPrimitives []string `json:"execution_primitives"`
}

FrontendConstructMatrixEntry is the language-neutral join between a frontend construct and the UAST/execution contracts that already exist in this backend. It is metadata, not a second IR: parser events still carry the actual operands and relations.

func UniversalFrontendConstructMatrix added in v1.2.1

func UniversalFrontendConstructMatrix() []FrontendConstructMatrixEntry

UniversalFrontendConstructMatrix returns a deterministic exact join of the generated frontend crosswalk and the existing execution primitive plane. Keeping this derived from frontendFactCrosswalk prevents a second list of language handlers from drifting away from the canonical UAST contracts.

type FrontendFactSink added in v1.0.5

type FrontendFactSink interface {
	AddNode(UniversalASTNode)
	AddField(FrontendFieldFact)
	AddSource(FrontendSourceFact)
	AddRole(FrontendRelationFact)
	AddOperand(FrontendRelationFact)
	AddSymbol(FrontendSymbolFact)
	AddBinding(FrontendRelationFact)
	AddRelation(FrontendRelationFact)
}

FrontendFactSink is the language-neutral output boundary for a parser core. It records only proved frontend facts; it never owns a second AST.

type FrontendFactsBuilder added in v1.0.5

type FrontendFactsBuilder struct{ Facts FrontendSemanticFacts }

FrontendFactsBuilder is the default in-memory sink used only until the shared facts-to-UAST builder consumes the collected frontend output.

func (*FrontendFactsBuilder) AddBinding added in v1.0.5

func (b *FrontendFactsBuilder) AddBinding(v FrontendRelationFact)

func (*FrontendFactsBuilder) AddField added in v1.0.5

func (b *FrontendFactsBuilder) AddField(v FrontendFieldFact)

func (*FrontendFactsBuilder) AddNode added in v1.0.5

func (b *FrontendFactsBuilder) AddNode(v UniversalASTNode)

func (*FrontendFactsBuilder) AddOperand added in v1.0.5

func (b *FrontendFactsBuilder) AddOperand(v FrontendRelationFact)

func (*FrontendFactsBuilder) AddRelation added in v1.0.5

func (b *FrontendFactsBuilder) AddRelation(v FrontendRelationFact)

func (*FrontendFactsBuilder) AddRole added in v1.0.5

func (*FrontendFactsBuilder) AddSource added in v1.0.5

func (b *FrontendFactsBuilder) AddSource(v FrontendSourceFact)

func (*FrontendFactsBuilder) AddSymbol added in v1.0.5

func (b *FrontendFactsBuilder) AddSymbol(v FrontendSymbolFact)

type FrontendFeatureEvidence added in v1.2.1

type FrontendFeatureEvidence struct {
	Language, Feature, State, Proof, IDs string
	Count                                int
}

type FrontendFieldFact added in v1.0.5

type FrontendFieldFact struct {
	NodeID int
	Name   string
	Value  json.RawMessage
}

type FrontendInputKind added in v1.2.8

type FrontendInputKind string

FrontendInputKind separates evidence extractors at the input boundary. All successful extractors still return the existing SemanticProgram/UAST; this registry is not a second intermediate representation.

const (
	FrontendInputSource     FrontendInputKind = "source"
	FrontendInputAssembly   FrontendInputKind = "assembly"
	FrontendInputMachine    FrontendInputKind = "machine_code"
	FrontendInputObject     FrontendInputKind = "object"
	FrontendInputExecutable FrontendInputKind = "executable"
)

func SupportedFrontendInputKinds added in v1.2.8

func SupportedFrontendInputKinds() []FrontendInputKind

type FrontendLanguageClosure added in v1.2.1

type FrontendLanguageClosure struct {
	Language                  string   `json:"language"`
	ParserForms               []string `json:"parser_forms"`
	AccountedForms            []string `json:"accounted_forms"`
	DirectCanonical           []string `json:"direct_canonical"`
	DesugaredCanonical        []string `json:"desugared_canonical"`
	CompiletimeMetadata       []string `json:"compiletime_metadata"`
	LanguageSpecificPreserved []string `json:"language_specific_preserved"`
	RecoveredError            []string `json:"recovered_error"`
	NodeGaps                  []string `json:"node_gaps"`
	UnownedSurface            []string `json:"unowned_surface"`
}

type FrontendParserFormEvidence added in v1.2.1

type FrontendParserFormEvidence struct {
	Language      string   `json:"language"`
	Form          string   `json:"form"`
	ParserSource  string   `json:"parser_source"`
	ParserSymbol  string   `json:"parser_symbol"`
	Origin        string   `json:"origin"`
	Productive    bool     `json:"productive"`
	Coverage      string   `json:"coverage"`
	NodeNamed     bool     `json:"node_named"`
	HasFields     bool     `json:"has_fields"`
	HasChildren   bool     `json:"has_children"`
	MatrixForms   []string `json:"matrix_forms"`
	MappingStatus string   `json:"mapping_status"`
	CanonicalForm string   `json:"canonical_form"`
}

type FrontendParserInventory added in v1.2.1

type FrontendParserInventory struct {
	Languages   []string
	Forms       []string
	Accept      matrixir.SparseMatrix
	Evidence    []FrontendParserFormEvidence
	PerLanguage map[string][]string
	ByLanguage  map[string]map[string]FrontendParserFormEvidence
}

func ActualFrontendParserInventory added in v1.2.1

func ActualFrontendParserInventory() FrontendParserInventory

type FrontendPhaseEvidence added in v1.2.1

type FrontendPhaseEvidence struct{ Language, Compiler, Area, Phase, Features, ID string }

type FrontendRelationEvidence added in v1.2.1

type FrontendRelationEvidence struct{ ID, Left, Relation, Right, Language, Proof, EvidenceID string }

type FrontendRelationFact added in v1.0.5

type FrontendRelationFact struct {
	Kind        string
	From        int
	To          UniversalASTReference
	Role        string
	Ordinal     int
	EvidenceRef int
	Attributes  map[string]json.RawMessage
}

type FrontendReturnFact added in v1.0.5

type FrontendReturnFact struct {
	ReturnNodeID   int
	FunctionNodeID int
	ValueNodeID    int
	Type           SemanticType
}

type FrontendSemanticFacts added in v1.0.5

type FrontendSemanticFacts struct {
	SchemaVersion          int
	BasisSHA256            string
	SemanticDocumentSHA256 string
	LanguageProfile        string
	LanguageFacet          []float64
	Projection             string
	Evaluation             string
	ValueModel             string
	IndexBase              int
	Types                  SemanticTypeContract
	Origin                 SemanticOrigin
	Metadata               map[string]string
	Extensions             map[string]any
	Contracts              SemanticContracts
	Dialects               []SemanticDialect
	SemanticFeatures       *SemanticFeatureModel
	TypeTable              []SemanticTypeDefinition
	TypeGraph              matrixir.SparseMatrix
	TypeRelations          *SemanticTypeRelations
	Surface                *UniversalASTSurface

	Nodes     []UniversalASTNode
	Fields    []FrontendFieldFact
	Sources   []FrontendSourceFact
	TypesFact []FrontendTypeFact
	Symbols   []FrontendSymbolFact
	Bindings  []FrontendRelationFact
	Relations []FrontendRelationFact
	Returns   []FrontendReturnFact
	Evidence  SemanticEvidence

	// LanguageFacts is reserved for frontend-local, proved data. It is never
	// emitted unless it is represented by a permitted UAST field, facet or
	// relation above.
	LanguageFacts map[string]json.RawMessage
}

FrontendSemanticFacts is the short-lived, language-neutral hand-off from a frontend analyser to the Universal AST builder. It is deliberately not an intermediate representation: it contains only facts proved by one frontend and is discarded once the canonical UniversalASTDocument is built.

Nodes and relations use the public UAST schema types so that the schema, field-mask and relation-matrix validators remain the single authority.

type FrontendSourceFact added in v1.0.5

type FrontendSourceFact struct {
	NodeID int
	Span   SemanticSourceSpan
}

type FrontendSpec

type FrontendSpec struct {
	ID           string
	Aliases      []string
	Extensions   []string
	Capabilities []string
	Dialects     []string
}

FrontendSpec and BackendSpec are declarative registries. They keep language selection, aliases, file extensions, dialects and feature boundaries out of growing switch statements. Their implementation remains local Go code; no CrossTL source is included.

func Frontends

func Frontends() []FrontendSpec

type FrontendSymbolFact added in v1.0.5

type FrontendSymbolFact struct {
	NodeID int
	Name   string
	Kind   string
}

type FrontendTypeFact added in v1.0.5

type FrontendTypeFact struct {
	NodeID int
	Type   SemanticType
}

type FullSemanticSource added in v1.2.9

type FullSemanticSource struct{ Program *SemanticProgram }

func (FullSemanticSource) GetBinding added in v1.2.9

func (s FullSemanticSource) GetBinding(id int) (*UniversalASTNode, bool)

func (FullSemanticSource) GetEffects added in v1.2.9

func (s FullSemanticSource) GetEffects(id int) []UniversalASTRelation

func (FullSemanticSource) GetFunction added in v1.2.9

func (s FullSemanticSource) GetFunction(id int) (*UniversalASTNode, bool)

func (FullSemanticSource) GetNode added in v1.2.9

func (s FullSemanticSource) GetNode(id int) (*UniversalASTNode, bool)

func (FullSemanticSource) GetRelations added in v1.2.9

func (s FullSemanticSource) GetRelations(id int, k string) []UniversalASTRelation

func (FullSemanticSource) GetType added in v1.2.9

type FunctionExpr

type FunctionExpr struct {
	Binding           string
	DefaultEvaluation string
	Params            []Param
	Body              *BlockStmt
}

type FunctionFlowEvidence

type FunctionFlowEvidence struct {
	Name         string              `json:"name"`
	Entry        int                 `json:"entry"`
	Nodes        []string            `json:"nodes"`
	Always       matrixir.Matrix     `json:"always"`
	WhenTrue     matrixir.Matrix     `json:"when_true"`
	WhenFalse    matrixir.Matrix     `json:"when_false"`
	Reachable    matrixir.Vector     `json:"reachable"`
	Error        string              `json:"error,omitempty"`
	Cycles       matrixir.Vector     `json:"cycles"`
	StateMachine bool                `json:"state_machine"`
	Slots        []string            `json:"slots"`
	Reads        matrixir.Matrix     `json:"reads"`
	Writes       matrixir.Matrix     `json:"writes"`
	Defined      matrixir.Matrix     `json:"defined"`
	Initial      matrixir.Vector     `json:"initial"`
	Iterations   []IterationEvidence `json:"iterations,omitempty"`
}

FunctionFlowEvidence exposes the very matrices used by the generator, not a second graph reconstructed from emitted text. It is intended for audit tools.

func AnalyzeFunctionFlows

func AnalyzeFunctionFlows(canonical string) ([]FunctionFlowEvidence, error)

func AnalyzeSemanticFunctionFlows

func AnalyzeSemanticFunctionFlows(program *SemanticProgram) ([]FunctionFlowEvidence, error)

AnalyzeSemanticFunctionFlows is the canonical UAST flow entry point. The older string function above remains a compatibility adapter for callers that still have R text; no target generator needs that text as state.

type GeneratedLoweringRecipe added in v1.2.1

type GeneratedLoweringRecipe struct {
	ID           string               `json:"id"`
	Primitive    string               `json:"primitive"`
	Class        string               `json:"class"`
	Dependencies []string             `json:"dependencies,omitempty"`
	Guards       []string             `json:"guards,omitempty"`
	Steps        []LoweringRecipeStep `json:"steps"`
	BasisHash    string               `json:"basis_hash"`
	ProofState   string               `json:"proof_state"`
}

GeneratedLoweringRecipe is an ephemeral rewrite plan. It contains no source program values and can safely be regenerated whenever its hash is stale.

func FindShortestExactRecipe added in v1.2.1

func FindShortestExactRecipe(target, primitive string) (GeneratedLoweringRecipe, error)

FindShortestExactRecipe performs deterministic exact witness selection over the generated equivalence library and target basis. Current recipes are single-step witnesses; the API is chain-ready for future transitive rules.

type GeneratedPrimitiveRegistry added in v1.2.1

type GeneratedPrimitiveRegistry struct {
	RecipesByPrimitive map[string]GeneratedLoweringRecipe
	AtomicKernels      map[string]string
}

GeneratedPrimitiveRegistry is the runtime view of the generated recipes. It is derived from the canonical specification and has no language branches.

type GoNativeFrontend added in v1.0.5

type GoNativeFrontend struct{}

GoNativeFrontend uses the official Go parser and type checker. Imports are rejected until an explicit, reproducible module resolver is supplied. Widths of platform-dependent int/uint/uintptr remain unknown, not host-derived.

func (GoNativeFrontend) Analyze added in v1.0.5

func (GoNativeFrontend) Analyze(filename, source string) (*NativeAnalysis, error)

type HelperRequirement added in v1.0.5

type HelperRequirement struct{ ID string }

type HelperSpec added in v1.0.5

type HelperSpec struct {
	ID, Target, RequiredCapability, Source string
	Dependencies                           []string
}

type IdentExpr

type IdentExpr struct{ Name string }

type IfStmt

type IfStmt struct {
	Cond Expr
	Then Stmt
	Else Stmt
}

type ImplementationMatrix added in v1.0.5

type ImplementationMatrix struct {
	Operations  []string              `json:"operations"`
	Stages      []string              `json:"stages"`
	Implemented matrixir.SparseMatrix `json:"implemented"`
	Unsupported matrixir.SparseMatrix `json:"unsupported"`
	Arity       matrixir.Vector       `json:"operand_count"`
	Results     []string              `json:"result_kinds"`
	Evidence    string                `json:"evidence_policy"`
	Languages   []string              `json:"languages"`
	Routes      matrixir.SparseMatrix `json:"declared_complete_operation_routes"`
}

ImplementationMatrix describes installed lowering paths, not test results. The operation basis and availability planes also gate actual code emission.

func TypedImplementationMatrix added in v1.0.5

func TypedImplementationMatrix() ImplementationMatrix

func (ImplementationMatrix) Check added in v1.0.5

func (m ImplementationMatrix) Check(required []string, stage string) error

func (ImplementationMatrix) Reject added in v1.0.5

func (m ImplementationMatrix) Reject(required []string) (matrixir.SparseMatrix, error)

type IndexExpr

type IndexExpr struct {
	X      Expr
	Args   []Arg
	Double bool
}

type IterationEvidence

type IterationEvidence struct {
	Sequence        string          `json:"sequence_slot"`
	Position        string          `json:"position_slot"`
	Length          string          `json:"length_slot"`
	Element         string          `json:"element_slot"`
	Advance         matrixir.Matrix `json:"advance"`
	InitialPosition float64         `json:"initial_position"`
}

type IterationExpr

type IterationExpr struct {
	Kind  string
	Value Expr
}

IterationExpr is an internal intrinsic, never resolved as a user function. Snapshot normalizes null/scalar/vector to a private outer vector; size then operates on that vector. Element gathers use the existing IndexExpr node.

type Language

type Language struct {
	ID        string
	Name      string
	Extension string
	Comment   string
}

func ByID

func ByID(id string) (Language, bool)

type LiteralExpr

type LiteralExpr struct{ Kind, Text string }

type LoweringExactness added in v1.2.1

type LoweringExactness string

LoweringExactness describes the semantic strength of a rewrite. Only EXACT rules may be applied by the native worklist; approximate/emulated candidates remain available for reports and later explicit fallback work.

const (
	LoweringExact       LoweringExactness = "EXACT"
	LoweringApproximate LoweringExactness = "APPROXIMATE"
	LoweringEmulated    LoweringExactness = "EMULATED"
)

type LoweringRecipeStep added in v1.2.1

type LoweringRecipeStep struct {
	Operation string   `json:"operation"`
	Inputs    []string `json:"inputs,omitempty"`
	Output    string   `json:"output,omitempty"`
	Order     int      `json:"order"`
}

type LoweringStatus added in v1.2.1

type LoweringStatus string
const (
	LoweringDirectProven LoweringStatus = "DIRECT_PROVEN"
	LoweringReachable    LoweringStatus = "LOWERING_REACHABLE"
	LoweringProven       LoweringStatus = "LOWERING_PROVEN"
	LoweringUnresolved   LoweringStatus = "UNRESOLVED"
	LoweringRuntimeOnly  LoweringStatus = "RUNTIME_REQUIRED"
)

type LoweringTrace added in v1.2.1

type LoweringTrace struct {
	Target       string         `json:"target"`
	Attempted    bool           `json:"attempted"`
	Success      bool           `json:"success"`
	Iterations   int            `json:"iterations"`
	Rules        []string       `json:"rules,omitempty"`
	Residuals    []string       `json:"residuals,omitempty"`
	Status       LoweringStatus `json:"status"`
	ErrorClass   string         `json:"error_class,omitempty"`
	BeforeDigest string         `json:"before_digest,omitempty"`
	AfterDigest  string         `json:"after_digest,omitempty"`
}

func EmitSemanticLoweredDirect added in v1.2.1

func EmitSemanticLoweredDirect(target string, p *SemanticProgram) (string, LoweringTrace, error)

EmitSemanticLoweredDirect is the explicit second stage in the native-first pipeline. It records lowering separately so a failed clone cannot leak into intermediate or runtime fallback.

type MachineIR added in v1.2.8

type MachineIR struct {
	Architecture string                 `json:"architecture"`
	BaseAddress  uint64                 `json:"base_address"`
	Instructions []MachineIRInstruction `json:"instructions"`
	CFG          []MachineIREdge        `json:"cfg"`
}

MachineIR is the lossless structural boundary between x86 decoding and the existing semantic lifter. It contains addressing/provenance facts without promoting instruction encodings into semantic primitives.

func DecodeMachineIR added in v1.2.8

func DecodeMachineIR(data []byte, opts CompileOptions) (*MachineIR, error)

DecodeMachineIR decodes assembly, raw machine bytes, COFF objects, or PE32+ executables using the same x64 decoder as the binary frontend. It is an evidence/inspection API; semantic promotion still occurs only in LiftBinaryInput and remains fail-closed for unknown dataflow.

type MachineIREdge added in v1.2.8

type MachineIREdge struct {
	From int    `json:"from"`
	To   int    `json:"to"`
	Kind string `json:"kind"`
}

type MachineIRInstruction added in v1.2.8

type MachineIRInstruction struct {
	Index          int                `json:"index"`
	Offset         int                `json:"offset"`
	Operation      string             `json:"operation"`
	Classification string             `json:"classification"`
	Primitive      string             `json:"primitive,omitempty"`
	Operands       []MachineIROperand `json:"operands,omitempty"`
}

type MachineIROperand added in v1.2.8

type MachineIROperand struct {
	Kind         string `json:"kind"`
	Register     string `json:"register,omitempty"`
	Index        string `json:"index,omitempty"`
	Scale        byte   `json:"scale,omitempty"`
	Immediate    int64  `json:"immediate,omitempty"`
	Displacement int64  `json:"displacement,omitempty"`
	Label        string `json:"label,omitempty"`
	HasBase      bool   `json:"has_base,omitempty"`
	RIPRelative  bool   `json:"rip_relative,omitempty"`
	Absolute     bool   `json:"absolute,omitempty"`
}

type ModuleImportOptions added in v1.2.9

type ModuleImportOptions struct{ Language string }

type NativeABIContext added in v1.2.8

type NativeABIContext string
const (
	NativeABIValue    NativeABIContext = "value"
	NativeABIArgument NativeABIContext = "argument"
	NativeABIResult   NativeABIContext = "result"
	NativeABICapture  NativeABIContext = "capture"
)

type NativeAnalysis added in v1.0.5

type NativeAnalysis struct {
	Schema                string                   `json:"schema"`
	Language              string                   `json:"language"`
	Executable            bool                     `json:"executable"`
	Events                []NativeEvent            `json:"events"`
	Syntax                matrixir.SparseMatrix    `json:"syntax"`
	Binding               matrixir.SparseMatrix    `json:"binding"`
	SameBinding           matrixir.SparseMatrix    `json:"same_binding"`
	Requirements          []string                 `json:"requirements"`
	Scopes                []SemanticScope          `json:"scopes"`
	ScopeMembership       matrixir.SparseMatrix    `json:"scope_membership"`
	TypeCheckArchitecture string                   `json:"type_check_architecture"`
	TypeTable             []SemanticTypeDefinition `json:"type_table"`
	TypeGraph             matrixir.SparseMatrix    `json:"type_graph"`
	TypeRelations         *SemanticTypeRelations   `json:"type_relations"`
}

NativeAnalysis is a frontend analysis artifact, NOT SemanticDocument v1. Syntax stores parent-to-child edges; Binding stores occurrences-to-symbols. The product Binding * Binding^T relates occurrences of the SAME symbol. It is not a dataflow or evaluation-order matrix.

type NativeCapabilityBasis added in v1.2.8

type NativeCapabilityBasis struct {
	Target     string
	Operations map[string]bool
	Runtime    map[string]bool
}

func BuildNativeCapabilityBasis added in v1.2.8

func BuildNativeCapabilityBasis(target string) (NativeCapabilityBasis, error)

type NativeClosure added in v1.2.8

type NativeClosure struct {
	Supported bool
	Ranks     map[string]int
	Witnesses map[string]NativeClosureWitness
	Missing   []string
}

func SolveExactClosure added in v1.2.8

func SolveExactClosure(requirements SemanticRequirements, recipes []GeneratedLoweringRecipe, capabilities NativeCapabilityBasis) NativeClosure

type NativeClosureWitness added in v1.2.8

type NativeClosureWitness struct {
	Operation string
	Rank      int
	RecipeID  string
}

type NativeEmissionInput added in v1.0.5

type NativeEmissionInput struct {
	NodeID   int
	Children []EmissionRecipeChild
}

NativeEmissionInput contains already-rendered UAST children. It is a transient layout input; semantic values remain in UniversalASTDocument.

type NativeEvent added in v1.0.5

type NativeEvent struct {
	ID           int                `json:"id"`
	Kind         string             `json:"kind"`
	Name         string             `json:"name,omitempty"`
	Literal      string             `json:"literal,omitempty"`
	Type         SemanticType       `json:"type"`
	Source       SemanticSourceSpan `json:"source"`
	Binding      *int               `json:"binding,omitempty"`
	Declaration  bool               `json:"declaration,omitempty"`
	Operation    string             `json:"operation,omitempty"`
	ShortCircuit bool               `json:"short_circuit,omitempty"`
	Confidence   string             `json:"confidence"`
	Scope        int                `json:"scope"`
}

type NativeFrontend added in v1.0.5

type NativeFrontend interface {
	Analyze(filename, source string) (*NativeAnalysis, error)
}

NativeFrontend extracts structured facts without reconstructing source text. Analysis is deliberately separate from executable lowering: a type-checked source construct is not automatically supported by the dynamic runtime.

type NativeGoEvidenceFact added in v1.0.5

type NativeGoEvidenceFact struct {
	NodeID       int
	Kind, Detail string
}

type NativeGoNodeFact added in v1.0.5

type NativeGoNodeFact struct {
	ID, Parent                                           int
	Kind, Name, Operator, LiteralKind, LiteralValue      string
	SourceID, TypeID, SymbolID                           int
	Children                                             []int
	Fields                                               map[string]string
	ParameterRefs, ArgumentRefs, OperandRefs, ReturnRefs []int
	CallTargetRef, FunctionRef, ScopeRef                 int
}

type NativeGoRelationFact added in v1.0.5

type NativeGoRelationFact struct {
	Kind        string
	From, To    int
	Role        string
	Ordinal     int
	EvidenceRef int
}

type NativeGoSemanticFacts added in v1.0.5

type NativeGoSemanticFacts struct {
	FrontendSemanticFacts
	Root                                                                       *SemanticStatement
	Structure, Fields, Sources, Types, Symbols, Calls, Control, Data, Evidence int
	SourceFacts                                                                []NativeGoSourceFact
	TypeFacts                                                                  []NativeGoTypeFact
	SymbolFacts                                                                []NativeGoSymbolFact
	BindingFacts                                                               []NativeGoRelationFact
	RelationFacts                                                              []NativeGoRelationFact
	EvidenceFacts                                                              []NativeGoEvidenceFact
	Nodes                                                                      []NativeGoNodeFact
	RawUAST                                                                    *UniversalASTDocument
}

NativeGoSemanticFacts are short-lived frontend facts shared by lowering adapters. They are not a second IR and are discarded after construction.

type NativeGoSourceFact added in v1.0.5

type NativeGoSourceFact struct {
	ID   int
	Span SemanticSourceSpan
}

type NativeGoSymbolFact added in v1.0.5

type NativeGoSymbolFact struct {
	ID         int
	Name, Kind string
}

type NativeGoTypeFact added in v1.0.5

type NativeGoTypeFact struct {
	ID   int
	Type SemanticType
}

type NativeLayout added in v1.2.8

type NativeLayout struct {
	Representation                                        NativeRepresentation
	SizeBits, SizeBytes, ABIAlignment, PreferredAlignment int
	FieldOffsets                                          []int
	Stride, IndexBitWidth, PointerSize, StackAlignment    int
	Endianness, MemorySpace                               string
}

func SolveNativeLayout added in v1.2.8

func SolveNativeLayout(profile NativeTargetProfile, typ SemanticType, context NativeABIContext) (NativeLayout, error)

SolveNativeLayout is target-scoped: no semantic type stores a platform layout. The caller supplies ABI context for aggregate result buffers and closure environments.

type NativeLegalityDecision added in v1.2.8

type NativeLegalityDecision struct {
	NodeID         int                  `json:"node_id"`
	StructuralKind string               `json:"structural_kind"`
	SemanticKind   string               `json:"semantic_kind"`
	Family         string               `json:"family"`
	Status         NativeLegalityStatus `json:"status"`
	Predicate      string               `json:"predicate,omitempty"`
	Reason         string               `json:"reason,omitempty"`
}

type NativeLegalityMode added in v1.2.8

type NativeLegalityMode string

NativeLegalityMode controls whether a caller only inspects the canonical graph, permits a partial repair search, or requires a selector-safe fixed point. It never owns another persistent program representation.

const (
	NativeLegalityAnalysis NativeLegalityMode = "ANALYSIS"
	NativeLegalityPartial  NativeLegalityMode = "PARTIAL"
	NativeLegalityFull     NativeLegalityMode = "FULL"
)

type NativeLegalityReport added in v1.2.8

type NativeLegalityReport struct {
	Target    string                   `json:"target"`
	Mode      NativeLegalityMode       `json:"mode"`
	Decisions []NativeLegalityDecision `json:"decisions"`
}

func AnalyzeNativeLegality added in v1.2.8

func AnalyzeNativeLegality(program *SemanticProgram, target string, mode NativeLegalityMode) (NativeLegalityReport, error)

AnalyzeNativeLegality is the non-mutating legality classification used by the semantic/native closure and by evidence reporting. A dynamic result records the predicate proved for the current UAST; it is selector-safe.

func (NativeLegalityReport) Blocking added in v1.2.8

func (NativeLegalityReport) FullLegal added in v1.2.8

func (r NativeLegalityReport) FullLegal() bool

type NativeLegalityStatus added in v1.2.8

type NativeLegalityStatus string
const (
	NativeLegal            NativeLegalityStatus = "LEGAL"
	NativeDynamicallyLegal NativeLegalityStatus = "DYNAMICALLY_LEGAL"
	NativeIllegal          NativeLegalityStatus = "ILLEGAL"
	NativeUnresolved       NativeLegalityStatus = "UNRESOLVED"
)

type NativeRepresentation added in v1.2.8

type NativeRepresentation string
const (
	NativeScalar            NativeRepresentation = "SCALAR"
	NativeAddress           NativeRepresentation = "ADDRESS"
	NativePair              NativeRepresentation = "PAIR"
	NativeDescriptor        NativeRepresentation = "DESCRIPTOR"
	NativeOwnedRegion       NativeRepresentation = "OWNED_REGION"
	NativeFunctionReference NativeRepresentation = "FUNCTION_REFERENCE"
	NativeClosureValue      NativeRepresentation = "CLOSURE_VALUE"
)

type NativeRewriteFixedPoint added in v1.2.8

type NativeRewriteFixedPoint struct {
	Program           *SemanticProgram     `json:"-"`
	Proofs            []NativeRewriteProof `json:"proofs"`
	Iterations        int                  `json:"iterations"`
	ReachedFixedPoint bool                 `json:"reached_fixed_point"`
	Unresolved        []string             `json:"unresolved,omitempty"`
}

NativeRewriteFixedPoint is the bounded, deterministic result of applying the registered verified graph rewrites. Recipes without a structural handler remain visible as unresolved rather than being represented by a disconnected synthetic node.

func RewriteNativeFixedPoint added in v1.2.8

func RewriteNativeFixedPoint(program *SemanticProgram, recipes []GeneratedLoweringRecipe, target string, maxIterations int) (NativeRewriteFixedPoint, error)

RewriteNativeFixedPoint applies every registered, exact structural rewrite until no matching UAST node remains. The worklist is recomputed after each successful transaction because canonical projection may renumber cloned nodes. This keeps operand/result wiring authoritative and makes progress observable without introducing a persistent lowering representation.

type NativeRewriteProof added in v1.2.8

type NativeRewriteProof struct {
	RecipeID                 string `json:"recipe_id"`
	MatchNodeID              int    `json:"match_node_id"`
	PreDigest                string `json:"pre_digest"`
	PostDigest               string `json:"post_digest"`
	EvaluationOrderPreserved bool   `json:"evaluation_order_preserved"`
	EffectsPreserved         bool   `json:"effects_preserved"`
	ValueContractPreserved   bool   `json:"value_contract_preserved"`
}

NativeRewriteProof is durable evidence for one actual graph replacement. It describes a change to the canonical UAST, not a parallel rewrite IR.

type NativeStorageDecision added in v1.2.8

type NativeStorageDecision string
const (
	NativeStaticStorage     NativeStorageDecision = "STATIC"
	NativeStackStorage      NativeStorageDecision = "STACK"
	NativeOwnedStorage      NativeStorageDecision = "OWNED_REGION"
	NativeStorageUnresolved NativeStorageDecision = "UNRESOLVED"
)

func DecideNativeStorage added in v1.2.8

func DecideNativeStorage(request NativeStorageRequest) NativeStorageDecision

DecideNativeStorage centralizes the lifetime decision shared by strings, aggregates, closure environments and returned dynamic values.

type NativeStorageRequest added in v1.2.8

type NativeStorageRequest struct {
	Escapes, ProgramStatic, OwnershipKnown, AliasMutationSafe bool
	DynamicSize                                               bool
	Lifetime                                                  string
}

type NativeTargetProfile added in v1.2.8

type NativeTargetProfile struct {
	OS, ISA, ObjectFormat, ABI, Endianness, SystemABI                    string
	PointerSize, StackAlignment, FunctionPointerAlignment, IndexBitWidth int
	LegalIntegerWidths                                                   []int
}

NativeTargetProfile is analysis data derived from a requested target. It is deliberately not a program IR and contains no source/UAST nodes.

func NativeWindowsX64TargetProfile added in v1.2.8

func NativeWindowsX64TargetProfile() NativeTargetProfile

type NextStmt

type NextStmt struct{}

type OperationExpr added in v1.0.5

type OperationExpr struct {
	Operation SemanticOperation
	Operands  []Expr
}

type Param

type Param struct {
	Mode    string
	Name    string
	Default Expr
	Type    *SemanticType // exact executable parameter type; nil is legacy dynamic
}

type ParsedNode added in v1.0.5

type ParsedNode struct {
	ID     int
	Kind   string
	Source *SemanticSourceSpan
}

type PreservationMode added in v1.0.5

type PreservationMode string
const (
	PreservationDirect  PreservationMode = "DIRECT"
	PreservationRewrite PreservationMode = "REWRITE"
	PreservationHelper  PreservationMode = "HELPER"
	PreservationEmulate PreservationMode = "EMULATE"
	PreservationRuntime PreservationMode = "RUNTIME"
	// PreservationError is an explicit semantic refusal.  It is deliberately
	// distinct from an absent matrix entry: every target × UASF cell must have
	// a deterministic result.
	PreservationError PreservationMode = "ERROR"
)

type PreservationRegistry added in v1.0.5

type PreservationRegistry struct{ Rules []PreservationRule }

func DefaultPreservationRegistry added in v1.0.5

func DefaultPreservationRegistry() PreservationRegistry

func (PreservationRegistry) Solve added in v1.0.5

func (r PreservationRegistry) Solve(target, capability string) (PreservationRule, bool)

type PreservationRule added in v1.0.5

type PreservationRule struct {
	Capability, Target          string
	Mode                        PreservationMode
	Preconditions, Requirements []string
	Handler, Test               string
}

type PrimitiveCompilerReport added in v1.2.1

type PrimitiveCompilerReport struct {
	Specs                      []SemanticPrimitiveSpec    `json:"specs"`
	Recipes                    []GeneratedLoweringRecipe  `json:"recipes"`
	PrimitiveDependencies      [][]int                    `json:"primitive_dependencies"`
	Closure                    [][]int                    `json:"closure"`
	Witness                    map[string]string          `json:"witness"`
	AtomicPrimitives           []string                   `json:"atomic_primitives"`
	KernelClasses              []string                   `json:"kernel_classes"`
	DerivedCount               int                        `json:"derived_count"`
	DerivedWithHandlers        int                        `json:"derived_with_handlers"`
	BasisHash                  string                     `json:"basis_hash"`
	Inventory                  []string                   `json:"inventory"`
	InventoryRecords           []PrimitiveInventoryRecord `json:"inventory_records"`
	ClassificationMatrix       [][]int                    `json:"classification_matrix"`
	ClassificationColumns      []string                   `json:"classification_columns"`
	DirectPrimitives           []string                   `json:"direct_primitives"`
	ParameterizedAtomic        []string                   `json:"parameterized_atomic_primitives"`
	RuntimeOnly                []string                   `json:"runtime_only_primitives"`
	ValidationOnly             []string                   `json:"validation_only_primitives"`
	Unresolved                 []string                   `json:"unresolved_primitives"`
	ContractGaps               []string                   `json:"contract_gaps"`
	EquivalenceMatrix          [][]int                    `json:"equivalence_matrix"`
	RequiredPrimitiveMatrix    [][]int                    `json:"required_primitive_matrix"`
	TargetBasis                map[string][]string        `json:"target_basis"`
	GeneratedRulesRegistered   int                        `json:"generated_rules_registered"`
	GeneratedClosureReachable  int                        `json:"generated_rules_closure_reachable"`
	GeneratedExecutorReachable int                        `json:"generated_rules_executor_reachable"`
	KernelMatrix               map[string]string          `json:"kernel_matrix"`
	RecoveredExactRecipes      []string                   `json:"recovered_exact_recipes"`
}

func CompileUniversalPrimitiveSpecs added in v1.2.1

func CompileUniversalPrimitiveSpecs() (*PrimitiveCompilerReport, error)

CompileUniversalPrimitiveSpecs is the single entry point for generated semantic lowering data. It performs deterministic dependency closure and records witnesses; callers do not need a second registry.

func WritePrimitiveCompilerReport added in v1.2.1

func WritePrimitiveCompilerReport(out string) (*PrimitiveCompilerReport, error)

func (*PrimitiveCompilerReport) Registry added in v1.2.1

type PrimitiveInventoryRecord added in v1.2.1

type PrimitiveInventoryRecord struct {
	ID                         string `json:"id"`
	Source                     string `json:"source"`
	Class                      string `json:"class"`
	SpecPresent                bool   `json:"spec_present"`
	DependenciesKnown          bool   `json:"dependencies_known"`
	RecipeGenerated            bool   `json:"recipe_generated"`
	RuleRegistered             bool   `json:"rule_registered"`
	ClosureReachable           bool   `json:"closure_reachable"`
	ExecutorReachable          bool   `json:"executor_reachable"`
	TargetTerminalReachable    bool   `json:"target_terminal_reachable"`
	SpecializedHandlerRequired bool   `json:"specialized_handler_required"`
	Status                     string `json:"status"`
	Reason                     string `json:"reason,omitempty"`
}

type PrimitiveSpec

type PrimitiveSpec struct {
	TableIndex string
	Name       string
	Kernel     string
	Arity      string
}

func PrimitiveRoute

func PrimitiveRoute(target, name string) (PrimitiveSpec, bool)

type ProductPathWitness added in v1.0.5

type ProductPathWitness struct{ Target, Primitive, Status, MissingFactor string }

ProductPathWitness is the matrix-derived reachability result for one target/primitive pair. It contains registry reachability only and never promotes a runtime terminal into native code.

type ProjectionDerivationRule added in v1.0.5

type ProjectionDerivationRule struct {
	ID        string
	Input     string
	Output    string
	Transform string
}

ProjectionDerivationRule is a declarative typed transform over existing UAST/schema information. It is not a semantic IR and cannot create a new semantic fact; it only exposes a proved projection input.

type ProjectionGapInformation added in v1.0.5

type ProjectionGapInformation struct {
	GapID                 string
	ProjectionPrimitive   string
	RequiredInformation   string
	Class                 ProjectionGapInformationClass
	ExistingUASTElement   string
	DerivationRule        string
	TargetSyntaxParameter string
	SemanticGapID         string
	EvidenceSource        string
	Conflict              bool
}

type ProjectionGapInformationAnalysis added in v1.0.5

type ProjectionGapInformationAnalysis struct {
	Rows   []ProjectionGapInformation
	Counts map[ProjectionGapInformationClass]int
}

func UniversalProjectionGapInformationAnalysis added in v1.0.5

func UniversalProjectionGapInformationAnalysis() (ProjectionGapInformationAnalysis, error)

UniversalProjectionGapInformationAnalysis classifies every remaining primitive obligation. The matrix is the proof boundary for any future UAST expansion: a schema mutation is impossible unless a D row is present.

func WriteProjectionGapInformationAnalysis added in v1.0.5

func WriteProjectionGapInformationAnalysis(dir string) (ProjectionGapInformationAnalysis, error)

type ProjectionGapInformationClass added in v1.0.5

type ProjectionGapInformationClass string

ProjectionGapInformationClass separates UAST facts from their projection consumption. Only class D is allowed to request an additive schema change.

const (
	ProjectionInfoAlready   ProjectionGapInformationClass = "A_ALREADY_IN_UAST"
	ProjectionInfoDerivable ProjectionGapInformationClass = "B_DERIVABLE"
	ProjectionInfoSyntax    ProjectionGapInformationClass = "C_TARGET_SYNTAX"
	ProjectionInfoSemantic  ProjectionGapInformationClass = "D_TRUE_UAST_SEMANTIC_GAP"
)

type ProjectionInformationIntegration added in v1.0.5

type ProjectionInformationIntegration struct {
	DirectBindings               []ProjectionGapInformation
	Derivations                  []ProjectionDerivationRule
	Syntax                       []ProjectionGapInformation
	PrimitiveInformationComplete map[string]bool
	PrimitiveEmissionComplete    map[string]bool
	DerivationClasses            []string
	TargetSyntaxCapabilities     []string
}

func UniversalProjectionInformationIntegration added in v1.0.5

func UniversalProjectionInformationIntegration() (ProjectionInformationIntegration, error)

UniversalProjectionInformationIntegration compiles A/B/C into projection data. The separate EmissionComplete bit is essential: information being available never pretends that a missing syntax combinator exists.

func WriteProjectionInformationIntegration added in v1.0.5

func WriteProjectionInformationIntegration(dir string) (ProjectionInformationIntegration, error)

type ProjectionObligationAnalysis added in v1.0.5

type ProjectionObligationAnalysis struct {
	Archetypes   []string
	Obligations  []string
	Primitives   []ProjectionObligationPrimitive
	Requirements map[string]map[string]bool // M_AO
}

ProjectionObligationAnalysis is a declarative factorization of the residual renderer contracts. It contains no AST values and is not another IR: it is the checked, boolean requirement table consumed by TargetSpec/renderer registration.

func UniversalProjectionObligationAnalysis added in v1.0.5

func UniversalProjectionObligationAnalysis() (ProjectionObligationAnalysis, error)

UniversalProjectionObligationAnalysis returns the immutable, exact matrix quotient cached for this process. All consumers therefore use the same minimum primitive basis and do not repeat the exponential cover search.

func WriteProjectionObligationAnalysis added in v1.0.5

func WriteProjectionObligationAnalysis(dir string) (ProjectionObligationAnalysis, error)

WriteProjectionObligationAnalysis exports the factor matrices. These are declarative registries used for deterministic renderer composition.

func (ProjectionObligationAnalysis) ValidateExact added in v1.0.5

func (a ProjectionObligationAnalysis) ValidateExact() error

ValidateExact proves M_AO = M_AP odot M_PO. It rejects both added and lost cells, protecting the projection contract against accidental broadening.

type ProjectionObligationPrimitive added in v1.0.5

type ProjectionObligationPrimitive struct {
	ID          string
	Archetypes  []string
	Obligations []string
}

ProjectionObligationPrimitive represents one formal concept (a complete rectangle of true cells). Its extent is M_AP and its intent is M_PO.

type ProjectionPrimitiveReduction added in v1.0.5

type ProjectionPrimitiveReduction struct {
	Before            int
	Primitives        []ProjectionObligationPrimitive
	DuplicatesRemoved int
	Compositions      map[string][]string
	ExistingRenderers map[string][]string
	TargetSpecOnly    map[string]bool
	Rewrite           map[string][]string
	Helpers           map[string][]string
	Runtime           map[string][]string
	Irreducible       []string
}

ProjectionPrimitiveReduction is the proof-oriented residual reduction for the renderer primitive basis. It is a registry calculation, not an IR.

func UniversalProjectionPrimitiveReduction added in v1.0.5

func UniversalProjectionPrimitiveReduction() (ProjectionPrimitiveReduction, error)

UniversalProjectionPrimitiveReduction applies duplicate elimination, exact primitive composition and every currently registered positive path. A legacy renderer is never a positive match: it may appear in audit reports, but only direct UAST renderer bindings can cover a primitive.

func WriteProjectionPrimitiveReduction added in v1.0.5

func WriteProjectionPrimitiveReduction(dir string) (ProjectionPrimitiveReduction, error)

type ProjectionPrimitiveTargetSupport added in v1.0.5

type ProjectionPrimitiveTargetSupport struct {
	Target     string
	Primitive  string
	Available  bool
	Mode       PreservationMode
	Parameters map[string]string
}

ProjectionPrimitiveTargetSupport is M_TP plus the target parameters used by the syntax-only composition. A target is marked available only if it has a registered direct UAST renderer for the primitive; parameters alone never upgrade an unsupported semantic contract.

func ProjectionPrimitiveTargetSupports added in v1.0.5

func ProjectionPrimitiveTargetSupports(analysis ProjectionObligationAnalysis) ([]ProjectionPrimitiveTargetSupport, error)

ProjectionPrimitiveTargetSupports derives M_TP directly from TargetSpec. Residual primitives intentionally remain ERROR until a generic direct UAST renderer registers their form. This makes the next implementation step a small primitive registration rather than a Target×UASF special case.

type ProjectionRendererArchetype added in v1.0.5

type ProjectionRendererArchetype struct {
	ID                string   `json:"id"`
	ProjectionClasses []string `json:"projection_classes"`
	Signature         string   `json:"signature"`
	ExistingRenderers []string `json:"existing_renderers"`
	Implemented       bool     `json:"implemented"`
}

type ProjectionRendererBinding added in v1.0.5

type ProjectionRendererBinding struct {
	Form       string
	RendererID string
	SourceFile string
	Function   string
	Reusable   bool
}

type ProjectionRendererCatalogEntry added in v1.0.5

type ProjectionRendererCatalogEntry struct {
	RendererID         string   `json:"renderer_id"`
	SourceFile         string   `json:"source_file"`
	SourceFunction     string   `json:"source_function"`
	SyntacticCategory  string   `json:"syntactic_category"`
	RequiredChildren   []string `json:"required_children"`
	RequiredFields     []string `json:"required_fields"`
	RequiredRelations  []string `json:"required_relations"`
	TargetScope        string   `json:"target_scope"`
	ReturnsDocOrSource string   `json:"returns_doc_or_source"`
	Reusable           bool     `json:"reusable"`
}

ProjectionRendererCatalogEntry records a renderer's syntax interface. It is harvested from Go source and remains declarative: no AST node or semantic value is copied into the catalog.

func HarvestProjectionRenderers added in v1.0.5

func HarvestProjectionRenderers() ([]ProjectionRendererCatalogEntry, error)

HarvestProjectionRenderers parses the checked-in renderer sources. A legacy renderer is catalogued for auditability but is marked non-reusable unless it consumes the UAST execution graph directly.

type ProjectionRendererComposition added in v1.0.5

type ProjectionRendererComposition struct {
	ArchetypeID string
	Primitives  []string
}

ProjectionRendererComposition is the generated, syntax-only sequence for a renderer archetype. It is a registry entry rather than another program IR: nodes and semantic values are still read directly from UniversalASTDocument.

func GeneratedProjectionRendererCompositions added in v1.0.5

func GeneratedProjectionRendererCompositions() ([]ProjectionRendererComposition, error)

GeneratedProjectionRendererCompositions is derived from the exact boolean factorization M_AO = M_AP odot M_PO. It makes later renderer additions a primitive registration: all archetype compositions update at once.

type ProjectionRendererHarvest added in v1.0.5

type ProjectionRendererHarvest struct {
	Catalog     []ProjectionRendererCatalogEntry `json:"catalog"`
	Archetypes  []ProjectionRendererArchetype    `json:"archetypes"`
	Assignments map[string]string                `json:"class_to_archetype"`
	Matches     []ProjectionRendererMatch        `json:"matches"`
}

func UniversalProjectionRendererHarvest added in v1.0.5

func UniversalProjectionRendererHarvest() (ProjectionRendererHarvest, error)

UniversalProjectionRendererHarvest constructs the exact quotient of the remaining projection classes by renderer requirements.

func WriteProjectionRendererHarvest added in v1.0.5

func WriteProjectionRendererHarvest(dir string) (ProjectionRendererHarvest, error)

type ProjectionRendererMatch added in v1.0.5

type ProjectionRendererMatch struct {
	ArchetypeID string `json:"archetype_id"`
	RendererID  string `json:"renderer_id"`
	Compatible  bool   `json:"compatible"`
}

ProjectionRendererMatch is one cell of M_AR. A true cell means that the renderer's checked-in UAST syntax contract supplies every requirement of the archetype. Partial matches never authorize a projection.

type ProjectionResidualAnalysis added in v1.0.5

type ProjectionResidualAnalysis struct {
	Targets         []string
	Archetypes      []string
	Primitives      []string
	Rows            []ProjectionResidualCell
	Classes         []ProjectionResidualClass
	ColumnGapCounts map[string]int
	PrimitiveImpact map[string]int
	SetCounts       map[string]int
}

ProjectionResidualAnalysis is the exact residual plane used to select the next common renderer contract. PrimitiveImpact counts only rows whose complete residual would become empty if the primitive (or exact set) were supported; it does not count partial improvements.

func UniversalProjectionResidualAnalysis added in v1.0.5

func UniversalProjectionResidualAnalysis() (ProjectionResidualAnalysis, error)

UniversalProjectionResidualAnalysis computes M_RESIDUAL directly from the existing renderer composition and target syntax matrices. The synthetic form:<projection-form> atoms are syntax obligations, not new UAST structures; they expose exactly which generic form contract is absent.

func WriteProjectionResidualAnalysis added in v1.0.5

func WriteProjectionResidualAnalysis(dir string) (ProjectionResidualAnalysis, error)

WriteProjectionResidualAnalysis emits the residual quotient and exact column/impact tables consumed by the next generic projection iteration.

type ProjectionResidualCell added in v1.0.5

type ProjectionResidualCell struct {
	Target             string
	Archetype          string
	RequiredPrimitives []string
	Supported          []string
	Missing            []string
	AffectedUASFCells  int
}

ProjectionResidualCell is one exact Target × renderer-archetype row. It contains no program data; it is the boolean residual of the existing renderer obligation matrix against the target syntax/template matrix.

type ProjectionResidualClass added in v1.0.5

type ProjectionResidualClass struct {
	ID                string
	MemberCount       int
	Targets           []string
	Archetypes        []string
	MissingPrimitives []string
	AffectedUASFCells int
}

ProjectionResidualClass groups rows only when their missing primitive vector is byte-for-byte identical after sorting. Similarity and heuristic scores are deliberately not used.

type RecoveryKind added in v1.2.8

type RecoveryKind string
const (
	RecoveryNone      RecoveryKind = "NONE"
	RecoveryLocal     RecoveryKind = "SAFE_LOCAL_RECOVERY"
	RecoveryStatement RecoveryKind = "SAFE_STATEMENT_RECOVERY"
	RecoveryBlock     RecoveryKind = "SAFE_BLOCK_RECOVERY"
	RecoveryAnchor    RecoveryKind = "UNSAFE_CONTROL_RECOVERY"
	RecoveryFatal     RecoveryKind = "FATAL_PARSE_DESYNC"
)

type ReductionNode added in v1.2.8

type ReductionNode struct {
	Kind     string
	Payload  any
	Children []*ReductionNode
}

ReductionNode is a transient structural view supplied by a frontend. It contains no canonical program data and is discarded after reduction.

type ReductionResult added in v1.2.8

type ReductionResult struct {
	Root  *ReductionNode       `json:"-"`
	Steps []ReductionTraceStep `json:"steps"`
}

func ReduceFailure added in v1.2.8

func ReduceFailure(root *ReductionNode, expectedSignature string, check func(*ReductionNode) (string, error)) (ReductionResult, error)

ReduceFailure performs deterministic hierarchical reduction. check must re-run the diagnostic projection and return the normalized signature. A candidate is accepted only when the signature is unchanged.

type ReductionTraceStep added in v1.2.8

type ReductionTraceStep struct {
	Action    string `json:"action"`
	Path      []int  `json:"path"`
	Accepted  bool   `json:"accepted"`
	Signature string `json:"signature"`
}

type RepeatStmt

type RepeatStmt struct{ Body Stmt }

type RepositoryPrimitiveResolution added in v1.2.1

type RepositoryPrimitiveResolution struct {
	ID, Status, Kernel string
}

RepositoryPrimitiveResolution is the terminal, data-driven classification used by the repository-wide primitive handoff. It binds candidate semantics to existing kernels or shared helper families without adding UAST nodes.

func ResolveRepositoryPrimitive added in v1.2.1

func ResolveRepositoryPrimitive(id, family, scope, handler string) RepositoryPrimitiveResolution

ResolveRepositoryPrimitive returns one of the handoff's five terminal states. The decision uses structured candidate metadata only.

type RequiredSemantics added in v1.0.5

type RequiredSemantics struct{ Structures, Relations, Facets, Fields []string }

func RequiredSemanticsFromUAST added in v1.0.5

func RequiredSemanticsFromUAST(u *UniversalASTDocument) RequiredSemantics

RequiredSemanticsFromUAST reads the canonical graph without source-language provenance or a legacy compatibility view.

type Requirement added in v1.0.5

type Requirement struct {
	ID                   string
	Kind                 RequirementKind
	Target               string
	Dependencies         []string
	Preconditions, Tests []string
	Emit                 string
}

type RequirementKind added in v1.0.5

type RequirementKind string
const (
	RequirementImport    RequirementKind = "IMPORT"
	RequirementHelper    RequirementKind = "HELPER"
	RequirementEmulation RequirementKind = "EMULATION"
	RequirementRuntime   RequirementKind = "RUNTIME"
)

type RequirementRegistry added in v1.0.5

type RequirementRegistry struct{ Rules map[string]Requirement }

func DefaultRequirementRegistry added in v1.0.5

func DefaultRequirementRegistry() RequirementRegistry

func (RequirementRegistry) Resolve added in v1.0.5

func (r RequirementRegistry) Resolve(ids []string) ([]Requirement, error)

type ReturnStmt

type ReturnStmt struct{ X Expr }

type RewriteProof added in v1.2.8

type RewriteProof struct {
	Original  RewriteState
	RuleChain []string
	Result    []RewriteState
	Depth     int
	Valid     bool
}

func FindSemanticRewriteClosure added in v1.2.8

func FindSemanticRewriteClosure(start RewriteState, rules []SemanticRewriteRule, target func(RewriteState) bool, maxDepth, maxCandidates int) (RewriteProof, bool)

FindSemanticRewriteClosure performs bounded deterministic BFS with cycle detection and effect/order guards supplied by the rule. It returns the shortest exact closure to a target capability predicate.

type RewriteProofRecord added in v1.2.8

type RewriteProofRecord struct {
	Original RewriteState
	Proof    RewriteProof
}

RewriteProofRecord is kept in the diagnostic plane so closure evidence can be reported without introducing a second semantic representation.

type RewriteState added in v1.2.8

type RewriteState struct {
	Operation  string
	Operands   []string
	Properties map[string]bool
}

RewriteState and SemanticRewriteRule are transient search values. The resulting replacement is still consumed as ordinary SemanticProgram/UAST operations by the existing executor; no RewriteIR is introduced.

type RuntimeModule added in v1.0.5

type RuntimeModule struct {
	ID, Target                                                        string
	ProvidedCapabilities, RequiredCapabilities, Dependencies, Imports []string
	Emit                                                              Doc
	Tests                                                             []string
}

RuntimeModule is a modular, source-independent target support declaration. It is registered as a normal RUNTIME requirement and is emitted only when a preservation rule explicitly requests one.

type RuntimeModuleRegistry added in v1.0.5

type RuntimeModuleRegistry struct{ Modules map[string]RuntimeModule }

func (RuntimeModuleRegistry) Provides added in v1.0.5

func (r RuntimeModuleRegistry) Provides(target, capability string) bool

func (RuntimeModuleRegistry) RequirementRegistry added in v1.0.5

func (r RuntimeModuleRegistry) RequirementRegistry() RequirementRegistry

type RuntimePromotionAnalysis added in v1.0.5

type RuntimePromotionAnalysis struct {
	Schema                 string                         `json:"schema"`
	Targets                []string                       `json:"targets"`
	ProjectionClasses      []string                       `json:"projection_classes"`
	RuntimeUASF            [][]string                     `json:"runtime_uasf"`
	RuntimeProjectionClass map[string]map[string]bool     `json:"runtime_projection_classes"`
	DirectProjectionClass  map[string]map[string]bool     `json:"direct_projection_classes"`
	Residual               map[string]map[string][]string `json:"direct_residual"`
	Promotable             map[string]map[string]bool     `json:"promotable"`
}

RuntimePromotionAnalysis is a report/registry view over the existing target×UASF preservation matrix. It is deliberately not an IR: it records which runtime cells have a complete direct projection contract and which obligations still prevent promotion.

func UniversalRuntimePromotionAnalysis added in v1.0.5

func UniversalRuntimePromotionAnalysis() (RuntimePromotionAnalysis, error)

UniversalRuntimePromotionAnalysis derives M_RU and M_RP directly from the current preservation and projection-class matrices. A cell is promotable only when the class has a direct syntax contract and no residual obligation.

func WriteRuntimePromotionAnalysis added in v1.0.5

func WriteRuntimePromotionAnalysis(dir string) (RuntimePromotionAnalysis, error)

WriteRuntimePromotionAnalysis persists the matrix views used by the next evidence-mining round. Existing runtime support remains untouched.

type RuntimePromotionEvidence added in v1.0.5

type RuntimePromotionEvidence struct {
	Source, Target, ProjectionClass, UASF, SourceID, Package, SourceHash string
}

RuntimePromotionEvidence is an observational record. It is deliberately separate from UAST semantics and cannot promote a target capability by itself. Proof rows are added only by the existing roundtrip/compiler/runtime test gates.

type RuntimePromotionEvidenceSummary added in v1.0.5

type RuntimePromotionEvidenceSummary struct {
	Schema                   string `json:"schema"`
	SourceRecordsRead        int    `json:"source_records_read"`
	RelevantRuntimeMatches   int    `json:"relevant_runtime_matches"`
	DirectCandidates         int    `json:"direct_candidates"`
	NoDirectCandidate        int    `json:"no_direct_candidate"`
	NewProvenDirectContracts int    `json:"new_proven_direct_contracts"`
	RuntimeCellsPromoted     int    `json:"runtime_cells_promoted"`
	MLCPDRows                int    `json:"mlcpd_rows"`
	EcosystemPackages        int    `json:"ecosystem_packages"`
	CrossSourceConfirmed     int    `json:"cross_source_confirmed"`
	EmpiricalSemanticProven  int    `json:"empirical_semantic_proven"`
	Rejected                 int    `json:"rejected"`
	Conflicts                int    `json:"conflicts"`
	DirectBefore             int    `json:"direct_before"`
	RuntimeBefore            int    `json:"runtime_before"`
	DirectAfter              int    `json:"direct_after"`
	RuntimeAfter             int    `json:"runtime_after"`
	MLCPDInputState          string `json:"mlcpd_input_state"`
}

func WriteRuntimePromotionEvidence added in v1.0.5

func WriteRuntimePromotionEvidence(out, ecosystemProvenance, ecosystemArtifacts string) (RuntimePromotionEvidenceSummary, error)

WriteRuntimePromotionEvidence imports only source-free evidence emitted by the ecosystem miner. Native observations are filtered through the current runtime matrix and projected with the existing UAST crosswalk. They remain candidates until a semantic roundtrip and/or runtime differential test proves the direct contract.

type RuntimeTaintCell added in v1.0.6

type RuntimeTaintCell struct {
	Target, Fixture, Primitive, NativeError, RuntimeError, SyntaxFailure   string
	NativeReached, PureNative, RuntimeFallback, SyntaxChecked, SyntaxValid bool
	TaintArtifacts                                                         []string
}

RuntimeTaintCell records the real two-stage result for one target and one emitted fixture: native first, then the private compatibility fallback.

func AnalyzeRuntimeTaintMatrix added in v1.0.6

func AnalyzeRuntimeTaintMatrix(fixtures []RuntimeTaintFixture) ([]RuntimeTaintCell, error)

AnalyzeRuntimeTaintMatrix obtains its observations from final emitted target source. It never turns an unchecked toolchain, a registry label, or an unavailable native route into a positive direct claim.

func WriteRuntimeTaintMatrix added in v1.0.6

func WriteRuntimeTaintMatrix(out string) ([]RuntimeTaintCell, error)

WriteRuntimeTaintMatrix writes observations, not capability declarations.

type RuntimeTaintFixture added in v1.0.6

type RuntimeTaintFixture struct {
	ID, Source string
	Primitives []string
}

RuntimeTaintFixture is one real, minimal program context. It is deliberately limited to syntax-emitting primitives; metadata, proof and validation-only primitives never receive invented source fixtures.

func DefaultRuntimeTaintFixtures added in v1.0.6

func DefaultRuntimeTaintFixtures() []RuntimeTaintFixture

DefaultRuntimeTaintFixtures covers the executable emission basis rather than manufacturing 28 language snippets. The primitive labels come from the existing syntax structure contracts.

type RuntimeTaintReport added in v1.0.6

type RuntimeTaintReport struct {
	Artifacts []string `json:"artifacts"`
}

RuntimeTaintReport is an observation of generated target source. It is not an IR and carries no program semantics: it records only whether a final target document reaches a known compatibility-runtime artifact.

func AnalyzeRuntimeTaint added in v1.0.6

func AnalyzeRuntimeTaint(source string, helperIDs []string) RuntimeTaintReport

AnalyzeRuntimeTaint is the final-source half of the runtime-taint matrix. A native UAST result is accepted only when this report is empty. The same detector is used before entering the explicit compatibility fallback.

func (RuntimeTaintReport) Tainted added in v1.0.6

func (r RuntimeTaintReport) Tainted() bool

type SFGCReport added in v1.2.9

type SFGCReport struct {
	Schema                   string            `json:"schema"`
	Root                     string            `json:"root"`
	Nodes                    int               `json:"nodes"`
	Relations                int               `json:"relations"`
	UTF8Bytes                int               `json:"utf8_bytes"`
	FieldCounts              map[string]int    `json:"field_counts"`
	FieldClasses             map[string]string `json:"field_classes"`
	ExpansionBound           int               `json:"expansion_bound"`
	DerivationGraphAcyclic   bool              `json:"derivation_graph_acyclic"`
	GrammarDependencyAcyclic bool              `json:"grammar_dependency_acyclic"`
}

func BuildSFGCReport added in v1.2.9

func BuildSFGCReport(p *SemanticProgram, dir string) (SFGCReport, error)

BuildSFGCReport computes deterministic, reproducible accounting and writes the requested evidence artifacts. It never infers semantics from text.

type SFPCExpansionLevel added in v1.2.9

type SFPCExpansionLevel int
const (
	SFPCLevelDirect SFPCExpansionLevel = iota
	SFPCLevelInstance
	SFPCLevelRegion
	SFPCLevelCapsule
	SFPCLevelFull
	SFPCLevelClassic
)

type SFPCLoweringPlan added in v1.2.9

type SFPCLoweringPlan struct {
	Status DirectLoweringStatus
	Level  SFPCExpansionLevel
	Reason string
}

func PlanSFPCLowering added in v1.2.9

func PlanSFPCLowering(source SemanticSource, nodeID int) SFPCLoweringPlan

PlanSFPCLowering returns a closed, auditable escalation decision. No direct native operation is selected unless its semantic contract is proven.

type SFPCQuery added in v1.2.9

type SFPCQuery struct {
	// contains filtered or unexported fields
}

SFPCQuery provides deterministic semantic queries behind the SE boundary. It is intentionally an adapter over the canonical UAST; callers can use these operations without depending on the transport syntax.

func (*SFPCQuery) GetBinding added in v1.2.9

func (q *SFPCQuery) GetBinding(id int) (*UniversalASTNode, bool)

func (*SFPCQuery) GetEffects added in v1.2.9

func (q *SFPCQuery) GetEffects(id int) []UniversalASTRelation

func (*SFPCQuery) GetFunction added in v1.2.9

func (q *SFPCQuery) GetFunction(id int) (*UniversalASTNode, bool)

func (*SFPCQuery) GetNode added in v1.2.9

func (q *SFPCQuery) GetNode(id int) (*UniversalASTNode, bool)

func (*SFPCQuery) GetRelations added in v1.2.9

func (q *SFPCQuery) GetRelations(id int, kind string) []UniversalASTRelation

func (*SFPCQuery) GetType added in v1.2.9

func (q *SFPCQuery) GetType(id int) (*SemanticTypeDefinition, bool)

func (*SFPCQuery) MerkleRoots added in v1.2.9

func (q *SFPCQuery) MerkleRoots() (SFPCTreeRoots, error)

SFPCTreeRoots computes domain-separated deterministic subroots. Sorting is inherited from canonical JSON serialization, so map iteration cannot alter the result.

type SFPCSemanticSource added in v1.2.9

type SFPCSemanticSource struct{ Query *SFPCQuery }

func (SFPCSemanticSource) GetBinding added in v1.2.9

func (s SFPCSemanticSource) GetBinding(id int) (*UniversalASTNode, bool)

func (SFPCSemanticSource) GetEffects added in v1.2.9

func (s SFPCSemanticSource) GetEffects(id int) []UniversalASTRelation

func (SFPCSemanticSource) GetFunction added in v1.2.9

func (s SFPCSemanticSource) GetFunction(id int) (*UniversalASTNode, bool)

func (SFPCSemanticSource) GetNode added in v1.2.9

func (s SFPCSemanticSource) GetNode(id int) (*UniversalASTNode, bool)

func (SFPCSemanticSource) GetRelations added in v1.2.9

func (s SFPCSemanticSource) GetRelations(id int, k string) []UniversalASTRelation

func (SFPCSemanticSource) GetType added in v1.2.9

type SFPCTransformResult added in v1.2.9

type SFPCTransformResult struct {
	Applied    bool
	Reason     string
	Expression *SemanticExpression
}

func FoldConstantExpression added in v1.2.9

func FoldConstantExpression(e *SemanticExpression) SFPCTransformResult

FoldConstantExpression is the first compressed-domain witness. It is intentionally restricted to integer literals with no observable effects; overflow, floating point, NaN, dispatch, and effectful expressions return NO_REWRITE rather than guessing.

type SFPCTreeRoots added in v1.2.9

type SFPCTreeRoots struct {
	ProgramRoot  string `json:"program_root"`
	NodeRoot     string `json:"node_root"`
	TypeRoot     string `json:"type_root"`
	RelationRoot string `json:"relation_root"`
	ContractRoot string `json:"contract_root"`
}

type SFPCVerificationResult added in v1.2.9

type SFPCVerificationResult struct {
	Valid          bool     `json:"valid"`
	Errors         []string `json:"errors,omitempty"`
	Root           string   `json:"root,omitempty"`
	Nodes          int      `json:"nodes"`
	Relations      int      `json:"relations"`
	ExpansionBound int      `json:"expansion_bound"`
}

func VerifySemanticSE added in v1.2.9

func VerifySemanticSE(data []byte, maxBytes int) SFPCVerificationResult

VerifySemanticSE is an independent, fail-closed verification kernel. It validates the transport and canonical UAST without performing lowering or using compiler diagnostics as semantic evidence.

type SaturationSummary added in v1.2.8

type SaturationSummary struct {
	Failures []SemanticFailure `json:"failures"`
	Families int               `json:"failure_families"`
	Holes    int               `json:"diagnostic_holes"`
}

SaturationSummary is serialisable report data, not a semantic IR.

type SemanticArgument

type SemanticArgument struct {
	Name    string              `json:"name,omitempty"`
	Missing bool                `json:"missing,omitempty"`
	Value   *SemanticExpression `json:"value,omitempty"`
}

type SemanticBinding

type SemanticBinding struct {
	ID         int    `json:"id"`
	Name       string `json:"name"`
	Scope      int    `json:"scope"`
	Mutable    bool   `json:"mutable"`
	Definition int    `json:"definition"`
	TypeOrigin string `json:"type_origin"`
}

type SemanticCallCandidate added in v1.0.5

type SemanticCallCandidate struct {
	Name        string       `json:"name"`
	Declaration string       `json:"declaration"`
	Type        SemanticType `json:"type,omitempty"`
}

type SemanticCallResolution added in v1.0.5

type SemanticCallResolution struct {
	Candidates     []SemanticCallCandidate `json:"candidates"`
	Obligations    []string                `json:"obligations"`
	Required       matrixir.Matrix         `json:"required"`
	Satisfied      matrixir.Matrix         `json:"satisfied"`
	ConversionCost matrixir.Matrix         `json:"conversion_cost"`
	Priority       []float64               `json:"priority"`
	Selected       *int                    `json:"selected"`
}

SemanticCallResolution records frontend overload/binder output as matrices. Rows are candidates; Required and Satisfied columns are obligations, while ConversionCost columns correspond to call arguments. Selected is accepted only when it is the unique lexicographic minimum derived from these planes.

type SemanticClosureMatrix added in v1.2.1

type SemanticClosureMatrix struct {
	Languages         []string
	CanonicalForms    []string
	Features          []string
	Relations         []string
	DependencyKinds   []string
	PhaseKinds        []string
	MLang             matrixir.SparseMatrix
	MUAST             matrixir.SparseMatrix
	MFrontend         matrixir.SparseMatrix
	MRel              matrixir.SparseMatrix
	MObserved         matrixir.SparseMatrix
	MCompose          matrixir.SparseMatrix
	MDep              matrixir.SparseMatrix
	MPhase            matrixir.SparseMatrix
	RelationPatterns  []SemanticRelationPattern
	Composition       []SemanticCompositionRecipe
	CompilerEvidence  []CompilerFrontendEvidence
	FrontendFeatures  []FrontendFeatureEvidence
	FrontendPhases    []FrontendPhaseEvidence
	FrontendRelations []FrontendRelationEvidence
	CompilerSources   []CompilerSourceEvidence
}

func SemanticClosureMatrices added in v1.2.1

func SemanticClosureMatrices() (SemanticClosureMatrix, error)

SemanticClosureMatrices returns the cached, matrix-derived closure used by all frontends. It is intentionally cheap after the first call.

type SemanticCompositionRecipe added in v1.2.1

type SemanticCompositionRecipe struct {
	ID         string   `json:"id"`
	Pattern    string   `json:"pattern"`
	Operations []string `json:"operations"`
	Guards     []string `json:"guards,omitempty"`
	Evidence   string   `json:"evidence"`
}

type SemanticContracts

type SemanticContracts struct {
	Requires   []string `json:"requires,omitempty"`
	Ensures    []string `json:"ensures,omitempty"`
	Invariants []string `json:"invariants,omitempty"`
}

SemanticContracts state assertions made by a producer. They are data, not executable checks: backends must reject contracts they cannot preserve.

type SemanticDialect

type SemanticDialect struct {
	Name         string                     `json:"name"`
	Capabilities []string                   `json:"capabilities"`
	Operations   []SemanticDialectOperation `json:"operations"`
}

SemanticDialect keeps specialist domains out of the universal core. A backend may emit it only after declaring every required capability.

type SemanticDialectOperation

type SemanticDialectOperation struct {
	ID         string         `json:"id"`
	Kind       string         `json:"kind"`
	Attributes map[string]any `json:"attributes,omitempty"`
}

type SemanticDocument

type SemanticDocument struct {
	SchemaVersion    int                      `json:"schema_version"`
	Schema           string                   `json:"schema"`
	Evaluation       string                   `json:"evaluation"`
	ValueModel       string                   `json:"value_model"`
	IndexBase        int                      `json:"index_base"`
	Types            SemanticTypeContract     `json:"type_contract"`
	Origin           SemanticOrigin           `json:"origin"`
	Metadata         map[string]string        `json:"metadata,omitempty"`
	Extensions       map[string]any           `json:"extensions,omitempty"`
	Contracts        SemanticContracts        `json:"contracts,omitempty"`
	Dialects         []SemanticDialect        `json:"dialects,omitempty"`
	SemanticFeatures *SemanticFeatureModel    `json:"semantic_features,omitempty"`
	UniversalAST     *UniversalASTDocument    `json:"universal_ast,omitempty"`
	TypeTable        []SemanticTypeDefinition `json:"type_table,omitempty"`
	TypeGraph        matrixir.SparseMatrix    `json:"type_graph,omitempty"`
	TypeRelations    *SemanticTypeRelations   `json:"type_relations,omitempty"`
	Root             SemanticStatement        `json:"root"`
	Evidence         SemanticEvidence         `json:"evidence"`
}

func SemanticDocumentFromUniversalAST added in v1.0.5

func SemanticDocumentFromUniversalAST(u *UniversalASTDocument) (SemanticDocument, error)

SemanticDocumentFromUniversalAST is lossless for the currently executable SemanticDocument projection. Pure UAST nodes outside that projection remain representable but are rejected instead of being approximated.

func (SemanticDocument) MarshalJSON added in v1.0.5

func (doc SemanticDocument) MarshalJSON() ([]byte, error)

type SemanticEffectSummary

type SemanticEffectSummary struct {
	Counts           map[string]int `json:"counts"`
	ConservativePure bool           `json:"conservative_pure"`
	Unknown          bool           `json:"unknown"`
}

SemanticEffectSummary is computed from the effect matrix. ConservativePure becomes true only when every observed effect is proven non-observable.

func SummarizeEffects

func SummarizeEffects(program *SemanticProgram) SemanticEffectSummary

type SemanticEvidence

type SemanticEvidence struct {
	Nodes        []SemanticNode        `json:"nodes"`
	TypeAxes     []string              `json:"type_axes"`
	EffectAxes   []string              `json:"effect_axes"`
	Types        matrixir.SparseMatrix `json:"types"`
	Effects      matrixir.SparseMatrix `json:"effects"`
	Syntax       matrixir.SparseMatrix `json:"syntax"`
	Control      matrixir.SparseMatrix `json:"control"`
	Data         matrixir.SparseMatrix `json:"data"`
	Binding      matrixir.SparseMatrix `json:"binding"`
	Order        matrixir.SparseMatrix `json:"evaluation_order"`
	CallModes    matrixir.SparseMatrix `json:"call_modes"`
	CallModeAxes []string              `json:"call_mode_axes"`
	Scope        matrixir.SparseMatrix `json:"scope_membership"`
	Scopes       []SemanticScope       `json:"scopes"`
	Bindings     []SemanticBinding     `json:"bindings"`
	Contract     matrixir.Vector       `json:"contract"`
	ContractAxes []string              `json:"contract_axes"`
}

func AnalyzeUniversalEvidence added in v1.0.5

func AnalyzeUniversalEvidence(u *UniversalASTDocument) (SemanticEvidence, error)

AnalyzeUniversalEvidence derives executable evidence exclusively from the canonical UAST graph. It is shared by direct frontends and never traverses a legacy Stmt or Expr tree.

type SemanticExpression

type SemanticExpression struct {
	Operation   *SemanticOperation      `json:"typed_operation,omitempty"`
	ID          int                     `json:"id"`
	Kind        string                  `json:"kind"`
	Scope       int                     `json:"scope"`
	Type        SemanticType            `json:"type,omitempty"`
	TypeOrigin  string                  `json:"type_origin,omitempty"`
	Semantics   SemanticSemantics       `json:"semantics,omitempty"`
	Effects     []string                `json:"effects,omitempty"`
	Binding     *int                    `json:"binding,omitempty"`
	Source      *SemanticSourceSpan     `json:"source,omitempty"`
	Attributes  map[string]any          `json:"attributes,omitempty"`
	Extensions  map[string]any          `json:"extensions,omitempty"`
	Name        string                  `json:"name,omitempty"`
	Operator    string                  `json:"operator,omitempty"`
	LiteralKind string                  `json:"literal_kind,omitempty"`
	Text        string                  `json:"text,omitempty"`
	Left        *SemanticExpression     `json:"left,omitempty"`
	Right       *SemanticExpression     `json:"right,omitempty"`
	Value       *SemanticExpression     `json:"value,omitempty"`
	Function    *SemanticFunction       `json:"function,omitempty"`
	Arguments   []SemanticArgument      `json:"arguments,omitempty"`
	Resolution  *SemanticCallResolution `json:"call_resolution,omitempty"`
	DoubleIndex bool                    `json:"double_index,omitempty"`
}

type SemanticFailure added in v1.2.8

type SemanticFailure struct {
	FailureID             string         `json:"failure_id"`
	Stage                 string         `json:"stage"`
	Category              string         `json:"category"`
	SourceLanguage        string         `json:"source_language,omitempty"`
	SourceFile            string         `json:"source_file,omitempty"`
	Function              string         `json:"function,omitempty"`
	SourceStart           int            `json:"source_start,omitempty"`
	SourceEnd             int            `json:"source_end,omitempty"`
	NodeKind              string         `json:"node_kind,omitempty"`
	SemanticRole          string         `json:"semantic_role,omitempty"`
	ExpectedSemanticClass string         `json:"expected_semantic_class,omitempty"`
	ObservedStructure     string         `json:"observed_structure,omitempty"`
	Diagnostic            string         `json:"diagnostic,omitempty"`
	NormalizedSignature   string         `json:"normalized_signature"`
	FailureFamily         string         `json:"failure_family,omitempty"`
	RecoveryKind          RecoveryKind   `json:"recovery_kind"`
	RecoverySafety        string         `json:"recovery_safety,omitempty"`
	Evidence              map[string]any `json:"evidence,omitempty"`
}

SemanticFailure is transient diagnostic data. Source file and spans are provenance only; NormalizedSignature is the quotient key.

type SemanticFeatureBasis added in v1.0.5

type SemanticFeatureBasis struct {
	Schema                 string            `json:"schema"`
	Languages              []string          `json:"languages"`
	Features               []string          `json:"features"`
	LanguageFeature        matrixir.Matrix   `json:"language_feature"`
	DialectFeatures        []string          `json:"dialect_features"`
	LanguageDialectFeature matrixir.Matrix   `json:"language_dialect_feature"`
	DialectObserved        matrixir.Vector   `json:"dialect_observed"`
	NodeKinds              []string          `json:"node_kinds"`
	FeatureNode            matrixir.Matrix   `json:"feature_node"`
	RelationKinds          []string          `json:"relation_kinds"`
	FeatureRelation        matrixir.Matrix   `json:"feature_relation"`
	Provenance             map[string]string `json:"provenance"`
}

type SemanticFeatureModel added in v1.0.5

type SemanticFeatureModel struct {
	BasisSHA256       string               `json:"basis_sha256"`
	Basis             SemanticFeatureBasis `json:"basis"`
	ProfileLanguage   string               `json:"profile_language"`
	LanguageSelection matrixir.Vector      `json:"language_selection"`
	FeatureDemand     matrixir.Vector      `json:"feature_demand"`
	DialectDemand     matrixir.Vector      `json:"dialect_demand"`
	NodeDemand        matrixir.Vector      `json:"node_demand"`
	RelationDemand    matrixir.Vector      `json:"relation_demand"`
}

SemanticFeatureModel makes the complete supplied eight-language feature space part of SemanticProgram. All derived vectors are matrix products and are validated on every interchange boundary.

type SemanticField

type SemanticField struct {
	Name string       `json:"name"`
	Type SemanticType `json:"type"`
}

type SemanticFunction

type SemanticFunction struct {
	Binding           string              `json:"binding,omitempty"`
	DefaultEvaluation string              `json:"default_evaluation,omitempty"`
	Parameters        []SemanticParameter `json:"parameters"`
	Body              SemanticStatement   `json:"body"`
}

type SemanticLock added in v1.2.9

type SemanticLock struct {
	Version int                 `json:"version"`
	Module  string              `json:"module"`
	Entries []SemanticLockEntry `json:"entries"`
}

func (SemanticLock) MarshalDeterministic added in v1.2.9

func (l SemanticLock) MarshalDeterministic() ([]byte, error)

type SemanticLockEntry added in v1.2.9

type SemanticLockEntry struct {
	Identity     string `json:"identity,omitempty"`
	Language     string `json:"language,omitempty"`
	SourceHash   string `json:"source_hash,omitempty"`
	SemanticRoot string `json:"semantic_root,omitempty"`
	CacheKey     string `json:"cache_key,omitempty"`
}

type SemanticManifest added in v1.2.9

type SemanticManifest struct {
	Version  int
	Module   string
	Requires []SemanticRequirement
}

func ParseSemanticManifest added in v1.2.9

func ParseSemanticManifest(data []byte) (SemanticManifest, error)

type SemanticModule added in v1.2.9

type SemanticModule struct {
	Identity            string           `json:"identity"`
	Origin              SemanticOrigin   `json:"origin"`
	Version             string           `json:"version,omitempty"`
	Exports             []string         `json:"exports,omitempty"`
	Imports             []string         `json:"imports,omitempty"`
	Dependencies        []string         `json:"dependencies,omitempty"`
	SemanticRoot        string           `json:"semantic_root"`
	SourceHash          string           `json:"source_hash,omitempty"`
	Frontend            string           `json:"frontend,omitempty"`
	FrontendVersion     string           `json:"frontend_version,omitempty"`
	CacheKey            string           `json:"cache_key"`
	Kind                ArtifactKind     `json:"kind,omitempty"`
	Capabilities        []string         `json:"capabilities,omitempty"`
	ABI                 string           `json:"abi,omitempty"`
	RuntimeRequirements []string         `json:"runtime_requirements,omitempty"`
	Types               []string         `json:"types,omitempty"`
	Functions           []string         `json:"functions,omitempty"`
	Globals             []string         `json:"globals,omitempty"`
	Constants           []string         `json:"constants,omitempty"`
	Bindings            []string         `json:"bindings,omitempty"`
	Effects             []string         `json:"effects,omitempty"`
	Contracts           []string         `json:"contracts,omitempty"`
	Capsules            []string         `json:"capsules,omitempty"`
	Program             *SemanticProgram `json:"-"`
}

func ImportModule added in v1.2.9

func ImportModule(identity, language, filename, source string) (*SemanticModule, error)

func NewSemanticModule added in v1.2.9

func NewSemanticModule(identity, language, source string, p *SemanticProgram) (*SemanticModule, error)

func (*SemanticModule) MetadataSet added in v1.2.9

func (m *SemanticModule) MetadataSet(k, v string)

type SemanticModuleGraph added in v1.2.9

type SemanticModuleGraph struct {
	Modules map[string]*SemanticModule
	Edges   map[string][]string
}

func BuildModuleGraph added in v1.2.9

func BuildModuleGraph(mods []*SemanticModule) *SemanticModuleGraph

func (*SemanticModuleGraph) Dependencies added in v1.2.9

func (g *SemanticModuleGraph) Dependencies(id string) []string

type SemanticModuleStore added in v1.2.9

type SemanticModuleStore struct{ Root string }

func DefaultSemanticModuleStore added in v1.2.9

func DefaultSemanticModuleStore() (SemanticModuleStore, error)

func (SemanticModuleStore) FindModule added in v1.2.9

func (s SemanticModuleStore) FindModule(identity string) (*SemanticModule, error)

func (SemanticModuleStore) ListModules added in v1.2.9

func (s SemanticModuleStore) ListModules() ([]string, error)

func (SemanticModuleStore) Open added in v1.2.9

func (s SemanticModuleStore) Open(cacheKey string) (*SemanticModule, error)

func (SemanticModuleStore) OpenModule added in v1.2.9

func (s SemanticModuleStore) OpenModule(key string) (*SemanticModule, error)

func (SemanticModuleStore) Put added in v1.2.9

func (SemanticModuleStore) RemoveModule added in v1.2.9

func (s SemanticModuleStore) RemoveModule(key string) error

func (SemanticModuleStore) SaveModule added in v1.2.9

func (s SemanticModuleStore) SaveModule(m *SemanticModule) error

func (SemanticModuleStore) VerifyModule added in v1.2.9

func (s SemanticModuleStore) VerifyModule(key string) error

type SemanticNode

type SemanticNode struct {
	ID     int    `json:"id"`
	Kind   string `json:"kind"`
	Symbol string `json:"symbol,omitempty"`
	Scope  int    `json:"scope"`
}

type SemanticNominalRelations added in v1.0.5

type SemanticNominalRelations struct {
	Identities  []string              `json:"identities"`
	Definitions matrixir.SparseMatrix `json:"definitions"`
	References  matrixir.SparseMatrix `json:"references"`
	Resolution  matrixir.SparseMatrix `json:"resolution"`
	Unresolved  []int                 `json:"unresolved"`
}

Identity columns group views of the same nominal declaration/instantiation. Resolution links a finite reference to all captured definition views of that identity. It is not structural equivalence, assignability or alias erasure.

type SemanticObservation

type SemanticObservation struct {
	Stdout  string                `json:"stdout"`
	Error   string                `json:"error,omitempty"`
	Effects SemanticEffectSummary `json:"effects"`
}

SemanticObservation is the deterministic observation available from the embedded semantic runtime. External native tests may extend this with files, state snapshots and process exit information.

func ObserveSemantic

func ObserveSemantic(program *SemanticProgram) SemanticObservation

type SemanticOperation added in v1.0.5

type SemanticOperation struct {
	Name string       `json:"name"`
	Type SemanticType `json:"type"`
	Text string       `json:"text,omitempty"`
}

SemanticOperation is a typed core operation, independent of source spelling. Type is the integer domain; comparison/format operations return bool/string.

type SemanticOrigin

type SemanticOrigin struct {
	SourceLanguage string   `json:"source_language"`
	SourceVersion  string   `json:"source_version,omitempty"`
	EntryPoint     string   `json:"entry_point"`
	Modules        []string `json:"modules"`
}

type SemanticParameter

type SemanticParameter struct {
	Mode    string              `json:"mode,omitempty"`
	ID      int                 `json:"id"`
	Name    string              `json:"name"`
	Type    SemanticType        `json:"type,omitempty"`
	Passing string              `json:"passing,omitempty"`
	Default *SemanticExpression `json:"default,omitempty"`
}

type SemanticParameterVisitor

type SemanticParameterVisitor interface {
	EnterParameter(*SemanticParameter) error
}

type SemanticPrimitiveSpec added in v1.2.1

type SemanticPrimitiveSpec struct {
	ID      string   `json:"id"`
	Arity   int      `json:"arity"`
	Class   string   `json:"class"`
	Rewrite string   `json:"rewrite"`
	Guards  []string `json:"guards,omitempty"`
	// Family is the matrix-derived semantic family. It is metadata on the
	// existing primitive spec, never a second IR or registry.
	Family string `json:"family,omitempty"`
}

type SemanticProgram

type SemanticProgram struct {

	// CompatibilityR is a generated diagnostic view retained for callers that
	// still execute the matrix language's canonical compatibility form. It is
	// produced by the modern MatrixIR frontend; it is never used as semantic
	// input by emitters or by TranspileCore.
	CompatibilityR   string                `json:"-"`
	Body             *BlockStmt            `json:"-"`
	Evaluation       string                `json:"evaluation"`
	ValueModel       string                `json:"value_model"`
	IndexBase        int                   `json:"index_base"`
	Types            SemanticTypeContract  `json:"type_contract"`
	Origin           SemanticOrigin        `json:"origin"`
	Metadata         map[string]string     `json:"metadata,omitempty"`
	Extensions       map[string]any        `json:"extensions,omitempty"`
	Contracts        SemanticContracts     `json:"contracts,omitempty"`
	Dialects         []SemanticDialect     `json:"dialects,omitempty"`
	SemanticFeatures *SemanticFeatureModel `json:"semantic_features,omitempty"`
	UniversalAST     *UniversalASTDocument `json:"universal_ast,omitempty"`
	Evidence         SemanticEvidence      `json:"evidence"`
	// contains filtered or unexported fields
}

SemanticProgram owns the executable tree. Canonical R is now a diagnostic serialization, not the carrier of evaluation semantics. Legacy values retain the binary64 contract; typed operations use an explicit exact-scalar contract and integer-width domains. Unknown types/effects remain explicit in matrices.

func ApplyVerifiedGraphRewrite added in v1.2.8

func ApplyVerifiedGraphRewrite(program *SemanticProgram, match []int, recipe GeneratedLoweringRecipe, target string) (*SemanticProgram, error)

func DecodeGenerated

func DecodeGenerated(source, code string) (*SemanticProgram, bool, error)

DecodeGenerated reads the actual emitted program. Only an exact known runtime prefix may be removed; every remaining token must be decoded and reproduced. There is no original-source payload, comment recovery or cache. The shared emitter functions define the inverse operation templates.

func LiftBinaryInput added in v1.2.1

func LiftBinaryInput(data []byte, opts CompileOptions) (*SemanticProgram, error)

LiftBinaryInput exposes the same canonical SemanticProgram used by source inputs for a straight-line integer subset. The recovery is dataflow based: register definitions are represented as canonical expressions and a return is recovered only when every instruction on the path has a proven semantic transfer. No opcode spelling is promoted to a source-language construct.

func LowerMatrixActions

func LowerMatrixActions(source string, nodes []matrixir.CanonicalNode) (*SemanticProgram, error)

LowerMatrixActions is an explicit compatibility bridge. MatrixIR has already recognized the source grammar and selected normalized actions; this function consumes those actions rather than CanonicalProgram.R. The action payload is deliberately kept local to the frontend and never becomes a transport representation of Program.

It is retained for old action-stream callers and is not a productive source entry point. Source-specific modern frontends must produce structured facts and call LowerMatrixLanguage instead.

func LowerMatrixEvents

func LowerMatrixEvents(source string, events []matrixir.CanonicalEvent) (*SemanticProgram, error)

LowerMatrixEvents is an explicit compatibility adapter for legacy callers; the productive source path consumes CanonicalSemanticEvents directly in LowerMatrixLanguage and never reparses Event.Text.

func LowerMatrixEventsWithFactSink added in v1.0.5

func LowerMatrixEventsWithFactSink(language string, events []matrixir.CanonicalEvent, sink *FrontendFactsBuilder) (*SemanticProgram, error)

LowerMatrixEventsWithFactSink is an explicit compatibility bridge for callers that still provide event text. It is never called by LowerSource or the product TranspileCore path. New frontends must use materializeStructuredMatrixFacts through LowerMatrixLanguage.

func LowerMatrixLanguage added in v1.0.5

func LowerMatrixLanguage(language, source string) (*SemanticProgram, error)

LowerMatrixLanguage is the shared frontend path for every currently matrix-recognised source language. Parser-specific facts remain transient; the returned SemanticProgram owns only the canonical UAST.

func LowerMatrixLanguageFromTables added in v1.2.8

func LowerMatrixLanguageFromTables(language, source, tableDir string) (*SemanticProgram, error)

LowerMatrixLanguageFromTables is the explicit production entry for an execution-ready grammar partition. It keeps the same downstream FrontendSemanticFacts/UAST contract as LowerMatrixLanguage while replacing the bootstrap source canonicalizer with ParseNode facts from the generic lexer/LR/GLR machine. The table directory is supplied by the host/package loader, so the frontend remains independent of repository layout.

func LowerNativeGo added in v1.0.5

func LowerNativeGo(filename, source string) (*SemanticProgram, error)

LowerNativeGo lowers the structurally supported Go subset directly from Go's AST. Scalar, aggregate, channel, function and control-flow values share the same semantic contracts; target-specific unsupported representations are deferred to legalization rather than rejected during source lowering. No normalized source text is created or fed to the legacy parser. Unsupported syntax is an error, including dead unsupported code.

func LowerNativeGoWithDiagnostics added in v1.2.8

func LowerNativeGoWithDiagnostics(filename, source string, diagnostics *DiagnosticContext) (*SemanticProgram, error)

LowerNativeGoWithDiagnostics runs the same structured Go AST producer as the production frontend, but records every node-local unsupported contract in a separate diagnostic context. No hole is returned to the canonical program.

func LowerPython added in v1.0.5

func LowerPython(source string) (*SemanticProgram, error)

LowerPython keeps the concrete frontend entry point while delegating to the language-neutral matrix extractor.

func LowerSource added in v1.2.1

func LowerSource(language, filename, source string) (*SemanticProgram, error)

LowerSource is the sole source-to-UAST frontend selector used by the product. Frontends may use different parser implementations, but every successful implementation returns the same canonical UniversalASTDocument. A native structured frontend is attempted where one is registered; the matrix frontend is the language-neutral fallback. Neither branch invokes a text/regex semantic parser or a legacy AST adapter.

func NewSemanticProgram

func NewSemanticProgram(body *BlockStmt, evaluation string) *SemanticProgram

func ParseSemantic

func ParseSemantic(source, code string) (*SemanticProgram, error)

ParseSemantic is kept as a source-compatible alias for older callers. New product code must use LowerSource so text parsing cannot re-enter the canonical frontend after structured facts have been produced. Deprecated: use LowerSource for production and ParseSemanticCompatibility only for explicit compatibility/oracle work.

func ParseSemanticCompatibility added in v1.2.1

func ParseSemanticCompatibility(source, code string) (*SemanticProgram, error)

ParseSemanticCompatibility is the explicit legacy text ingress retained for compatibility fixtures and oracle tooling. The productive source path is LowerSource, which never calls this function.

func ParseSemanticDocument

func ParseSemanticDocument(doc SemanticDocument) (*SemanticProgram, error)

func ParseSemanticJSON

func ParseSemanticJSON(data []byte) (*SemanticProgram, error)

func ParseSemanticSE added in v1.2.9

func ParseSemanticSE(data []byte) (*SemanticProgram, error)

ParseSemanticSE imports a readable .se document. The envelope is kept wire-compatible with .sp so existing files and tooling remain usable.

func ParseSemanticSP added in v1.2.8

func ParseSemanticSP(data []byte) (*SemanticProgram, error)

ParseSemanticSP validates and imports the versioned SP envelope.

func ParseSemanticSPZ added in v1.2.8

func ParseSemanticSPZ(data []byte) (*SemanticProgram, error)

func ParseUniversalASTJSON added in v1.0.5

func ParseUniversalASTJSON(data []byte) (*SemanticProgram, error)

ParseUniversalASTJSON imports a canonical UAST without fabricating a second legacy tree. Compatibility views are materialized only when the projection proves that they are lossless.

func ResolveCompileTimeConstructs added in v1.2.8

func ResolveCompileTimeConstructs(program *SemanticProgram, target string) (*SemanticProgram, error)

ResolveCompileTimeConstructs is the explicit compile-time boundary between canonical UAST validation and target lowering. It consumes the already resolved binding/type/call facts; it never guesses or creates source-level semantics. The returned program keeps the same canonical document.

func (*SemanticProgram) AttachSemanticFeatureProfile added in v1.0.5

func (p *SemanticProgram) AttachSemanticFeatureProfile(source string) error

AttachSemanticFeatureProfile selects one language row and calculates every program vector. It never fills individual feature cells.

func (*SemanticProgram) Document

func (p *SemanticProgram) Document() (SemanticDocument, error)

func (*SemanticProgram) MarshalSemanticJSON

func (p *SemanticProgram) MarshalSemanticJSON() ([]byte, error)

func (*SemanticProgram) MarshalSemanticSE added in v1.2.9

func (p *SemanticProgram) MarshalSemanticSE() ([]byte, error)

MarshalSemanticSE emits the same lossless SemanticProgram envelope as SP, under the new .se format name.

func (*SemanticProgram) MarshalSemanticSECompact added in v1.2.9

func (p *SemanticProgram) MarshalSemanticSECompact() ([]byte, error)

MarshalSemanticSECompact is the canonical minimal UTF-8 text form.

func (*SemanticProgram) MarshalSemanticSEReadable added in v1.2.9

func (p *SemanticProgram) MarshalSemanticSEReadable() ([]byte, error)

MarshalSemanticSEReadable keeps exactly the same grammar and values as the compact form, but formats top-level members with four-space indentation and blank lines between semantic sections. The parser ignores this whitespace, so both modes have identical SemanticProgram meaning.

func (*SemanticProgram) MarshalSemanticSESemanticOnly added in v1.2.9

func (p *SemanticProgram) MarshalSemanticSESemanticOnly() ([]byte, error)

MarshalSemanticSESemanticOnly emits the canonical semantic core without the DEBUG_ONLY source surface. The surface hash/length can be retained by a caller separately when source preservation is required.

func (*SemanticProgram) MarshalSemanticSEWithSource added in v1.2.9

func (p *SemanticProgram) MarshalSemanticSEWithSource() ([]byte, error)

MarshalSemanticSEWithSource is the explicit provenance-preserving form of .se. The default command-line export intentionally uses the semantic-only form; callers that need byte-for-byte source provenance must opt in.

func (*SemanticProgram) MarshalSemanticSP added in v1.2.8

func (p *SemanticProgram) MarshalSemanticSP() ([]byte, error)

MarshalSemanticSP emits deterministic, line-oriented SP. Metadata fields are intentionally human readable while semantic data is carried losslessly in the canonical JSON payload.

func (*SemanticProgram) MarshalSemanticSPZ added in v1.2.8

func (p *SemanticProgram) MarshalSemanticSPZ() ([]byte, error)

MarshalSemanticSPZ stores canonical SP bytes in a small independent RLE block stream. It has no external compression dependency.

func (*SemanticProgram) MarshalUniversalASTJSON added in v1.0.5

func (p *SemanticProgram) MarshalUniversalASTJSON() ([]byte, error)

MarshalUniversalASTJSON serializes the canonical representation directly. It also supports richer, currently non-executable UAST documents without inventing a misleading SemanticDocument tree beside them.

func (*SemanticProgram) RSource

func (p *SemanticProgram) RSource(enforce bool) (string, error)

RSource writes executable R syntax from the typed tree. In eager mode calls with user functions are handled by the explicit call-boundary lowering below.

type SemanticRelationPattern added in v1.2.1

type SemanticRelationPattern struct {
	ID            string `json:"id"`
	FromFeature   string `json:"from_feature"`
	Relation      string `json:"relation"`
	ToFeature     string `json:"to_feature"`
	EvidenceState string `json:"evidence_state"`
}

type SemanticRequirement added in v1.2.9

type SemanticRequirement struct{ Language, Target string }

type SemanticRequirements added in v1.2.8

type SemanticRequirements struct {
	Operations  []string
	CompileTime []string
	Runtime     []string
}

func CollectSemanticRequirements added in v1.2.8

func CollectSemanticRequirements(program *SemanticProgram, target string) (SemanticRequirements, error)

type SemanticRewriteRule added in v1.2.8

type SemanticRewriteRule struct {
	ID       string
	From     string
	To       []RewriteState
	Requires func(RewriteState) bool
	Preserve func(RewriteState, []RewriteState) bool
}

type SemanticSEFieldClass added in v1.2.9

type SemanticSEFieldClass string

SemanticSEFieldClass describes how a field is represented in the compact format. The classifier is deliberately conservative: only values that are provably reconstructible are omitted by the writer.

const (
	SemanticSEExplicit   SemanticSEFieldClass = "EXPLICIT"
	SemanticSEReferenced SemanticSEFieldClass = "REFERENCED"
	SemanticSEDerived    SemanticSEFieldClass = "DERIVED"
	SemanticSEDefault    SemanticSEFieldClass = "DEFAULT"
	SemanticSEDebugOnly  SemanticSEFieldClass = "DEBUG_ONLY"
)

type SemanticScope

type SemanticScope struct {
	ID     int    `json:"id"`
	Kind   string `json:"kind"`
	Parent int    `json:"parent"`
}

type SemanticSemantics

type SemanticSemantics struct {
	Operation       string `json:"operation,omitempty"`
	Dispatch        string `json:"dispatch,omitempty"`
	Overflow        string `json:"overflow,omitempty"`
	EvaluationOrder string `json:"evaluation_order,omitempty"`
	ShortCircuit    bool   `json:"short_circuit,omitempty"`
	IndexBase       int    `json:"index_base,omitempty"`
	NegativeIndex   string `json:"negative_index,omitempty"`
	OutOfBounds     string `json:"out_of_bounds,omitempty"`
	Slicing         string `json:"slicing,omitempty"`
	ErrorModel      string `json:"error_model,omitempty"`
	Confidence      string `json:"confidence,omitempty"`
}

type SemanticSource added in v1.2.9

type SemanticSource interface {
	GetNode(id int) (*UniversalASTNode, bool)
	GetType(id int) (*SemanticTypeDefinition, bool)
	GetBinding(id int) (*UniversalASTNode, bool)
	GetEffects(id int) []UniversalASTRelation
	GetRelations(id int, kind string) []UniversalASTRelation
	GetFunction(id int) (*UniversalASTNode, bool)
}

SemanticSource is the common read contract for classic and compressed semantic input. It exposes only canonical UAST facts, so native lowering can remain independent of the physical representation.

type SemanticSourceSpan

type SemanticSourceSpan struct {
	File        string `json:"file,omitempty"`
	StartOffset int    `json:"start_offset,omitempty"`
	EndOffset   int    `json:"end_offset,omitempty"`
	StartLine   int    `json:"start_line,omitempty"`
	StartColumn int    `json:"start_column,omitempty"`
	EndLine     int    `json:"end_line,omitempty"`
	EndColumn   int    `json:"end_column,omitempty"`
}

type SemanticStatement

type SemanticStatement struct {
	ID         int                 `json:"id"`
	Kind       string              `json:"kind"`
	Scope      int                 `json:"scope"`
	Type       SemanticType        `json:"type,omitempty"`
	TypeOrigin string              `json:"type_origin,omitempty"`
	Semantics  SemanticSemantics   `json:"semantics,omitempty"`
	Effects    []string            `json:"effects,omitempty"`
	Source     *SemanticSourceSpan `json:"source,omitempty"`
	Attributes map[string]any      `json:"attributes,omitempty"`
	Extensions map[string]any      `json:"extensions,omitempty"`
	Name       string              `json:"name,omitempty"`
	AssignOp   string              `json:"assign_op,omitempty"`
	Expression *SemanticExpression `json:"expression,omitempty"`
	Condition  *SemanticExpression `json:"condition,omitempty"`
	Sequence   *SemanticExpression `json:"sequence,omitempty"`
	Then       *SemanticStatement  `json:"then,omitempty"`
	Else       *SemanticStatement  `json:"else,omitempty"`
	Body       *SemanticStatement  `json:"body,omitempty"`
	Statements []SemanticStatement `json:"statements,omitempty"`
}

type SemanticTrace added in v1.2.1

type SemanticTrace struct {
	SchemaVersion    string                         `json:"schema_version"`
	ParseSuccess     bool                           `json:"parse_success"`
	UASTSuccess      bool                           `json:"uast_success"`
	UASTHash         string                         `json:"uast_hash,omitempty"`
	Nodes            []SemanticTraceNode            `json:"nodes"`
	PrimitiveDemands []SemanticTracePrimitiveDemand `json:"primitive_demands,omitempty"`
	Route            SemanticTraceRoute             `json:"route"`
	// FrontendEvidence is provenance from the same canonical UAST closure. It
	// lets downstream matrix tooling distinguish observed compiler facts from
	// ordinary UAST demand without deriving semantics from source or diagnostics.
	FrontendEvidence map[string]any `json:"frontend_evidence,omitempty"`
}

func BuildSemanticTrace added in v1.2.1

func BuildSemanticTrace(parseSuccess bool, u *UniversalASTDocument, route SemanticTraceRoute) SemanticTrace

BuildSemanticTrace materializes the same structured sidecar document used by the miner without performing target projection. This is the discovery-only entry point: every primitive comes from the canonical UAST itself.

type SemanticTraceNode added in v1.2.1

type SemanticTraceNode struct {
	NodeID            string `json:"node_id"`
	ParentNodeID      string `json:"parent_node_id"`
	NodeKind          string `json:"node_kind"`
	SemanticOperation string `json:"semantic_operation"`
	SemanticFamily    string `json:"semantic_family"`
	Arity             int    `json:"arity"`
	OperandRoles      string `json:"operand_roles"`
	ResultRole        string `json:"result_role"`
	TypeModel         string `json:"type_model"`
	NumericModel      string `json:"numeric_model"`
	Effects           string `json:"effects"`
	EvaluationOrder   string `json:"evaluation_order"`
	Binding           string `json:"binding"`
	Scope             string `json:"scope"`
	Ownership         string `json:"ownership"`
	Lifetime          string `json:"lifetime"`
	Representation    string `json:"representation"`
	ControlFlow       string `json:"control_flow"`
	MemoryBehavior    string `json:"memory_behavior"`
	ExceptionBehavior string `json:"exception_behavior"`
	PrimitiveID       string `json:"primitive_id,omitempty"`
	PrimitiveFamily   string `json:"primitive_family,omitempty"`
	Parameterization  string `json:"parameterization,omitempty"`
	LanguageOperation string `json:"language_operation"`
	SourceStart       string `json:"source_start"`
	SourceEnd         string `json:"source_end"`
}

type SemanticTracePrimitiveDemand added in v1.2.1

type SemanticTracePrimitiveDemand struct {
	PrimitiveID      string `json:"primitive_id"`
	PrimitiveFamily  string `json:"primitive_family"`
	Parameterization string `json:"parameterization"`
	OccurrenceCount  int    `json:"occurrence_count"`
}

type SemanticTraceRoute added in v1.2.1

type SemanticTraceRoute struct {
	RouteType                string `json:"route_type"`
	ProjectionMode           string `json:"projection_mode,omitempty"`
	RuntimeFallbackUsed      bool   `json:"runtime_fallback_used"`
	DirectSuccess            bool   `json:"direct_success"`
	PrimitiveLoweringSuccess bool   `json:"primitive_lowering_success"`
	IntermediateSuccess      bool   `json:"intermediate_success"`
	IntermediateLanguage     string `json:"intermediate_language,omitempty"`
	IntermediateRoute        string `json:"intermediate_route,omitempty"`
	Leg1CaseID               string `json:"leg1_case_id,omitempty"`
	Leg2CaseID               string `json:"leg2_case_id,omitempty"`
	Leg1InputHash            string `json:"leg1_input_hash,omitempty"`
	Leg1OutputHash           string `json:"leg1_output_hash,omitempty"`
	Leg2InputHash            string `json:"leg2_input_hash,omitempty"`
	Leg2OutputHash           string `json:"leg2_output_hash,omitempty"`
	RootUASTHash             string `json:"root_uast_hash,omitempty"`
	IntermediateUASTHash     string `json:"intermediate_uast_hash,omitempty"`
	FinalUASTHash            string `json:"final_uast_hash,omitempty"`
}

type SemanticType

type SemanticType struct {
	Identity       string             `json:"identity,omitempty"`
	Reference      bool               `json:"reference,omitempty"`
	Kind           string             `json:"kind,omitempty"`
	Name           string             `json:"name,omitempty"`
	Bits           int                `json:"bits,omitempty"`
	Signed         *bool              `json:"signed,omitempty"`
	IEEE754        bool               `json:"ieee754,omitempty"`
	Element        *SemanticType      `json:"element,omitempty"`
	Key            *SemanticType      `json:"key,omitempty"`
	Value          *SemanticType      `json:"value,omitempty"`
	Parameters     []SemanticType     `json:"parameters,omitempty"`
	Result         *SemanticType      `json:"result,omitempty"`
	Fields         []SemanticField    `json:"fields,omitempty"`
	Length         int                `json:"length,omitempty"`
	Rows           int                `json:"rows,omitempty"`
	Columns        int                `json:"columns,omitempty"`
	Constraints    []string           `json:"constraints,omitempty"`
	Nullable       string             `json:"nullable,omitempty"`
	Ownership      string             `json:"ownership,omitempty"`
	Lifetime       string             `json:"lifetime,omitempty"`
	TypeOrigin     string             `json:"type_origin,omitempty"`
	TypeParameters []SemanticType     `json:"type_parameters,omitempty"`
	TypeArguments  []SemanticType     `json:"type_arguments,omitempty"`
	Constraint     *SemanticType      `json:"constraint,omitempty"`
	Embedded       []SemanticType     `json:"embedded,omitempty"`
	Methods        []SemanticField    `json:"methods,omitempty"`
	Terms          []SemanticTypeTerm `json:"terms,omitempty"`
}

SemanticType is recursive so no JSON number has to carry type information. The textual literal value remains exact even for values JSON cannot represent.

type SemanticTypeContract

type SemanticTypeContract struct {
	SchemaVersion int    `json:"schema_version"`
	Numeric       string `json:"numeric"`
	IntegerWidth  string `json:"integer_width"`
	Text          string `json:"text"`
	Truth         string `json:"truth"`
	Null          string `json:"null"`
	Collection    string `json:"collection"`
	Pointer       string `json:"pointer"`
	Ownership     string `json:"ownership"`
	ABI           string `json:"abi"`
}

SemanticTypeContract is deliberately explicit about what is not yet known. It is part of the language-neutral program contract, not a target profile.

type SemanticTypeDefinition added in v1.0.5

type SemanticTypeDefinition struct {
	ID   int          `json:"id"`
	Type SemanticType `json:"type"`
}

SemanticTypeDefinition gives structural types a stable document-local ID. IDs are assigned from canonical JSON order, never from source traversal.

type SemanticTypeEdge added in v1.0.5

type SemanticTypeEdge struct {
	Role       string `json:"role"`
	Index      int    `json:"index"`
	Name       string `json:"name,omitempty"`
	Underlying bool   `json:"underlying,omitempty"`
}

type SemanticTypeEquivalence added in v1.0.5

type SemanticTypeEquivalence struct {
	Equivalent matrixir.SparseMatrix `json:"equivalent"`
	Unknown    []int                 `json:"unknown"`
	Rounds     int                   `json:"refinement_rounds"`
}

SemanticTypeEquivalence proves exact type-domain equality only. It is not implicit conversion, language-specific assignability, subtyping or ABI equality. Unknown marks types whose identity/shape is insufficient; zero matrix cells involving such types must not be interpreted as a proof of incompatibility.

type SemanticTypeRelations added in v1.0.5

type SemanticTypeRelations struct {
	Occurrences []string                  `json:"occurrences"`
	Uses        matrixir.SparseMatrix     `json:"uses"`
	Edges       []SemanticTypeEdge        `json:"edges"`
	Parents     matrixir.SparseMatrix     `json:"parents"`
	Children    matrixir.SparseMatrix     `json:"children"`
	UsageCounts []int                     `json:"usage_counts"`
	Nominal     *SemanticNominalRelations `json:"nominal,omitempty"`
	Equivalence *SemanticTypeEquivalence  `json:"equivalence,omitempty"`
}

SemanticTypeRelations is a lossless incidence projection of type uses and direct structural edges. Edge rows preserve order and repeated children. The matrices do not assert assignability or executable backend support.

type SemanticTypeTerm added in v1.0.5

type SemanticTypeTerm struct {
	Type       SemanticType `json:"type"`
	Underlying bool         `json:"underlying,omitempty"`
}

SemanticTypeTerm distinguishes an exact type from its underlying-type set.

type SemanticVisitor

type SemanticVisitor interface {
	EnterStatement(*SemanticStatement) error
	LeaveStatement(*SemanticStatement) error
	EnterExpression(*SemanticExpression) error
	LeaveExpression(*SemanticExpression) error
}

SemanticVisitor provides deterministic pre-order traversal of a complete SemanticDocument. Visitors can analyze, validate, optimize or annotate a document without embedding target-specific logic in AST node types.

type SignatureArgument added in v1.0.5

type SignatureArgument struct {
	Name   string `json:"name,omitempty"`
	Spread bool   `json:"spread,omitempty"`
}

SignatureArgument columns preserve original evaluation order. Spread inputs must be expanded by a semantic runtime before binding, never guessed here.

type SignatureBinding added in v1.0.5

type SignatureBinding struct {
	ParameterArguments matrixir.SparseMatrix `json:"parameter_arguments"`
	UseDefaults        []int                 `json:"use_defaults"`
	ArgumentCounts     []int                 `json:"argument_counts"`
}

func BindSignature added in v1.0.5

func BindSignature(parameters []SignatureParameter, arguments []SignatureArgument) (*SignatureBinding, error)

BindSignature derives a parameter x argument incidence matrix. Matrix row sums then check required/default/variadic cardinalities for the whole call. It does not execute defaults, annotation expressions or function bodies.

type SignatureParameter added in v1.0.5

type SignatureParameter struct {
	Name       string `json:"name"`
	Passing    string `json:"passing"`
	HasDefault bool   `json:"has_default"`
}

SignatureParameter describes call binding, independently of evaluation and value/reference passing. Defaults must be evaluated by the source contract.

type Stmt

type Stmt interface {
	// contains filtered or unexported methods
}

type StructureProjectionContract added in v1.0.5

type StructureProjectionContract struct {
	StructureKind       string   `json:"structure_kind"`
	ProjectionClass     string   `json:"projection_class"`
	ProjectionForm      string   `json:"projection_form"`
	SyntacticCategory   string   `json:"syntactic_category"`
	ChildRelations      []string `json:"child_relations"`
	RequiredFields      []string `json:"required_fields"`
	ExecutionPrimitives []string `json:"execution_primitives"`
	PrecedenceRole      string   `json:"precedence_role"`
	BlockPolicy         string   `json:"block_policy"`
	TerminatorPolicy    string   `json:"terminator_policy"`
	EmissionPolicy      string   `json:"emission_policy"`
	Implemented         bool     `json:"implemented"`
}

StructureProjectionContract is a declarative, schema-derived syntax contract. It is not an IR and never stores program data: the projector reads program semantics only from UniversalASTDocument.

type StructuredConstructInput added in v1.0.6

type StructuredConstructInput struct {
	Family       string
	NodeKind     string
	Roles        []matrixir.CanonicalRoleFact
	Operands     []matrixir.CanonicalOperandFact
	Bindings     []matrixir.CanonicalBindingFact
	Types        []matrixir.CanonicalSymbolFact
	Fields       map[string]string
	SourceOffset int
}

StructuredConstructInput is a short-lived parser DTO. It deliberately has no target, runtime, UAST facet, or execution information.

func MatrixStructuredAdapter added in v1.0.6

func MatrixStructuredAdapter(event matrixir.CanonicalSemanticEvent) (StructuredConstructInput, bool)

MatrixStructuredAdapter transfers only already-proven MatrixIR structure. Event.Text is intentionally not read on this path.

type StructuredSemanticDemand added in v1.2.1

type StructuredSemanticDemand struct {
	UASTHash       string
	Nodes          []string
	Operations     []string
	Primitives     []string
	Kernels        []string
	Types          []string
	Effects        []string
	Evaluation     []string
	Bindings       []string
	Ownership      []string
	Representation []string
}

StructuredSemanticDemand is derived only from canonical UAST nodes and facets. Diagnostics are deliberately absent from this type.

func AnalyzeStructuredSemanticDemand added in v1.2.1

func AnalyzeStructuredSemanticDemand(u *UniversalASTDocument) StructuredSemanticDemand

AnalyzeStructuredSemanticDemand creates the case x primitive input matrix. It is the only supported demand classifier for corpus evidence.

type TargetCapabilityDecision added in v1.0.5

type TargetCapabilityDecision struct {
	Direct, Rewrite, Helper, Emulate, Runtime, Unsupported []string
}

type TargetImportSpec added in v1.0.5

type TargetImportSpec struct {
	RuntimeRequirement string `json:"runtime_requirement"`
	Ordering           string `json:"ordering"`
	Prelude            string `json:"-"`
}

type TargetLiteralSpec added in v1.0.5

type TargetLiteralSpec struct {
	True        string `json:"true"`
	False       string `json:"false"`
	Null        string `json:"null"`
	StringQuote string `json:"string_quote"`
	StringWrap  string `json:"string_wrap"`
	NumberWrap  string `json:"number_wrap"`
	NumberRule  string `json:"number_rule"`
}

type TargetNamingSpec added in v1.0.5

type TargetNamingSpec struct {
	CaseSensitive    bool   `json:"case_sensitive"`
	StyleInsensitive bool   `json:"style_insensitive"`
	GeneratedPrefix  string `json:"generated_prefix"`
}

type TargetOperatorSpec added in v1.0.5

type TargetOperatorSpec struct {
	Spelling      string `json:"spelling"`
	Precedence    int    `json:"precedence"`
	Associativity string `json:"associativity"`
	Fixity        string `json:"fixity"`
}

type TargetProjectionSpec added in v1.0.5

type TargetProjectionSpec struct {
	Mode         PreservationMode `json:"mode"`
	Requirements []string         `json:"requirements,omitempty"`
}

TargetProjectionSpec is a syntax/runtime declaration for a whole family of schema-derived projection contracts. It contains no source-program data.

type TargetSpec added in v1.0.5

type TargetSpec struct {
	ID                  string                          `json:"id"`
	Aliases             []string                        `json:"aliases"`
	Capabilities        []string                        `json:"capabilities"`
	StatementTerminator string                          `json:"statement_terminator"`
	ChildSeparator      string                          `json:"child_separator"`
	Indent              string                          `json:"indent"`
	BlockOpen           string                          `json:"block_open"`
	BlockClose          string                          `json:"block_close"`
	Hooks               []string                        `json:"hooks"`
	Operators           map[string]TargetOperatorSpec   `json:"operators"`
	Types               map[string]string               `json:"types"`
	Literals            TargetLiteralSpec               `json:"literals"`
	Naming              TargetNamingSpec                `json:"naming"`
	Imports             TargetImportSpec                `json:"imports"`
	TypedOperations     TargetTypedOperationSpec        `json:"typed_operations"`
	ProjectionForms     map[string]TargetProjectionSpec `json:"projection_forms"`
	SyntaxTokens        map[string]string               `json:"syntax_tokens"`
}

TargetSpec is declarative target syntax and capability metadata. It never carries source-program semantics: those remain exclusively in UAST.

func RegisteredTargetSpecs added in v1.0.5

func RegisteredTargetSpecs() []TargetSpec

RegisteredTargetSpecs is derived from the target registry, keeping the set of targets single-sourced. The hook names document existing syntax helpers that are deliberately reused during this migration.

type TargetStructureSyntaxCell added in v1.0.5

type TargetStructureSyntaxCell struct {
	Target          string
	StructureKind   string
	ProjectionClass string
	TemplateID      string
	ProjectionForm  string
	Complete        bool
	MissingReason   string
}

TargetStructureSyntaxCell is the exact structure-granular expansion of a TargetSyntaxTemplateCell. The 13×73 class matrix is retained for quotient analysis; this table is used when a class contains multiple syntax forms. It is a checked contract row, never a program representation.

type TargetSyntaxCheck added in v1.0.6

type TargetSyntaxCheck struct {
	Checked             bool   `json:"checked"`
	Valid               bool   `json:"valid"`
	Tool                string `json:"tool,omitempty"`
	Failure             string `json:"failure,omitempty"`
	SemanticDiagnostics bool   `json:"semantic_diagnostics,omitempty"`
}

TargetSyntaxCheck is an observation of a parser/compiler in syntax-only mode. Checked=false means the local toolchain is unavailable; it is not a positive syntax proof and is kept separate in reports.

func CheckTargetSyntax added in v1.0.6

func CheckTargetSyntax(target, source string) TargetSyntaxCheck

CheckTargetSyntax parses generated source without executing it. Native output that fails an available target parser is ineligible for DIRECT and will reach the central compatibility fallback.

type TargetSyntaxTemplate added in v1.0.5

type TargetSyntaxTemplate struct {
	ID              string
	Signature       string
	ProjectionForms []string
	RecipeIDs       []string
	Available       bool
}

TargetSyntaxTemplate is a declarative, syntax-only quotient class. It has neither UAST node data nor source-language meaning; the canonical UAST remains the only semantic input to the projector.

type TargetSyntaxTemplateAnalysis added in v1.0.5

type TargetSyntaxTemplateAnalysis struct {
	Templates        []TargetSyntaxTemplate
	Cells            []TargetSyntaxTemplateCell
	StructureCells   []TargetStructureSyntaxCell
	ExistingMatches  int
	MissingTemplate  int
	MissingParameter int
}

TargetSyntaxTemplateAnalysis is the checked 13×73 syntax contract plane. It is a registry/report, not a target or semantic intermediate representation.

func UniversalTargetSyntaxTemplateAnalysis added in v1.0.5

func UniversalTargetSyntaxTemplateAnalysis() (TargetSyntaxTemplateAnalysis, error)

func WriteTargetSyntaxTemplateAnalysis added in v1.0.5

func WriteTargetSyntaxTemplateAnalysis(dir string) (TargetSyntaxTemplateAnalysis, error)

func (TargetSyntaxTemplateAnalysis) Cell added in v1.0.5

func (a TargetSyntaxTemplateAnalysis) Cell(target, projectionClass string) (TargetSyntaxTemplateCell, bool)

func (TargetSyntaxTemplateAnalysis) StructureCell added in v1.0.5

func (a TargetSyntaxTemplateAnalysis) StructureCell(target, structure string) (TargetStructureSyntaxCell, bool)

func (TargetSyntaxTemplateAnalysis) SupportsContract added in v1.0.5

func (a TargetSyntaxTemplateAnalysis) SupportsContract(target string, contract StructureProjectionContract, spec TargetSpec) bool

SupportsContract resolves a single structural member of a projection class. Projection classes are an execution quotient and can contain more than one syntax form. A class-level Complete=false must therefore never suppress a separately proved direct renderer for another member of that class.

type TargetSyntaxTemplateCell added in v1.0.5

type TargetSyntaxTemplateCell struct {
	Target          string
	ProjectionClass string
	TemplateID      string
	SyntaxSignature string
	ProjectionForm  string
	RecipeIDs       []string
	Complete        bool
	MissingReason   string
	Parameters      map[string]string
}

TargetSyntaxTemplateCell is one Target × ProjectionClass decision. Target parameters are deliberately stored separately from the target-independent template signature.

type TargetSyntaxTemplateForm added in v1.0.5

type TargetSyntaxTemplateForm struct {
	ProjectionForm string
	RendererID     string
}

TargetSyntaxTemplateForm identifies a syntax form already emitted directly from uastExecutionGraph. The table contains no program semantics and is deliberately smaller than the target×projection matrix.

type TargetTypedOperationSpec added in v1.0.5

type TargetTypedOperationSpec struct{ Form, Runtime, ArgumentsOpen, ArgumentsClose, SignedTrue, SignedFalse string }

type TranspileFailure added in v1.2.1

type TranspileFailure struct {
	Class  FailureClass
	Stage  string
	Source string
	Target string
	Reason string
	Cause  error
}

TranspileFailure is the typed error crossing the public source-to-target boundary. Callers can inspect Class without parsing diagnostic strings.

func (*TranspileFailure) Error added in v1.2.1

func (f *TranspileFailure) Error() string

func (*TranspileFailure) Unwrap added in v1.2.1

func (f *TranspileFailure) Unwrap() error

type TypeConversionRecipe added in v1.2.1

type TypeConversionRecipe struct {
	ID                string               `json:"id"`
	FromKind          string               `json:"from_kind"`
	ToKind            string               `json:"to_kind"`
	Target            string               `json:"target"`
	Guard             []string             `json:"guard,omitempty"`
	PreservationClass LoweringExactness    `json:"preservation_class"`
	Status            TypeConversionStatus `json:"status"`
}

TypeConversionRecipe describes one canonical type conversion witness. It contains no target AST or intermediate representation.

func ResolveUniversalTypeConversion added in v1.2.1

func ResolveUniversalTypeConversion(from, to SemanticType, target string) (TypeConversionRecipe, error)

ResolveUniversalTypeConversion proves an exact conversion recursively. It returns TYPE_CONVERSION_UNRESOLVED for incomplete, unknown, or lossy pairs.

func UniversalTypeConversionRegistry added in v1.2.1

func UniversalTypeConversionRegistry() []TypeConversionRecipe

UniversalTypeConversionRegistry is the data-driven registry for exact structural conversions. Target names are metadata for emitters; validity is proven from the canonical source/target type pair, never guessed from source spelling.

type TypeConversionStatus added in v1.2.1

type TypeConversionStatus string

TypeConversionStatus is deliberately separate from renderer selection. A conversion is usable by UniversalLowering only when its structural contract is exact; unknown source information never gets coerced to a convenient target type.

const (
	TypeConversionExact      TypeConversionStatus = "EXACT"
	TypeConversionUnresolved TypeConversionStatus = "TYPE_CONVERSION_UNRESOLVED"
)

type UASTBackendAuditReport added in v1.0.5

type UASTBackendAuditReport struct {
	CanonicalInput                 string                        `json:"canonical_input"`
	UniversalCoreUASTOnly          bool                          `json:"universal_core_uast_only"`
	ProductiveLegacyASTDependency  bool                          `json:"productive_legacy_ast_dependency"`
	SourceLanguageSemanticBranches int                           `json:"source_language_semantic_branches"`
	FrontendSemanticBoundaries     int                           `json:"frontend_semantic_conversion_boundaries"`
	BackendSemanticBoundaries      int                           `json:"backend_semantic_conversion_boundaries"`
	Targets                        []UASTTargetBackendAudit      `json:"targets"`
	Compatibility                  UASTSourceTargetCompatibility `json:"source_target_compatibility"`
}

func UniversalBackendAuditReport added in v1.0.5

func UniversalBackendAuditReport() (UASTBackendAuditReport, error)

UniversalBackendAuditReport is generated from the registered backends and the same capability planes used before target emission. The compatibility matrix covers the currently tested common UAST baseline, not unimplemented schema rows.

type UASTBackendPath added in v1.0.5

type UASTBackendPath struct {
	Name     string `json:"name"`
	Mode     string `json:"mode"`
	Function string `json:"function"`
}

type UASTCapabilityPlane added in v1.0.5

type UASTCapabilityPlane struct {
	Rows             []string              `json:"rows"`
	Targets          []string              `json:"targets"`
	Direct           matrixir.SparseMatrix `json:"direct"`
	LoweringRequired matrixir.SparseMatrix `json:"lowering_required"`
	RuntimeRequired  matrixir.SparseMatrix `json:"runtime_required"`
	Unsupported      matrixir.SparseMatrix `json:"unsupported"`
	Unknown          matrixir.SparseMatrix `json:"unknown"`
}

UASTCapabilityPlane is a one-hot status tensor flattened into five sparse matrices. Rows are universal items and columns are registered targets.

func (UASTCapabilityPlane) Status added in v1.0.5

func (p UASTCapabilityPlane) Status(row, col int) UASTExecutionStatus

type UASTConsumerKind added in v1.0.5

type UASTConsumerKind string

UASTConsumerKind identifies the productive direct-UAST consumer that owns a contract. It classifies consumption without creating a second IR.

const (
	UASTRuntimeConsumed          UASTConsumerKind = "RUNTIME_CONSUMED"
	UASTValidationConsumed       UASTConsumerKind = "VALIDATION_CONSUMED"
	UASTTypeSystemConsumed       UASTConsumerKind = "TYPE_SYSTEM_CONSUMED"
	UASTControlFlowConsumed      UASTConsumerKind = "CONTROL_FLOW_CONSUMED"
	UASTRequirementConsumed      UASTConsumerKind = "REQUIREMENT_CONSUMED"
	UASTTargetProjectionConsumed UASTConsumerKind = "TARGET_PROJECTION_CONSUMED"
	UASTCompileTimeConsumed      UASTConsumerKind = "COMPILETIME_CONSUMED"
)

type UASTDirectExecutionItem added in v1.0.5

type UASTDirectExecutionItem struct {
	Category                   string   `json:"category"`
	Name                       string   `json:"name"`
	Projected                  bool     `json:"projected"`
	CurrentlyDirect            bool     `json:"currently_direct"`
	CurrentlyViaLegacyAdapter  bool     `json:"currently_via_legacy_adapter"`
	RepresentableNotExecutable bool     `json:"representable_not_executable"`
	StoredOnly                 bool     `json:"stored_only,omitempty"`
	DirectTargets              []string `json:"direct_targets,omitempty"`
	LowerableTargets           []string `json:"lowerable_targets,omitempty"`
	RuntimeRequiredTargets     []string `json:"runtime_required_targets,omitempty"`
	UnsupportedTargets         []string `json:"unsupported_targets,omitempty"`
	UnknownTargets             []string `json:"unknown_targets,omitempty"`
}

type UASTDirectExecutionReport added in v1.0.5

type UASTDirectExecutionReport struct {
	Schema             string                       `json:"schema"`
	BasisSHA256        string                       `json:"basis_sha256"`
	Summary            map[string]map[string]int    `json:"summary"`
	Items              []UASTDirectExecutionItem    `json:"items"`
	BackendPaths       []UASTBackendPath            `json:"backend_paths"`
	TargetCapabilities UASTTargetCapabilityMatrix   `json:"target_capabilities"`
	TargetPreservation UASTTargetPreservationMatrix `json:"target_preservation"`
	Execution          UASTExecutionAnalysis        `json:"execution"`
	EndToEnd           UASTEndToEndCapabilityReport `json:"end_to_end"`
	BackendAudit       UASTBackendAuditReport       `json:"backend_audit"`
}

func UniversalDirectExecutionReport added in v1.0.5

func UniversalDirectExecutionReport() (UASTDirectExecutionReport, error)

type UASTEndToEndCapabilityPlane added in v1.0.5

type UASTEndToEndCapabilityPlane struct {
	Rows               []string              `json:"rows"`
	Representable      matrixir.SparseMatrix `json:"representable"`
	Frontend           matrixir.SparseMatrix `json:"frontend"`
	Enrichment         matrixir.SparseMatrix `json:"enrichment"`
	Evidence           matrixir.SparseMatrix `json:"evidence"`
	Normalize          matrixir.SparseMatrix `json:"normalize"`
	Backend            matrixir.SparseMatrix `json:"backend"`
	Target             matrixir.SparseMatrix `json:"target"`
	Test               matrixir.SparseMatrix `json:"test"`
	Full               matrixir.SparseMatrix `json:"full"`
	RepresentationOnly matrixir.SparseMatrix `json:"representation_only"`
	FrontendGap        matrixir.SparseMatrix `json:"frontend_gap"`
	EnrichmentGap      matrixir.SparseMatrix `json:"enrichment_gap"`
	EvidenceGap        matrixir.SparseMatrix `json:"evidence_gap"`
	BackendGap         matrixir.SparseMatrix `json:"backend_gap"`
	TargetGap          matrixir.SparseMatrix `json:"target_gap"`
	TestGap            matrixir.SparseMatrix `json:"test_gap"`
}

UASTEndToEndCapabilityPlane records one boolean column per pipeline stage. It is deliberately a report of proved paths, not a priority or ranking.

type UASTEndToEndCapabilityReport added in v1.0.5

type UASTEndToEndCapabilityReport struct {
	Structures UASTEndToEndCapabilityPlane `json:"structures"`
	Relations  UASTEndToEndCapabilityPlane `json:"relations"`
	Facets     UASTEndToEndCapabilityPlane `json:"facets"`
	Fields     UASTEndToEndCapabilityPlane `json:"fields"`
	Summary    map[string]map[string]int   `json:"summary"`
}

func UniversalEndToEndCapabilityReport added in v1.0.5

func UniversalEndToEndCapabilityReport() (UASTEndToEndCapabilityReport, error)

UniversalEndToEndCapabilityReport combines the existing schema/crosswalk matrices with the proven direct frontend, normalizer, backend and test contracts. A cell becomes FULL only when every boolean pipeline vector is 1.

type UASTExecutionAnalysis added in v1.0.5

type UASTExecutionAnalysis struct {
	Schema                    string                        `json:"schema"`
	BasisSHA256               string                        `json:"basis_sha256"`
	Primitives                []UASTExecutionPrimitiveSpec  `json:"primitives"`
	Capabilities              []string                      `json:"capabilities"`
	Structures                []string                      `json:"structures"`
	Relations                 []string                      `json:"relations"`
	Fields                    []string                      `json:"fields"`
	MCE                       matrixir.SparseMatrix         `json:"m_ce"`
	MSE                       matrixir.SparseMatrix         `json:"m_se"`
	MRE                       matrixir.SparseMatrix         `json:"m_re"`
	MDE                       matrixir.SparseMatrix         `json:"m_de"`
	Implemented               matrixir.Vector               `json:"exec_primitive_implemented"`
	Executable                matrixir.Vector               `json:"executable_uasf"`
	ExecutableStructures      matrixir.Vector               `json:"executable_structures"`
	ExecutableRelations       matrixir.Vector               `json:"executable_relations"`
	ExecutableFields          matrixir.Vector               `json:"executable_fields"`
	ProductivelyConsumed      matrixir.Vector               `json:"productively_consumed_uasf"`
	ConsumerCoverage          map[string][]UASTConsumerKind `json:"consumer_coverage"`
	Missing                   matrixir.SparseMatrix         `json:"missing_primitives"`
	GlobalMissing             map[string]int                `json:"global_missing_primitives"`
	EquivalenceClasses        []UASTExecutionClass          `json:"execution_equivalence_classes"`
	ProductiveLegacyRelations int                           `json:"productive_legacy_semantic_dependencies"`
}

UASTExecutionAnalysis contains the four required boolean matrices and the exact UASF quotient. Executable is one only when each primitive in the UASF row has a real product handler.

func UniversalExecutionAnalysis added in v1.0.5

func UniversalExecutionAnalysis() (UASTExecutionAnalysis, error)

UniversalExecutionAnalysis derives M_CE, M_SE, M_RE and M_DE directly from the canonical UAST basis. It uses exact row equality for the quotient.

func WriteUniversalExecutionAnalysis added in v1.0.5

func WriteUniversalExecutionAnalysis(dir string) (UASTExecutionAnalysis, error)

WriteUniversalExecutionAnalysis writes the quotient and missing primitive matrices. The files are reproducible reports of the canonical UAST basis.

type UASTExecutionClass added in v1.0.5

type UASTExecutionClass struct {
	ID                 string   `json:"id"`
	UASFMembers        []string `json:"uasf_members"`
	ExecutionSignature string   `json:"execution_signature"`
	RequiredPrimitives []string `json:"required_primitives"`
}

type UASTExecutionPrimitive added in v1.0.5

type UASTExecutionPrimitive string

UASTExecutionPrimitive is a behavior already consumed by the direct UAST runtime, validator, or target projector. It is not another semantic IR: the UAST graph remains the sole input and the registry only describes which existing execution paths a graph requires.

func EmpiricalCompilerDetailExecution added in v1.1.1

func EmpiricalCompilerDetailExecution(primitive string) (UASTExecutionPrimitive, bool)

EmpiricalCompilerDetailExecution keeps compiler/bytecode-only observations on the existing validation path. They are useful contracts but do not imply a new executable UAST semantic.

func EmpiricalPy2ManyExecution added in v1.1.1

func EmpiricalPy2ManyExecution(primitive string) (UASTExecutionPrimitive, bool)

EmpiricalPy2ManyExecution links an observed py2many primitive to the existing productive UAST execution handler.

func ResolveEmpiricalPrimitive added in v1.1.1

func ResolveEmpiricalPrimitive(primitive string) (UASTExecutionPrimitive, bool)

ResolveEmpiricalPrimitive is the common bridge used by evidence consumers for both compiler and py2many primitive names.

func ResolveEmpiricalPrimitiveVector added in v1.1.1

func ResolveEmpiricalPrimitiveVector(primitives []string) []UASTExecutionPrimitive

ResolveEmpiricalPrimitiveVector resolves a composed evidence signature to the unique set of existing productive handlers. Ambiguous source evidence therefore remains a composition of normal UAST consumers rather than a new primitive or language-specific path.

func ResolveObservedPrimitive added in v1.1.1

func ResolveObservedPrimitive(primitive string) (UASTExecutionPrimitive, bool)

ResolveObservedPrimitive is the shared evidence bridge used by the all-to-all matrix. It links observed semantic names to productive handlers while leaving parser-only operations to their existing machine handlers.

type UASTExecutionPrimitiveSpec added in v1.0.5

type UASTExecutionPrimitiveSpec struct {
	ID          UASTExecutionPrimitive `json:"id"`
	Implemented bool                   `json:"implemented"`
	Handler     string                 `json:"handler,omitempty"`
	Consumers   []UASTConsumerKind     `json:"consumers,omitempty"`
}

type UASTExecutionRegistry added in v1.0.5

type UASTExecutionRegistry struct {
	Primitives      []UASTExecutionPrimitiveSpec
	SemanticAxis    map[string][]UASTExecutionPrimitive
	RelationAxis    map[string][]UASTExecutionPrimitive
	StructuralLayer map[string][]UASTExecutionPrimitive
	Relation        map[string][]UASTExecutionPrimitive
	Field           map[string][]UASTExecutionPrimitive
}

UASTExecutionRegistry maps canonical schema axes to execution primitives. All rows are boolean and are derived from the checked-in axis labels and the actual direct UAST entry points named in Handler.

func DefaultUASTExecutionRegistry added in v1.0.5

func DefaultUASTExecutionRegistry() UASTExecutionRegistry

type UASTExecutionStatus added in v1.0.5

type UASTExecutionStatus string
const (
	UASTDirect          UASTExecutionStatus = "direct"
	UASTLowering        UASTExecutionStatus = "lowerable"
	UASTRuntimeRequired UASTExecutionStatus = "runtime-required"
	UASTUnsupported     UASTExecutionStatus = "unsupported"
	UASTUnknown         UASTExecutionStatus = "unknown"
)

type UASTPreservationAnalysis added in v1.0.5

type UASTPreservationAnalysis struct {
	Schema               string                             `json:"schema"`
	BasisSHA256          string                             `json:"basis_sha256"`
	Capabilities         []string                           `json:"capabilities"`
	Targets              []string                           `json:"targets"`
	Primitives           []UASTPreservationPrimitive        `json:"primitives"`
	MCP                  matrixir.SparseMatrix              `json:"m_cp"`
	MTP                  matrixir.SparseMatrix              `json:"m_tp"`
	Contracts            []UASTPreservationContract         `json:"m_ctp"`
	EquivalenceClasses   []UASTPreservationEquivalenceClass `json:"preservation_equivalence_classes"`
	GlobalMissing        map[string]int                     `json:"global_missing_preservation_primitives"`
	ErrorReasons         map[string]int                     `json:"error_reasons"`
	Unclassified         int                                `json:"unclassified"`
	ProductiveLegacyDeps int                                `json:"productive_legacy_semantic_dependencies"`
}

UASTPreservationAnalysis is the complete matrix-derived target preservation contract. MCP is UASF × PreservationPrimitive, MTP is Target × PreservationPrimitive, and MCTP is the explicit flattened product in Contracts. No source-language data occurs in this analysis.

func UniversalTargetPreservationAnalysis added in v1.0.5

func UniversalTargetPreservationAnalysis() (UASTPreservationAnalysis, error)

UniversalTargetPreservationAnalysis computes the target contract quotient from the canonical execution matrix and the existing proven target paths. Target primitive availability is proved by a currently executable UAST facet that requires the primitive; an unused primitive is not promoted by declaration alone. The target.syntax requirement is then added per cell from the real direct-UAST emitter boundary, so broader UASF rows cannot borrow syntax support from the small tested core.

func WriteUASTPreservationAnalysis added in v1.0.5

func WriteUASTPreservationAnalysis(dir string) (UASTPreservationAnalysis, error)

type UASTPreservationContract added in v1.0.5

type UASTPreservationContract struct {
	Target              string           `json:"target"`
	UASF                string           `json:"uasf"`
	CurrentMode         PreservationMode `json:"current_mode"`
	RequiredPrimitives  []string         `json:"required_primitives"`
	AvailablePrimitives []string         `json:"available_primitives"`
	MissingPrimitives   []string         `json:"missing_primitives"`
	ErrorReason         string           `json:"error_reason,omitempty"`
	FallbacksChecked    []string         `json:"fallbacks_checked"`
}

UASTPreservationContract is one flattened Target × UASF × Primitive cell. Required, Available and Missing make M_CTP inspectable without inventing a tensor type or a second semantic representation.

type UASTPreservationEquivalenceClass added in v1.0.5

type UASTPreservationEquivalenceClass struct {
	ID                 string           `json:"class_id"`
	Targets            []string         `json:"targets"`
	UASFMembers        []string         `json:"uasf_members"`
	RequiredPrimitives []string         `json:"required_primitives"`
	CurrentMode        PreservationMode `json:"current_mode"`
	MissingPrimitives  []string         `json:"missing_primitives"`
	ErrorReason        string           `json:"error_reason,omitempty"`
}

type UASTPreservationPrimitive added in v1.0.5

type UASTPreservationPrimitive struct {
	ID        string                 `json:"id"`
	Execution UASTExecutionPrimitive `json:"execution_primitive"`
}

UASTPreservationPrimitive is a target-side realization of one already canonical execution contract. It is a registry row, not an IR node.

type UASTSourceTargetCompatibility added in v1.0.5

type UASTSourceTargetCompatibility struct {
	Sources     []string              `json:"sources"`
	Targets     []string              `json:"targets"`
	Full        matrixir.SparseMatrix `json:"full"`
	Partial     matrixir.SparseMatrix `json:"partial"`
	Unsupported matrixir.SparseMatrix `json:"unsupported"`
}

type UASTStructureProjectionRegistry added in v1.0.5

type UASTStructureProjectionRegistry struct {
	Schema           string                        `json:"schema"`
	BasisSHA256      string                        `json:"basis_sha256"`
	Contracts        []StructureProjectionContract `json:"contracts"`
	Classes          map[string][]string           `json:"classes"`
	ClassProjectable map[string]bool               `json:"class_projectable"`
	FieldUse         map[string]string             `json:"field_use"`
	RelationUse      map[string]string             `json:"relation_use"`
}

UASTStructureProjectionRegistry is the exact quotient of the canonical structural matrix by syntax requirements. Contracts sharing a class have the same layers, child relations, fields and execution requirements.

func UniversalStructureProjectionRegistry added in v1.0.5

func UniversalStructureProjectionRegistry() (UASTStructureProjectionRegistry, error)

UniversalStructureProjectionRegistry returns the immutable schema quotient cached for this process. The registry is recomputed only across processes from the embedded matrices; callers must treat the returned data as read-only.

func WriteUASTStructureProjectionRegistry added in v1.0.5

func WriteUASTStructureProjectionRegistry(dir string) (UASTStructureProjectionRegistry, error)

WriteUASTStructureProjectionRegistry produces the machine-readable projection quotient used to identify a shared projector gap before any target-specific code is written.

type UASTTargetBackendAudit added in v1.0.5

type UASTTargetBackendAudit struct {
	Language                 string         `json:"language"`
	UASTDirect               bool           `json:"uast_direct"`
	LegacyDependency         bool           `json:"legacy_dependency"`
	SourceLanguageDependency bool           `json:"source_language_dependency"`
	StructureCapabilities    map[string]int `json:"structure_capabilities"`
	RelationCapabilities     map[string]int `json:"relation_capabilities"`
	FacetCapabilities        map[string]int `json:"facet_capabilities"`
	FieldCapabilities        map[string]int `json:"field_capabilities"`
}

UASTTargetBackendAudit describes the registered target contract. Semantic lowering always enters through UAST; target-specific code only renders the already-proved canonical facts in its own syntax.

type UASTTargetCapabilityMatrix added in v1.0.5

type UASTTargetCapabilityMatrix struct {
	Structures   UASTCapabilityPlane                  `json:"structures"`
	Facets       UASTCapabilityPlane                  `json:"facets"`
	Relations    UASTCapabilityPlane                  `json:"relations"`
	Fields       UASTCapabilityPlane                  `json:"fields"`
	StatusCounts map[string]map[string]map[string]int `json:"status_counts"`
}

func UniversalTargetCapabilityMatrix added in v1.0.5

func UniversalTargetCapabilityMatrix() (UASTTargetCapabilityMatrix, error)

type UASTTargetPreservationMatrix added in v1.0.5

type UASTTargetPreservationMatrix struct {
	Schema       string                    `json:"schema"`
	BasisSHA256  string                    `json:"basis_sha256"`
	Capabilities []string                  `json:"capabilities"`
	Targets      []string                  `json:"targets"`
	Direct       matrixir.SparseMatrix     `json:"direct"`
	Rewrite      matrixir.SparseMatrix     `json:"rewrite"`
	Helper       matrixir.SparseMatrix     `json:"helper"`
	Emulate      matrixir.SparseMatrix     `json:"emulate"`
	Runtime      matrixir.SparseMatrix     `json:"runtime"`
	Error        matrixir.SparseMatrix     `json:"error"`
	StatusCounts map[string]map[string]int `json:"status_counts"`
}

UASTTargetPreservationMatrix is the complete target × UASF decision plane. It is a declaration of actual product paths, not a prediction. Every cell is one-hot: DIRECT, REWRITE, HELPER, EMULATE, RUNTIME, or explicit ERROR. The matrix is a registry-derived table and is not another semantic IR.

func UniversalTargetPreservationMatrix added in v1.0.5

func UniversalTargetPreservationMatrix() (UASTTargetPreservationMatrix, error)

UniversalTargetPreservationMatrix classifies every canonical UASF for every registered target. The generic target emitter and checked-in per-target runtime support the core structural quotient. Remaining canonical UASF rows are deliberately ERROR until a real lowering, helper, emulator, or runtime module is registered; they are never silently treated as unknown.

func WriteUASTTargetPreservationMatrix added in v1.0.5

func WriteUASTTargetPreservationMatrix(dir string) (UASTTargetPreservationMatrix, error)

func (UASTTargetPreservationMatrix) Status added in v1.0.5

type UnaryExpr

type UnaryExpr struct {
	Op string
	X  Expr
}

type UniversalASTBasis added in v1.0.5

type UniversalASTBasis struct {
	Schema                     string                `json:"schema"`
	Features                   []string              `json:"features"`
	Facets                     []string              `json:"facets"`
	SemanticAxes               []string              `json:"semantic_axes"`
	RelationAxes               []string              `json:"relation_axes"`
	Languages                  []string              `json:"languages"`
	StructuralKinds            []string              `json:"structural_kinds"`
	ConcreteRelations          []string              `json:"concrete_relations"`
	Fields                     []string              `json:"fields"`
	Layers                     []string              `json:"layers"`
	GlobalRelations            []string              `json:"global_relations"`
	CrosswalkFields            []string              `json:"crosswalk_fields"`
	FeatureFacet               matrixir.SparseMatrix `json:"feature_facet"`
	FeatureSignature           matrixir.SparseMatrix `json:"feature_signature"`
	FacetAxis                  matrixir.SparseMatrix `json:"facet_axis"`
	FacetRelationAxis          matrixir.SparseMatrix `json:"facet_relation_axis"`
	LanguageFacet              matrixir.SparseMatrix `json:"language_facet"`
	CoverageLower              matrixir.SparseMatrix `json:"coverage_lower"`
	CoverageUpper              matrixir.SparseMatrix `json:"coverage_upper"`
	StructuralFacetSeed        matrixir.SparseMatrix `json:"structural_facet_seed"`
	FacetLayer                 matrixir.SparseMatrix `json:"facet_layer"`
	StructuralLayer            matrixir.SparseMatrix `json:"structural_layer"`
	FacetConcreteRelation      matrixir.SparseMatrix `json:"facet_concrete_relation"`
	StructuralConcreteRelation matrixir.SparseMatrix `json:"structural_concrete_relation"`
	FacetField                 matrixir.SparseMatrix `json:"facet_field"`
	StructuralField            matrixir.SparseMatrix `json:"structural_field"`
}

type UniversalASTCanonicalCoverage added in v1.0.5

type UniversalASTCanonicalCoverage struct {
	Structures int `json:"structures"`
	Relations  int `json:"relations"`
	Facets     int `json:"facets"`
	Fields     int `json:"fields"`
	UASFReady  int `json:"uast_ready"`
}

UniversalASTCanonicalCoverage describes the representability contract of the embedded UAST schema. It is deliberately separate from execution and target-preservation reports: a canonical facet can be represented before a frontend mapping is proven or a target lowering exists.

func CanonicalUniversalASTCoverage added in v1.0.5

func CanonicalUniversalASTCoverage() (UniversalASTCanonicalCoverage, error)

CanonicalUniversalASTCoverage returns the complete structural coverage of the canonical UAST basis. It fails if the embedded schema is malformed.

type UniversalASTDocument added in v1.0.5

type UniversalASTDocument struct {
	SchemaVersion          int                      `json:"schema_version"`
	BasisSHA256            string                   `json:"basis_sha256"`
	LanguageProfile        string                   `json:"language_profile"`
	LanguageFacet          matrixir.Vector          `json:"language_facet"`
	Projection             string                   `json:"projection,omitempty"`
	SemanticDocumentSHA256 string                   `json:"semantic_document_sha256,omitempty"`
	Evaluation             string                   `json:"evaluation,omitempty"`
	ValueModel             string                   `json:"value_model,omitempty"`
	IndexBase              int                      `json:"index_base,omitempty"`
	Types                  SemanticTypeContract     `json:"type_contract,omitempty"`
	Origin                 SemanticOrigin           `json:"origin,omitempty"`
	Metadata               map[string]string        `json:"metadata,omitempty"`
	Extensions             map[string]any           `json:"extensions,omitempty"`
	Contracts              SemanticContracts        `json:"contracts,omitempty"`
	Dialects               []SemanticDialect        `json:"dialects,omitempty"`
	SemanticFeatures       *SemanticFeatureModel    `json:"semantic_features,omitempty"`
	TypeTable              []SemanticTypeDefinition `json:"type_table,omitempty"`
	TypeGraph              matrixir.SparseMatrix    `json:"type_graph,omitempty"`
	TypeRelations          *SemanticTypeRelations   `json:"type_relations,omitempty"`
	Evidence               SemanticEvidence         `json:"evidence,omitempty"`
	// Surface is the lossless source plane. It carries original bytes only;
	// semantic lowering continues to use Nodes/Relations as the sole semantic
	// representation. Same-language preservation can therefore round-trip
	// source without reparsing or inventing a second IR.
	Surface   *UniversalASTSurface   `json:"surface,omitempty"`
	Nodes     []UniversalASTNode     `json:"nodes"`
	Relations []UniversalASTRelation `json:"relations"`
}

func ApplyPrimitiveClosure added in v1.2.1

func ApplyPrimitiveClosure(original *UniversalASTDocument, target string) (*UniversalASTDocument, []string, error)

ApplyPrimitiveClosure is the productive bridge from canonical UAST to the bounded transactional rewrite driver. Generated recipes are never treated as executable merely because they parse: only recipes with a registered structural handler can alter the graph, and each alteration carries proof.

func BuildCanonicalUniversalASTFromFrontendFacts added in v1.0.5

func BuildCanonicalUniversalASTFromFrontendFacts(f FrontendSemanticFacts) (*UniversalASTDocument, error)

BuildCanonicalUniversalASTFromFrontendFacts is the single generic frontend route. Evidence is always derived by AnalyzeUniversalEvidence; the frontend cannot add guessed evidence through this builder.

func BuildCanonicalUniversalASTFromParseNode added in v1.0.6

func BuildCanonicalUniversalASTFromParseNode(language string, root *matrixir.ParseNode) (*UniversalASTDocument, error)

BuildCanonicalUniversalASTFromParseNode is the common, language-neutral bridge from the table parser's neutral reduction tree to the existing UAST facts pipeline. It deliberately uses only node shape, fields and source spans; language-specific parser branches are not involved.

func BuildRawUniversalASTFromFrontendFacts added in v1.0.5

func BuildRawUniversalASTFromFrontendFacts(f FrontendSemanticFacts) (*UniversalASTDocument, error)

BuildRawUniversalASTFromFrontendFacts materializes exactly the facts that a frontend proved. It does not infer fields, facets, relations or evidence.

func ExecuteLoweringRecipe added in v1.2.1

func ExecuteLoweringRecipe(original *UniversalASTDocument, recipe GeneratedLoweringRecipe, target string) (*UniversalASTDocument, error)

ExecuteLoweringRecipe validates and applies a generated recipe to a private UAST clone. The generic executor records the recipe provenance and leaves semantic payloads untouched when a target already supports the node.

func NewUniversalASTDocument added in v1.0.5

func NewUniversalASTDocument(source string) (*UniversalASTDocument, error)

func NormalizeUniversalAST added in v1.0.5

func NormalizeUniversalAST(d *UniversalASTDocument) (*UniversalASTDocument, error)

NormalizeUniversalAST is the shared canonical validation/normalization pass for all ingress paths. It operates only on UAST data and never constructs a legacy statement or expression tree.

func ProjectSemanticDocumentToUniversal added in v1.0.5

func ProjectSemanticDocumentToUniversal(doc SemanticDocument) (*UniversalASTDocument, error)

ProjectSemanticDocumentToUniversal is the compatibility crosswalk. Facets come only from supplied structural seed rows; no unseeded facet is guessed.

func (*UniversalASTDocument) AddNode added in v1.0.5

func (d *UniversalASTDocument) AddNode(kind string, facets []string, fields map[string]json.RawMessage) (int, error)

func (*UniversalASTDocument) AddRelation added in v1.0.5

func (d *UniversalASTDocument) AddRelation(kind string, from int, to UniversalASTReference, attributes map[string]json.RawMessage) error

type UniversalASTNode added in v1.0.5

type UniversalASTNode struct {
	ID             int                        `json:"id"`
	StructuralKind string                     `json:"structural_kind"`
	SemanticFacets []string                   `json:"semantic_facets,omitempty"`
	FieldMask      []string                   `json:"field_mask"`
	Fields         map[string]json.RawMessage `json:"fields,omitempty"`
	Source         *SemanticSourceSpan        `json:"source_span,omitempty"`
	Attributes     map[string]json.RawMessage `json:"attributes,omitempty"`
}

type UniversalASTReference added in v1.0.5

type UniversalASTReference struct {
	Domain string `json:"domain"`
	ID     string `json:"id"`
}

type UniversalASTRelation added in v1.0.5

type UniversalASTRelation struct {
	Kind       string                     `json:"kind"`
	From       int                        `json:"from"`
	To         UniversalASTReference      `json:"to"`
	Attributes map[string]json.RawMessage `json:"attributes,omitempty"`
}

type UniversalASTSurface added in v1.2.1

type UniversalASTSurface struct {
	Language        string `json:"language"`
	Encoding        string `json:"encoding"`
	SHA256          string `json:"sha256"`
	ByteLength      int    `json:"byte_length"`
	BytesBase64     string `json:"bytes_base64"`
	BytesGzipBase64 string `json:"bytes_gzip_base64,omitempty"`
}

func NewUniversalASTSurface added in v1.2.1

func NewUniversalASTSurface(language, source string) *UniversalASTSurface

func (*UniversalASTSurface) Bytes added in v1.2.1

func (s *UniversalASTSurface) Bytes() ([]byte, error)

type UniversalFormatter added in v1.0.5

type UniversalFormatter struct {
	Indent  string
	Newline string
}

UniversalFormatter knows only document layout. Semantic analysis is complete before a Doc is constructed.

func (UniversalFormatter) Format added in v1.0.5

func (f UniversalFormatter) Format(doc Doc) string

type UniversalHelperResolver added in v1.0.5

type UniversalHelperResolver struct{}

func (UniversalHelperResolver) Resolve added in v1.0.5

func (UniversalHelperResolver) Resolve(requirements []HelperRequirement, registry map[string]HelperSpec) ([]HelperSpec, error)

type UniversalLoweringAnalysis added in v1.2.1

type UniversalLoweringAnalysis struct {
	Schema                  string                    `json:"schema"`
	Rules                   []UniversalLoweringRule   `json:"rules"`
	FrontendProvenSemantics []string                  `json:"frontend_proven_semantics"`
	DirectTargetCells       int                       `json:"direct_target_cells"`
	LoweringReachableCells  int                       `json:"lowering_reachable_cells"`
	LoweringProvenCells     int                       `json:"lowering_proven_cells"`
	ResidualCells           int                       `json:"residual_cells"`
	RuntimeOnlyCells        int                       `json:"runtime_only_cells"`
	UnknownCells            int                       `json:"unknown_cells"`
	MaxLoweringDepth        int                       `json:"max_lowering_depth"`
	CyclesDetected          int                       `json:"cycles_detected"`
	PerTarget               map[string]map[string]int `json:"per_target"`
}

func AnalyzeUniversalLowering added in v1.2.1

func AnalyzeUniversalLowering() (UniversalLoweringAnalysis, error)

AnalyzeUniversalLowering derives a compact report from the existing UAST capability matrix and rule registry. It does not promote a rule to proven support; proven counts are populated only by successful executable witnesses.

func WriteUniversalLoweringAnalysis added in v1.2.1

func WriteUniversalLoweringAnalysis(out string) (UniversalLoweringAnalysis, error)

WriteUniversalLoweringAnalysis writes the requested report plane. CSVs are deterministic and contain only registry/matrix evidence; summary.json is the machine-readable aggregate.

type UniversalLoweringRule added in v1.2.1

type UniversalLoweringRule struct {
	ID                   string   `json:"id"`
	SourceSemantic       string   `json:"source_semantic"`
	ResultSemantics      []string `json:"result_semantics"`
	RequiredCapabilities []string `json:"required_capabilities,omitempty"`
	RequiredTypes        []string `json:"required_types,omitempty"`
	RequiredEffects      []string `json:"required_effects,omitempty"`
	RequiredContracts    []string `json:"required_contracts,omitempty"`
	RequiredRelations    []string `json:"required_relations,omitempty"`
	RepresentationGuards []string `json:"representation_guards,omitempty"`
	ForbiddenEffects     []string `json:"forbidden_effects,omitempty"`
	TargetGuards         []string `json:"target_guards,omitempty"`
	// PrimitiveFamily and KernelClass are derived from the same matrix
	// projection used by the primitive compiler. They document the quotient
	// family without introducing a second lowering registry.
	PrimitiveFamily string `json:"primitive_family,omitempty"`
	KernelClass     string `json:"kernel_class,omitempty"`
	// ValidationOnly closes an evidence/analysis contract without making it
	// an executable UAST rewrite. Such rules stay visible in the registry but
	// are excluded from the lowering worklist.
	ValidationOnly    bool              `json:"validation_only,omitempty"`
	PreservationClass LoweringExactness `json:"preservation_class"`
	EvidenceStatus    string            `json:"evidence_status"`
	Implemented       bool              `json:"implemented"`
	ComplexityBefore  int               `json:"complexity_before"`
	ComplexityAfter   int               `json:"complexity_after"`
	// Applier is intentionally not serialized.  It is only used after all
	// declarative guards have passed and receives a mutable UAST clone.
	Applier func(*UniversalASTDocument, int) error `json:"-"`
}

UniversalLoweringRule is a source-independent semantic rewrite contract. SourceSemantic is a canonical UAST semantic kind or operation identifier; ResultSemantics names the existing UAST kinds/operations produced by the rule. RequiredCapabilities are checked against the target's existing direct capability plane before an applier is run.

func GeneratedUniversalLoweringRules added in v1.2.1

func GeneratedUniversalLoweringRules() ([]UniversalLoweringRule, error)

GeneratedUniversalLoweringRules exposes the CSV-derived recipes through the same rule shape used by the existing worklist. Callers may merge these rules with the static evidence registry without introducing another IR or handler table.

func UniversalLoweringRegistry added in v1.2.1

func UniversalLoweringRegistry() []UniversalLoweringRule

UniversalLoweringRegistry is the single executable rule view consumed by the worklist: evidence-backed static rules plus generated recipe rules.

func UniversalLoweringRules added in v1.2.1

func UniversalLoweringRules() []UniversalLoweringRule

UniversalLoweringRules is the single registry used by closure analysis and the executable worklist. The entries are the evidence-backed, source independent contracts from the lowering matrix. Only entries marked Implemented and EXACT are executable; the remaining contracts deliberately stay visible as unresolved work instead of being guessed.

type UniversalModuleResolver added in v1.2.9

type UniversalModuleResolver struct{ Store SemanticModuleStore }

func NewUniversalModuleResolver added in v1.2.9

func NewUniversalModuleResolver() (UniversalModuleResolver, error)

func (UniversalModuleResolver) ImportGraph added in v1.2.9

ImportGraph resolves the root and locally addressable transitive dependencies through this same resolver. External package names remain graph edges and never cause an external toolchain invocation.

func (UniversalModuleResolver) ImportTarget added in v1.2.9

func (r UniversalModuleResolver) ImportTarget(target string, opts ModuleImportOptions) (*SemanticModule, error)

type UniversalTargetNameResolver added in v1.0.5

type UniversalTargetNameResolver struct{}

func (UniversalTargetNameResolver) Resolve added in v1.0.5

func (UniversalTargetNameResolver) Resolve(preferred string, spec TargetSpec) string

type UniversalTargetProjector added in v1.0.5

type UniversalTargetProjector struct{}

UniversalTargetProjector performs the two-pass target pipeline. It has no source-language input and delegates only syntax emission to the tested existing UAST emitter while the declarative TargetSpec controls selection.

func (UniversalTargetProjector) Analyze added in v1.0.5

func (UniversalTargetProjector) Emit added in v1.0.5

func (UniversalTargetProjector) EmitDirect added in v1.1.1

func (p UniversalTargetProjector) EmitDirect(u *UniversalASTDocument, target string) (string, error)

func (UniversalTargetProjector) Project added in v1.0.5

func (UniversalTargetProjector) ProjectDirect added in v1.1.1

func (p UniversalTargetProjector) ProjectDirect(u *UniversalASTDocument, spec TargetSpec) (Doc, error)

ProjectDirect is the strict counterpart used by the matrix route planner. It performs the same structural and capability validation but never selects compatibility runtime output. A caller can therefore try an intermediate target and only invoke the normal Project method as the final fallback.

func (UniversalTargetProjector) ProjectLoweredDirect added in v1.2.1

func (p UniversalTargetProjector) ProjectLoweredDirect(u *UniversalASTDocument, spec TargetSpec) (Doc, LoweringTrace, error)

ProjectLoweredDirect is the explicit second stage after ProjectDirect. It owns the private UAST clone and returns only a runtime-free native document.

type WhileStmt

type WhileStmt struct {
	Cond Expr
	Body Stmt
}

Source Files

Jump to

Keyboard shortcuts

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