Skip to content

Execution APIs ​

The execution guide connects source generation, BridgeStan compilation and descriptor operations. The prediction guide explains the generative roles of observed and unobserved quantities.

Source and compilation ​

StanBlocks.stan_model Function
julia
stan_model(slic::SlicModel) -> StanModel

Trace slic end-to-end (forward / backward / distribute passes), returning the inferred StanModel — a fully resolved representation of the Stan blocks plus the data dictionary.

Tracing is the expensive step. A StanModel is cheap to re-data: call model(; new_kwargs...) to swap the data dict without re-tracing. Use this in preference to repeatedly calling stan_instantiate on the original SlicModel.

Errors during tracing are wrapped in a StanBlocksError tagged with phase = :transpile.

Independent calls trace concurrently and observe completed SLIC definitions in the newest method world. Keep model ASTs, data, and published models read-only. The optional internal info builder must be fresh and exclusively owned by this call; sharing it also shares mutable blocks and variables. Extension hooks must be pure. Use slic_eval for runtime families with ordinary Julia hooks.

source
StanBlocks.stan_code Function
julia
stan_code(model) -> String

Return the generated Stan source for model (a SlicModel or StanModel) as a plain String. This is the intentional source-inspection API: ordinary terminal, Markdown, and HTML display shows a semantic model summary and never calls this function automatically.

For a SlicModel, tracing runs first via stan_model; for an already-traced StanModel, only the rendering pass runs. Output covers the full Stan program — data, transformed_data, parameters, transformed_parameters, model, and generated_quantities blocks — with automatic block placement applied.

Pair with transpiles for boolean smoke tests and stan_instantiate to compile the generated code via BridgeStan.

source
StanBlocks.stanc_check Function
julia
stanc_check(stan_code::AbstractString; warn_pedantic=true) -> (ok::Bool, output::String)

Run the stanc compiler on stan_code (written to a temporary file) and return whether it accepted the code plus any compiler output (warnings, errors). Binary discovery: $STANC_PATH env var → BridgeStan's bin/stanc. Errors if neither is available.

source
StanBlocks.stan_instantiate Function
julia
instantiate(model; nan_on_error=true, make_args=["STAN_THREADS=true"], warn=false, path=…) -> StanProblem
stan_instantiate(model; ...) -> StanProblem

Compile model (a SlicModel or StanModel) via BridgeStan and return a StanLogDensityProblems.StanProblem. The returned value implements the LogDensityProblems interface — call LogDensityProblems.dimension, logdensity, and logdensity_and_gradient on it.

stan_instantiate is an exported alias for instantiate.

Keyword arguments

  • path::AbstractString — optional source alias. Relative paths resolve against the cwd. The file is updated atomically; identical bytes preserve its mtime, and changed bytes produce a warning. The native library always comes from an immutable artifact under STANBLOCKS_BUILD_DIR, or tempdir()/stanblocks when unset. It is keyed by source, ordered make_args, source basename, build root, BridgeStan version/location, CPU/compiler identities, build configuration, and the state of every toolchain path the build names. Every call resolves this identity, including identical-source calls after an earlier program was loaded. Published libraries are never overwritten.

  • nan_on_error::Bool = true — make BridgeStan return NaN instead of throwing on evaluation failures.

  • make_args::Vector{String} = ["STAN_THREADS=true"] — extra arguments forwarded to Stan's make. An argument whose value names an existing file or directory (STAN=, MATH=, STANC=, USER_HEADER=, …; relative to the BridgeStan home, where make runs) is identified by its resolved path and a stamp of every entry beneath it, so a link moved to another tree, or a tree rebuilt in place, selects a fresh library. Build environment variables that name paths count the same way, except the PATH and LD_LIBRARY_PATH search lists and BRIDGESTAN, which selects the home itself. The files a USER_HEADER reaches through quoted #include lines count too, as for stan_library.

  • warn::Bool = false — forwarded to BridgeStan.

