Reproducible Artifact Store with Sidecars and Version History

Stores 'R' objects with sidecar metadata, including hashes, provenance, and primary keys. Keeps an immutable version history and removes older versions according to retention policies. Tracks changes and dependencies so that analytical outputs remain traceable and reproducible across sessions.


stamp

Codecov testcoverage

Lightweight versioned artifact store for R with sidecar metadata and pruning policies.

Installation

After the first CRAN release, install stamp with:

install.packages("stamp")

You can install the development version of stamp from GitHub with:

# install.packages("devtools")
devtools::install_github("randrescastaneda/stamp")

Quickstart

library(stamp)
root <- tempfile("stamp-readme-")
st_init(root)
#> ✔ stamp initialized
#>   alias: default
#>   root:
#>   /var/folders/y8/8yc4jpc167gf18tx3w3b858m0000gp/T/RtmpwTgfXN/stamp-readme-9754793f762a
#>   state:
#>   /var/folders/y8/8yc4jpc167gf18tx3w3b858m0000gp/T/RtmpwTgfXN/stamp-readme-9754793f762a/.stamp

p <- "demo.qs2"
x <- data.frame(id = 1:3, val = letters[1:3])

# Save with primary key (code parameter tracks provenance - see vignettes)
st_save(x, p, pk = "id")
#> ✔ Saved [qs2] →
#>   '/var/folders/y8/8yc4jpc167gf18tx3w3b858m0000gp/T/RtmpwTgfXN/stamp-readme-9754793f762a/demo.qs2'
#>   @ version 2b45dd07357b8f27
y <- st_load(p)
#> ✔ Loaded [qs2] ←
#>   '/var/folders/y8/8yc4jpc167gf18tx3w3b858m0000gp/T/RtmpwTgfXN/stamp-readme-9754793f762a/demo.qs2'
vrs <- st_versions(p)
head(vrs)
#>          version_id      artifact_id     content_hash code_hash size_bytes
#>              <char>           <char>           <char>    <char>      <num>
#> 1: 2b45dd07357b8f27 116d73b1d46ede57 af870b362628c1e0      <NA>        297
#>                     created_at sidecar_format
#>                         <char>         <char>
#> 1: 2026-10-26T21:47:16.455698Z           json

# Retention
st_opts(retain_versions = 2)
#> ✔ stamp options updated
#>   retain_versions = "2"
st_save(transform(x, val = toupper(val)), p)
#> ✔ Retention policy matched zero versions; nothing to prune.
#> ✔ Saved [qs2] →
#>   '/var/folders/y8/8yc4jpc167gf18tx3w3b858m0000gp/T/RtmpwTgfXN/stamp-readme-9754793f762a/demo.qs2'
#>   @ version 89a99c12e281212c
vrs <- st_versions(p)
head(vrs)
#>          version_id      artifact_id     content_hash code_hash size_bytes
#>              <char>           <char>           <char>    <char>      <num>
#> 1: 89a99c12e281212c 116d73b1d46ede57 e502c206ef276962      <NA>        265
#> 2: 2b45dd07357b8f27 116d73b1d46ede57 af870b362628c1e0      <NA>        297
#>                     created_at sidecar_format
#>                         <char>         <char>
#> 1: 2026-10-26T21:47:16.528095Z           json
#> 2: 2026-10-26T21:47:16.455698Z           json

Managing Multiple Stamp Folders with Aliases

See the vignette “Using Aliases with stamp” for a comprehensive guide:

File Formats

stamp supports multiple serialization formats. The two binary formats have distinct implementations:

Extension Format Package Required Notes
.qs2 qs2 {qs2} Binary format (recommended for new projects)
.rds rds (base R) R serialized format
.csv csv {data.table} Comma-separated values
.fst fst {fst} Fast columnar format
.json json {jsonlite} JSON format
.parquet parquet {nanoparquet} Columnar format

Important: .qs2 requires {qs2}. If you attempt to save or load a .qs2 file without {qs2} installed, stamp aborts with a clear error message.

Unrecognized extensions fall back to the default_format option ("qs2") rather than raising an error, so pass format = explicitly whenever the extension is not one of those listed above.

Installing Format Packages

# For qs2 format support
install.packages("qs2")

# For fst format support
install.packages("fst")

Format Selection

stamp infers format from file extension by default:

# Uses qs2 format (requires {qs2})
st_save(data, "output.qs2")

# Uses RDS (base R, always available)
st_save(data, "output.rds")

You can also specify format explicitly:

st_save(data, "output", format = "qs2")

Core Functions

The functions below are organized by workflow. New users should start with Initialization, Save & Load, and Versioning sections. Advanced features like lineage tracking and aliases are covered in the vignettes.

Initialization & Configuration

  • st_init(root) - Initialize stamp in a directory, creating the .stamp/ state folder
  • st_opts() - Get or set package options (versioning mode, retention policies, metadata format)
  • st_opts_get(key = NULL) - Read a single option, or all of them when key is NULL
  • st_opts_reset() - Reset all options to defaults

Save & Load

  • st_save(x, file, ...) - Save an artifact with automatic versioning, metadata, and lineage tracking
    • Optional: pk (primary key), parents (lineage), code (provenance), domain (category), alias (target directory)
  • st_load(file, ...) - Load the current artifact
    • Optional: alias (source directory). Use st_opts(verify_on_load = TRUE) for integrity warnings; there is no verify argument.
  • st_load_version(path, version_id) - Load a specific historical version by ID

