audit_fold: Combined Cross-Signal Fold Audit (Redirects + Canonicals)

View source: R/audit_canonicals.R

audit_foldR Documentation

Combined Cross-Signal Fold Audit (Redirects + Canonicals)

Description

Audits how 3xx **redirects** and declared **rel=canonical** links combine into a single fold map, surfacing exactly where the two signals interact. Wraps [audit_redirects()] and [audit_canonicals()] for the per-signal views and adds the cross-signal tables from [build_fold_map()]: same-source disagreements, canonicals ignored because their source also redirects, and the 'canonical_conflict_policy' outcome.

Disagreements are never silently resolved – they are always reported here, regardless of which policy decides the winner.

Usage

audit_fold(
  redirects_df = NULL,
  canonicals_df = NULL,
  edge_list_df = NULL,
  redirect_from_col = "from",
  redirect_to_col = "to",
  canonical_from_col = "from",
  canonical_to_col = "to",
  duplicate_from_policy = c("strict", "first_wins", "last_wins", "most_frequent",
    "prune_source", "resolve_if_consistent"),
  loop_handling = c("error", "prune_loop", "break_arrow"),
  canonical_duplicate_from_policy = c("strict", "first_wins", "last_wins",
    "most_frequent", "prune_source", "resolve_if_consistent"),
  canonical_loop_handling = c("error", "prune_loop", "break_arrow"),
  canonical_conflict_policy = c("redirect_wins", "error", "canonical_wins"),
  edge_from_col = "from",
  edge_to_col = "to"
)

Arguments

redirects_df

Optional data frame of 3xx redirect rules, or 'NULL'.

canonicals_df

Optional data frame of declared rel=canonical links, or 'NULL'. Each row pairs a source URL with the canonical it declares.

edge_list_df

Optional edge list, passed to the per-signal audits for orphan detection.

redirect_from_col, redirect_to_col

From/to columns in 'redirects_df'. Default '"from"' / '"to"'.

canonical_from_col, canonical_to_col

From/to columns in 'canonicals_df'. Default '"from"' / '"to"'.

duplicate_from_policy

How to handle a redirect source with multiple distinct targets. See [resolve_redirects()]. Default '"strict"'.

loop_handling

How to handle redirect cycles. See [resolve_redirects()]. Default '"error"'. Also governs cross-signal cycles in the composed graph.

canonical_duplicate_from_policy

How to handle a canonical source with multiple distinct declared canonicals. Reuses the 'duplicate_from_policy' enum. Default '"strict"'.

canonical_loop_handling

How to handle cycles among declared canonicals. Reuses the 'loop_handling' enum. Default '"error"'.

canonical_conflict_policy

How to resolve a redirect-vs-canonical disagreement on the **same source** URL. One of:

'"redirect_wins"'

(Default) The 3xx redirect wins; a canonical declared on a URL that itself redirects is ignored and flagged, never transferred onto the redirect target.

'"error"'

Error when a redirect and a canonical disagree on the same source (after audit context is computed). Sources where the two signals agree do not error.

'"canonical_wins"'

The declared canonical wins for that source; still flagged in the audit. The explicit exception to the default ignored-canonical-on-redirecting-source rule.

edge_from_col, edge_to_col

From/to columns in 'edge_list_df'.

Value

A list with class '"fold_audit"' containing:

redirects

The [audit_redirects()] result (or 'NULL').

canonicals

The [audit_canonicals()] result (or 'NULL').

conflicts

Data frame of same-source redirect-vs-canonical cases: 'source', 'redirect_to', 'canonical_to', 'disagrees', 'resolution'.

ignored_canonicals

Data frame of canonicals dropped because their source also redirects (populated under '"redirect_wins"').

conflict_policy

The 'canonical_conflict_policy' in effect.

See Also

[audit_redirects()], [audit_canonicals()], [build_fold_map()]

Examples

redirects <- data.frame(from = "http://a", to = "http://b")
canonicals <- data.frame(from = "http://a", to = "http://d")
# a redirects to b but also declares canonical d => disagreement
audit_fold(redirects, canonicals)

pagerankr documentation built on Oct. 1, 2026, 5:09 p.m.