Skip to content

fix: selectFrames(1, ...) drops the guaranteed wildcard frame - #60

Open
UditAkhourii wants to merge 1 commit into
mainfrom
bot/issue-43-wildcard-frame
Open

UditAkhourii wants to merge 1 commit into
mainfrom
bot/issue-43-wildcard-frame

Conversation

@UditAkhourii

Copy link
Copy Markdown
Owner

Summary

  • selectFrames picked n - 1 frames first, then pushed the wildcard and sliced back to n — at n=1 this threw the wildcard away whenever the first random pick wasn't already the wildcard (~50% of the time).
  • Fix reserves the wildcard slot up front: pick the wildcard, sample the rest from the remaining pool, and prepend the wildcard before slicing to n. Behavior for n > 1 is unchanged (wildcard still guaranteed, rest still uniformly shuffled from the pool).

Testing

  • Added tests/frames.test.ts: asserts selectFrames(1, ...) always returns a wildcard-tagged frame (50 iterations), and that selectFrames(n, ...) for n > 1 still includes at least one wildcard frame while returning exactly n frames.
  • npm test — all tests pass (3/3).
  • npm run typecheck — clean.

Closes #43

🤖 Generated with Claude Code

Reserve the wildcard slot before sampling the rest of the pool instead
of appending it after slicing to n, which silently dropped it whenever
n=1 and the first random pick wasn't already the wildcard (~50% of the
time). Adds a regression test asserting selectFrames(1, ...) always
returns a wildcard-tagged frame.

Closes #43

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

This branch has not been deployed

No deployments
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.

selectFrames(1, ...) drops the guaranteed wildcard ~50% of the time

1 participant