Run a call before and after temporary function patches, assess the graph
impact of each patched function, and assemble an advisory handoff. Composes
with_patch() and change_impact() without modifying package source.
Arguments
- expr
A function call to evaluate. Passed to
with_patch().- patches
A named list of replacement functions. Passed to
with_patch().- graph
An
insider_graph, source directory, or installed package name used bychange_impact().- ignore
Character vector of top-level fields to ignore. Passed to
with_patch().- tolerance
Single non-negative numeric comparison tolerance. Passed to
with_patch().- output_dir
Optional directory in which to write
proposal.mdandproposal.json.
Value
An insider_proposal object containing the comparison, provenance,
per-patch impact, advisory recommendation, and validation commands.
Examples
dir <- tempfile()
dir.create(dir)
writeLines("helper <- function(x) x + 1", file.path(dir, "code.R"))
helper <- function(x) x + 1
propose_change(
helper(1),
patches = list(helper = function(x) x + 2),
graph = dir
)
#>
#> ── insideR patch ───────────────────────────────────────────────────────────────
#> Call: `helper(1)`
#> Patched function: `helper()`
#> helper(): session-local function, not part of an installed package
#>
#> ── insideR comparison ──────────────────────────────────────────────────────────
#> Status: structural_difference
#> all.equal() reports structural differences between custom_result and
#> original_result.
#>
#> ── Details ──
#>
#> all.equal():
#> • Mean relative difference: 0.3333333
#> Numeric summary (beyond tolerance = 1.49011611938477e-08):
#> • Max absolute difference: 1
#> • Differing elements: 1 / 1
#> • Differing percent: 100%
#>
#> ── insideR proposal ────────────────────────────────────────────────────────────
#> Call: `helper(1)`
#> Patched function: `helper()`
#>
#> ── Comparison ──
#>
#> ── insideR comparison ──────────────────────────────────────────────────────────
#> Status: structural_difference
#> all.equal() reports structural differences between custom_result and
#> original_result.
#>
#> ── Details ──
#>
#> all.equal():
#> • Mean relative difference: 0.3333333
#> Numeric summary (beyond tolerance = 1.49011611938477e-08):
#> • Max absolute difference: 1
#> • Differing elements: 1 / 1
#> • Differing percent: 100%
#>
#> ── Change impact ──
#>
#> ── helper ──────────────────────────────────────────────────────────────────────
#> Kind: function | export status unknown | Risk: low
#> Callers
#> Exported: none
#> Internal: none
#> Total distinct callers: 0
#> Method family
#> not identified as an S3 method
#> Related tests
#> none
#> Risk notes
#> • none identified
#> Validation commands
#> • R CMD check
#>
#> ── Recommendation ──
#>
#> Recommendation (advisory): local-customization
#> Rationale: Behaviour changed, but no patched function is exported and no
#> high-risk signal was found.
#>
#> ── Validation commands ──
#>
#> • R CMD check