Skip to content

feat(monorepo): detect dependency cycles and release in topological order#618

Merged
BryanFRD merged 1 commit into
mainfrom
feat/monorepo-cycle-detection
Jun 26, 2026
Merged

feat(monorepo): detect dependency cycles and release in topological order#618
BryanFRD merged 1 commit into
mainfrom
feat/monorepo-cycle-detection

Conversation

@BryanFRD

Copy link
Copy Markdown
Contributor

Closes #418.

dependsOn was handled as a flat list with no cycle behaviour: the dependency cascade simply capped its fixed-point loop at packages.len() rounds to avoid spinning forever, so a cyclic config silently produced an incorrect/partial result instead of a clear error.

This adds a single graph pass (Tarjan SCC) over the package dependency graph, run at the very top of run_release_logic — before any git work, lock, or write — so it covers both ferrflow check and ferrflow release and can never leave a partial release behind:

  • Cycle detection. Any strongly-connected component with more than one member (or a package depending on itself) is a cycle. The error names the loop, e.g. cycle detected: api → web → api, and carries error code E8003 (MONOREPO_DEPENDENCY_CYCLE).
  • Topological ordering. When the graph is acyclic, the same pass yields a dependencies-first release order (a dependency is released before the packages that depend on it). Packages without any dependsOn keep their config order, so existing behaviour is unchanged for the common case.

Tests

  • graph.rs unit tests: identity order with no deps, dependency-before-dependent, linear chain, unknown-dependency names ignored, two-package cycle, self-dependency, three-package cycle path rendering.
  • Integration test (cycle_detection): two packages depending on each other → a real (non-dry-run) release aborts with E8003, the message names both packages, no panic, and both version files are left untouched (no partial release).

Full suite green (858 + 668 tests), cargo fmt + clippy clean.

Docs

In-repo docs/errors.md gains the E8003 entry. The public docs-site monorepo page + errors reference are updated in a companion FerrFlow-Cloud PR (cross-repo changes are kept separate).

@BryanFRD BryanFRD enabled auto-merge (squash) June 26, 2026 18:09
@BryanFRD BryanFRD merged commit 1fd18ec into main Jun 26, 2026
39 checks passed
@BryanFRD BryanFRD deleted the feat/monorepo-cycle-detection branch June 26, 2026 18:11

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Details
Benchmark suite Current: 042a7e6 Previous: 0b5fe57 Ratio
full_check_flow/100_commits 5489553 ns/iter (± 157149)
full_check_flow/1000_commits 51558258 ns/iter (± 644307)

This comment was automatically generated by workflow using github-action-benchmark.

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.

feat(monorepo): topological release ordering with cycle detection error

1 participant