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
stan_model(slic::SlicModel) -> StanModelTrace 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.
StanBlocks.stan_code Function
stan_code(model) -> StringReturn 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.
StanBlocks.stanc_check Function
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.
StanBlocks.stan_instantiate Function
instantiate(model; nan_on_error=true, make_args=["STAN_THREADS=true"], warn=false, path=…) -> StanProblem
stan_instantiate(model; ...) -> StanProblemCompile 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 underSTANBLOCKS_BUILD_DIR, ortempdir()/stanblockswhen unset. It is keyed by source, orderedmake_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 returnNaNinstead of throwing on evaluation failures.make_args::Vector{String} = ["STAN_THREADS=true"]— extra arguments forwarded to Stan'smake. An argument whose value names an existing file or directory (STAN=,MATH=,STANC=,USER_HEADER=, …; relative to the BridgeStan home, wheremakeruns) 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 thePATHandLD_LIBRARY_PATHsearch lists andBRIDGESTAN, which selects the home itself. The files aUSER_HEADERreaches through quoted#includelines count too, as forstan_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.
StanBlocks.stan_library Function
stan_library(source; make_args=["STAN_THREADS=true"], stanc_args=String[], dependencies=String[]) -> StringCompile 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'smake, in order. The words of aSTANCFLAGS=entry are passed tostancahead ofstanc_args.stanc_args— arguments forstanc, such as"--allow-undefined"for a program whose declared functions a C++ header implements. All of them reachstanc: StanBlocks hands BridgeStan one combinedSTANCFLAGSassignment, whereBridgeStan.compile_modelgiven several would keep only the last.dependencies— further files the build reads, such as a C++ header found through an-Ipath 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.
Inspection and operations
StanBlocks.stan_descriptor Function
stan_descriptor(model; name=nothing) -> ModelDescriptorReflect 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.
| operation | offered when |
|---|---|
:transpile | always |
:instantiate | always (fails loudly at run time if a required input is unbound) |
:fit | the 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.
StanBlocks.stan_definition Function
stan_definition(d::ModelDescriptor, name; signature=nothing) -> ModelDefinitionLook 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.
StanBlocks.stan_definition_closure Function
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.
StanBlocks.stan_operation Function
stan_operation(d::ModelDescriptor, name::Symbol) -> ModelOperationThe 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.
StanBlocks.stan_execute Function
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→ aStanLogDensityProblems.StanProblemimplementing theLogDensityProblemsinterface. Data keyword arguments re-bind inputs before compiling (stan_execute(d, :fit; y=newy)); reservedinstantiatekeywords (path,nan_on_error,make_args,warn) are forwarded to it. Refuses, naming them, if any required input is still unbound.:predict,:pointwise_loglik→ aNamedTuplemapping each of the operation'soutputsto its drawn values. Required keyword arguments:draws— one unconstrained parameter vector (Vector{Float64}), or aMatrixwhose COLUMNS are such vectors, or a vector of them.seed::Int— seeds BridgeStan's RNG for the generated-quantities draw.
Optional:
problem— aStanProblemfrom 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 aVector{Float64}(length 1 for a scalar output); for several, aMatrixwith one column per draw.
StanBlocks.stan_interface Function
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 descriptorid, 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'sparam_unc_names/param_nameslist 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"—truefor a value the caller provides,falsefor one computed from another;"computed"then names the rule{"rule": "size", "of": <input>, "component": [<field names>], "axis": <k>}: the size along axisk(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>}— groupghas<input>[g]values, so the ends are their cumulative sums.{"rule": "expression", "cell_size": <Stan text>, "index": <name>}— groupindexhascell_sizevalues.nothingfor 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.
StanBlocks.stan_data_json Function
stan_data_json(model) -> StringThe 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.
Descriptor types
StanBlocks.ModelDescriptor Type
ModelDescriptorThe 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 keyinstantiatecaches the compiled artifact under). Two models with byte-identical Stan share anid; changing the model changes it. Independent of the process, of tracing order, and of the gensym'dname.name::Symbol— the model's name. Informational only —@slic begin … endproduces a gensym; passname=tostan_descriptorto 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 thefunctionsblock emitter.operations::Tuple{Vararg{ModelOperation}}
StanBlocks.ModelInput Type
ModelInputOne 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, aSymbolnaming another input, or a larger expression. Resolve a symbolic entry against the other inputs'value.constraints::NamedTuple— thelower/upper/offset/multipliersubset actually spelled on the declaration, each as spelled: a literal, or an emitted expression. Readconstraint_valuesfor the values. Empty does not mean unconstrained: a natively constrained center (simplex,cholesky_factor_corr, …) carries its support intype.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—truefor a value the emitter folds into the generated source rather than passing as data (functions, closures, 0-dim type tokens).derived::Bool—truewhen this input is another input's declared size (y_nforvector[y_n] y), including the size of a tuple input's component (y_mem_n/y_ends_nof a raggedy, a table's shareddf_nrow; seefields). Re-binding the container re-derives it, so a consumer must never ask for it separately. Neither aninlinednor aderivedinput is part ofrequired_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 viaStanBlocks.stan.maybecvcan make several inputs reportheld_out.constraint_values::NamedTuple—constraintsevaluated against the bound data, with the same keys; seeModelOutput. 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, componentsmemandends), a table (one component per column, all sized by the shared row count), andNamedTupleorTupledata. There is one entry per component, in Stan tuple order, keyed by the Julia field name; a positionalTuple's components are keyedSymbol("1"),Symbol("2"), …. Positioniis the key"i"of the input's object in the CmdStan JSON data. Each entry is aNamedTuple(; 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 ofNamedTupledata nests one level). The input's owntypeandsizedescribe only the tuple (sizeis its array dims,()for a single tuple). A ragged vector exposes its flattened values inmemand cumulative segment ends inends. An integer ragged vector reportsmem.type == :int.
StanBlocks.ModelOutput Type
ModelOutputOne quantity the model produces — see stan_descriptor.
Fields
name::Symbol— the Stan variable name (matches BridgeStan'sparam_namesprefix; a container appears there asname.1,name.2, …).kind::Symbol— which Stan block declares it::parameter,:transformed_parameter, or:generated_quantity.type::Symbol,size::Tuple,constraints::NamedTuple— as forModelInput, except that an output's size entry may also name a transformed-data value (JforJ = maximum(subject)), which is not an input. Readdimsfor the resolved sizes andconstraint_valuesfor 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>_gentwin).sourcenames the observation.:pointwise_loglik— the per-element log-likelihood of an observation (the compiler-owned<obs>_likelihoodcompanion).sourcenames it.:derived— any other generated quantity: a prior-only sample, a cv-flipped re-draw of a latent, a modelreturnvalue.
source::Union{Symbol,Nothing}— the observation a:draw/:pointwise_loglikderives from;nothingotherwise.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;nothingfor every dense quantity. The entries are the carrier's own inclusive 1-based end indices, so groupgof a flat carrier or:drawoccupiessegments[g-1]+1 : segments[g](withsegments[0] ≡ 0), while groupgof a:pointwise_loglikis elementg. 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 nonnegativeIntper axis (()for a scalar). It issizeevaluated 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](likewisecholesky_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). Avector[n_levels - 1]withn_levels == 1reports(0,). For an output that is not a tuple,prod(dims)is the number of entries BridgeStan'sparam_nameslists for it, so an empty output (noname.ientry at all) is distinguishable from a missing one. Those entries run first index fastest, soreshape(values, dims)rebuilds the value from them. A tuple-typed output reports its own container size here; its components' shapes are infields. A rebound model reports rebound values, as forsegments.constraint_values::NamedTuple—constraintsevaluated 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_))>withfloor_ = 0.3reports(lower = 0.6,). Evaluation follows the emitted Stan:lower=(k / 2)with the integerk = 7is3.5, as in Julia (integer division isk ÷ 2). A per-coordinate bound is an array with one entry per coordinate,-InforInfwhere a coordinate is unbounded, including the bound arrays the compiler fills intransformed 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 holdsnothing. A rebound model reports rebound values, as fordims.fields::NamedTuple— the components of a Stan tuple output (a record a@deffunreturns, such as(; loc = a, count = n)),(;)for any other output. Keys and order are as forModelInput'sfields. Each entry is aNamedTuple(; type, size, dims, fields): the component's center type, size expressions, resolved shape (asdimsis for the output itself) and own components.
StanBlocks.ModelDefinition Type
ModelDefinitionOne 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 leadingubecause Stan identifiers cannot start with an underscore.binding::Union{Symbol,Nothing}— the author-side Julia binding when there is one. It can differ fromnamewhen StanBlocks specialises or renames a helper; compiler-lifted closures have no author binding and reportnothing.kind::Symbol—:functionor:closure.signature::String— the exact emitted return/name/argument signature, normalized onto one line. It distinguishes valid Stan overloads that share onename.source::String— the complete emitted definition, without the surroundingfunctions {}block.span::UnitRange{Int}— the string-index range ofsourceinstan_code(descriptor.model), soSubString(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 withdependencies; these remain unambiguous when Stan overloads share a name.
StanBlocks.ModelOperation Type
ModelOperationOne 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 asrun(descriptor; kwargs...).
Diagnostics
StanBlocks.StanBlocksError Type
StanBlocksError <: ExceptionWraps 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
StanBlocks.StanBlocksDiagnostic Type
StanBlocksDiagnosticMachine-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.
StanBlocks.diagnostic Function
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.