Locking a corpus prevents mutation by sm_refresh() and other modifying
operations. This is useful for archival or when you want to guarantee
reproducibility after generating a sm_certificate().
sm_lock() sets metadata$is_locked = TRUE with an optional reason.
sm_unlock() reverses the lock but requires explicit confirmation to
prevent accidental unlocking of archived corpora.
Usage
sm_lock(corpus, reason = NULL, call = rlang::caller_env())
sm_unlock(corpus, confirm = FALSE, call = rlang::caller_env())Arguments
- corpus
An
sm_corpusobject.- reason
Optional character string documenting why the corpus was locked (e.g.,
"submitted for review","certificate generated").- call
Caller environment for error reporting.
- confirm
Logical. Must be
TRUEto actually unlock. This safeguard prevents accidental unlocking of archived corpora.
See also
Other refresh:
sm_refresh(),
sm_staleness()
Examples
corpus <- sm_example_corpus()
locked <- sm_lock(corpus, reason = "archival snapshot")
#> ✔ Corpus locked.
#> ℹ Reason: archival snapshot
locked$metadata$is_locked
#> [1] TRUE
unlocked <- sm_unlock(locked, confirm = TRUE)
#> ✔ Corpus unlocked.
unlocked$metadata$is_locked
#> [1] FALSE