refactor(workspace): make env-DAG layering recursive#10350
Merged
davidfirst merged 1 commit intorefactor/component-loading-v2-take-2from May 7, 2026
Merged
Conversation
Replaces V1's one-level partition with a proper topological sort over the env-of-env DAG. Cycles fall back to a single layer defensively. Per D-001, this is the load-order primitive the rewrite depends on.
36e4734
into
refactor/component-loading-v2-take-2
12 checks passed
davidfirst
added a commit
that referenced
this pull request
May 7, 2026
Extracts a generic topo-sort helper (topoLayerByDeps) and uses it for both envs (refactored to share) and extensions. regroupExtIdsFromTheList was a documented no-op TODO; this implements it. Same shape fix as #10350 for envs, applied to ext-of-ext chains.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #10349.
Replaces V1's one-level partition in `groupEnvsByDepLayer` with a real topological sort over the env-of-env DAG. Per D-001, this is the load-order primitive the rest of the rewrite depends on.
Behavior change
Before: `A → B → C` (chain, all in input list) layered as `[[B, C], [A]]` — incorrect, B and C end up in the same load batch even though B depends on C.
After: `[[C], [B], [A]]` — load C first, then B, then A.
Diamonds (`A → C, B → C`) layer as `[[C], [A, B]]`. Cycles (shouldn't happen for real env DAGs) fall back to a single layer defensively, with no infinite loop.
Verification
Not in this PR
Removing the hardcoded `teambit.harmony/envs/core-aspect-env` special case in `buildLoadGroups` — D-001 noted it should become unnecessary, but verifying that on bit7 itself requires running the harness on a 300-component workspace, which OOMs at default heap. Separate PR after the harness sampling story is solved.