Skip to content

Make final score penalties configurable#718

Merged
adamdecaf merged 3 commits intomoov-io:masterfrom
pvpacheco:configurable-final-score-multipliers
Mar 9, 2026
Merged

Make final score penalties configurable#718
adamdecaf merged 3 commits intomoov-io:masterfrom
pvpacheco:configurable-final-score-multipliers

Conversation

@pvpacheco
Copy link
Contributor

Adds env vars to configure final-score penalty multipliers in Watchman search.

This change makes these final aggregation penalties configurable:

  • FINAL_SCORE_LOW_COVERAGE_MULTIPLIER
  • FINAL_SCORE_MIN_REQUIRED_FIELDS_MULTIPLIER
  • FINAL_SCORE_NAME_ONLY_MULTIPLIER

These apply in the final entity score calculation in pkg/search/similarity.go. They do not change the underlying Jaro-Winkler or token matching algorithms.

Why

For name-only searches, strong or exact matches can still be reduced by hardcoded final-score penalties. Making these multipliers configurable allows operators to tune behavior without modifying code.

Notes

This does not change default behavior. Existing installations keep the same scoring unless the new env vars are set.

@pvpacheco pvpacheco requested a review from adamdecaf as a code owner March 9, 2026 13:06
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the flexibility of the Watchman search functionality by making key final score penalty multipliers configurable via environment variables. This change allows operators to fine-tune search behavior, particularly for scenarios involving low coverage, minimum required fields, and name-only queries, without needing to modify the application's source code. The default behavior remains unchanged unless these new environment variables are explicitly set.

Highlights

  • Configurable Final Score Penalties: Introduced three new environment variables (FINAL_SCORE_LOW_COVERAGE_MULTIPLIER, FINAL_SCORE_MIN_REQUIRED_FIELDS_MULTIPLIER, FINAL_SCORE_NAME_ONLY_MULTIPLIER) to allow operators to configure final score penalty multipliers in Watchman search.
  • Dynamic Penalty Application: Updated the pkg/search/similarity.go file to read these penalty multipliers from environment variables, replacing previously hardcoded values.
  • Documentation Update: Added documentation for the new configurable penalty multipliers in docs/config.md.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • docs/config.md
    • Added documentation for FINAL_SCORE_LOW_COVERAGE_MULTIPLIER.
    • Added documentation for FINAL_SCORE_MIN_REQUIRED_FIELDS_MULTIPLIER.
    • Added documentation for FINAL_SCORE_NAME_ONLY_MULTIPLIER.
  • pkg/search/similarity.go
    • Imported the os and strconv packages to enable environment variable reading and string-to-float conversion.
    • Defined global variables for lowCoveragePenaltyMultiplier, minimumRequiredFieldsPenaltyMultiplier, and nameOnlyPenaltyMultiplier, initialized by reading from environment variables or using default values.
    • Implemented a readFloat helper function to safely parse float values from environment variables.
    • Replaced the hardcoded 0.95 penalty for low coverage with the lowCoveragePenaltyMultiplier variable.
    • Replaced the hardcoded 0.90 penalty for minimum required fields with the minimumRequiredFieldsPenaltyMultiplier variable.
    • Replaced the hardcoded 0.95 penalty for name-only matches with the nameOnlyPenaltyMultiplier variable.
Activity
  • No activity has occurred yet on this pull request.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces configurability for several final score penalty multipliers through environment variables, which is a useful enhancement for operators. The changes include updating the documentation and modifying the scoring logic to use these new variables.

My review focuses on improving the robustness of the configuration loading and the maintainability of the code. Specifically:

  • In pkg/search/similarity.go, I've suggested adding a warning log when an environment variable for a penalty multiplier cannot be parsed as a float. This will prevent silent failures and make debugging easier for operators.
  • I've also pointed out that using package-level variables for configuration can impact testability and suggested a potential refactoring to use a configuration struct.
  • In docs/config.md, I've recommended a minor formatting fix to the documentation table for consistency.

Overall, the changes are good, and with these suggested improvements, the feature will be more robust and maintainable.

pvpacheco and others added 2 commits March 9, 2026 11:21
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@adamdecaf
Copy link
Member

Thanks. Good idea.

@adamdecaf adamdecaf merged commit 3a35681 into moov-io:master Mar 9, 2026
17 of 22 checks passed
@pvpacheco pvpacheco deleted the configurable-final-score-multipliers branch March 9, 2026 17:44
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.

2 participants