# sea-orm diamond recursion scan — CLEAN

Scanned: 2026-03-29
Scope: diamond recursion / CWE-407 in ORM dependency graph traversal

## Files checked

- `src/schema/topology.rs` — vendored from `gifnksm/topological-sort-rs`;
  uses Kahn's algorithm with `HashMap<T, Dependency<T>>` where `Dependency` holds
  `num_prec: usize` (predecessor count) and `succ: HashSet<T>`. Both the topology
  queue and the adjacency set use O(1) hash operations throughout.
  `pop_all()` filters by `num_prec == 0` in O(V) per pass. Clean.

## Verdict

CLEAN. Topological sort is Kahn's algorithm with HashSet adjacency. No diamond
recursion and no Array linear scan in the critical path.