An experimental, disabled-by-default st_opts(reference_copy_on_save = TRUE) pilot protects only supported root ordinary-environment graphs in native RDS st_save() calls by copying once. Ordinary values keep their existing path. It is not a global hashing policy: direct st_hash_obj() and comparison APIs remain unchanged. Classed/R6 environments, active/lazy bindings, special roots, opaque resources and unsupported graph values are outside the pilot and rejected when it is enabled. Recognized special parents stay shared, uninspected boundaries; ordinary parent environments are inspected and copied. See ?st_save for the accepted values and graph limits. Do not enable it broadly as generic reference-object support.

Formats

  • st_formats() - List the registered format handlers (csv, fst, json, parquet, qs2, rds)
  • st_register_format(name, read, write, extensions = NULL) - Register or override a format handler, optionally mapping file extensions to it

Versioning & History

  • st_versions(path) - List all versions of an artifact with metadata (timestamp, size, hashes)
  • st_latest(path) - Get the version ID of the most recent version
  • st_changed(path, x = NULL) - Check if an object differs from the saved version
  • st_changed_reason(path, x = NULL) - Explain why content/code changed
  • st_should_save(path, x = NULL) - Determine whether saving would create a new version
  • st_restore(file, version = "oldest", ...) - Restore a retained snapshot. Use 0 for latest, -1 for previous, or -n for n retained versions back. Positive positions are deprecated; the default remains "oldest".

For st_changed(), st_changed_reason() and st_should_save(), omit x to leave object content unchecked. Explicit x = NULL compares with a NULL value. Use RDS or QS2 to save and restore NULL as an R object; it is not a deletion.

Native RDS/QS2 saves also preserve original data.table keys in per-version sidecars. Unkeyed inputs remain unkeyed; PK declarations do not create keys. Key-only changes can create metadata versions without changing the data hash. Loading never sorts rows to invent or repair a key, and legacy snapshots without descriptors cannot recover keys that were not recorded.

Lineage & Dependencies

  • st_lineage(path, depth = 1) - Show parent artifacts (inputs) for a given artifact
  • st_children(path, depth = 1) - Show child artifacts (outputs) that depend on this artifact
  • st_is_stale(path) - Check if an artifact needs rebuilding because parents changed

Catalog Queries

  • st_catalog_query(alias = NULL) - Return a data.table with the latest version metadata for every artifact in a catalog — one row per artifact (path, version_id, content_hash, code_hash, size_bytes, created_at). Useful for downstream consumers that need a snapshot of all tracked artifacts without iterating over individual paths.

Metadata & Inspection

  • st_info(path) - Get comprehensive artifact information (sidecar, catalog, snapshot location, parents)
  • st_read_sidecar(path) - Read sidecar metadata (hashes, timestamps, primary keys, domain, parents)
  • st_hash_obj(x) - Compute stable hash for any R object

Primary Keys

  • st_add_pk(path, keys) - Add or update primary key definition for an artifact
  • st_get_pk(x_or_meta) - Retrieve primary key columns from metadata
  • st_inspect_pk(path) - Inspect recorded primary-key metadata; this does not scan the payload for uniqueness
  • st_pk(x = NULL, keys, ...) - Normalize a primary-key specification, optionally validating it against x
  • st_with_pk(x, keys) - Attach primary-key metadata to a data.frame in memory, without saving

Pruning Data

  • st_prune_versions(path, policy) - Remove old versions based on retention policy

Aliases (Multi-Directory Support)

  • st_alias_list() - List all registered aliases
  • st_alias_get(alias = NULL) - Get configuration for an alias
  • st_switch(alias) - Switch the session’s default alias

Builders & Rebuilds ⚠️ Experimental

Note: The builder system is under active development. Safe for prototyping, but consider pinning your stamp version in production code until the API stabilizes (expected in v1.0).

  • st_register_builder(path, fun, name = NULL) - Register a function to rebuild an artifact from its parents
  • st_clear_builders(path = NULL) - Clear registered builders
  • st_builders() - List the currently registered builders
  • st_plan_rebuild(targets, ...) - Compute rebuild plan (which targets are stale and why)
  • st_rebuild(plan) - Execute a rebuild plan, calling builders and saving results

Filtering Helpers ⚠️ Experimental

Note: Advanced filtering utilities are under development.

  • st_filter(df, filters = list(), strict = TRUE) - Apply named list filters to data frames

Learn More

For detailed guides and workflows, see the package vignettes:

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("stamp")

0.1.1 by R.Andres Castaneda, 5 hours ago


https://randrescastaneda.github.io/stamp/, https://github.com/randrescastaneda/stamp


Report a bug at https://github.com/randrescastaneda/stamp/issues


Browse source code at https://github.com/cran/stamp


Authors: R.Andres Castaneda [aut, cre, cph] (ORCID: , Diana C. Garcia Rojas [aut, cph] (ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports cli, fs, rlang, secretbase, jsonlite, data.table, utils, nanoparquet, qs2

Suggests fst, testthat, knitr, rmarkdown, filelock, collapse, withr, pkgload, covr, callr


See at CRAN