Skip to contents

Derives the execution routing directly from spec lineage instead of a hand-registered process DAG: topological waves (a variable enters wave k only when every variable it references landed in an earlier wave), per-variable dependencies, and the two fail-closed lanes - variables blocked by dependency cycles and variables routed to human review. The ordering is computed, not declared; [validate_ir()] refuses cyclic specs outright, so a plan built from a validated IR always exists.

Usage

routing_plan(ir, known_columns = character())

Arguments

ir

List of `aa_variable_ir` objects.

known_columns

Character vector of column names assumed to pre-exist in the source data (e.g. SDTM base columns).

Value

A data.frame with columns `variable`, `wave` (0-based topological level; `NA` for cycle-blocked or human-routed variables), `depends_on` (comma-joined variable names produced earlier in the same IR), `layers` (layer chain or `"needs_human"`), and `needs_human`. Attributes: `blocked` (cycle-blocked variables) and `duplicate` (columns produced by more than one variable).

Details

Plan the derivation routing for an IR

Examples

spec <- mock_spec_adsl()
ir <- classify_variables(spec, "ADSL", backend = "rules")
plan <- routing_plan(ir)
plan[, c("variable", "wave", "layers")]
#>    variable wave                   layers
#> 1   STUDYID    0                   assign
#> 2   USUBJID    0                   assign
#> 3    SUBJID    0                   assign
#> 4    TRT01P    0                   assign
#> 5   TRTSDTM    0               impute_dtc
#> 6   TRTEDTM    0               impute_dtc
#> 7       AGE    0                 duration
#> 8    AGEGR1   NA              needs_human
#> 9     RACEN    0             codelist_var
#> 10    BMIBL    1 compute_param->merge_var