fix(share-ai): lower default per-workspace cap to 100 (#62)
The fail-closed limiter behavior (#62 primary item) already shipped; this finishes the issue by lowering the default hourly per-workspace cap from 300 to 100 to better fit real anonymous-assistant load. Still overridable via SHARE_AI_WORKSPACE_MAX_PER_HOUR. - public-share-workspace-limiter.ts: SHARE_AI_WORKSPACE_MAX_PER_WINDOW 300 -> 100. - .env.example: documented default + example value 300 -> 100. - public-share-chat.spec.ts: update the default-cap assertion to 100. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -147,8 +147,8 @@ MCP_DOCMOST_PASSWORD=
|
|||||||
# per-IP limit is fully evaded. It is a COST backstop, not an access control, and
|
# per-IP limit is fully evaded. It is a COST backstop, not an access control, and
|
||||||
# FAILS CLOSED if Redis is unavailable (an optional assistant briefly going
|
# FAILS CLOSED if Redis is unavailable (an optional assistant briefly going
|
||||||
# offline is safer than an unbounded bill). Override the hourly cap below
|
# offline is safer than an unbounded bill). Override the hourly cap below
|
||||||
# (default: 300 calls per workspace per rolling hour).
|
# (default: 100 calls per workspace per rolling hour).
|
||||||
# SHARE_AI_WORKSPACE_MAX_PER_HOUR=300
|
# SHARE_AI_WORKSPACE_MAX_PER_HOUR=100
|
||||||
#
|
#
|
||||||
# Per-request output-token ceiling for the anonymous assistant (default: 512).
|
# Per-request output-token ceiling for the anonymous assistant (default: 512).
|
||||||
# Worst-case output per accepted call = agent steps (5) × this value.
|
# Worst-case output per accepted call = agent steps (5) × this value.
|
||||||
|
|||||||
@@ -386,7 +386,7 @@ describe('resolveShareAiWorkspaceMax (env-overridable per-workspace cap)', () =>
|
|||||||
it('falls back to the default for an unparseable / NaN value', () => {
|
it('falls back to the default for an unparseable / NaN value', () => {
|
||||||
process.env[ENV] = 'not-a-number';
|
process.env[ENV] = 'not-a-number';
|
||||||
expect(resolveShareAiWorkspaceMax()).toBe(SHARE_AI_WORKSPACE_MAX_PER_WINDOW);
|
expect(resolveShareAiWorkspaceMax()).toBe(SHARE_AI_WORKSPACE_MAX_PER_WINDOW);
|
||||||
expect(SHARE_AI_WORKSPACE_MAX_PER_WINDOW).toBe(300);
|
expect(SHARE_AI_WORKSPACE_MAX_PER_WINDOW).toBe(100);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('falls back to the default when unset', () => {
|
it('falls back to the default when unset', () => {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import type { Redis } from 'ioredis';
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/** Default cap: anonymous share-AI calls allowed per workspace per window. */
|
/** Default cap: anonymous share-AI calls allowed per workspace per window. */
|
||||||
export const SHARE_AI_WORKSPACE_MAX_PER_WINDOW = 300;
|
export const SHARE_AI_WORKSPACE_MAX_PER_WINDOW = 100;
|
||||||
/** Default window length: one rolling hour. */
|
/** Default window length: one rolling hour. */
|
||||||
export const SHARE_AI_WORKSPACE_WINDOW_MS = 60 * 60 * 1000;
|
export const SHARE_AI_WORKSPACE_WINDOW_MS = 60 * 60 * 1000;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user