Imported from ACCIDDA/hestia (
AGENTS.md). Install upstream withnpx skills add ACCIDDA/hestia. Copyright stays with the author.
Agent Guidelines for hestia
This document provides concise instructions and rules for AI coding assistants working in the hestia repository. For full developer documentation and CI architecture, see CONTRIBUTING.md.
1. Core Architecture & Invariants
- Package Purpose:
hestiafits Bayesian compartmental infection models (such as SIR and multi-compartment hidden Markov variants) from individual-level outcome data. Models are composed from infection-process and observation-process components and fit using Stan viarstanandflexstanr. - Stan Backend (
flexstanr/rstan):- Backend abstraction is provided by imported package
flexstanr (>= 0.2.0). - Precompiled Stan models live in
inst/stan/(hmm.stan,hmm_cov.stan). R/stanmodels.Randsrc/stanExports_*are generated byrstantoolsand must not be edited by hand.
- Backend abstraction is provided by imported package
- Tracked vs. Untracked Artifacts:
R/globals.Randman/*.Rdare generated byroxygen2and are untracked in git.NAMESPACEis tracked in git.src/RcppExports.cppis generated byRcpp::compileAttributes()and is tracked in git. Although generated, standard remote / GitHub installers (devtools::install_github(),pak::pak()) only download git-tracked files and do not run attribute compilers prior toR CMD INSTALL;src/RcppExports.cppis required to register DLL entry points. Synchronization with Stan models is verified automatically byjust check-rcpp(injust lint) and unit testtests/testthat/test-rcpp_exports.R.
- Model Workflow:
- Infection models are specified with
make_infection_model(transmit(...), progress(...)) - Observation models are specified with
make_observation_model(...) - Model fitting is executed via
run_model(inf_model, obs_model, data, ...)
- Infection models are specified with
2. Coding, Error Handling & Documentation Standards
- Formatting & Linting:
- Format code with
just format(air). - Verify lint compliance with
just lint(airandlintr). - Maximum line length is 100 characters.
- Format code with
- Roxygen Documentation Standards:
- Explicit
@titleand@description: Roxygen blocks must use explicit@titleand@descriptiontags rather than relying on automatic inference. @autoglobal: Functions containing non-standard evaluation expressions should be annotated with@autoglobalsoroxyglobalsgenerates appropriate symbol declarations inR/globals.R.- Internal Helper Functions: Unexported internal functions should be marked with
@keywords internaland@noRdto keep code documented in source without generating unused.Rdfiles. - Parameter & Return Documentation: Explicitly state input types/classes using standard roxygen conventions, and describe return structures clearly.
- Explicit
- Examples:
- For computationally heavy functions (e.g.
run_model()), combine@examplesIf interactive()with\donttest{ ... }so CRAN--as-cranchecks and site builds remain fast.
- For computationally heavy functions (e.g.
- Test Suite Conventions:
- Unit tests live in
tests/testthat/. - Reusable test helpers and model constructors live in
tests/testthat/helper-fixtures.R. - Use
expect_shape(df, expected_nrow = ..., expected_ncol = ...)for verifying tabular shapes.
- Unit tests live in
3. Common Development Commands & CI Architecture
justfileas Single Source of Truth:- The
justfileserves as the single authoritative reference for all build, validation, doc, and test tasks. - CI workflows (
.github/workflows/*.yaml) and composite actions (.github/actions/setup-hestia/action.yaml) invokejust <recipe>.
- The
Use just recipes for development workflows:
just format # Format R code (air)
just lint # Lint R code (air + lintr)
just docs # Regenerate man/*.Rd, R/globals.R
just install # Install package into R library
just test # Run devtools test suite
just test-fast # Run test suite stopping on first failure
just coverage # Check test coverage via covr
just spell # Run spelling checks
just build # Build package source tarball (hestia_*.tar.gz)
just check-cran # Run R CMD check --as-cran on built tarball
just site # Build pkgdown documentation site
just site-preview # Preview pkgdown site locally on port 8000