Skip to contents

Returns snapshot metadata plus computed row counts for bars and instruments. This function does not mutate the database.

Usage

ledgr_snapshot_info(con, snapshot_id)

Arguments

con

A DBI connection to DuckDB or a ledgr_snapshot.

snapshot_id

Snapshot id (must exist) when con is a connection.

Value

A 1-row tibble with: snapshot_id, status, created_at_utc, sealed_at_utc, snapshot_hash, hash_rule_version, verified_in_process, bar_count, instrument_count, off_session_bar_count, start_date, end_date, meta_json, error_msg.

bar_count and instrument_count are live counts from the snapshot tables. off_session_bar_count counts sealed bars that fall on no declared open-session close; they are never a pulse of an availability-aware run, and ledgr_snapshot_quarantine() lists them with reason off_session_bar. start_date and end_date are parsed from seal metadata when present. meta_json remains available as the raw envelope metadata written on the snapshot row. Seal-time metadata inside meta_json may use n_bars and n_instruments; the public columns are bar_count and instrument_count. Metadata is not part of snapshot_hash. verified_in_process is TRUE only when the current process holds the exact snapshot-store, snapshot-id, stored-root, and rule tuple in its private PID-bound verified set. Reading metadata does not establish that proof, and the value is never persisted or serialized.

Details

Timestamps are returned as ISO8601 UTC strings with trailing Z. Call it as ledgr_snapshot_info(snapshot) for a ledgr_snapshot handle, or as ledgr_snapshot_info(con, snapshot_id) for a raw DuckDB connection.

Errors:

  • ledgr_invalid_con if con is not a valid DBI connection.

  • ledgr_invalid_args if snapshot_id is not a non-empty character scalar.

  • LEDGR_SNAPSHOT_NOT_FOUND if snapshot_id does not exist.

Articles

Durable experiment stores: vignette("experiment-store", package = "ledgr") system.file("doc", "experiment-store.html", package = "ledgr")

Examples

bars <- ledgr_sim_bars(n_instruments = 1, n_days = 3, seed = 1)
snapshot <- ledgr_snapshot_from_df(bars)
ledgr_snapshot_info(snapshot)
#> # A tibble: 1 × 14
#>   snapshot_id                  status created_at_utc sealed_at_utc snapshot_hash
#>   <chr>                        <chr>  <chr>          <chr>         <chr>        
#> 1 snapshot_20261027_174441_10… SEALED 2026-10-27T17… 2026-10-27T1… 1af9eb342091…
#> # ℹ 9 more variables: hash_rule_version <int>, verified_in_process <lgl>,
#> #   bar_count <int>, instrument_count <int>, off_session_bar_count <int>,
#> #   start_date <chr>, end_date <chr>, meta_json <chr>, error_msg <chr>
ledgr_snapshot_close(snapshot)

db_path <- tempfile(fileext = ".duckdb")
con <- ledgr_db_init(db_path)
snapshot_id <- ledgr_snapshot_create(
  con,
  snapshot_id = "snapshot_20200101_000000_abcd"
)
ledgr_snapshot_info(con, snapshot_id)
#> # A tibble: 1 × 14
#>   snapshot_id                  status created_at_utc sealed_at_utc snapshot_hash
#>   <chr>                        <chr>  <chr>          <chr>         <chr>        
#> 1 snapshot_20200101_000000_ab… CREAT… 2026-10-27T17… NA            NA           
#> # ℹ 9 more variables: hash_rule_version <int>, verified_in_process <lgl>,
#> #   bar_count <int>, instrument_count <int>, off_session_bar_count <int>,
#> #   start_date <chr>, end_date <chr>, meta_json <chr>, error_msg <chr>
DBI::dbDisconnect(con, shutdown = TRUE)