Skip to content

Enforce data caps: suspend an account when its usage reaches its quota - #18

Merged
iamfarhad merged 1 commit into
mainfrom
feat/bot-api-additions
Oct 29, 2026
Merged

iamfarhad merged 1 commit into
mainfrom
feat/bot-api-additions

Conversation

@iamfarhad

Copy link
Copy Markdown
Owner

Nothing ever suspended an account over its quota, so a capped account kept working without limit. One rule now lives in store/limits.go and is applied on the traffic path (same transaction as the usage update), at read time (beside the existing expiry reconcile), and at the end of PATCH, renew and reset-usage:

  • An active account whose usage reaches a non-null quota is suspended with quota_exceeded; nodes drop it on their next heartbeat. Other suspend reasons and deleted accounts are never touched; a NULL quota is unlimited.
  • Expired wins over quota_exceeded, and adding data never revives an expired account.
  • A PATCH that raises the quota above usage lifts quota_exceeded; one that lowers it to usage or below suspends. Renew, reset-usage and clear_data_quota still lift.
  • POST /enable on an account still over its cap answers 409 quota_exhausted instead of switching it on to be suspended again a heartbeat later.
  • The reseller bulk reactivate and the quota report use the same rule.
  • Side fix: the reseller guard in EnableAccount was not NULL-safe, so a reseller enabling an already-active account got 403.

README (en/fa): the bot API additions and how data caps behave.

Nothing ever suspended an account over its quota, so a capped account kept
working without limit. One rule now lives in store/limits.go and is applied
on the traffic path (same transaction as the usage update), at read time
(beside the existing expiry reconcile), and at the end of PATCH, renew and
reset-usage:

- An active account whose usage reaches a non-null quota is suspended with
  quota_exceeded; nodes drop it on their next heartbeat. Other suspend
  reasons and deleted accounts are never touched; a NULL quota is unlimited.
- Expired wins over quota_exceeded, and adding data never revives an
  expired account.
- A PATCH that raises the quota above usage lifts quota_exceeded; one that
  lowers it to usage or below suspends. Renew, reset-usage and
  clear_data_quota still lift.
- POST /enable on an account still over its cap answers 409 quota_exhausted
  instead of switching it on to be suspended again a heartbeat later.
- The reseller bulk reactivate and the quota report use the same rule.
- Side fix: the reseller guard in EnableAccount was not NULL-safe, so a
  reseller enabling an already-active account got 403.

README (en/fa): the bot API additions and how data caps behave.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iamfarhad
iamfarhad merged commit 51cd521 into main Oct 29, 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