Re-checks a capsule directory against its provenance record, one row per
check: the record is readable, the data file is present with its pinned
SHA-256, size and row count, the recorded schema still validates, a
results manifest still reproduces its recorded verdicts, a pinned script
still has its digest, and the data are not synthetic. This is
rmoriebricklayer::vrfcps(); see its help for every row.
Usage
morie_capsule_verify(
dir,
provenance_file = "data_provenance.json",
data_file = NULL,
manifest_file = NULL,
script_file = NULL
)Arguments
- dir
The capsule directory, a single string.
- provenance_file
The provenance record, relative to
dir.- data_file
The data file, relative to
dir.NULLuses the record'sresource$filename.- manifest_file
A results manifest (JSON) relative to
dir.NULLusesmanifest.jsonwhen the capsule has one.- script_file
An analysis script relative to
dir, checked against the pinned script digest.NULLuses the one the record or the manifest names.
Value
A bricklayer_capsule_check: a list with ok
(logical), checks (data frame of check, ok,
detail), required and missing (character).
Details
Entirely offline; nothing is written. A failed check is a row, not an
error: a provenance record that does not parse as JSON is a failed
provenance_readable row, as in morie (vrfcps() itself stops
on one). The errors are dir not an existing directory and an
argument that is not one string.
Examples
dir <- file.path(tempdir(), "capsule-verify")
dir.create(dir, showWarnings = FALSE)
write.csv(data.frame(id = 1:3), file.path(dir, "data.csv"), row.names = FALSE)
morie_capsule_write(dir, "data.csv", retrieved = "2026-10-20")
morie_capsule_verify(dir)
#> Capsule verification: intact (7 of 7 checks passed)
#> ok provenance_readable /tmp/Rtmp0CK4Yk/capsule-verify/data_provenance.json
#> ok data_present /tmp/Rtmp0CK4Yk/capsule-verify/data.csv
#> ok data_sha256 da4aaa3a009d063f36d0515f2b50a11bcc578264aa7c45504b46fedbbae4f8f7
#> ok data_size_bytes 11 bytes on disk
#> ok data_readable /tmp/Rtmp0CK4Yk/capsule-verify/data.csv
#> ok data_row_count 3 rows on disk
#> ok data_not_synthetic no synthetic marker: sidecar, manifest and provenance all say real data
# an edited data file fails its digest, size and row count
write.csv(data.frame(id = 1:4), file.path(dir, "data.csv"), row.names = FALSE)
chk <- morie_capsule_verify(dir)
chk$checks[!chk$checks$ok, c("check", "detail")]
#> check
#> 3 data_sha256
#> 4 data_size_bytes
#> 6 data_row_count
#> detail
#> 3 expected da4aaa3a009d063f36d0515f2b50a11bcc578264aa7c45504b46fedbbae4f8f7, got b24bb2c082053f4d1f5db97140babb86d4cc7e31b49be4e3c4cf94ca87a86d2b
#> 4 13 bytes on disk
#> 6 4 rows on disk
unlink(dir, recursive = TRUE)
