
Global-merge (Stage 4) conservation + completeness invariants
Source:R/hf_invariants.R
hf_check_merge_invariants.RdComplements the structural merge checks (id-uniqueness, prefixes, toid resolution, divide FK, DAG) with the conservation/completeness class that catches SILENT data loss or corruption when per-VPU fabrics are merged into a global domain: a dropped/duplicated feature, lost catchment area, a missing VPU, zeroed drainage area (the `add_measures` zero-fill class), mixed CRS, or an untagged feature. Reusable across any domain merge.
Usage
hf_check_merge_invariants(
merged,
expected = NULL,
area_tol = 0.005,
stage = "merge",
strict = FALSE
)Arguments
- merged
named list with `flowpaths`, `divides`, `nexus` (sf/data.frame) for the merged domain product.
- expected
optional list of input expectations summed over the per-VPU inputs: `vpus` (character), `n_flowpaths`, `n_divides`, `area_sqkm`. When a field is absent the corresponding check reports as info (skipped).
- area_tol
fractional tolerance for divide-area conservation (default 0.005).
- stage
message label (default "merge").
- strict
if TRUE, a failed check stops execution (else warns).