RuleContext exposes typed, read-only views over the compiled project:
ctx.sql: authored and expanded SQLctx.graph: compiler-resolved dependencies and dependentsctx.columns: declared and inferred output columnsctx.contracts: enforcement and grain factsctx.testsandctx.audits: checks associated with a modelctx.declarations: public and model-scoped enums and constantsctx.project: compiled resources and deterministic project-tree observations
Authored and expanded SQL
Choose the SQL representation that matches the requirement:Common SQL structures
Common structures are available through typed source nodes:Lazy Polyglot access
Use the full Polyglot AST only when common projections are insufficient:Project structure
Use the compiler-owned tree rather than direct filesystem calls:Choose the subject deliberately
A model-subject Rule is evaluated and cached per model. A project-subject Rule runs once and can iteratectx.project.models. Use a project subject only when the invariant genuinely needs a
project-wide view; its cache invalidation is intentionally broader.