Concurrent calls own separate model instances. Calls for identical content, in one process or in several processes on one host, share one published library: the first compiles it, the others wait for it or load it, and none rewrites it, so a process that loaded it keeps evaluating the same bytes. Artifact, source-alias, and BridgeStan setup/build locks coordinate Julia tasks and cooperating processes; independent tracing stays parallel. Only building the toolchain's shared files (stanc, BridgeStan's bridge object, Stan Math's libraries) takes the toolchain lock; distinct models then compile concurrently under their own artifact locks. A BridgeStan tree this process may not write (a read-only mount or store path, another user's install) is used as it stands: models compile once make reports its shared files current, and otherwise the call raises naming them (StanBlocks.with_toolchain_lock). Only the build directory must be writable. Native constructor calls are serialized within the process. Compilation publishes only a completed library from a private staging directory. Failures propagate and release the locks; partial build outputs are discarded. An abruptly killed process can leave a pidfile: confirm that its owner has exited before removing the lock. A slow live compiler's lock never expires.

Keep inputs, environment, and the installed toolchain read-only during calls. The identity covers the documented make/local override, compiler binaries, and toolchain paths named by make_args or the build environment. The default BridgeStan home's own trees are identified by its version and location; for source edits there, or external compiler inputs not represented in that configuration, use a new STANBLOCKS_BUILD_DIR. Direct external BridgeStan builds must not mutate the same toolchain concurrently.

With the default threaded build, any number of threads may evaluate at once, on one returned problem or on several problems that share a library: BridgeStan gives every thread its own autodiff tape. A BridgeStan.StanRNG is not thread-safe; give each task its own. A library built without threading shares one tape across threads and must be evaluated from one thread at a time; evaluating it from several crashes the process. Keep BridgeStan's threading/ABI configuration consistent across libraries loaded in one process. Stan enables threading for any nonempty STAN_THREADS value, including false; an empty value disables it.

source
StanBlocks.stan_library Function
julia
stan_library(source; make_args=["STAN_THREADS=true"], stanc_args=String[], dependencies=String[]) -> String

Compile the complete Stan program text source into StanBlocks' immutable artifact store and return the path of the published BridgeStan shared library. Use it for Stan text that does not come from a SLIC model: an archived emitted program, a hand-written .stan file's contents, or a program that calls caller-owned C++ functions. Construct the model from the returned path, for example StanLogDensityProblems.StanProblem(library, stan_json) or BridgeStan.StanModel(library, stan_json). stan_instantiate uses the same store for SLIC models.

The library is <build-dir>/<key>/model_<key>_model.so, beside its source model_<key>.stan, where <build-dir> is $STANBLOCKS_BUILD_DIR, else tempdir()/stanblocks. The key covers everything stan_instantiate's does (source text, ordered make_args, build root, BridgeStan version and location, CPU and compiler identities, build environment, make/local, and the state of every toolchain path the build names), plus the stanc_args and the state of every dependency below. A change to any of them selects a new library; a published library is never rebuilt or overwritten, so one already loaded by a process stays valid. Identical calls return the same path without compiling.

Keyword arguments

  • make_args — arguments forwarded to BridgeStan's make, in order. The words of a STANCFLAGS= entry are passed to stanc ahead of stanc_args.

  • stanc_args — arguments for stanc, such as "--allow-undefined" for a program whose declared functions a C++ header implements. All of them reach stanc: StanBlocks hands BridgeStan one combined STANCFLAGS assignment, where BridgeStan.compile_model given several would keep only the last.

  • dependencies — further files the build reads, such as a C++ header found through an -I path or a Stan file reached through --include-paths. Relative paths resolve against the current directory; each must exist.

The C++ header BridgeStan includes, named by USER_HEADER= in make_args or in the environment, is a toolchain path like any other. make runs in the BridgeStan home, so a relative USER_HEADER names a file there; pass an absolute path. That header and every listed dependency are scanned for quoted #include "…" lines, and each included file that exists relative to the including file is a dependency too, transitively. Angle-bracket includes are treated as part of the toolchain.

