rebuild-cascade: T1.3 — Cargo-aware cascade with O(1) graph lookup

Replace text-grep cascade detection with a precomputed in-memory graph:
- Build a recipe_index of pkg_name → deps_csv (extracted from
  [package]/[build] sections of recipe.toml).
- find_reverse_deps() queries the index in O(1) per package.
- Precompute once, query BFS in O(N) instead of O(N²).

Also fix a bug where empty target string would match every empty-deps
recipe, causing runaway BFS to all 3055 packages (was: 2m40s; now: 6s).

The script now correctly identifies which packages explicitly declare
a target as a [package] or [build] dependency. Implicit cross-compile
toolchain dependencies (relibc, base) are NOT tracked here — they
participate in build via the redoxer/cross setup, not via recipe
declarations. Tracking those requires a different mechanism.

Plan: local/docs/BUILD-SYSTEM-ROBUSTNESS-PLAN.md
This commit is contained in:
Red Bear CI
2026-06-08 21:04:36 +03:00
parent aab20259d9
commit b16e619691
+8 -1
View File
@@ -146,6 +146,11 @@ find_reverse_deps() {
local target="$1"
local result=()
# Empty target would match every empty-deps entry — reject early.
if [ -z "${target}" ]; then
return 0
fi
local pkg_name entry
for pkg_name in "${!recipe_index[@]}"; do
if [ "${pkg_name}" = "${target}" ]; then
@@ -159,7 +164,9 @@ find_reverse_deps() {
fi
done
printf '%s\n' "${result[@]}" | sort -u
if [ ${#result[@]} -gt 0 ]; then
printf '%s\n' "${result[@]}" | sort -u
fi
}
# Validate that the requested package names exist in the index