fix(health): fresh-session guard against stale-state false-rot [GET-36]#60
Conversation
…-36] Rule 0 returns Healthy when turnCount <= 2 AND contextPct < 30, before the per-model classifier runs. Blocks stale growthRate, isDetailHeavy, and any future projection wrapper from escalating a session that has no real history yet. Acceptance criteria: - Healthy on any conversation with turnCount <= 2 AND contextPct < 30 regardless of prior tab/conversation state - Wrappers like escalateForProjection still run on the returned HealthScore so a real draft can escalate after the guard - AC OpenCodeIntel#3 (overlay resets on new chat) already satisfied by existing SPA-nav reset path in claude-ai.content.ts (PR OpenCodeIntel#29) 12 new tests: positive path (5), boundary (3), does-not-mask (4).
|
@DevanshuNEU is attempting to deploy a commit to the Dev's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA fresh-session guard is added to ChangesFresh-Session Guard Implementation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Review rate limit: 0/1 reviews remaining, refill in 31 minutes and 3 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/unit/health-score.test.ts`:
- Around line 242-258: The test comment misleadingly claims it verifies the
guard path vs primary classifier, but both branches call getRotCoaching(model,
contextPct, isDetailHeavy) so the coaching check cannot distinguish paths;
update the test comment in the it(...) block for computeHealthScore (using
SONNET_45 and FRESH_SESSION_CONTEXT_CEIL) to remove or rewrite the paragraph
that asserts "specifically verify the guard did not produce this result" and
instead state that the test only verifies the exclusive boundary behavior (guard
does not fire at ceiling) and that the coaching string is expected but not proof
of which branch produced it.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 48e2d854-2742-49db-816d-beb52a6e1149
📒 Files selected for processing (2)
lib/health-score.tstests/unit/health-score.test.ts
…ch claim [GET-36] The 'guard ceiling is exclusive' test asserted the coaching string cites the model and previously claimed this distinguished the guard branch from the primary fall-through. Both branches call getRotCoaching with identical arguments, so the string is byte-identical from either path. Comment now states honestly that the level assertion is the boundary check and the coaching match is a non-empty/shape sanity check, not proof of branch.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Summary
Adds a Rule 0 guard at the top of `computeHealthScore` that returns Healthy when `turnCount <= 2 AND contextPct < 30`, before any per-model or secondary classifier runs. This blocks stale derived signals (growthRate from a prior conversation, leaked isDetailHeavy, and any future projection wrapper) from escalating a session that has no real history yet. The guard is defensive: the bug as originally filed referenced `escalateForProjection` which does not exist on main today, so the guard primarily protects against a class of leak paths and pre-emptively covers the orphan PR #56 commits when they land.
Type of Change
What Was Changed
`lib/health-score.ts`
`tests/unit/health-score.test.ts`
How to Test
Acceptance Criteria
Checklist
Related Issues
Closes GET-36 (https://linear.app/getsaar/issue/GET-36/health-indicator-context-rot-signal-fires-on-fresh-sessions)
Notes for Reviewer
Summary by CodeRabbit
Release Notes