Keep the source, the dependencies, the environment, and the toolchain read-only during the call. Compilation runs in a private staging directory under the artifact's own build lock, so concurrent calls in this and other processes publish each library once while distinct programs compile at the same time. Only bringing the toolchain's shared files (stanc, BridgeStan's bridge object, Stan Math's libraries) up to date takes the toolchain build lock (StanBlocks.with_toolchain_lock); a toolchain this process may not write compiles programs once those files are current, and otherwise the call raises naming them. Unlike stan_instantiate, this function constructs no native model: serializing construction and evaluation is the caller's responsibility.

source

Inspection and operations ​

StanBlocks.stan_descriptor Function
julia
stan_descriptor(model; name=nothing) -> ModelDescriptor

Reflect model (a SlicModel or an already-traced StanModel) as one descriptor-bearing, executable declaration: stable identity, inputs, outputs with their generative semantics, included Stan definitions, and the operations DERIVED from them.

A SlicModel is traced first (via stan_model); prefer passing a StanModel when reflecting the same model repeatedly, since tracing is the expensive step.

name overrides the model's own (gensym'd, for an anonymous @slic begin … end) name. It is informational — id is derived from the generated Stan source, not from the name.

Derived operations

Nothing here is a hand-maintained list; each operation appears exactly when the traced model supports it.

operationoffered when
:transpilealways
:instantiatealways (fails loudly at run time if a required input is unbound)
:fitthe model has ≥1 parameter and ≥1 likelihood term — i.e. a non-held-out observation reaches the model block. A pure prior-predictive model, or one whose every observation is cv-held-out, offers no :fit
:predict≥1 output with generative == :draw
:pointwise_loglik≥1 output with generative == :pointwise_loglik

Ask for one with stan_operation and run it with stan_execute; both fail closed on an operation the model does not offer.

Resolved dimensions

Each output's dims is the shape of its value: its size evaluated against the bound data, together with the transformed-data values and ragged-plate layouts that size reads. A constrained square matrix declared by one size fills both of its matrix axes, so cholesky_factor_corr[K] reports (K, K); for every non-tuple output prod(dims) is its number of BridgeStan param_names entries. Every top-level Stan size is a data-only expression. Available Julia implementations evaluate directly; unsupported deterministic expressions use a parameter-free native Stan projection of their required data dependencies. This may compile a BridgeStan artifact, cached in the normal immutable artifact store. Each evaluation binds the current data. Numerical errors propagate on the selected path; they never trigger a retry with another implementation.

Evaluated constraints

Each input's and output's constraint_values holds its constraints evaluated the same way, with Stan's semantics: real<lower=fmax(0.0, (2 * floor_))> with floor_ = 0.3 reports (lower = 0.6,), and a per-coordinate bound reports one value per coordinate (-Inf/Inf where unbounded). A bound that reads a parameter reports nothing. A data-only bound computed through a Stan-only @deffun, including an algebraic root, uses the native projection as a size does. No model likelihood or predictive draws are evaluated for metadata.

See also stan_operation, stan_execute, stan_definition, stan_definition_closure, required_inputs.

source
StanBlocks.stan_definition Function
julia
stan_definition(d::ModelDescriptor, name; signature=nothing) -> ModelDefinition

Look up one included Stan definition by its exact emitted name (a Symbol or string). The lookup fails closed when the name is absent. If valid Stan overloads make the emitted name ambiguous, it also fails closed and lists the available signatures; pass one back via signature= to select exactly.

source
StanBlocks.stan_definition_closure Function
julia
stan_definition_closure(d::ModelDescriptor, selected...) -> Tuple{Vararg{ModelDefinition}}

Select one or more emitted definition names (or ModelDefinition values) and return them with their complete transitive included-definition dependencies. The result preserves d.definitions' authoritative functions-block order. Name selection uses stan_definition, so an absent or overloaded-ambiguous name fails closed rather than returning a non-executable fragment.

source
StanBlocks.stan_operation Function
julia
stan_operation(d::ModelDescriptor, name::Symbol) -> ModelOperation

