Remove stale cache causing Besample active-set overshoot - #304
Open
joshnguyen99 wants to merge 1 commit into
Open
Remove stale cache causing Besample active-set overshoot#304joshnguyen99 wants to merge 1 commit into
joshnguyen99 wants to merge 1 commit into
Conversation
Real Mexico recruitment data showed statements reaching 31-32 confirmed ratings against the 10-rating cap. getGlobalOrder() cached remaining(i,j) for up to an hour; bumpCountryRatings wrote real confirmedCount on every completion, but nothing invalidated the cache in response, so a burst of completions within one cache window all got handed the identical active set. Verified directly: 13 Mexico completions in one window shared a byte-identical 15-statement list. Removed the cache entirely rather than shrinking the refresh interval, since any fixed window has the same failure mode. Benchmarked the underlying query first - a few ms - so recomputing on every call has negligible cost. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Selection is not atomic under concurrent assignments; add reservation protection and a concurrent regression test.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Removes stale Besample active-set caching so confirmed ratings are reflected immediately.
Changes:
- Recomputes the global order on every assignment.
- Adds unit and integration regression coverage.
- Updates architecture documentation and changelog.
File summaries
| File | Reviewed changes |
|---|---|
server/src/tests/unit/survey/besample-matrix.test.ts |
Verifies fresh recomputation. |
server/src/tests/integration/besample-experiment.test.ts |
Adds sequential overshoot regression coverage. |
server/src/survey/experiments/utils/besample-matrix.ts |
Removes the in-process cache. |
CLAUDE.md |
Updates architecture guidance. |
CHANGES.md |
Documents the incident and resolution. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Real Mexico recruitment data showed statements reaching 31-32 confirmed ratings against the 10-rating cap. getGlobalOrder() cached remaining(i,j) for up to an hour; bumpCountryRatings wrote real confirmedCount on every completion, but nothing invalidated the cache in response, so a burst of completions within one cache window all got handed the identical active set. Verified directly: 13 Mexico completions in one window shared a byte-identical 15-statement list.
Removed the cache entirely rather than shrinking the refresh interval, since any fixed window has the same failure mode. Benchmarked the underlying query first - a few ms - so recomputing on every call has negligible cost.