Package com.darkcollective.relix.semantic.internal
package com.darkcollective.relix.semantic.internal
The engine-side machinery behind
com.darkcollective.relix.semantic: not exported by the published
artifact. What follows describes the package as a whole, as it stood before the split.
Five-phase semantic analysis pipeline for Relix scripts.
Overview
This package transforms a parsed Script
AST into a validated SemanticModel that
downstream tools (execution engines, optimisers, IDEs) can query. Analysis is
orchestrated by SemanticAnalyzer and
proceeds in five sequential phases:
- Import Graph (
ImportGraph) — resolvesimportstatements depth-first and detects cycles. - Symbol Collection (
SymbolCollector) — registers every relation and function declared in all reachable scripts into anInMemorySymbolTable. - Schema Inference (
SchemaInferenceEngine) — walks each query body and annotates everyRelNodewith its inferred outputSchema. - Validation (
SemanticValidator) — checks predicate attribute references, rename arity, join conditions, and function existence/arity. - Model Assembly — produces a
SemanticModelcontaining the namespace, symbol table, source declarations, schema annotations, and root query statements.
Key classes
SemanticAnalyzer- Entry point; call
analyze(Script)to run the full pipeline. SemanticResult- Returned by
SemanticAnalyzer: carries errors and, on success, theSemanticModel. SchemaAnnotations- Identity-keyed side-map from
RelNodeto inferredSchema. FunctionCatalog- The functions a script may call, discovered from the installed libraries. A function enters the symbol table on first reference, so an analysed script carries the functions it calls rather than the whole library.
IrReport- Generates a concise ≤80 char/line IR report from a
SemanticModel.
Error reporting
SemanticError carries a file path,
line, column, message, and Severity.
When AST nodes have been parsed with explicit source coordinates (via
SourceLocation), errors are reported at
the precise source position rather than the file level.
- See Also:
-
ClassDescriptionHook for registering built-in symbols into the symbol table before any user-defined symbols are processed.Builds the read-only system catalog relations — the
relix.*namespace that lets a script query the engine's own knowledge about itself (theinformation_schemaanalogue; see ADR-0007).What is installed in this process, for the parts of it the engine cannot see.One installed thing.Which columns aDOWNSAMPLEconsolidates, and what each one is called.One consolidated output column, and the input column reduced into it.Supplies the schema of a generator source during semantic analysis — the seam through which the analyzer learns a generator's heading without the script declaring it (generator-owned schema).Directed dependency graph of all.relixfiles reachable from a root.AScriptLoaderthat serves pre-parsedScripts from an in-memory map, keyed by path string.Produces a concise human-readable IR report from aSemanticModel.Serializes a logical relational-algebra tree to JSON, annotating every node with its inferredSchema.Validates attribute references and function calls within a predicate tree.Validates structural and semantic constraints over a single relational algebra expression tree.Answers one question about a named relation: is it finite? — the extent ofrelix.relations.boundedness.Answers one question about a relational expression: would evaluating it twice necessarily give the same relation?What a call site's function name resolved to — the symbols visible to the rest of the pipeline, and the catalogue definition behind them when there is one.How the analyser records a node's schema in aSchemaAnnotations.Recordsschemaasnode's schema inannotations.Public facade for running schema inference over an arbitraryRelNodetree outside the full five-phase analysis pipeline.Orchestrates the schema-inference pass (Phase 4 of semantic analysis).Infers the outputSchemaof every node in a relational algebra tree.Entry point for semantic analysis — the engine's front door.The outcome of a semantic analysis run.Orchestrates the validation pass (Phase 5 of semantic analysis).Performs the symbol-collection pass over all files reachable from the root.