The operation name of descriptor d, or a loud error naming the operations d actually offers.

Fails closed by design: which operations exist is DERIVED from the model (see stan_descriptor), so asking for one the model does not support is a statement about the model — a prior-predictive model has no :fit, a model with no _gen twin has no :predict — and silently returning nothing would push that discovery into the consumer.

source
StanBlocks.stan_execute Function
julia
stan_execute(d::ModelDescriptor, name::Symbol; kwargs...)

Run operation name of descriptor d. Errors loudly if d does not offer it (see stan_operation).

Per-operation contract

  • :transpile → String. Takes no keyword arguments.

  • :instantiate, :fit → a StanLogDensityProblems.StanProblem implementing the LogDensityProblems interface. Data keyword arguments re-bind inputs before compiling (stan_execute(d, :fit; y=newy)); reserved instantiate keywords (path, nan_on_error, make_args, warn) are forwarded to it. Refuses, naming them, if any required input is still unbound.

  • :predict, :pointwise_loglik → a NamedTuple mapping each of the operation's outputs to its drawn values. Required keyword arguments:

    • draws — one unconstrained parameter vector (Vector{Float64}), or a Matrix whose COLUMNS are such vectors, or a vector of them.

    • seed::Int — seeds BridgeStan's RNG for the generated-quantities draw.

    Optional: problem — a StanProblem from a previous :fit / :instantiate, to skip recompilation. Any other keyword argument is forwarded to the compilation step exactly as for :fit. For a single draw each entry is a Vector{Float64} (length 1 for a scalar output); for several, a Matrix with one column per draw.

source
StanBlocks.stan_interface Function
julia
stan_interface(model) -> OrderedDict{String,Any}

Describe a traced program for a consumer that runs its Stan code outside Julia, through BridgeStan (from Python, for example, with nutpie for sampling). model is a SlicModel, a StanModel or a ModelDescriptor. The result holds only strings, numbers, booleans, nothing, vectors and dictionaries, so JSON.json(stan_interface(m)) is the interface file; it is regenerated with the program and pinned to it by program_id. CmdStan is not a supported runtime; see "Running a program outside Julia" in the authoring guide.

Top level:

  • "format" — "stanblocks-interface/1".

  • "program_id" — the descriptor id, a hash of the emitted Stan source.

  • "name" — the model name.

  • "data" — one entry per data-block variable, in data-block order (below).

  • "parameters" — the parameter variables in the order BridgeStan's param_unc_names / param_names list their coordinates.

  • "outputs" — one entry per parameter, transformed parameter and generated quantity (below).

