refactor: improve costs code layering and readability - #1526
Conversation
After many changes I have accumulated some crufty code in costs. This PR tries to add a couple of abstractions and split big methods into smaller and more logical.
There was a problem hiding this comment.
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.
📝 WalkthroughWalkthroughRefactor bundles cost computation inputs into an internal costInput and thread it through CostTreeNode.cost, costsAndMultiplier, childrenCost, and debug printing; adjust abstract-type aggregation and list-size multiplier behavior to branch between estimation and actual modes using costInput data. ChangesCost calculation refactor (costInput)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@v2/pkg/engine/plan/cost.go`:
- Line 995: The debug output currently only prints the first root child via
c.tree.children[0].debugPrint(...), missing other top-level fields; update the
code in cost.go to iterate over c.tree.children (e.g., for _, child := range
c.tree.children { child.debugPrint(&sb, input, 0) }) so every root child is
printed, preserving the same arguments and ordering; ensure you remove the
hardcoded index usage and handle the empty children case if needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e20ac453-c63c-489e-a922-fc32e7db6311
📒 Files selected for processing (1)
v2/pkg/engine/plan/cost.go
After many changes I have accumulated some crufty code in costs. This PR tries to add a couple of abstractions and split big methods into smaller and more logical.