---
title: "Criticality Scores"
subtitle: "Structural Dependency Criticality via PageRank: dependency, business-weighted and exposure scores against simple baselines"
---
```{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)
rho <- \(x) cor(s$p_custom, x, method = "spearman")
ties <- s |> count(rank_custom) |> filter(n > 1)
rank_shift <- s |>
mutate(rank_indeg = rank(-in_degree, ties.method = "min"), shift = rank_indeg - rank_custom) |>
filter(abs(shift) >= 3)
top_business <- s |> slice_min(rank_business, n = 3, with_ties = FALSE)
pay <- s |> filter(name == "Payment_Execution_API")
rev_top <- s |> slice_min(rank_reverse, n = 2, with_ties = FALSE)
get_s <- \(x, col) s[[col]][s$name == x]
```
This page reports three PageRank-based scores for every system and compares them with two simpler baselines. All results use the v1 dependency map and $\alpha =$ `r res$params$pagerank$alpha`.
- **PageRank (dependency criticality):** how much the system is relied on, directly and indirectly, with a uniform restart.
- **Business-weighted PageRank:** the same, but the walk starts at client-facing systems in proportion to their business value ([Method](method.qmd#sec-business)).
- **Reverse PageRank (exposure):** PageRank with every arrow reversed. It ranks systems by how much sits *behind* them, which is what an outage at the front door or an intruder at the perimeter would reach.
- **In-degree:** the number of systems that depend on it directly.
- **Blast radius:** the number of systems that depend on it directly or indirectly ([Failure Cascades](cascades.qmd)).
## All scores
```{r scores-table}
s |>
select(rank_custom, name, tier, p_custom, p_business, p_reverse, in_degree, blast_n) |>
gt_house(
title = "Criticality scores for all systems",
subtitle = "Sorted by PageRank; tied systems share the lower rank"
) |>
cols_label(
rank_custom = "Rank", name = "Asset", tier = "Tier",
p_custom = "PageRank", p_business = "Business-weighted PageRank",
p_reverse = "Reverse PageRank (exposure)", in_degree = "Direct dependents",
blast_n = "All dependents (blast radius)"
) |>
fmt_percent(columns = c(p_custom, p_business, p_reverse), decimals = 2) |>
data_color(columns = p_custom, palette = c("#ffffff", "#2a78d6"))
```
**How to read the table.** Each row is one system, sorted by PageRank with the most relied-on first. The three percentage columns are scores that each add up to 100% across all systems: plain PageRank, PageRank started from the revenue-earning systems, and PageRank on the reversed map, which measures exposure. The last two columns count the systems that depend on it directly, and directly or indirectly. Tied systems share a rank.
**What the table tells you.** The vault leads on both dependency measures, at `r pct(get_s("Secrets_Vault", "p_custom"))` and `r pct(get_s("Secrets_Vault", "p_business"))`, with cloud IAM close behind on plain PageRank. Exposure tells the opposite story: the CDN and firewall, near the bottom of the PageRank list, score highest. `r nrow(ties)` groups of systems tie exactly because their dependency structures are identical. All scores are relative shares, so every one would fall if more systems were added to the map.
## PageRank against simple baselines {#sec-baselines}
```{r baseline-correlation}
tibble(
Baseline = c("Direct dependents (in-degree)", "All dependents (blast radius)",
"Business value disabled (hard-edge cascade)", "Business-weighted PageRank",
"Reverse PageRank (exposure)"),
rho = c(rho(s$in_degree), rho(s$blast_n), rho(s$blast_value_hard), rho(s$p_business), rho(s$p_reverse))
) |>
gt_house(title = "How closely PageRank tracks other measures", subtitle = "Spearman rank correlation with PageRank across all systems") |>
cols_label(rho = "Spearman ρ") |>
fmt_number(columns = rho, decimals = 2)
```
**How to read the table.** Each row compares PageRank with one other way of ranking the systems. Spearman ρ measures how similar two rankings are: 1 means the same order, 0 means no relationship, and a negative value means the order is roughly reversed. The first three rows are simple counts of dependents and the business value a failure disables; the last two are the other PageRank variants on this page.
**What the table tells you.** PageRank orders the systems almost exactly as a simple count of direct dependents does (ρ = `r number(rho(s$in_degree), 0.01)`), so here it adds little. It agrees less with business value disabled in a cascade (ρ = `r number(rho(s$blast_value_hard), 0.01)`), because PageRank splits a system's importance among its dependencies, while a cascade stops a system if any one hard dependency fails. Exposure tends to run the other way (ρ = `r number(rho(s$p_reverse), 0.01)`): the most relied-on systems are among the least exposed.
`r nrow(rank_shift)` systems move three or more places between the two rankings: `r knitr::combine_words(paste0(rank_shift$name, " (PageRank rank ", rank_shift$rank_custom, ", in-degree rank ", rank_shift$rank_indeg, ")"))`. None of these moves changes which systems sit at the top. The weaker link to cascade impact is why the [Failure Cascades](cascades.qmd) page names single points of failure that PageRank ranks low.
## Dependency criticality and exposure
```{r forward-reverse-plot}
#| fig-height: 7
label_set <- s |> filter(rank_custom <= 4 | rank_reverse <= 4)
s |>
ggplot(aes(p_custom, p_reverse, color = tier, shape = tier)) +
geom_point(size = 3.5, stroke = 0.5) +
ggrepel::geom_text_repel(data = label_set, aes(label = name), size = 3.3, color = "#222222",
min.segment.length = 0, seed = 1, box.padding = 0.4) +
scale_color_manual(values = tier_colors, name = NULL) +
scale_shape_manual(values = tier_shapes, name = NULL) +
scale_x_continuous(labels = percent_format(1)) +
scale_y_continuous(labels = percent_format(1)) +
guides(color = guide_legend(nrow = 2), shape = guide_legend(nrow = 2)) +
labs(
title = "Relied on vs. exposed: two different questions",
subtitle = "PageRank on the dependency map (x) and on the reversed map (y)",
x = "PageRank: how much the system is relied on",
y = "Reverse PageRank: how much sits behind it"
)
```
**How to read the plot.** Each point is a system, with color and shape showing its tier. Further right means more of the estate depends on the system. Higher up means more of the estate sits behind it, so an outage or an intruder there would reach more. Both axes are PageRank shares: the first on the dependency map, the second on the same map with every arrow reversed. Only the highest-scoring systems on either axis are labeled.
**What the plot tells you.** No system scores high on both axes. The vault and cloud IAM sit far to the right but near the bottom, while `r knitr::combine_words(rev_top$name)` sit at the top left, at `r knitr::combine_words(pct(rev_top$p_reverse))`. These are two different risks: losing a shared core system, and a failure or attack at the front door that every customer request passes through. A resilience review needs the first view; a security review also needs the second.
## Business-weighted PageRank
```{r business-weighted-plot}
#| fig-height: 8
s |>
mutate(name = fct_reorder(name, p_business)) |>
pivot_longer(c(p_custom, p_business), names_to = "score", values_to = "value") |>
mutate(score = recode(score, p_custom = "PageRank (uniform restart)",
p_business = "Business-weighted PageRank")) |>
ggplot(aes(value, name)) +
geom_line(aes(group = name), color = "#bbbbbb", linewidth = 1) +
geom_point(aes(color = score), size = 3) +
scale_color_manual(values = c("PageRank (uniform restart)" = "#888888",
"Business-weighted PageRank" = "#2a78d6"), name = NULL) +
scale_x_continuous(labels = percent_format(1)) +
labs(
title = "Starting the walk at the revenue-earning systems",
subtitle = "Systems sorted by business-weighted PageRank",
x = "Score", y = NULL
)
```
**How to read the plot.** Each row is a system, sorted by business-weighted PageRank. The grey dot is its plain PageRank, where every system starts the random walk equally often. The blue dot is its score when the walk starts only at the revenue-earning systems, in proportion to their business value. The line between the two dots shows how far the score moves once business value is taken into account.
**What the plot tells you.** The vault stays first, but the payment API jumps from rank `r pay$rank_custom` to rank `r pay$rank_business`, and order routing rises to rank `r get_s("Order_Routing_Svc", "rank_business")`, because revenue flows through them. Systems that no revenue path reaches, such as the CDN, firewall and DNS, fall to zero. That reflects a gap in the original map, where no client-facing system is recorded as depending on them. It is not evidence that those systems are unimportant.