Skip to content

test: add test suite, wire SALES_STAGE_CLASSIFIER_MODEL, surface gradeSkills errors#1

Merged
chatman-media merged 1 commit into
mainfrom
claude/vibrant-volhard-04e17f
May 14, 2026
Merged

test: add test suite, wire SALES_STAGE_CLASSIFIER_MODEL, surface gradeSkills errors#1
chatman-media merged 1 commit into
mainfrom
claude/vibrant-volhard-04e17f

Conversation

@chatman-media

Copy link
Copy Markdown
Owner

Summary

  • 73 unit tests across 5 new files (elo, stage-router, judge, skill-recommendations, ab-router) — all pass
  • bun test added to package.json scripts and CI pipeline
  • @types/bun pinned to 1.3.14 (was mutable latest)
  • .env.example created, documenting SALES_STAGE_CLASSIFIER_MODEL
  • SALES_STAGE_CLASSIFIER_MODEL env var wired into classifyStage (previously a TODO comment)
  • Per-turn gradeSkills errors now surface in SelfPlayMatchResult.warnings[] instead of being swallowed by console.warn

What changed and why

Tests (src/__tests__/)

No test coverage existed for any of the core algorithms. The new suite covers:

  • elo.test.ts — actualScore, expectedScore, eloUpdate (K factor, opponent rating, rounding), eloUpdatePair symmetry and zero-sum
  • stage-router.test.ts — objection/pricing/agreement/qualifier detection on Russian text, turn-based stage transitions, objection priority
  • judge.test.ts — parseVerdict with clean JSON, code-fenced JSON, <think> block stripping, regex fallback, fully unparseable input
  • skill-recommendations.test.ts — wilsonLowerBound edge cases (0/0, all-wins, large sample), rankSkillRecommendations filtering (disabled, noise) and sorting
  • ab-router.test.ts — determinism, 50/50 and 80/20 weight distributions over 1000 users, error cases

SALES_STAGE_CLASSIFIER_MODEL

The env var was mentioned in a comment as "TODO Phase 3+". It's now read via process.env.SALES_STAGE_CLASSIFIER_MODEL and passed as model option to chat.complete when set — zero-cost when unset.

matchResult.warnings[]

gradeSkills failures during self-play were silently logged. They're now accumulated in SelfPlayMatchResult.warnings: string[] so callers can inspect, log, or alert on them without losing the match result.

Test plan

  • bun test — 73 tests pass
  • bun run typecheck — no type errors
  • bun run check — biome clean

🤖 Generated with Claude Code

- Add 73 unit tests across 5 files (elo, stage-router, judge, skill-recommendations, ab-router)
- Add `"test": "bun test"` script and `bun test` step to CI
- Pin `@types/bun` to 1.3.14 (was `latest`)
- Add `.env.example` documenting SALES_STAGE_CLASSIFIER_MODEL
- Implement SALES_STAGE_CLASSIFIER_MODEL env var in classifyStage (was TODO)
- Replace console.warn in gradeSkills catch with matchResult.warnings[]

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@chatman-media has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 47 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ccd2b776-a3f4-4b60-9fc2-87bc09894bf8

📥 Commits

Reviewing files that changed from the base of the PR and between 0f1b5bf and e3cd0fe.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • .env.example
  • .github/workflows/ci.yml
  • package.json
  • src/__tests__/ab-router.test.ts
  • src/__tests__/elo.test.ts
  • src/__tests__/judge.test.ts
  • src/__tests__/skill-recommendations.test.ts
  • src/__tests__/stage-router.test.ts
  • src/self-play/orchestrator.ts
  • src/stage-classifier.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/vibrant-volhard-04e17f

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatman-media chatman-media merged commit 55d6c34 into main May 14, 2026
3 checks passed
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