Skip to content

Stabilize adaptive process-noise source weighting#4380

Merged
FlorianPfaff merged 2 commits into
mainfrom
agent/stabilize-adaptive-source-weights-20260714
Jul 14, 2026
Merged

Stabilize adaptive process-noise source weighting#4380
FlorianPfaff merged 2 commits into
mainfrom
agent/stabilize-adaptive-source-weights-20260714

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

  • normalize positive source weights after scaling by their largest value
  • preserve the intended weighted NIS ratio when direct weighted sums would overflow
  • validate source-weight scalars through the existing nonnegative-finite scalar path
  • add a focused regression using maximum finite floating-point weights

Root cause

RollingNISProcessNoiseAdapter.ratio() accumulated raw weighted sums:

numerator += weight * ratio
denominator += weight

Individually finite source weights can still overflow both accumulators. For example, weights [max_float, max_float / 2] have a valid 2:1 ratio, but the direct calculation produces inf / inf, so the aggregate becomes NaN and downstream adaptive scaling rejects it.

Fix

Collect positive validated weights, divide them by their largest entry, normalize the scaled weights to unit mass, and compute the weighted ratio from those normalized weights. This preserves relative weighting without creating oversized intermediate sums.

Validation

  • reproduced the pre-fix result as inf / inf -> NaN
  • verified the patched 2:1 weighted ratio is 7/3
  • verified the corresponding adaptive scale remains finite
  • PYTHONPATH=. python -m pytest -q test_weight_stability.py (1 passed)
  • Python compilation passed for the modified module and regression test
  • branch is two commits ahead of main, zero behind; only the adapter and focused regression are changed

@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 17.85s
✅ JSON prettier 7 0 0 0 0.8s
✅ JSON v8r 7 0 0 3.09s
✅ MARKDOWN markdownlint 68 0 0 0 1.35s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.42s
✅ PYTHON black 1490 183 0 0 68.89s
✅ PYTHON isort 1490 328 0 0 2.5s
✅ REPOSITORY betterleaks yes no no 2.02s
✅ REPOSITORY checkov yes no no 42.36s
✅ REPOSITORY gitleaks yes no no 10.61s
✅ REPOSITORY git_diff yes no no 0.32s
✅ REPOSITORY secretlint yes no no 46.92s
✅ REPOSITORY syft yes no no 4.99s
✅ REPOSITORY trivy-sbom yes no no 4.91s
✅ REPOSITORY trufflehog yes no no 24.38s
✅ YAML prettier 11 0 0 0 0.47s
✅ YAML v8r 11 0 0 8.19s
✅ YAML yamllint 11 0 0 0.49s

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:14
@FlorianPfaff FlorianPfaff merged commit ba8032d 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