Aliases let you work with multiple, independent stamp folders in a single R session. An alias is a selector for which folder configuration to use; it does not change any on-disk paths. All artifact paths remain the same regardless of alias; only the catalog, versions, and options used are selected by alias.
Storage model (v0.0.9+): Artifacts are stored as
<root>/<path>/<filename>/<filename>
with version history in
<root>/<path>/<filename>/versions/. The
.stamp/ directory within each aliased root contains only
state (catalog, locks, temp files).
Key properties:
st_init()."default" exists and can be re-based
with st_switch().Initialize one or more stamp folders and give each an alias:
root_a <- fs::path(tempdir(), "projA")
root_b <- fs::path(tempdir(), "projB")
# Note: st_init() creates the folder if missing
st_init(root_a, alias = "A")
#> ✔ stamp initialized
#> alias: A
#> root: /tmp/Rtmp16hUjf/projA
#> state: /tmp/Rtmp16hUjf/projA/.stamp
st_init(root_b, alias = "B")
#> ✔ stamp initialized
#> alias: B
#> root: /tmp/Rtmp16hUjf/projB
#> state: /tmp/Rtmp16hUjf/projB/.stamp
# Inspect what was created
fs::dir_tree(fs::path(root_a, ".stamp"), recurse = TRUE, all = TRUE)
#> /tmp/Rtmp16hUjf/projA/.stamp
#> ├── logs
#> └── temp
fs::dir_tree(fs::path(root_b, ".stamp"), recurse = TRUE, all = TRUE)
#> /tmp/Rtmp16hUjf/projB/.stamp
#> ├── logs
#> └── tempYou can inspect registered aliases:
st_alias_list()
#> alias root state_dir stamp_path
#> 1 A /tmp/Rtmp16hUjf/projA .stamp /tmp/Rtmp16hUjf/projA/.stamp
#> 2 B /tmp/Rtmp16hUjf/projB .stamp /tmp/Rtmp16hUjf/projB/.stamp
#> 3 default /tmp/Rtmp16hUjf/s .stamp /tmp/Rtmp16hUjf/s/.stamp
# Get alias details
st_alias_get("A")
#> $root
#> /tmp/Rtmp16hUjf/projA
#>
#> $state_dir
#> [1] ".stamp"
#>
#> $stamp_path
#> /tmp/Rtmp16hUjf/projA/.stampUse the same artifact path patterns; pass alias to
select which catalog/versions apply:
pA <- fs::path(root_a, "data.qs")
pB <- fs::path(root_b, "data.qs")
# Save different data to A and B to ensure versions are created
st_save(data.frame(id = 1:2), pA, alias = "A")
#> ✔ Saved [qs2] → '/tmp/Rtmp16hUjf/projA/data.qs' @ version 12fe60858b9d6e11
st_save(data.frame(id = 3:4), pB, alias = "B")
#> ✔ Saved [qs2] → '/tmp/Rtmp16hUjf/projB/data.qs' @ version a885f7ab494b5ef6
# Each alias has its own version history
st_versions(pA, alias = "A")
st_versions(pB, alias = "B")
# Loading respects the alias
objA <- st_load(pA, alias = "A")
#> Warning: No primary key recorded for '/tmp/Rtmp16hUjf/projA/data.qs'.
#> ℹ You can add one with `st_add_pk()`.
#> ✔ Loaded [qs2] ← '/tmp/Rtmp16hUjf/projA/data.qs'
objB <- st_load(pB, alias = "B")
#> Warning: No primary key recorded for '/tmp/Rtmp16hUjf/projB/data.qs'.
#> ℹ You can add one with `st_add_pk()`.
#> ✔ Loaded [qs2] ← '/tmp/Rtmp16hUjf/projB/data.qs'
list(A = objA, B = objB)
#> $A
#> id
#> 1 1
#> 2 2
#>
#> $B
#> id
#> 1 3
#> 2 4
# Inspect what was created within the stamp folders
# Note: Artifacts are stored as <root>/<path>/<filename>/<filename>
# with versions in <root>/<path>/<filename>/versions/
cat("\nStructure in root_a:\n")
#>
#> Structure in root_a:
fs::dir_tree(root_a, recurse = 2)
#> /tmp/Rtmp16hUjf/projA
#> └── data.qs
#> ├── data.qs
#> ├── data.qs.lock
#> ├── stmeta
#> │ └── data.qs.stmeta.json
#> └── versions
#> └── 12fe60858b9d6e11
cat("\nStructure in root_b:\n")
#>
#> Structure in root_b:
fs::dir_tree(root_b, recurse = 2)
#> /tmp/Rtmp16hUjf/projB
#> └── data.qs
#> ├── data.qs
#> ├── data.qs.lock
#> ├── stmeta
#> │ └── data.qs.stmeta.json
#> └── versions
#> └── a885f7ab494b5ef6Version resolution is non-interactive. NULL or
0 resolve to the latest version:
# Load latest (using default version = NULL for latest)
latestA <- st_load(pA, alias = "A")
#> Warning: No primary key recorded for '/tmp/Rtmp16hUjf/projA/data.qs'.
#> ℹ You can add one with `st_add_pk()`.
#> ✔ Loaded [qs2] ← '/tmp/Rtmp16hUjf/projA/data.qs'
latestB <- st_load(pB, alias = "B")
#> Warning: No primary key recorded for '/tmp/Rtmp16hUjf/projB/data.qs'.
#> ℹ You can add one with `st_add_pk()`.
#> ✔ Loaded [qs2] ← '/tmp/Rtmp16hUjf/projB/data.qs'
list(latestA = latestA, latestB = latestB)
#> $latestA
#> id
#> 1 1
#> 2 2
#>
#> $latestB
#> id
#> 1 3
#> 2 4The special alias "default" exists for backward
compatibility. You can re-base it to point at any initialized folder and
keep legacy state in sync:
st_init()._, -).A, B, or project
codes) and avoid reassigning them.st_switch() sparingly; explicit
alias = in calls is clearer in shared code.0 for latest.version = 0 or
NULL; loading without version loads the
current version by default.stamp maintains a catalog with an index for
lineage (parents_index) to make reverse lookups fast.
Aliases do not change filesystem layout; they only select which catalog
is used.st_opts() after
st_init()..stamp/ - state only (catalog, locks, temp)<path>/<filename>/ - artifact directories
containing:
<filename> - the actual filestmeta/ - sidecar metadataversions/ - version history for that specific
artifact