Skip to contents

Assembles a self-contained audit directory suitable for attachment to an IRB protocol submission, HIPAA Security Officer review, or reproducible publication supplement. The packet includes a verified hash-chained JSONL audit log, pre-flight isolation attestation JSON, hardened container configurations (docker run, Compose YAML, Apptainer .def) when a pinned container_spec is supplied, ready-to-paste Markdown and Quarto IRB narratives, and a SHA-256 packet_manifest.json. Every file written to the packet is scanned for accidental raw PII before sealing.

Usage

export_irb_compliance_packet(
  out_dir,
  extraction = NULL,
  audit_log_path = NULL,
  container_spec = NULL,
  preflight = NULL,
  study_title = NULL,
  protocol_id = NULL,
  institution = NULL,
  pi_name = NULL,
  regulatory_framework = c("HIPAA", "IRB"),
  overwrite = FALSE
)

Arguments

out_dir

Character scalar destination directory path for the compliance packet.

extraction

Optional airgap_extraction or airgap_consensus result from airgap_extract() or airgap_extract_consensus().

audit_log_path

Optional path to an existing hash-chained JSONL audit log (verified via audit_log_verify() prior to inclusion).

container_spec

Optional airgap_container_spec() object. If pinned with image_digest, emits container_docker_run.sh, docker-compose.yml, and container_apptainer.def into the packet.

preflight

Optional airgap_preflight record (defaults to extraction_preflight(extraction) when extraction is provided).

study_title

Optional character scalar study title.

protocol_id

Optional character scalar IRB protocol ID.

institution

Optional character scalar institutional name.

pi_name

Optional character scalar Principal Investigator name (for protocol header; omitted when NULL).

regulatory_framework

Character vector subset of c("HIPAA", "IRB", "FERPA").

overwrite

Logical scalar; if FALSE (default), refuses to overwrite a non-empty out_dir.

Value

An S3 object of class "airgap_compliance_packet" containing out_dir, files (tibble of relative paths, sizes, and SHA-256 digests), packet_digest, audit_valid, audit_chain_head, and created_at.

Examples

df <- tibble::tibble(id = c("N1", "N2"), txt = c("Dr. Jane Doe visited.", "Mood stable."))
sc <- extraction_schema(mood = schema_field("enum", values = c("calm", "anxious")))
res <- airgap_extract(df, "txt", sc, runtime_mock(), id_col = "id")
pkt_dir <- file.path(tempdir(), "demo_irb_packet")
pkt <- export_irb_compliance_packet(
  pkt_dir,
  extraction = res,
  protocol_id = "IRB-2026-0412",
  overwrite = TRUE
)
pkt
#> <airgap_compliance_packet> [AUDIT: VERIFIED]
#>   Directory:     /tmp/RtmpcWDmac/demo_irb_packet
#>   Artifacts:     4 file(s) + packet_manifest.json
#>   Audit head:    sha256:964ef8a5585d84697f216fa9c99cce7fe21826ab26cd25512ee88621bafce274
#>   Packet digest: sha256:eceda0037993a670eca3cc9ca469da7bd6c4b2060334c6ce43d3bcd3aecc7ef6
unlink(pkt_dir, recursive = TRUE)