Skip to content

Fix flaky entropy test and refresh lockfile for security patches - #16

Merged
chrishayuk merged 1 commit into
mainfrom
fix/flaky-entropy-test-and-lockfile-security
Jul 15, 2026
Merged

Fix flaky entropy test and refresh lockfile for security patches#16
chrishayuk merged 1 commit into
mainfrom
fix/flaky-entropy-test-and-lockfile-security

Conversation

@chrishayuk

Copy link
Copy Markdown
Collaborator

Summary

  • test_entropy_requirements (both the class method and the parametrized [256] case) occasionally failed (~0.7-0.8% of runs empirically, most recently on windows-latest/3.13) because the entropy estimator's pattern-penalty heuristic can over-penalize a single genuinely-random 256-bit draw when it happens to contain an adjacent repeated character or short sequential run. Fixed by sampling 5 draws and asserting on the best one — drops the flake rate to effectively zero while still exercising real crypto-random generation, no production code changed.
  • uv lock --upgrade closes the remaining Dependabot alerts not covered by the already-merged pytest security PR: Pygments 2.20.0 (ReDoS), requests 2.34.2 (insecure temp file reuse).

Test plan

  • uv run pytest tests/ — 264 passed (all extras) / 214 passed, 50 skipped (default)
  • uv run ruff check . / ruff format --check . — clean
  • uv run mypy src --ignore-missing-imports — no issues
  • Empirically verified fix drops flake probability from ~0.8% to ~(0.008)^5 ≈ negligible
  • CI green on this PR

test_entropy_requirements occasionally failed (~0.7-0.8% of runs, seen
on windows-latest/3.13) because the entropy estimator's pattern-penalty
heuristic can over-penalize a single genuinely-random 256-bit draw when
it happens to contain an adjacent repeated character or short sequential
run. Sample 5 draws and assert on the best one, dropping the flake rate
to effectively zero while still exercising real crypto-random generation.

uv lock --upgrade closes the remaining Dependabot alerts not covered by
the merged pytest security PR: Pygments 2.20.0 (ReDoS), requests 2.34.2
(insecure temp file reuse).

Signed-off-by: chris hay <chris.hay@uk.ibm.com>
@chrishayuk
chrishayuk merged commit a39e470 into main Jul 15, 2026
10 checks passed
@chrishayuk
chrishayuk deleted the fix/flaky-entropy-test-and-lockfile-security branch July 15, 2026 13:07
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