Skip to content

Conversation

@devsergiy
Copy link
Member

@devsergiy devsergiy commented Oct 24, 2025

Summary by CodeRabbit

  • New Features

    • Added public entry points for operation planning with improved error messages and stability.
    • Added benchmarking and profiling tasks to measure planning performance.
  • Tests

    • Added integration-style tests and benchmarks for the planning flow.
  • Chores

    • Updated prerelease dependency versions and added example benchmark config and ignore patterns.
  • Documentation

    • Added a README describing how to run the planning benchmarks and profiles.

Checklist

  • I have discussed my proposed changes in an issue and have received approval to proceed.
  • I have followed the coding standards of the project.
  • Tests or benchmarks have been added or updated.
  • Documentation has been updated on https://github.com/wundergraph/cosmo-docs.
  • I have read the Contributors Guide.

@coderabbitai
Copy link

coderabbitai bot commented Oct 24, 2025

Walkthrough

Updates dependencies (graphql-go-tools and cosmo modules), refactors planner flow by splitting parsing/preparation and introducing exported PlanPreparedOperation/PrepareOperation/ParseAndPrepareOperation helpers, and adds a planning benchmark suite (Taskfile, example config, tests, .gitignore).

Changes

Cohort / File(s) Summary
Dependency updates
router-tests/go.mod, router/go.mod
Bumped github.com/wundergraph/graphql-go-tools/v2 to v2.0.0-rc.235 and updated github.com/wundergraph/cosmo/* module versions; adjusted a replace directive line formatting.
Planner refactor & API changes
router/core/plan_generator.go, router/core/plan_generator_test.go
Reworked planning flow: added ParseAndPrepareOperation(operationFilePath string), PrepareOperation(operation *ast.Document), and exported PlanPreparedOperation(operation *ast.Document); PlanOperation now delegates to these helpers; updated error messages and panic recovery; tests updated to call PlanPreparedOperation.
Benchmarking tooling
router/internal/planningbenchmark/Taskfile.yaml, router/internal/planningbenchmark/benchmark_config.json.example, router/internal/planningbenchmark/README.md
Added Taskfile tasks for running benchmarks and profiles, example JSON config with executionConfigPath and operationPath, and README with usage instructions.
Benchmark tests & ignores
router/internal/planningbenchmark/benchmark_test.go, router/internal/planningbenchmark/.gitignore
Added BenchmarkConfig, TestPlanning, and BenchmarkPlanning to exercise the planning flow; added .gitignore patterns *.json, *.txt, *.out, *.test.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review router/core/plan_generator.go for correctness of parsing → normalization → validation → planning sequence and error wrapping.
  • Verify tests in benchmark_test.go are file-system safe and correctly load benchmark_config.json.
  • Confirm dependency bump/replace-change does not introduce API mismatches elsewhere.

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "fix: improve query planning time" is related to the changeset, which includes refactoring of the plan_generator.go to introduce new orchestrating methods (ParseAndPrepareOperation and PlanPreparedOperation) that separate concerns in the planning flow, along with comprehensive benchmarking infrastructure (Taskfile.yaml, benchmark_test.go, README.md). The title conveys the primary objective of these changes—to improve query planning performance and measurement. While the title doesn't explicitly detail that benchmarking tools are being added or that the planning flow is being refactored, it clearly communicates the intended outcome and would allow a developer scanning PR history to understand the general purpose of the change.
✨ Finishing touches
  • 📝 Generate docstrings

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

@github-actions
Copy link

github-actions bot commented Oct 24, 2025

❌ Internal Query Planner CI checks failed

The Internal Query Planner CI checks failed in the celestial repository, and this is going to stop the merge of this PR.
If you are part of the WunderGraph organization, you can see the PR with more details.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b3e64e and 6f33b4a.

⛔ Files ignored due to path filters (2)
  • router-tests/go.sum is excluded by !**/*.sum
  • router/go.sum is excluded by !**/*.sum
📒 Files selected for processing (7)
  • router-tests/go.mod (1 hunks)
  • router/core/plan_generator.go (1 hunks)
  • router/go.mod (1 hunks)
  • router/internal/planningbenchmark/.gitignore (1 hunks)
  • router/internal/planningbenchmark/Taskfile.yaml (1 hunks)
  • router/internal/planningbenchmark/benchmark_config.json.example (1 hunks)
  • router/internal/planningbenchmark/benchmark_test.go (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-20T22:13:25.222Z
Learnt from: StarpTech
PR: wundergraph/cosmo#2157
File: router-tests/go.mod:16-16
Timestamp: 2025-08-20T22:13:25.222Z
Learning: github.com/mark3labs/mcp-go v0.38.0 has regressions and should not be used in the wundergraph/cosmo project. v0.36.0 is the stable version that should be used across router-tests and other modules.

Applied to files:

  • router-tests/go.mod
🧬 Code graph analysis (2)
router/core/plan_generator.go (1)
router/pkg/pubsub/datasource/planner.go (1)
  • Planner (14-21)
router/internal/planningbenchmark/benchmark_test.go (1)
router/core/plan_generator.go (1)
  • NewPlanGenerator (270-286)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: build-router
  • GitHub Check: build_push_image (nonroot)
  • GitHub Check: build_test
  • GitHub Check: integration_test (./events)
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: integration_test (./telemetry)
  • GitHub Check: build_push_image
  • GitHub Check: image_scan (nonroot)
  • GitHub Check: image_scan
  • GitHub Check: build_test
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)

@devsergiy devsergiy requested a review from Noroth October 29, 2025 13:35
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
router/internal/planningbenchmark/README.md (1)

23-23: Minor: Inconsistent Taskfile reference.

Line 23 references Taskfile.yml but the actual file appears to be Taskfile.yaml (based on the context). Ensure consistency in documentation.

router/core/plan_generator.go (1)

113-129: PrepareOperation provides clear preparation phase.

The function appropriately separates normalization and validation into a discrete preparation step, enabling benchmarking of this phase independently.

Note that PrepareOperation modifies the operation document in-place (via normalizeOperation) and returns the same pointer. While this is consistent with typical AST manipulation patterns, consider adding a comment to clarify this behavior for future maintainers.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ab5bd1c and f12104e.

📒 Files selected for processing (4)
  • router/core/plan_generator.go (5 hunks)
  • router/core/plan_generator_test.go (1 hunks)
  • router/internal/planningbenchmark/README.md (1 hunks)
  • router/internal/planningbenchmark/benchmark_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • router/internal/planningbenchmark/benchmark_test.go
🧰 Additional context used
🪛 LanguageTool
router/internal/planningbenchmark/README.md

[style] ~24-~24: The double modal “needed Run” is nonstandard (only accepted in certain dialects). Consider “to be Run”.
Context: ...ningbenchmark/Taskfile.ymlif needed - Runtask bench-cpufromrouter/internal/...

(NEEDS_FIXED)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: build-router
  • GitHub Check: Analyze (go)
  • GitHub Check: build_test
  • GitHub Check: image_scan (nonroot)
  • GitHub Check: image_scan
  • GitHub Check: build_push_image (nonroot)
  • GitHub Check: build_push_image
  • GitHub Check: integration_test (./events)
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (7)
router/internal/planningbenchmark/README.md (1)

1-27: Documentation is clear and helpful.

The README provides a good foundation for using the planning benchmark feature. The prerequisites and running instructions are straightforward.

Note: The LanguageTool style hint about "if needed - Run" is a false positive—the markdown bullet formatting is correct.

router/core/plan_generator_test.go (1)

32-32: Test correctly updated to use the new API.

The change from the unexported planOperation to the exported PlanPreparedOperation aligns with the refactoring in plan_generator.go. The test continues to validate panic handling and error propagation correctly.

router/core/plan_generator.go (5)

77-101: Well-structured refactoring with improved error messaging.

The delegation to ParseAndPrepareOperation and PlanPreparedOperation creates a cleaner separation of concerns and enables granular benchmarking of individual planning phases. The error message improvement on line 100 ("invalid outputFormat specified") is more accurate than the previous version.


103-111: Clear API for parse and prepare workflow.

This function provides a convenient entry point for parsing an operation from a file and preparing it for planning. The error wrapping with PlannerOperationValidationError is consistent with the error handling strategy.


162-194: Core planning function is well-structured.

PlanPreparedOperation correctly assumes the operation is normalized and validated, performs planning with appropriate error handling and panic recovery, and post-processes the plan. The switch statement properly handles both synchronous and subscription response plans.


404-404: Reasonable TODO for future enhancement.

The TODO about assigning a static operation name for single anonymous operations is a valid future improvement. Currently, anonymous operations will cause PrepareOperation to fail (line 116-118), which appears to be intentional behavior for now.


113-129: Addressing past review comments: wrapper functions serve the new API design.

Previous review comments suggested inlining the normalization and validation calls. However, the current refactoring with PrepareOperation, ParseAndPrepareOperation, and PlanPreparedOperation as exported functions serves a clear purpose: enabling granular control and benchmarking of individual planning phases. This design is more flexible and appropriate for the PR's goal of improving query planning time measurement.

@devsergiy devsergiy merged commit f9f15e3 into main Oct 29, 2025
37 of 38 checks passed
@devsergiy devsergiy deleted the sergiy/eng-8285-improve-query-planning-time branch October 29, 2025 14:34
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.

3 participants