feat: let the operator set the daily comment limit per account

The allowance was derived from the adaptive trust level with no way to
change it, which made the dashboard's "1 / 2 today" unexplainable and
left no way to slow an account down or push one along.

`dailyLimit` is null by default, keeping today's adaptive behaviour. A
whole number between 1 and 50 overrides it and is enforced verbatim in
either direction — it can raise an account above what it has earned or
hold it below. The trust level keeps being tracked underneath and is
reported as `adaptiveAllowance`, so the earned figure stays visible next
to the override, and clearing the field hands pacing back to the ladder.

Raising the limit above the earned allowance does remove the adaptive
backoff after a bad comment, so the dashboard says exactly that where the
limit is set. It does not touch the pause on two consecutive removals, a
comment the public cannot see, or a captcha challenge: those are safety
stops rather than rate controls and no limit setting can disable them.

Also correct two things the page was saying badly. The allowance is now
labelled "used in last 24h" with the trust level shown as what it earns,
because it is a rolling window and not a midnight reset. And a
per-community cap above the account allowance now states how much of it
is actually reachable — "1 of 10 today" beside an account limit of 2 read
as far more headroom than existed, since caps distribute the allowance
rather than adding to it.

Verified against a local instance: override above and below the earned
allowance, unrelated saves preserving it, clearing it through the UI,
rejection of 0/51/2.5/non-numeric, and a limit failing to clear a pause.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Jamie BruntonandClaude Opus 5 committed 2026-08-11 21:07:25 +01:00
1 parent f88db1ae7d
commit 5deac87cf1
15 files changed
+351 -26

No files matched your search

+53
View File
@@ -5,6 +5,7 @@ import type {
} from '../src/database/growth-repository.js';
import {
DEMOTION_SCORE_THRESHOLD,
effectiveDailyAllowance,
MAX_TRUST_LEVEL,
PROMOTION_HOLD_MS,
TRUST_LEVEL_ALLOWANCES,
@@ -23,6 +24,7 @@ function settings(overrides: Partial<GrowthSettingsRecord> = {}): GrowthSettings
accountId: '@t2_a:reddit.com',
enabled: true,
trustLevel: 0,
dailyLimit: null,
levelChangedAt: null,
consecutiveRemovals: 0,
pausedReason: null,
@@ -64,6 +66,25 @@ describe('dailyAllowance', () => {
});
});
describe('effectiveDailyAllowance', () => {
it('uses the earned allowance when no override is set', () => {
expect(effectiveDailyAllowance({ trustLevel: 2, dailyLimit: null })).toBe(5);
});
it('enforces an override above the earned allowance', () => {
expect(effectiveDailyAllowance({ trustLevel: 0, dailyLimit: 20 })).toBe(20);
});
it('enforces an override below the earned allowance', () => {
expect(effectiveDailyAllowance({ trustLevel: 4, dailyLimit: 1 })).toBe(1);
});
it('ignores a nonsensical override rather than blocking all commenting', () => {
expect(effectiveDailyAllowance({ trustLevel: 1, dailyLimit: 0 })).toBe(3);
expect(effectiveDailyAllowance({ trustLevel: 1, dailyLimit: -5 })).toBe(3);
});
});
describe('assessTrust', () => {
it('holds at level 0 with no history', () => {
const assessment = assessTrust(settings(), [], NOW);
@@ -372,6 +393,38 @@ describe('evaluateGrowthWindow', () => {
});
});
it('enforces an operator override instead of the earned allowance', () => {
const decision = evaluateGrowthWindow({
...base,
settings: settings({ trustLevel: 0, dailyLimit: 10 }),
postedLast24h: 4,
});
expect(decision).toEqual({ allowed: true, allowance: 10, postedLast24h: 4 });
});
it('stops at an override lower than the earned allowance', () => {
const decision = evaluateGrowthWindow({
...base,
settings: settings({ trustLevel: 4, dailyLimit: 2 }),
postedLast24h: 2,
});
expect(decision).toMatchObject({ allowed: false });
if (!decision.allowed) expect(decision.reason).toMatch(/allowance of 2 comments/);
});
it('an override never overrides the safety pause', () => {
const decision = evaluateGrowthWindow({
...base,
settings: settings({ dailyLimit: 50, pausedReason: 'Two consecutive removals' }),
});
expect(decision).toEqual({
allowed: false, reason: 'Two consecutive removals', retryAt: null,
});
});
it('uses the raised allowance at a higher trust level', () => {
const decision = evaluateGrowthWindow({
...base,