A "data" entry:

  • "name", "type" (the descriptor's center type: "real", "int", "vector", "matrix", "RaggedVector", "ntup", …) and "size" (each declared size as Stan source text).

  • "supplied" — true for a value the caller provides, false for one computed from another; "computed" then names the rule {"rule": "size", "of": <input>, "component": [<field names>], "axis": <k>}: the size along axis k (1-based) of that input, or of its named component.

  • "encoding" — how the caller's value becomes JSON:

    • "value" — as is; a matrix is a list of rows.

    • "ragged" — a list of groups. The JSON is a Stan tuple: key "1" the groups' values concatenated in order, key "2" their inclusive 1-based ends. "ragged" names the element type ("real" or "int") and the component keys.

    • "tuple" — a record. The JSON is an object keyed by component position, "1", "2", …; "fields" lists the components in that order.

  • "fields" — the components of a tuple-typed input ([] otherwise), each with "key", "name", "type", "size", "encoding" and its own "fields".

  • "observed", "held_out" and "constraints" (each declared bound's value).

An "outputs" entry: "name" (the Stan name; a container's coordinates are name.i.j…, first index fastest), "block", "type", "size" (Stan text), "dims" (resolved for the bound data), "generative" and "source" as for ModelOutput, "segments" (a ragged output's inclusive group ends for the bound data, else nothing), and "segments_rule" — where those ends come from, so a consumer can rebuild them for other data:

  • {"rule": "groups_of", "of": <input>} — the ends of a ragged data input.

  • {"rule": "lengths", "of": <input>} — group g has <input>[g] values, so the ends are their cumulative sums.

  • {"rule": "expression", "cell_size": <Stan text>, "index": <name>} — group index has cell_size values.

  • nothing for a dense output.

A tuple-typed output also lists its components in "fields".

The JSON a program receives is stan_data_json; a consumer that encodes its own values from this interface produces the same file.

source
StanBlocks.stan_data_json Function
julia
stan_data_json(model) -> String

The data model binds, as the Stan JSON data file its program reads — the same bytes instantiate hands BridgeStan. Matrices are written as lists of rows and Stan tuples (a ragged input, a table) as objects keyed by component position. model is a SlicModel, a StanModel or a ModelDescriptor; write it with write(path, stan_data_json(model)) and pass the path to BridgeStan's StanModel. A non-finite real is written as the bare token Infinity, -Infinity or NaN, which Stan's JSON reader takes (and Python's json writes); strict JSON has no such numbers, so read the file back in Julia with JSON.parse(text; allownan=true). stan_interface describes how each entry is encoded.

source

Descriptor types ​

StanBlocks.ModelDescriptor Type
julia
ModelDescriptor

The reflectable, executable declaration of one Stan model — the value returned by stan_descriptor.

Fields

  • id::String — stable identity, derived from the generated Stan source (the same key instantiate caches the compiled artifact under). Two models with byte-identical Stan share an id; changing the model changes it. Independent of the process, of tracing order, and of the gensym'd name.

  • name::Symbol — the model's name. Informational only — @slic begin … end produces a gensym; pass name= to stan_descriptor to set it.

  • docstring::String — the model's leading docstring, if any.

  • model::StanModel — the traced model the descriptor reflects.

  • inputs::Tuple{Vararg{ModelInput}}

  • outputs::Tuple{Vararg{ModelOutput}}

  • definitions::Tuple{Vararg{ModelDefinition}} — included Stan definitions in the exact order used by the functions block emitter.

  • operations::Tuple{Vararg{ModelOperation}}

source
StanBlocks.ModelInput Type
julia
ModelInput

One entry of a descriptor's data block — see stan_descriptor.

Fields

  • name::Symbol — the Stan data variable name.

  • type::Symbol — the declared Stan center type (:real, :int, :vector, :matrix, :simplex, …).

  • size::Tuple — the declared size expressions, outermost first. Entries are emitted expressions: a literal, a Symbol naming another input, or a larger expression. Resolve a symbolic entry against the other inputs' value.

  • constraints::NamedTuple — the lower/upper/offset/multiplier subset actually spelled on the declaration, each as spelled: a literal, or an emitted expression. Read constraint_values for the values. Empty does not mean unconstrained: a natively constrained center (simplex, cholesky_factor_corr, …) carries its support in type.

  • value — the bound Julia value. Always present: a symbol with no value never reaches the data block (an unresolvable one fails at tracing time, not here).

  • inlined::Bool — true for a value the emitter folds into the generated source rather than passing as data (functions, closures, 0-dim type tokens).

  • derived::Bool — true when this input is another input's declared size (y_n for vector[y_n] y), including the size of a tuple input's component (y_mem_n/y_ends_n of a ragged y, a table's shared df_nrow; see fields). Re-binding the container re-derives it, so a consumer must never ask for it separately. Neither an inlined nor a derived input is part of required_inputs, and neither belongs in a generated form.

  • observed::Bool — this variable appears on the left of a ~ (it is data the model conditions on), as opposed to a covariate or a size.

  • held_out::Bool — the cross-validation flag: this variable's likelihood contribution is dropped and it re-draws in generated quantities. Contagion- aware, not a record of what you marked — cv propagates through every expression it reaches, so marking one input via StanBlocks.stan.maybecv can make several inputs report held_out.

  • constraint_values::NamedTuple — constraints evaluated against the bound data, with the same keys; see ModelOutput. A data declaration's bounds read only data, so every entry has a value.

  • fields::NamedTuple — the components of a Stan tuple input, (;) for any other input. Tuple inputs are a ragged vector (type = :RaggedVector, components mem and ends), a table (one component per column, all sized by the shared row count), and NamedTuple or Tuple data. There is one entry per component, in Stan tuple order, keyed by the Julia field name; a positional Tuple's components are keyed Symbol("1"), Symbol("2"), …. Position i is the key "i" of the input's object in the CmdStan JSON data. Each entry is a NamedTuple (; type, size, value, fields): the component's center type, size expressions and bound value as for the input itself, and its own components (a ragged field of NamedTuple data nests one level). The input's own type and size describe only the tuple (size is its array dims, () for a single tuple). A ragged vector exposes its flattened values in mem and cumulative segment ends in ends. An integer ragged vector reports mem.type == :int.

source
StanBlocks.ModelOutput Type
julia
ModelOutput

One quantity the model produces — see stan_descriptor.

Fields

  • name::Symbol — the Stan variable name (matches BridgeStan's param_names prefix; a container appears there as name.1, name.2, …).

  • kind::Symbol — which Stan block declares it: :parameter, :transformed_parameter, or :generated_quantity.

  • type::Symbol, size::Tuple, constraints::NamedTuple — as for ModelInput, except that an output's size entry may also name a transformed-data value (J for J = maximum(subject)), which is not an input. Read dims for the resolved sizes and constraint_values for the evaluated bounds.

  • generative::Symbol — what the quantity MEANS:

    • :posterior — a sampled parameter or a deterministic function of one.

    • :draw — a predictive draw of an observation (the compiler-owned <obs>_gen twin). source names the observation.

    • :pointwise_loglik — the per-element log-likelihood of an observation (the compiler-owned <obs>_likelihood companion). source names it.

    • :derived — any other generated quantity: a prior-only sample, a cv-flipped re-draw of a latent, a model return value.

  • source::Union{Symbol,Nothing} — the observation a :draw / :pointwise_loglik derives from; nothing otherwise.

  • segments::Union{Nothing,Vector{Int}} — group boundaries when this quantity is either the twin of a ragged observation or the emitted flat-memory carrier of a ragged plate result/member; nothing for every dense quantity. The entries are the carrier's own inclusive 1-based end indices, so group g of a flat carrier or :draw occupies segments[g-1]+1 : segments[g] (with segments[0] ≡ 0), while group g of a :pointwise_loglik is element g. Each ragged plate member reports its own layout; members may have different axes, so consumers must not copy segments from a sibling or an input. Publishing the layout here lets consumers restore groups without reaching into compiler-owned names or carrier tuples.

  • dims::Tuple{Vararg{Int}} — the shape of the output's value, resolved against the model's current data: one nonnegative Int per axis (() for a scalar). It is size evaluated entry by entry, except that a constrained square matrix declared by one size fills both of its matrix axes with it: cholesky_factor_corr[K] (likewise cholesky_factor_cov[K], cov_matrix[K], corr_matrix[K]) reports (K, K), and an array of them, cholesky_factor_corr[G, K], reports (G, K, K). A vector[n_levels - 1] with n_levels == 1 reports (0,). For an output that is not a tuple, prod(dims) is the number of entries BridgeStan's param_names lists for it, so an empty output (no name.i entry at all) is distinguishable from a missing one. Those entries run first index fastest, so reshape(values, dims) rebuilds the value from them. A tuple-typed output reports its own container size here; its components' shapes are in fields. A rebound model reports rebound values, as for segments.

  • constraint_values::NamedTuple — constraints evaluated against the model's current data, with the same keys, so a consumer that reproduces Stan's constraining transform never evaluates an emitted expression itself. real<lower=fmax(0.0, (2 * floor_))> with floor_ = 0.3 reports (lower = 0.6,). Evaluation follows the emitted Stan: lower=(k / 2) with the integer k = 7 is 3.5, as in Julia (integer division is k ÷ 2). A per-coordinate bound is an array with one entry per coordinate, -Inf or Inf where a coordinate is unbounded, including the bound arrays the compiler fills in transformed data; a bound that names a data input is that input's value. A bound that reads a parameter or a generated quantity (real<lower=a>) has no value without a draw and holds nothing. A rebound model reports rebound values, as for dims.

  • fields::NamedTuple — the components of a Stan tuple output (a record a @deffun returns, such as (; loc = a, count = n)), (;) for any other output. Keys and order are as for ModelInput's fields. Each entry is a NamedTuple (; type, size, dims, fields): the component's center type, size expressions, resolved shape (as dims is for the output itself) and own components.

source
StanBlocks.ModelDefinition Type
julia
ModelDefinition

One included definition in a model's emitted Stan functions block — see stan_descriptor, stan_definition, and stan_definition_closure.

The descriptor is projected from the traced functions dictionary that the emitter itself prints. It is not reconstructed by parsing generated Stan.

Fields

  • name::Symbol — the exact emitted Stan callable name. This is the stable public lookup key. A Julia binding that starts with _ is emitted with a leading u because Stan identifiers cannot start with an underscore.

  • binding::Union{Symbol,Nothing} — the author-side Julia binding when there is one. It can differ from name when StanBlocks specialises or renames a helper; compiler-lifted closures have no author binding and report nothing.

  • kind::Symbol — :function or :closure.

  • signature::String — the exact emitted return/name/argument signature, normalized onto one line. It distinguishes valid Stan overloads that share one name.

  • source::String — the complete emitted definition, without the surrounding functions {} block.

  • span::UnitRange{Int} — the string-index range of source in stan_code(descriptor.model), so SubString(code, first(span), last(span)) == source.

  • dependencies::Tuple{Vararg{Symbol}} — direct included-definition names in first-use order.

  • dependency_signatures::Tuple{Vararg{String}} — exact dependency links, aligned with dependencies; these remain unambiguous when Stan overloads share a name.

source
StanBlocks.ModelOperation Type
julia
ModelOperation

One executable operation DERIVED from a model declaration — never a consumer-maintained entry. See stan_descriptor for the derivation rules and stan_execute to run one.

Fields

  • name::Symbol — :transpile, :instantiate, :fit, :predict, or :pointwise_loglik.

  • title::String — a human label a UI can render without a lookup table.

  • inputs::Tuple{Vararg{Symbol}} — descriptor input names this operation consumes (empty for :transpile, which needs no data).

  • outputs::Tuple{Vararg{Symbol}} — descriptor output names it produces.

  • run — the executor, called as run(descriptor; kwargs...).

source

Diagnostics ​

StanBlocks.StanBlocksError Type
julia
StanBlocksError <: Exception

Wraps errors that occur during transpilation, compilation, or evaluation of Stan models.

Fields

  • phase::Symbol: the pipeline stage where the error occurred (:transpile, :compile, or :evaluate)

  • context::String: a description of what was being processed (e.g. "model: eight_schools")

  • cause::Any: the underlying error, typically an (exception, backtrace) tuple

source
StanBlocks.StanBlocksDiagnostic Type
julia
StanBlocksDiagnostic

Machine-readable location and classification for a SLIC failure.

source_part identifies the caller-supplied source/editor part. line and column are one-based when known and nothing when the compiler has no span at that granularity. code is a stable, coarse failure class; message is a concise user-facing description of the immediate cause.

source
StanBlocks.diagnostic Function
julia
diagnostic(error; source_part=nothing, line_offset=0)

Return a StanBlocksDiagnostic for a StanBlocksError or Julia Meta.ParseError, and nothing for unsupported exceptions. source_part can label a parser error (or supply a fallback label); line_offset maps a synthetic parser wrapper back to the caller's source, e.g. -1 for a leading begin line.

Stable SLIC codes are :slic_parse_error, :slic_trace_error, and :slic_lowering_error.

source