V02 Compare contract versions
Use your current course session. Preparation and course runner · R script ↓
Optional deep dive. Enable only the options named in each block, after preparing its packages or services.
V02a Add descriptive metadata
Goal: Document ownership and grain.
Prerequisites: H04; extras.
Descriptive metadata does not enforce access control or approval policies.
training_step(
"V02a",
{
owned_contract <- policy_contract |>
dr_contract_meta(
owner = "Risk Analytics",
description = "Synthetic training policies",
grain = "One policy"
)
print(owned_contract)
},
needs = c("H04"),
enabled = training_options$extras,
optional = TRUE
)Expected result: Owner and grain are documented.
Task: Does owner grant read access?
Show solution
No. Authorization is outside this metadata.
V02b Choose a validation policy
Goal: Allow extra columns deliberately.
Prerequisites: V02a.
Contract policy should be explicit, rather than hidden in transformations.
training_step(
"V02b",
{
flexible_contract <- owned_contract |>
dr_contract_policy(allow_extra = TRUE)
print(flexible_contract$allow_extra)
},
needs = c("V02a"),
enabled = training_options$extras,
optional = TRUE
)Expected result: Additional columns are allowed; declared keys remain binding.
Task: Should every delivery use this policy?
Show solution
Only when extra fields are acceptable to the business.
V02 Compare contract versions
Goal: Review a change before using it.
Prerequisites: V02b.
A new version makes the revision explicit. A diff may require review instead of declaring every change compatible.
training_step(
"V02",
{
contract_v2 <- dr_contract_update(
owned_contract,
version = "2.0.0",
columns = c(channel = "character")
)
print(dr_contract_diff(owned_contract, contract_v2))
stopifnot(!"channel" %in% names(owned_contract$columns))
},
needs = c("V02b"),
enabled = training_options$extras,
optional = TRUE
)Expected result: The diff shows the change; the old contract is unchanged.
Task: Is a newly added column automatically required?
Show solution
Not with dr_contract_update. Maintain required explicitly.