stan_model_contract
Extract a structured contract from simple Stan programs so score-model workflows can identify data, constrained parameters, transforms, model terms, and generated quantities.
Files1
View on GitHubSKILL.mdbasicagent-skill/skill_library/paperbench/bam/skill/bridgestan_score_models/stan_model_contract/SKILL.md
GitHubStan Model Contract
Use this skill when a recovery or algorithm needs a lightweight, language-neutral contract for a small Stan model. Do not use it as a general Stan compiler or full parser.
Inputs
- Stan source text or a path to a
.stanfile. - Optional observed data dictionary for downstream validation.
Outputs
- JSON with
data,parameters,transformed_parameters,model_terms, andgenerated_quantities. - Diagnostics for unsupported or missing sections.
Workflow
- Read the Stan source.
- Call
scripts/stan_contract.py --stan <path> --output <json>. - Inspect the output contract before passing it to transform or score-evaluation modules.
- Treat unsupported syntax as a blocker for this reduced parser, not as evidence about real BridgeStan.
Validation
Run python tests/test_stan_contract.py from this skill directory.
Limitations
The parser intentionally supports the Bernoulli-style recovery subset: scalar bounded real parameters, integer data arrays, simple transformed-parameter assignments, distribution statements, and generated-quantity assignments.