Skip to content

refactor(workspace): make env-DAG layering recursive#10350

Merged
davidfirst merged 1 commit intorefactor/component-loading-v2-take-2from
refactor/component-loader-recursive-env-sort
May 7, 2026
Merged

refactor(workspace): make env-DAG layering recursive#10350
davidfirst merged 1 commit intorefactor/component-loading-v2-take-2from
refactor/component-loader-recursive-env-sort

Conversation

@davidfirst
Copy link
Copy Markdown
Member

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

  • Unit tests extended: 8 cases (added recursive chain, diamond, cycle-detection)
  • e2e contract tests: all 21 scenarios pass
  • Diff harness e2e: V1-vs-V1 produces zero diffs

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.

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.
@davidfirst davidfirst merged commit 36e4734 into refactor/component-loading-v2-take-2 May 7, 2026
12 checks passed
@davidfirst davidfirst deleted the refactor/component-loader-recursive-env-sort branch May 7, 2026 19:53
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant