Skip to content

feat: implement topological dependency planner#14

Merged
bella-247 merged 2 commits into
devfrom
improve/planner-layer
Jul 4, 2026
Merged

feat: implement topological dependency planner#14
bella-247 merged 2 commits into
devfrom
improve/planner-layer

Conversation

@bella-247

Copy link
Copy Markdown
Owner

This pull request introduces new logic for handling table dependency resolution in the presence of foreign key cycles and blocked tables in the planner package. The changes implement robust algorithms (including Tarjan's strongly connected components and Kahn's topological sort) to analyze and resolve cycles, identify blocked tables, and determine a valid generation order for tables based on their dependencies.

The most important changes are:

Cycle Detection and Resolution:

  • Added cycles.go with functions to detect strongly connected components (cycles) using Tarjan's algorithm, determine true cycles, and resolve them by identifying nullable foreign key breakpoints and producing table generation plans that defer certain foreign keys when necessary.

Topological Sorting and Blocked Table Handling:

  • Added topsort.go implementing Kahn’s algorithm for topological sorting of tables by their foreign key dependencies, and for identifying tables that are blocked or involved in cycles.
  • Added blocked.go to process tables that are blocked (not in a true cycle but dependent on unresolved cycles), allowing them to be generated once their dependencies are resolved, and reporting errors if any remain unresolvable.## What does this PR do?

Why is it needed?

Closes #

How was it tested?

Does it change any existing behavior?

Checklist

  • Tests added or updated
  • make test passes (go test ./... -race)
  • make lint passes (golangci-lint run ./...)
  • No cross-stage imports (parser doesn't import generator, etc.)
  • No time.Now() or unseeded randomness in the generation pipeline
  • Error messages follow the format in SRS §12.2
  • Exported functions have doc comments
  • Golden files updated if output format changed (make test-golden UPDATE=true)

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: ab94e636-3235-4ce3-88cd-eacb3bf9a910

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

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

@bella-247 bella-247 merged commit 8baa455 into dev Jul 4, 2026
1 check passed
@bella-247 bella-247 deleted the improve/planner-layer branch July 4, 2026 02:15
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