Skip to contents

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_corpus object.

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 TRUE to actually unlock. This safeguard prevents accidental unlocking of archived corpora.

Value

A modified sm_corpus with updated lock status.

See also

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