Skip to content

Prevent manifold EMA state aliasing - #5244

Open
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/fix-manifold-ema-state-aliasing
Open

Prevent manifold EMA state aliasing#5244
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/fix-manifold-ema-state-aliasing

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Bug

ManifoldExponentialMovingAverage overrides the base filter's filter_state setter and assigned states directly instead of copying them. Its first-update path also stored the caller's sample object directly.

For mutable manifold states such as NumPy arrays, mutating the original sample or replacement state after assignment therefore changed the filter estimate without another filter update. This violates the state-ownership behavior established by AbstractFilter, whose constructor and setter deep-copy assigned state.

Fix

  • deep-copy values assigned through ManifoldExponentialMovingAverage.filter_state;
  • route first-sample initialization through that setter;
  • route retraction results through the same setter so all state writes follow one ownership contract.

Regression coverage

Add focused tests verifying that:

  • the first sample can be mutated after update(...) without changing the stored estimate;
  • an array assigned through filter_state can be mutated afterward without changing the stored estimate.

Validation

  • reproduced the old aliasing behavior: changing the input array changed the stored state from [2, 3] to [-1, -1];
  • verified the corrected ownership behavior preserves [2, 3];
  • syntax-compiled both changed Python modules;
  • checked both changed files for the repository's 88-column limit;
  • branch comparison: 2 commits ahead and 0 behind main;
  • final diff is limited to 4 additions / 3 deletions in the implementation and one focused regression module.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 26.36s
✅ JSON prettier 7 0 0 0 0.91s
✅ JSON v8r 7 0 0 3.12s
✅ MARKDOWN markdownlint 68 0 0 0 1.83s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.65s
✅ PYTHON black 1866 87 0 0 91.14s
✅ PYTHON isort 1866 140 0 0 2.75s
✅ REPOSITORY betterleaks yes no no 2.55s
✅ REPOSITORY checkov yes no no 48.4s
✅ REPOSITORY gitleaks yes no no 17.22s
✅ REPOSITORY git_diff yes no no 0.33s
✅ REPOSITORY secretlint yes no no 85.6s
✅ REPOSITORY syft yes no no 5.75s
✅ REPOSITORY trivy-sbom yes no no 6.02s
✅ REPOSITORY trufflehog yes no no 30.79s
✅ YAML prettier 11 0 0 0 0.73s
✅ YAML v8r 11 0 0 10.94s
✅ YAML yamllint 11 0 0 0.55s

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 August 7, 2026 17:57
@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) August 7, 2026 17:57
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