Repository navigation
test(graph): experiment: planner pulls cycle breakers with no cycle (path shadowing) - #3969
bryan-minimal wants to merge 4 commits into
Conversation
… with no cycle Experiment, not for merge. make_reachable pushes the child, not the parent, onto path in its uncached branch, so every uncached child of an uncached parent finds itself in path and brings in its replace_on_cycle spec, cycle or not. These tests pin what the planner does today, on small fixtures (acyclic, chain3, chain4, chain4 with the breaker cached, a real 2-cycle) and on an approximation of the pkgs bootstrap cycle (49 packages, 29 replace_on_cycle specs, read from the build.ncl text of pkgs main). Each test prints a SHADOW-EXP line; the nextest ci profile shows it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
…fix one expectation The bootstrap fixture overflowed the 2 MiB test-thread stack while it loaded (CI, SIGABRT before its first SHADOW-EXP line). Run it on a 128 MiB thread, as the evaluation of a package tree does. chain4 with the breaker cached ends after two phases, not three: "x" is never built a second time, because finished() looks only at the top-levels and their runtime_deps, and "x" is a build_dep. Pin that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…make_reachable Experiment, not for merge. In the branch for a spec that is not cached, the loop variable shadowed the parent's bsr, so the loop pushed the child onto path and every uncached child found itself there. Rename the loop variable and push the parent, as the cached branch does, so the cycle check fires only on a real cycle. Nothing else changes. Only the experiment's expectations that move are updated here; any other test that fails is left failing on purpose. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… fix Experiment, not for merge; a separate commit so it can be dropped. With the fix, two tests of #3921 failed in CI (and only those two in the workspace): breaker_runtime_deps_add_builds_to_the_plan_but_nothing_to_a_build_box and loop_of_prebuilt_breakers_through_runtime_deps_plans_to_the_end. Every build box in those plans stays the same. What moves: the replace_on_cycle spec of "a" now comes from the lazy path in next() one phase later (the walk from "b" closes the cycle at "b", which has none), and "c (prebuilt)", which no box used, is no longer fetched. The assertions that the first failure hid (without_list, by_breaker) are expectations derived by hand, to be checked by this run. With the fix the by_package half of the loop test no longer plans the loop of prebuilts; the comment says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Reviewed the draft experiment at c64e5fd. The one-line fix in make_reachable is correct. Renaming the loop variable to dep makes path.push(*bsr) push the parent, as the cached branch does. The DFS still finds a back edge on every cycle reached through uncached specs, and seen_before keeps the recursion finite. Cycles whose back-edge node has no replace_on_cycle spec now go to the lazy find_cycles path in next(). CI is green, and the SHADOW-EXP lines show every plan ends result=ok, including the 49-package bootstrap approximation (cold: 19 eager breakers, 29 in the end, 13 phases). The rebased #3921 expectations match the explanation in the commit message: the boxes stay the same, the plan no longer fetches "c (prebuilt)", which no box used, and the spec of "a" arrives one phase later.
Findings: one medium (the bootstrap test does not assert that its plans succeed, which is the regression the fix could bring) and one low (a stale block comment).
Observation, outside this PR's scope: shadow_exp_chain4_no_cycle_breaker_cached pins a planner behaviour that main already has. "x" is built once with "y (prebuilt)" in place of "y". It is never rebuilt, because finished() walks only the top-levels and their runtime_deps. So "top" ships built on a first build of "x". If that is not intended, it may deserve its own issue.
Generated by Claude Code
|
|
||
| // Nothing cached. With the fix make_reachable brings in 19 of the 29. | ||
| let cold = shadow_run("bootstrap-cold", &dp, "leaf", &[]); | ||
| assert_eq!(cold.eager_breakers, 19); |
There was a problem hiding this comment.
Medium: the bootstrap fixture never asserts that its plans finish, so the main risk of the fix has no test.
Before the fix, make_reachable brought in every replace_on_cycle spec it reached. With the fix it brings in only the spec at the node where the walk closes a cycle: 19 of the 29 here. The other 10 now depend on the lazy path in next(). That path calls find_cycles and then looks only at the first and last node of each cycle. If neither node has a replace_on_cycle spec, next() returns PlanErr::Cycles, and that is a failure the eager pull used to hide. shadow_run stores that outcome in run.plan and prints it, but this test checks only eager_breakers. A plan that ends in Err(PlanErr::Cycles(..)) would still pass. The CI log at this head shows result=ok for bootstrap-cold, bootstrap-cold-seeds-cached and all 58 all-but runs, so the code works today. Nothing fails if that changes.
Suggested fix: assert run.plan.is_ok() (or the phase count) for cold, seeds and both runs in the all-but loop. Pinning breakers/used for cold (29/29 in the log) would also show that the lazy path brings in the other 10.
Generated by Claude Code
| // into a plan, cycle or not. | ||
| // | ||
| // In the branch for a spec that is not cached, the loop over build_deps and runtime_deps | ||
| // pushes the CHILD onto `path` before it recurses into the child. The child then finds |
There was a problem hiding this comment.
Low: this block comment is stale at this head. After the fix commit (9725750) the loop pushes the parent, not the child, and the tests below assert the behaviour with the fix, not "what the planner does today". Reword it to describe the bug in the past tense and say that the assertions pin the plan with the fix. Otherwise a reader of git show pr-3969:crates/graph/src/planner.rs takes the explanation as the current code.
Generated by Claude Code
Experiment, not for merge. Draft only; nothing here is meant to land as-is.
The suspicion
In
crates/graph/src/planner.rs,make_reachable, the branch for a spec that is not cached loops over its build_deps and runtime_deps asIn the child,
path.contains(bsr)is then always true, so any uncached child of an uncached parent that has areplace_on_cyclespec (not already inbuilds) brings that spec in eagerly, cycle or not. The cached branch pushes the parent.Commits
replace_on_cyclespecs; edges read from the build.ncl text of gominimal/pkgs main, approximate). Each test prints aSHADOW-EXPline;.config/nextest.tomlshows those tests' output in the ci profile.Grep the
testsjob log forSHADOW-EXPto read the numbers.🤖 Generated with Claude Code