Compile any R project, Quarto manuscript,
targetspipeline, or Shiny app into lean Docker/Apptainer containers with cryptographic reproducibility verification.
rcapsule bridges the reproducibility gap between R package lockfiles (renv.lock) and the underlying operating system, native libraries, compiled scientific toolchains, cross-architecture builds, and output verification required for durable open science and production deployment.
- Documentation website: https://marcusharrisphd.com/rcapsule/
- Source repository: https://github.com/MarcusHarrisUConn/rcapsule
Why rcapsule?
-
renvstops at the R library layer. Projects still break across machines due to mismatched OS system libraries (libgdal-dev,libxml2-dev,libharfbuzz-dev), C++ compilers,CmdStan,TMB/RTMB,JAGS,Rust,Python/reticulate,Quarto,LaTeX/TinyTeX, or hidden.Rprofiletraps. -
Multi-target & cross-architecture portability. Compile pinned, Posit PPM binary-accelerated multi-stage
Dockerfiles (with--platform=linux/amd64/linux/arm64support), production multi-servicedocker-compose.ymlstacks (Shiny + async worker + reverse proxy), and HPC-ready Apptainer.defrecipes from a single project scan. -
Cryptographic proof & peer-review bundles. Hash inputs, scripts, container specs, seeds, environment digests, and outputs into a tamper-evident, optionally
HMAC-SHA256-signedcapsule.json, verify in an isolated sandbox (with ambient secret scrubbing) or Docker container, compare runs across machines withdiff_capsules(), and export zip-slip-safe journal supplements viaexport_capsule_bundle().
Core Capabilities
| Pillar | Key Functions | What It Does |
|---|---|---|
| 1. Project & Toolchain Scanner |
scan_project(), sysreqs_db(), resolve_sysreqs()
|
Parses R scripts (library, pacman::p_load, xfun::pkg_attach, box::use, ::), Quarto/Rmd chunks, DESCRIPTION, renv.lock (including non-CRAN remotes), _targets.R, here::here(), .Rprofile hazards, and host architecture to resolve OS apt libraries and toolchains (C++, CmdStan, TMB/RTMB, JAGS, Rust, Java, Python, Quarto, LaTeX). |
| 2. Multi-Target Container Compiler, HPC Handoff & Linter |
compile_dockerfile(), compile_compose(), compile_apptainer(), as_apptainer_spec(), lint_container_spec()
|
Emits pinned, layer-cached multi-stage Dockerfiles (platform, Posit PPM binaries), hardened Shiny + worker + proxy Compose stacks, HPC Apptainer .def recipes, and plain-list Apptainer descriptors for HPC orchestrators; statically audits specs for :latest tags, curl\|sh, root execution, network_mode: host, docker.sock mounts, and baked secrets. |
| 3. Cryptographic Provenance, CycloneDX 1.5 SBOM & Diffing |
create_capsule_manifest(), sign_manifest(), verify_manifest_integrity(), diff_capsules(), export_sbom(), validate_sbom()
|
Generates canonical UTF-8 capsule.json (schema v1.0.0) with Git state, environment digest, RNG kind/seed, SHA-256 hashes, and constant-time HMAC-SHA256 verification; exports/validates CycloneDX 1.5 SBOMs (pkg:cran, pkg:github, pkg:bioconductor, pkg:deb, pkg:pypi, toolchains); diffs runs across machines (Laptop vs. HPC). |
| 4. Isolated Auditor, Diagnostics, Certificates & Bundler |
verify_capsule(), verify_with_script(), compare_artifacts(), diagnose_reproducibility(), render_certificate(), export_capsule_bundle(), build_capsule()
|
Re-runs pipelines and external .R audit scripts in an isolated local sandbox (scrubbing ambient host credentials and detecting extra artifacts) or Docker container, compares CSV/TSV/JSON/RDS outputs with exact and atol/rtol comparators, classifies drift root causes with ranked remediations, renders CSP-hardened HTML5/Markdown certificates, and packages journal-ready ZIP supplements. |
Installation
# Install development version from GitHub
# remotes::install_github("MarcusHarrisUConn/rcapsule")Quick Start
library(rcapsule)
# 1. Scan, compile (pinned linux/amd64 + Posit PPM binaries), lint, sign, and verify
bundle <- build_capsule(
path = "path/to/project",
targets = c("dockerfile", "compose", "apptainer"),
inputs = "data/raw.csv",
outputs = c("results/summary.csv", "results/metrics.json"),
seed = 2026L,
tolerances = list(atol = 1e-4, rtol = 1e-4),
key = Sys.getenv("CAPSULE_SIGNING_KEY"),
platform = "linux/amd64",
use_ppm = TRUE,
verify = TRUE,
certificate = TRUE
)
# 2. Compare manifests across runs or machines
diff_capsules("author_capsule.json", "reviewer_capsule.json")
# 3. Export & validate a CycloneDX 1.5 SBOM
sbom <- export_sbom("path/to/project", manifest = bundle$manifest, output = "sbom.cdx.json")
validate_sbom(sbom)
# 4. Diagnose any verification failure or cross-machine drift
diagnose_reproducibility(bundle$verification)
# 5. Export a zip-slip-safe journal peer-review supplement bundle
export_capsule_bundle(
path = "path/to/project",
output = "journal_supplement.zip",
manifest = bundle$manifest,
verification = bundle$verification,
platform = "linux/amd64"
)Vignettes & Guides
-
vignette("getting-started", package = "rcapsule"): End-to-end reproducibility capsules, HMAC signing, tamper detection, and tolerance-aware verification. -
vignette("multi-target-containers", package = "rcapsule"): Compiling Quarto manuscripts, production Shiny + async worker Compose stacks, and Bayesian HPC Apptainer recipes. -
vignette("journal-submission-workflow", package = "rcapsule"): Signed peer-review capsules, cross-machinediff_capsules(), andexport_capsule_bundle(). -
vignette("troubleshooting-reproducibility", package = "rcapsule"): Monte Carloatol/rtoltolerances,.Rprofiletraps,targetspipelines, and Apple Silicon vs.amd64builds. -
vignette("sbom-and-supply-chain", package = "rcapsule"): CycloneDX 1.5 SBOMs, automateddiagnose_reproducibility(), HPCas_apptainer_spec(), and isolatedverify_with_script()audits. - See ARCHITECTURE.md and SECURITY.md for architecture and red-team security details.
Quantitative Research Suite
rcapsule is part of an integrated six-package open-source R suite for end-to-end quantitative, statistical, and computational research workflows:
| Package | Focus |
|---|---|
specshiny |
Declarative YAML-to-Shiny application compiler and verifiable bundle engine |
airgapllm |
Air-gapped local LLM workflows with HIPAA/IRB PII redaction and audit trails |
llmmetric |
Validated LLM measurement, inter-rater reliability, and PPI inference |
statci |
Statistical verification, calibration, and manuscript auditing |
slurmpilot |
Resilient Slurm HPC job orchestration, array recovery, and profiling |
rcapsule |
Reproducibility capsules, multi-target containerization, CycloneDX SBOMs, and verification |
