Skip to content

Remove stale cache causing Besample active-set overshoot - #304

Open
joshnguyen99 wants to merge 1 commit into
mainfrom
fix/besample-active-set-overshoot
Open

Remove stale cache causing Besample active-set overshoot#304
joshnguyen99 wants to merge 1 commit into
mainfrom
fix/besample-active-set-overshoot

Conversation

@joshnguyen99

Copy link
Copy Markdown
Collaborator

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.

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread server/src/survey/experiments/utils/besample-matrix.ts
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.

3 participants