Authored resource roots
Inherited and exact-local declaration directories may appear below these canonical roots:
Files may be organized recursively inside a declaration directory. That internal organization does
not change the directory’s owning path.
Which path resolves SQL
- Models
- Tests and scenarios
- Hooks and functions
- Audits and sources
A model query and its inline SQL hooks resolve from the model file. Model-private constants and
enums are available only in that model’s query and inline hooks.
@@CTX values still describe the invoking model. Only declaration
resolution comes from the named hook’s definition path.
Expected-model grants
A test or scenario has two distinct visibility sources:__ref__, or nearby model does not.
Macro lexical resolution
Calls written directly in authored SQL resolve from that SQL’s path, including nested argument calls:format_money returns SQL
containing another macro call, that emitted call resolves from format_money’s definition path:
@macro() calls rather than importing one another in Python. SQLBuild rejects inaccessible
emitted dependencies and dependency cycles. A project-wide macro cannot depend on an inherited or
exact-local macro because its top-level definition path cannot see narrower declarations.
Generated manifest macro nodes expose declaration scope, owning path, and tracked macro dependencies.
Names and shadowing
Every public name must be globally unique within its declaration kind. A narrower declaration cannot shadow a project-wide or ancestor declaration, even when their visible scopes do not overlap. Macro, constant, and enum namespaces remain independent. These may coexist because each reference identifies its kind:enum:model:stg_orders._state. They may repeat
across models because they never enter the public namespace. Names beginning with __ are reserved
for SQLBuild.
Next: Placement and Usage
See how compiler-recorded usage determines the closest valid declaration directory.

