Skip to contents

Compile any R project, Quarto manuscript, targets pipeline, 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.

Why rcapsule?

  • renv stops 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 .Rprofile traps.
  • Multi-target & cross-architecture portability. Compile pinned, Posit PPM binary-accelerated multi-stage Dockerfiles (with --platform=linux/amd64 / linux/arm64 support), production multi-service docker-compose.yml stacks (Shiny + async worker + reverse proxy), and HPC-ready Apptainer .def recipes 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-signed capsule.json, verify in an isolated sandbox (with ambient secret scrubbing) or Docker container, compare runs across machines with diff_capsules(), and export zip-slip-safe journal supplements via export_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

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

License

MIT © 2026 Marcus Harris