Skip to content

feat: add configurable rate limits for local extension usage to prevent runaway API spend #50

Description

@charannyk06

Priority: P3 — Low

Problem

The VS Code extension has no rate limiting for tool calls. A user could accidentally (or intentionally) trigger hundreds of review runs, exhausting their Anthropic API quota or incurring unexpected charges in managed mode.

There is also no limit on web search calls from src/server/tools/web.ts, which could hit search API quotas.

Solution

1. Per-day review limit (configurable)

VS Code setting: chainreview.limits.reviewsPerDay (default: 20)

When the daily limit is reached:

  • Show a notification: "Daily review limit (20) reached. Resets at midnight."
  • Provide a "Manage Limits" button linking to settings

2. Per-session review limit

VS Code setting: chainreview.limits.reviewsPerSession (default: 5)

3. Web search per-review limit

In src/server/tools/web.ts:

const MAX_WEB_SEARCHES_PER_REVIEW = process.env.CHAINREVIEW_MAX_WEB_SEARCHES ?? 10;

4. Track usage locally

Store daily usage counts in SQLite:

CREATE TABLE usage_local (
  date TEXT PRIMARY KEY,  -- YYYY-MM-DD
  review_count INTEGER DEFAULT 0,
  token_count INTEGER DEFAULT 0
);

5. Show usage in status bar

VS Code status bar: ChainReview: 3/20 reviews today

Acceptance Criteria

  • VS Code settings for review limits (per-day, per-session)
  • Notification when limit reached
  • Web search per-review limit
  • Local usage tracked in SQLite
  • Usage visible in VS Code status bar or settings panel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions