
Live Specification & Deterministic Codegen Preview Shiny Module (Server)
Source:R/mod-preview.R
mod_spec_preview_server.RdReactively renders mathematical summaries, YAML/JSON IR, AST-verified R code,
and Quarto reports, and enforces hard replication, sample-size, and wall-time
budgets on the interactive quick preview runner so large simulation specs
(e.g., n_reps = 50000) never freeze the Shiny session.
Usage
mod_spec_preview_server(
id,
spec_rv,
last_diff_rv = NULL,
max_preview_reps = 10L,
max_preview_n = 2000L,
max_preview_seconds = 5
)Arguments
- id
Module namespace ID.
- spec_rv
A
shiny::reactiveValholding the current validatedspec_ir.- last_diff_rv
Optional
shiny::reactiveValholding the latestspec_diff.- max_preview_reps
Positive integer hard cap on preview replications (defaults to
10L).- max_preview_n
Positive integer soft cap on total observations simulated per preview replication (defaults to
2000L).- max_preview_seconds
Positive numeric wall-clock budget in seconds for the preview loop (defaults to
5).
Value
A list of reactive expressions: math, yaml, json, r_script,
quarto_report, preview_results, and preview_warnings.
Examples
spec_rv <- shiny::reactiveVal(new_spec_ir(simulation = list(n_reps = 5L, seed = 1L)))
shiny::testServer(
mod_spec_preview_server,
args = list(spec_rv = spec_rv),
{
grepl("run_simulation", session$returned$r_script(), fixed = TRUE)
}
)