Skip to content

feat: Add circular package dependency detection to boundaries#12567

Merged
anthonyshew merged 2 commits intomainfrom
shew/circular-package-boundaries
Apr 6, 2026
Merged

feat: Add circular package dependency detection to boundaries#12567
anthonyshew merged 2 commits intomainfrom
shew/circular-package-boundaries

Conversation

@anthonyshew
Copy link
Copy Markdown
Contributor

Summary

  • Adds a CircularDependency rule to turbo boundaries that detects circular package dependency chains using Tarjan's SCC algorithm. Previously, cycles were only logged as tracing::warn!() during package graph validation — now they surface as actionable diagnostics.
  • Adds a vscode module exception to the NotTypeOnlyImport rule (matching existing bun builtin pattern), since VS Code extensions use @types/vscode for type-checking but vscode is a runtime-provided module.
  • Fixes progress bar count mismatch where root package was included in the total but skipped during checking (24 vs 23).

How to test

Build and run turbo boundaries against a monorepo with circular package dependencies:

cargo build -p turbo
./target/debug/turbo boundaries

Or run the new tests directly:

cargo test -p turborepo-repository -- test_find_cycles
cargo test -p turborepo-boundaries -- test_is_vscode_module vscode_import_not_flagged
cargo test -p turbo -- test_boundaries_circular

Adds a new CircularDependency rule to turbo boundaries that detects
circular package dependency chains using Tarjan's SCC algorithm.
Previously, cycles were only logged as warnings during package graph
validation — now they surface as actionable diagnostics.

Also adds a vscode module exception to the NotTypeOnlyImport rule
(matching existing bun builtin pattern) and fixes a progress bar
count mismatch where root package was included in the total but
skipped during checking.
@anthonyshew anthonyshew requested a review from a team as a code owner April 6, 2026 16:12
@anthonyshew anthonyshew requested review from tknickman and removed request for a team April 6, 2026 16:12
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
examples-basic-web Ready Ready Preview, Comment, Open in v0 Apr 6, 2026 4:29pm
examples-designsystem-docs Building Building Preview, Comment, Open in v0 Apr 6, 2026 4:29pm
examples-gatsby-web Ready Ready Preview, Comment, Open in v0 Apr 6, 2026 4:29pm
examples-kitchensink-blog Ready Ready Preview, Comment, Open in v0 Apr 6, 2026 4:29pm
examples-nonmonorepo Ready Ready Preview, Comment, Open in v0 Apr 6, 2026 4:29pm
examples-svelte-web Ready Ready Preview, Comment, Open in v0 Apr 6, 2026 4:29pm
examples-tailwind-web Ready Ready Preview, Comment, Open in v0 Apr 6, 2026 4:29pm
examples-vite-web Ready Ready Preview, Comment, Open in v0 Apr 6, 2026 4:29pm
turbo-site Ready Ready Preview, Comment, Open in v0 Apr 6, 2026 4:29pm
turborepo-agents Ready Ready Preview, Comment, Open in v0 Apr 6, 2026 4:29pm

trace_cycle_path was non-deterministic because it started from
HashSet::iter().next() (random seed) and followed arbitrary edges.
On Ubuntu CI, this caused test_find_cycles_complex_scc to trace
only 3 of 4 SCC members.

Fix: start from min(NodeIndex) and always pick the smallest
NodeIndex neighbor. Relax the complex SCC test to accept that a
traced path through a multi-cycle SCC may cover a subset of
members.
@anthonyshew anthonyshew enabled auto-merge (squash) April 6, 2026 16:29
@anthonyshew anthonyshew merged commit 217d486 into main Apr 6, 2026
58 checks passed
@anthonyshew anthonyshew deleted the shew/circular-package-boundaries branch April 6, 2026 16:39
github-actions Bot added a commit that referenced this pull request Apr 6, 2026
## Release v2.9.5-canary.3

Versioned docs: https://v2-9-5-canary-3.turborepo.dev

### Changes

- release(turborepo): 2.9.5-canary.2 (#12566) (`8479f02`)
- feat: Add circular package dependency detection to boundaries (#12567)
(`217d486`)
- perf: Increase remote cache upload chunk size from 8KB to 256KB
(#12568) (`374f7a7`)

Co-authored-by: Turbobot <turbobot@vercel.com>
github-actions Bot added a commit that referenced this pull request Apr 7, 2026
## Release v2.9.5

Versioned docs: https://v2-9-5.turborepo.dev

### Changes

- release(turborepo): 2.9.4 (#12559) (`20dfb78`)
- feat: Replace package manager commands in scaffolded README files
(#6747) (`8f6f012`)
- release(turborepo): 2.9.5-canary.1 (#12564) (`891188e`)
- chore: Remove top issues Slack notification (#12565) (`49e484f`)
- release(turborepo): 2.9.5-canary.2 (#12566) (`8479f02`)
- feat: Add circular package dependency detection to boundaries (#12567)
(`217d486`)
- perf: Increase remote cache upload chunk size from 8KB to 256KB
(#12568) (`374f7a7`)
- release(turborepo): 2.9.5-canary.3 (#12570) (`0387bad`)
- perf: Parallelize `boundaries` checking with Rayon and cache DFS
traversals (#12569) (`7830df4`)
- release(turborepo): 2.9.5-canary.4 (#12571) (`53eb059`)
- fix: Normalize CRLF line endings in file hashing to match git (#12572)
(`1403c9e`)
- release(turborepo): 2.9.5-canary.5 (#12574) (`f0e18d2`)
- fix: Suppress telemetry alert when running on Vercel (#12576)
(`ecb1040`)

---------

Co-authored-by: Turbobot <turbobot@vercel.com>
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