Skip to content

fix(graph): use round-based topological sort in sortNodeIDsWithPriority#235

Merged
skevetter merged 2 commits into
mainfrom
fix/devsy-031-round-based-topo-sort
May 6, 2026
Merged

fix(graph): use round-based topological sort in sortNodeIDsWithPriority#235
skevetter merged 2 commits into
mainfrom
fix/devsy-031-round-based-topo-sort

Conversation

@skevetter

@skevetter skevetter commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Rewrites sortNodeIDsWithPriority() to use the same round-based collection pattern as sortNodeIDs(). The previous single-queue Kahn's algorithm processed one node at a time, which could emit nodes from later topological levels before all same-level siblings were emitted. The fix collects all zero-in-degree nodes per round, sorts them by priority within the round, and emits the entire round before advancing — matching the spec-required behavior for feature installation ordering.

Spec Reference

The devcontainer Features specification describes how features must be installed in dependency order using a round-based topological sort. Specifically, installsAfter is used to declare explicit ordering constraints between features, and compliant implementations must resolve these dependencies such that all features in a given topological level are processed before advancing to the next. This PR aligns sortNodeIDsWithPriority() with that required round-based behavior.

@netlify

netlify Bot commented May 5, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 8c8018d
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/69fae8be208f500008dca831

@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@skevetter has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 36 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bf31ee5b-87ec-4bf5-8d71-ef24573a3145

📥 Commits

Reviewing files that changed from the base of the PR and between a640dba and 8c8018d.

📒 Files selected for processing (2)
  • pkg/devcontainer/graph/graph.go
  • pkg/devcontainer/graph/graph_test.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the size/m label May 5, 2026
@skevetter
skevetter marked this pull request as ready for review May 6, 2026 00:50
@skevetter
skevetter enabled auto-merge (squash) May 6, 2026 00:50
@skevetter
skevetter force-pushed the fix/devsy-031-round-based-topo-sort branch from 2b5d280 to d35cf3e Compare May 6, 2026 06:02
skevetter added 2 commits May 6, 2026 02:07
The single-queue Kahn's algorithm processed one node at a time, which
could interleave nodes from different topological levels. This aligns
sortNodeIDsWithPriority with the round-based pattern already used by
sortNodeIDs — collecting all zero-in-degree nodes per round, sorting
within the round by priority, and emitting the full round before
advancing.
Adds a test case where the old single-queue algorithm would produce a
different (incorrect) ordering by promoting C ahead of B when A frees C
mid-queue. The round-based approach correctly emits [A, B] in round 1
and [C] in round 2.
@skevetter
skevetter force-pushed the fix/devsy-031-round-based-topo-sort branch from d35cf3e to 8c8018d Compare May 6, 2026 07:07
@skevetter
skevetter merged commit b3d0008 into main May 6, 2026
54 checks passed
@skevetter
skevetter deleted the fix/devsy-031-round-based-topo-sort branch May 6, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant