Skip to content

Stabilize measurement reliability covariance scaling#4374

Merged
FlorianPfaff merged 2 commits into
mainfrom
agent/stabilize-measurement-reliability-scale-20260714
Jul 14, 2026
Merged

Stabilize measurement reliability covariance scaling#4374
FlorianPfaff merged 2 commits into
mainfrom
agent/stabilize-measurement-reliability-scale-20260714

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

  • evaluate reliability covariance-scale overflow in log space before exponentiation
  • apply a finite max_scale cap before the power operation can underflow to zero
  • raise a clear ValueError when an uncapped scale cannot be represented as a finite float
  • add regressions for both capped and uncapped extreme exponents

Bug

reliability_to_covariance_scale() computed

1.0 / max(reliability, floor) ** exponent

before applying max_scale. For large but finite exponents, the denominator can underflow to zero. The public helper then either returned inf or raised ZeroDivisionError; an explicit finite max_scale could not protect the computation because it was applied too late.

Fix

Compute the logarithm of the requested scale first. If it reaches a supplied finite cap, return that cap without evaluating the unstable power. If an uncapped result exceeds the largest finite float, raise a descriptive ValueError rather than leaking an incidental arithmetic exception or infinity.

Normal representable inputs still use the existing power expression, preserving current results and rounding behavior.

Validation

  • reproduced the existing ZeroDivisionError with reliability=0.5 and exponent=1e6
  • verified the patched calculation returns 7.0 when max_scale=7.0
  • verified the uncapped case raises ValueError containing covariance scale overflows
  • branch is two commits ahead of and zero commits behind current main
  • diff is limited to one production function and one focused regression file

@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 21.33s
✅ JSON prettier 7 0 0 0 1.55s
✅ JSON v8r 7 0 0 3.41s
✅ MARKDOWN markdownlint 68 0 0 0 1.89s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.78s
✅ PYTHON black 1490 183 0 0 85.42s
✅ PYTHON isort 1490 328 0 0 2.47s
✅ REPOSITORY betterleaks yes no no 2.34s
✅ REPOSITORY checkov yes no no 50.14s
✅ REPOSITORY gitleaks yes no no 13.59s
✅ REPOSITORY git_diff yes no no 0.38s
✅ REPOSITORY secretlint yes no no 58.89s
✅ REPOSITORY syft yes no no 6.51s
✅ REPOSITORY trivy-sbom yes no no 5.61s
✅ REPOSITORY trufflehog yes no no 30.87s
✅ YAML prettier 11 0 0 0 0.67s
✅ YAML v8r 11 0 0 10.37s
✅ YAML yamllint 11 0 0 0.64s

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:12
@FlorianPfaff FlorianPfaff merged commit ab5c5cb 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