Skip to contents

Compares two spec_ir specifications path-by-path and returns a structured spec_diff report suitable for CLI auditing and live visual diff badges in dynamic Shiny UIs.

Usage

diff_spec_ir(old, new, ignore_rationale = TRUE, ignore_metadata = FALSE)

Arguments

old

Previous spec_ir object (or NULL when comparing against empty state).

new

Updated spec_ir object.

ignore_rationale

Logical; if TRUE (default), ignores changes in defaults_rationale.

ignore_metadata

Logical; if TRUE, ignores changes in metadata. Defaults to FALSE (tracks metadata$title and metadata$description).

Value

An S3 object of class spec_diff with elements:

  • changes: data.frame (path, section, field, change_type, old_value, new_value, summary).

  • changed_paths: character vector of changed dotted paths.

  • changed_sections: unique character vector of changed top-level sections.

  • n_changes: integer number of semantic changes.

  • has_changes: logical scalar.

Examples

s1 <- new_spec_ir(hierarchy = list(levels = 1L, n_obs = 100L))
s2 <- new_spec_ir(hierarchy = list(levels = 1L, n_obs = 250L))
diff_spec_ir(s1, s2)
#> 
#> ── spec_diff (1 change across 1 section) 
#> • hierarchy.n_obs: 100 -> 250