---
title: "Verified production pipelines in WFC 2.0"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Verified production pipelines in WFC 2.0}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
```

A WFC 2.0 pipeline stores method and validation settings but does not construct
an unreviewed target at run time. It accepts an unchanged `wf_design_data` and
an unchanged `wf_verified_target`.

```{r object-pipeline, eval=FALSE}
spec <- wf_pipeline(
  target = target,
  stages = list(
    calibrate = list(method = "raking", tol = 1e-8)
  ),
  validate = list(max_deff = 6, max_margin_dev = 0.01)
)

weights <- wf_run(spec, design, dims)
```

The explicit population mode receives a verified population target, not a raw
population table:

```{r population-pipeline, eval=FALSE}
population_spec <- wf_pipeline(
  target = list(mode = "population"),
  stages = list(calibrate = list(method = "raking"))
)

weights <- wf_run(
  population_spec,
  design,
  dims,
  population = target
)
```

Reference mode works the same way with a target produced by
`wf_import_reference()` and supplied through `reference`.

Runtime changes to ID or base-weight roles are blocked. A runtime propensity
stage cannot be inserted before verified calibration. Declare design roles in
`wf_prepare_design()` and review every weighting method before execution.

```{r audit, eval=FALSE}
wf_audit_export(
  weights,
  "pipeline-audit.json",
  inputs = list(design = design, target = target)
)
```

The audit records pipeline, design, and target identities. Package release
approval does not authorize the specific analysis represented by that audit.
