Skip to content

fix: use float64 for intermediate cost calculations - #2887

Merged
ysmolski merged 2 commits into
mainfrom
yury/eng-9582-per-level-int-rounding-is-amplified-by-the-outer-board
May 25, 2026
Merged

fix: use float64 for intermediate cost calculations#2887
ysmolski merged 2 commits into
mainfrom
yury/eng-9582-per-level-int-rounding-is-amplified-by-the-outer-board

Conversation

@ysmolski

@ysmolski ysmolski commented May 25, 2026

Copy link
Copy Markdown
Contributor

Previously we were rounding cost at every level of cost calculation.
That lead to accumulated drift, especially on the deeply nested
queries.

Round the cost on the return (final node) instead of intermediate nodes.

Summary by CodeRabbit

  • Chores

    • Updated GraphQL tools dependency to a newer release across router modules.
  • Tests

    • Adjusted operation cost calculation test assertions to reflect updated expected values and multi-query scenarios.

Review Change Stack

@ysmolski
ysmolski requested a review from a team as a code owner May 25, 2026 07:13

@claude claude 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.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 63ce8f76-9226-4202-babb-6bc4319cc6e7

📥 Commits

Reviewing files that changed from the base of the PR and between b59dab5 and 327c829.

⛔ 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 (2)
  • router-tests/go.mod
  • router/go.mod

Walkthrough

This PR updates the graphql-go-tools/v2 dependency in both router and router-tests modules and adjusts cost calculation assertions in security tests to match the updated dependency behavior.

Changes

Dependency Update and Cost Test Adjustments

Layer / File(s) Summary
Dependency version updates
router/go.mod, router-tests/go.mod
Updated github.com/wundergraph/graphql-go-tools/v2 from v2.4.0 to v2.4.1-0.20260522152022-e2d6da4c8e50 in both modules' require blocks.
Cost calculation test expectations
router-tests/security/costs_test.go
Updated core.CostActualHeader expected values in nested list, multi-subgraph weight planning (Query 1 and Query 2), and cache consistency tests; adjusted formatting in a test message.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • wundergraph/cosmo#2801: The main PR updates router-tests to assert dot-path slicingArguments behavior (e.g., input.pagination.first) and bumps graphql-go-tools accordingly, which directly aligns with the retrieved PR’s implementation of dot-path parsing/validation for @listSize slicingArguments in composition.
  • wundergraph/cosmo#2882: Both PRs update router-tests/security/costs_test.go expectations around operation cost calculation (including scenarios affected by remapped variables), alongside router-tests/go.mod/router/go.mod bumps for graphql-go-tools/v2.
  • wundergraph/cosmo#2716: The main PR only updates router-tests/security/costs_test.go cost-control header expectations (e.g., core.CostActualHeader/cache miss-hit assertions), which overlaps directly with the retrieved PR’s input-object cost-control test assertion changes in the same file.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: updating a dependency that implements float64 for intermediate cost calculations, with test expectations updated to reflect the corrected behavior.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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

@github-actions

github-actions Bot commented May 25, 2026

Copy link
Copy Markdown

Router image scan passed

✅ No security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-b01649ff41735d7de76424c491a9ab253ec256ab

@codecov

codecov Bot commented May 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.24%. Comparing base (d211459) to head (327c829).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2887   +/-   ##
=======================================
  Coverage   66.24%   66.24%           
=======================================
  Files         258      258           
  Lines       27056    27056           
=======================================
  Hits        17923    17923           
+ Misses       7720     7719    -1     
- Partials     1413     1414    +1     

see 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ysmolski
ysmolski merged commit 33f4016 into main May 25, 2026
54 of 55 checks passed
@ysmolski
ysmolski deleted the yury/eng-9582-per-level-int-rounding-is-amplified-by-the-outer-board branch May 25, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants