Skip to content

Skip unused candidate-pruning penalty escalation#4392

Merged
FlorianPfaff merged 2 commits into
mainfrom
agent/skip-unused-pruning-penalty
Jul 14, 2026
Merged

Skip unused candidate-pruning penalty escalation#4392
FlorianPfaff merged 2 commits into
mainfrom
agent/skip-unused-pruning-penalty

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

  • compute the candidate mask before escalating the replacement cost
  • return a copy immediately when every matrix entry is retained
  • add a regression for an unpruned matrix containing the largest finite float

Bug

prune_pairwise_cost_matrix() always called _effective_large_cost() before checking whether the candidate mask actually pruned anything. For a retained cost equal to np.finfo(float).max, _effective_large_cost() attempted np.nextafter(max_float, np.inf), obtained infinity, and raised ValueError even though no replacement cost was needed.

This made a valid no-op pruning configuration fail solely because the input occupied the upper end of the floating-point range.

Fix

Build the mask first. When all entries are retained, return an owning copy of the validated costs and skip replacement-cost escalation. The existing behavior is unchanged whenever at least one entry must be replaced.

Validation

  • isolated regression reproduced the pre-fix failure and passes with the guard
  • verified an actually pruned max_float entry still raises because no larger finite replacement exists
  • python -m py_compile passes for the modified module and regression test
  • full multi-environment validation is delegated to GitHub Actions

@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 25.54s
✅ JSON prettier 7 0 0 0 0.87s
✅ JSON v8r 7 0 0 2.94s
✅ MARKDOWN markdownlint 68 0 0 0 2.13s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.38s
✅ PYTHON black 1490 182 0 0 96.75s
✅ PYTHON isort 1490 327 0 0 2.65s
✅ REPOSITORY betterleaks yes no no 2.52s
✅ REPOSITORY checkov yes no no 55.68s
✅ REPOSITORY gitleaks yes no no 15.1s
✅ REPOSITORY git_diff yes no no 0.23s
✅ REPOSITORY secretlint yes no no 63.51s
✅ REPOSITORY syft yes no no 5.56s
✅ REPOSITORY trivy-sbom yes no no 6.71s
✅ REPOSITORY trufflehog yes no no 31.82s
✅ YAML prettier 11 0 0 0 0.66s
✅ YAML v8r 11 0 0 11.25s
✅ YAML yamllint 11 0 0 0.63s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.6.0 --custom-flavor-setup --custom-flavor-linters PYTHON_BLACK,PYTHON_ISORT,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GITLEAKS,REPOSITORY_BETTERLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@FlorianPfaff FlorianPfaff marked this pull request as ready for review July 14, 2026 20:19
@FlorianPfaff FlorianPfaff merged commit 929688d into main Jul 14, 2026
26 checks passed
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.

1 participant