---
title: "Dirty data and safe infeasibility handling"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Dirty data and safe infeasibility handling}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

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

WFC stops early when design roles, source evidence, checksums, categories, or
sample support are inconsistent. A stop is evidence to repair or review the
inputs, not permission to choose a more convenient target.

Common safe responses are:

- remove outcome or undeclared columns before `wf_prepare_design()`;
- correct a target file and update its evidence checksum;
- reconcile category spelling against `wf_dims()`;
- document a deterministic support-based merge with `wf_plan_cells()`; or
- conclude that the requested calibration is not feasible.

```{r checks, eval=FALSE}
design <- wf_prepare_design(
  design_only,
  id = "person_id",
  calibration = c("age_group", "region"),
  base_weight = "base_weight"
)

target <- wf_import_target(
  "population-margins.csv",
  "population-margins.csv.source.dcf",
  dims,
  key_map = c(age_group = "age_group", region = "region"),
  count = "population_count"
)

precheck <- wf_precheck(design$data, target, id = design$roles$id)
cell_plan <- wf_plan_cells(design, target, dims)
```

WFC never widens bounds, changes method, changes target, or approves a plan in
response to infeasibility. Those are separate human decisions and may require a
new workflow.
