---
title: "Sensitivity"
subtitle: "Structural Dependency Criticality via PageRank: how far the ranking moves when the assumptions change"
---
```{r load}
#| include: false
for (f in sort(list.files("R", pattern = "^[0-9].*\\.R$", full.names = TRUE))) source(f)
res <- load_results()
s <- res$scores
n_assets <- nrow(s)
sw <- res$alpha_sweep
a_rng <- range(sw$alpha)
a_lo <- sw |> filter(alpha == a_rng[1])
a_hi <- sw |> filter(alpha == a_rng[2])
at <- \(d, x) d$criticality[d$name == x]
slopes <- sw |>
summarise(slope = coef(lm(criticality ~ alpha))[2], .by = name) |>
left_join(select(s, name, tier, rank_custom), by = "name")
rank_changes <- sw |>
filter(name %in% s$name[s$rank_custom <= 8]) |>
summarise(best = min(rank), worst = max(rank), .by = name)
top_stable <- sw |> filter(rank <= 2) |> distinct(alpha, name, rank) |> count(name, rank)
dg <- res$dangling
dg_base <- dg |> filter(option == "Uniform (baseline)") |> select(name, base_rank = rank, base_score = score)
tau <- dg |>
left_join(dg_base, by = "name") |>
summarise(tau = cor(score, base_score, method = "kendall"), .by = option)
es <- res$edge_scenarios
pert <- res$perturbation |>
summarise(median = median(rank), lo = quantile(rank, 0.05), hi = quantile(rank, 0.95),
top1 = mean(rank == 1), .by = name) |>
left_join(select(s, name, tier, rank_custom), by = "name")
pp_ <- res$params$perturbation
v2 <- res$scores_v2
max_shift <- rank_changes |> filter(!name %in% c("Secrets_Vault", "Cloud_IAM")) |> summarise(max(worst - best)) |> pull()
dg_v <- dg |> filter(name == "Secrets_Vault")
es_get <- \(sc, x) es$score[es$scenario == sc & es$name == x]
spof_n <- \(d) sum(d$blast_value_hard >= res$params$thresholds$spof_value_share)
```
The ranking on the [Criticality Scores](scores.qmd) page rests on four choices: the damping factor, the treatment of systems with no dependencies, the exact set of dependencies, and the map as a whole. This page varies each one.
## Damping factor {#sec-alpha}
$\alpha$ is the probability that the random walk follows a dependency rather than restarting at a random system. The sweep runs from `r a_rng[1]` to `r a_rng[2]`.
```{r contagion-sensitivity-plot}
#| fig-height: 8
sw |>
left_join(select(s, name, tier), by = "name") |>
ggplot(aes(alpha, criticality, group = name, color = tier)) +
geom_line(linewidth = 0.8) +
geom_point(size = 1.6) +
ggrepel::geom_text_repel(
data = \(d) filter(d, alpha == max(alpha), name %in% s$name[s$rank_custom <= 6]),
aes(label = name), size = 3, color = "#222222", direction = "y", hjust = 0,
nudge_x = 0.02, segment.color = "#bbbbbb", seed = 1
) +
facet_wrap(~tier, ncol = 2, scales = "free_y") +
scale_color_manual(values = tier_colors, guide = "none") +
scale_x_continuous(breaks = seq(0.5, 1, 0.1), expand = expansion(mult = c(0.02, 0.35))) +
scale_y_continuous(labels = percent_format(1)) +
labs(
title = "PageRank across the damping factor",
subtitle = "Every system, one panel per tier; each panel has its own vertical scale",
x = "Damping factor (α)", y = "PageRank share"
)
```
**How to read the plot.** Each line is one system, showing its PageRank share as the damping factor rises from `r a_rng[1]` to `r a_rng[2]`. The damping factor is the chance that the random walk follows a dependency at each step instead of restarting at a random system. Each panel holds one tier and has its own vertical scale, so compare slopes within a panel rather than heights across panels.
**What the plot tells you.** The vault rises from `r pct(at(a_lo, "Secrets_Vault"))` to `r pct(at(a_hi, "Secrets_Vault"))` and cloud IAM from `r pct(at(a_lo, "Cloud_IAM"))` to `r pct(at(a_hi, "Cloud_IAM"))`, because a walk that restarts less often collects more weight at systems with no dependencies. Root_DNS also has no dependencies, but only one system relies on it, so it falls from `r pct(at(a_lo, "Root_DNS"))` to `r pct(at(a_hi, "Root_DNS"))`. Most of the remaining systems drift slowly downward. These are mechanical effects of the restart rate, not evidence about how tightly the architecture is coupled.
```{r alpha-rank-table}
rank_changes |>
left_join(select(s, name, rank_custom), by = "name") |>
left_join(select(slopes, name, slope), by = "name") |>
arrange(rank_custom) |>
select(name, rank_custom, best, worst, slope) |>
gt_house(title = "Rank stability across the damping factor",
subtitle = paste0("Top 8 systems at α = ", res$params$pagerank$alpha, "; ranks across α = ", a_rng[1], " to ", a_rng[2])) |>
cols_label(name = "Asset", rank_custom = paste0("Rank at α = ", res$params$pagerank$alpha), best = "Best rank",
worst = "Worst rank", slope = "Change in share per 0.1 of α (pp)") |>
fmt(columns = slope, fns = \(x) number(x * 10, accuracy = 0.01))
```
**How to read the table.** Each row is one of the eight highest-ranked systems at the standard damping factor of `r res$params$pagerank$alpha`. The best and worst rank columns show the range of positions the system takes anywhere between `r a_rng[1]` and `r a_rng[2]`. The last column is the average change in its PageRank share, in percentage points, for each 0.1 increase in the damping factor; a negative value means the share falls.
**What the table tells you.** The vault is first and cloud IAM second at every damping factor tested, so the headline ranking does not depend on this setting. `r if (max_shift == 0) 'The next systems down hold their ranks across the whole range as well.' else paste0('Further down, ranks shift by at most ', max_shift, ' places.')` The vault and IAM gain about `r number(10 * slopes$slope[slopes$name == "Secrets_Vault"], 0.1)` and `r number(10 * slopes$slope[slopes$name == "Cloud_IAM"], 0.1)` points per 0.1 increase, while most others barely move. The conventional value of `r res$params$pagerank$alpha` affects the size of the scores, not the top of the ranking.
## Dangling-node convention {#sec-dangling-sens}
```{r dangling-sensitivity}
dg |>
filter(rank <= 10) |>
arrange(option, rank) |>
mutate(cell = paste0(name, " (", percent(score, 0.1), ")"), slot = row_number(), .by = option) |>
select(option, slot, cell) |>
pivot_wider(names_from = option, values_from = cell) |>
gt_house(title = "Top 10 under three treatments of systems with no dependencies",
subtitle = "Uniform is igraph's default and the convention used for headline results") |>
cols_label(slot = "Position") |>
sub_missing(missing_text = "–")
```
**How to read the table.** Each column lists the ten highest-scoring systems under one way of handling systems that depend on nothing, with each system's PageRank share in brackets. Uniform, used for the headline results, spreads their weight evenly over all systems. Self-loop keeps the weight where it lands. Business-weighted restart sends it to the revenue-earning systems. Each row is a position in the ranking, from first to tenth.
**What the table tells you.** The vault is first under all three treatments, but its share ranges from `r pct(min(dg_v$score), 0.1)` to `r pct(max(dg_v$score), 0.1)`. Self-loops concentrate weight on the systems with no dependencies, lifting the identity provider and DNS into the top four. The business-weighted option instead brings revenue-earning services, such as the payment API and order routing, into the top four. The treatment changes the size of the scores substantially and the order below first place noticeably.
```{r dangling-tau}
tau |>
gt_house(title = "Agreement with the uniform convention", subtitle = "Kendall τ between each option's scores and the baseline scores, all systems") |>
cols_label(option = "Option", tau = "Kendall τ") |>
fmt_number(columns = tau, decimals = 2)
```
**How to read the table.** Each row compares one treatment of systems that depend on nothing with the uniform treatment used for the headline results. Kendall τ measures how similar two rankings are: 1 means identical order, 0 means no relationship, and −1 means the order is reversed. It is calculated over all `r n_assets` systems, not only the top ten shown in the table above.
**What the table tells you.** Self-loops keep the order close to the baseline (τ = `r number(tau$tau[tau$option == "Self-loop on sinks"], 0.01)`), even though they more than double the vault's share to `r pct(dg$score[dg$option == "Self-loop on sinks" & dg$name == "Secrets_Vault"], 0.1)`. The business-weighted option agrees much less (τ = `r number(tau$tau[tau$option == "Business-weighted restart"], 0.01)`), because it also changes where the walk starts, and systems that no revenue-earning system reaches fall to zero. That is a different question, not a different answer to the same one, and the vault is still first.
## Single-edge scenarios {#sec-scenarios}
Each scenario adds dependencies that a real estate very likely has, one group at a time, then all together.
```{r edge-scenarios}
es |>
filter(rank <= 5) |>
arrange(scenario, rank, name) |>
mutate(cell = paste0(name, " (", percent(score, 0.01), ")"), slot = row_number(), .by = scenario) |>
filter(slot <= 5) |>
select(scenario, edges_added, slot, cell) |>
pivot_wider(names_from = slot, values_from = cell, names_prefix = "#") |>
left_join(es |> filter(name == "Secrets_Vault") |> select(scenario, vault = score, vault_rank = rank), by = "scenario") |>
gt_house(title = "Top 5 after adding plausible dependencies", subtitle = paste0("v1 map plus the listed edges, α = ", res$params$pagerank$alpha)) |>
cols_label(scenario = "Scenario", edges_added = "Edges added", vault = "Secrets_Vault share", vault_rank = "Secrets_Vault rank") |>
fmt_percent(columns = vault, decimals = 2)
```
**How to read the table.** Each row adds one group of plausible dependencies to the original map, and the last row adds all of them together. The middle column counts the arrows added. Columns #1 to #5 list the five highest-ranked systems afterward, with their PageRank shares in brackets. The final two columns track the vault's share and rank, which makes the effect on the original first-ranked system easy to follow.
**What the table tells you.** A single added dependency is enough to change first place. If the vault authenticates through cloud IAM, as real vaults usually do, IAM rises to `r pct(es_get("Vault authenticates via IAM", "Cloud_IAM"))`. If IAM federates through the identity provider, the provider becomes first. Recording every system's DNS dependency lifts Root_DNS from rank `r s$rank_custom[s$name == "Root_DNS"]` to first, at `r pct(es_get("Every asset uses DNS", "Root_DNS"))`. First place is therefore a property of how completely the map was drawn, not only of the estate.
## Random rewiring {#sec-perturbation}
To measure that sensitivity more generally, each of `r number(pp_$n_reps, big.mark = ",")` replicates (seed `r pp_$seed`) removes `r pct(pp_$edge_share, 1)` of the dependencies at random and adds the same number of random new ones. New dependencies run from a system to one in the same tier or a deeper tier, with no self-dependencies and no duplicates.
```{r perturbation-plot}
#| fig-height: 8
pert |>
mutate(name = fct_reorder(name, -median - rank_custom / 100)) |>
ggplot(aes(y = name, color = tier, shape = tier)) +
geom_linerange(aes(xmin = lo, xmax = hi), linewidth = 1.6, alpha = 0.6) +
geom_point(aes(x = median), size = 3.2) +
geom_point(aes(x = rank_custom), shape = 4, size = 2.5, color = "#222222") +
scale_x_continuous(breaks = c(1, 5, 10, 15, 20, 25)) +
scale_color_manual(values = tier_colors, name = NULL) +
scale_shape_manual(values = tier_shapes, name = NULL) +
guides(color = guide_legend(nrow = 2), shape = guide_legend(nrow = 2)) +
labs(
title = "Rank intervals under random rewiring",
subtitle = "Median rank (point), 5th–95th percentile (bar), baseline rank (×); 1 = most critical",
x = "Rank", y = NULL
)
```
**How to read the plot.** Each row is a system. The colored point is its median rank across `r number(pp_$n_reps, big.mark = ",")` randomly rewired versions of the map, and the bar spans the middle 90% of its ranks, from the 5th to the 95th percentile. The black cross is its rank on the original map. Rank 1 is the most relied-on system, so further left means more critical, and a shorter bar means a more stable rank.
**What the plot tells you.** The vault is first in `r pct(pert$top1[pert$name == "Secrets_Vault"], 1)` of rewired maps and cloud IAM in `r pct(pert$top1[pert$name == "Cloud_IAM"], 1)`, and in 90% of maps both stay within the top `r max(pert$hi[pert$name %in% c("Secrets_Vault", "Cloud_IAM")])`. Below them the bars widen quickly: `r knitr::combine_words(pert$name[pert$rank_custom %in% 3:6 & (pert$hi - pert$lo) >= 4])` each span four or more places, and Root_DNS ranges from `r pert$lo[pert$name == "Root_DNS"]` to `r pert$hi[pert$name == "Root_DNS"]`. The top pair is robust to modest map errors; the next tier is not.
## Second dependency map (v2) {#sec-v2-compare}
The v2 map adds DNS dependencies for every system, the vault's dependencies on IAM and object storage, IAM's federation through the IdP, and a vault–IAM bootstrap cycle ([Data & Topology](data.qmd#sec-v2)).
```{r v1-v2-compare}
s |>
select(name, tier, p_v1 = p_custom, rank_v1 = rank_custom, blast_v1 = blast_value_hard) |>
left_join(select(v2, name, p_v2 = p_custom, rank_v2 = rank_custom, blast_v2 = blast_value_hard), by = "name") |>
arrange(rank_v2) |>
slice_head(n = 12) |>
gt_house(title = "v1 and v2 side by side", subtitle = "Top 12 systems by v2 PageRank") |>
cols_label(name = "Asset", tier = "Tier", p_v1 = "PageRank", rank_v1 = "Rank", blast_v1 = "Value disabled (hard)",
p_v2 = "PageRank", rank_v2 = "Rank", blast_v2 = "Value disabled (hard)") |>
tab_spanner("v1 (original)", columns = c(p_v1, rank_v1, blast_v1)) |>
tab_spanner("v2 (more complete)", columns = c(p_v2, rank_v2, blast_v2)) |>
fmt_percent(columns = c(p_v1, p_v2), decimals = 2) |>
fmt_percent(columns = c(blast_v1, blast_v2), decimals = 0)
```
**How to read the table.** Each row is one of the twelve highest-ranked systems on the more complete v2 map. For each map, the table shows the system's PageRank share, its rank, and the share of business value that stops when it fails, counting hard dependencies only. Comparing the two groups of columns side by side shows how far the extra dependencies move each system, both in how much it is relied on and in what its failure would stop.
**What the table tells you.** On v2, Root_DNS ranks first at `r pct(v2$p_custom[v2$name == "Root_DNS"])` and stops `r pct(v2$blast_value_hard[v2$name == "Root_DNS"], 1)` of business value when it fails, matching its textbook status as a single point of failure. The vault and IAM stay in the top three, and because of the vault–IAM loop, each now takes the other down. Systems that stop at least half the business rise from `r spof_n(s)` to `r spof_n(v2)`. A more complete map makes concentration worse, not better.