Remove redundant weight parameter from RuleBuilder.Dimension method - weights now auto-populated from dimension config#19
Merged
massiveio merged 7 commits intoAug 29, 2025
Conversation
…omatic weight population Co-authored-by: cloorc <13597105+cloorc@users.noreply.github.com>
Co-authored-by: cloorc <13597105+cloorc@users.noreply.github.com>
Co-authored-by: cloorc <13597105+cloorc@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Weight in Dimension method of RuleBuilder is not necessary, cause dimension config contains weight already.
Remove redundant weight parameter from RuleBuilder.Dimension method - weights now auto-populated from dimension config
Aug 28, 2025
Signed-off-by: Cloorc <wittcnezh@foxmail.com>
Signed-off-by: Cloorc <wittcnezh@foxmail.com>
Signed-off-by: Cloorc <wittcnezh@foxmail.com>
massiveio
approved these changes
Aug 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
RuleBuilder.Dimension()method required users to manually specify weights, even though dimension configurations (DimensionConfig) already contained weight values. This created redundancy and potential for inconsistency between configured weights and weights specified during rule creation.Solution
Modified the
RuleBuilder.Dimension()method to automatically populate weights from dimension configurations during rule addition, eliminating the need for manual weight specification.Key Changes
API Simplification
Dimension(name, value, matchType)methodAddRule()andUpdateRule()operationsDimensionConfigif configured1.0for unconfigured dimensions (flexible mode compatibility)DimensionWithWeight()methodBackward Compatibility
DimensionWithWeight()method for cases requiring explicit weight overridesAddSimpleRule,AddAnyRule) to use appropriate APIsWeight Population Logic
Validation
Comprehensive Test Coverage
Working Demo
Created
example/weight_removal_demodemonstrating:DimensionWithWeight()Benefits
DimensionWithWeight()Migration Path
Dimension(name, value, matchType)- weights auto-populatedDimensionWithWeight(name, value, matchType, weight)This change addresses the core issue raised: "Weight in Dimension method of RuleBuilder is not necessary, cause dimension config contains weight already."
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.