Skip to content

♻️ refactor(models): remove redundant burst field from Limit model#408

Merged
sodre merged 7 commits into
mainfrom
refactor/406-burst-field
Feb 20, 2026
Merged

♻️ refactor(models): remove redundant burst field from Limit model#408
sodre merged 7 commits into
mainfrom
refactor/406-burst-field

Conversation

@sodre

@sodre sodre commented Feb 20, 2026

Copy link
Copy Markdown
Member

Summary

  • Remove the redundant burst field from Limit and burst_milli from BucketStatecapacity now serves as the bucket ceiling (max tokens), which is what burst was actually doing in all bucket math
  • Drop bx attribute from DynamoDB writes (bucket and config records); read path uses max(cp, bx) fallback for backward compatibility with existing records
  • Update refill_bucket() parameter naming (burst_millicapacity_milli), aggregator processor, CLI display, exception serialization, migration logic, examples, and all documentation
  • Add inline period suffix support to CLI -l flag: name:rate[/period][:burst] where period is /[N]sec, /[N]min (default), /[N]hour, or /[N]day — fully backward compatible

Test plan

  • uv run pytest tests/unit/ — all unit tests pass with updated assertions (models, bucket, limiter, repository, CLI, exceptions, migrations, processor)
  • uv run pytest tests/integration/ — integration tests pass with LocalStack
  • uv run pytest tests/e2e/ — end-to-end workflows pass
  • hatch run generate-sync output matches committed sync files
  • pre-commit run --all-files passes (lint, type check, sync verification)

Closes #406
Closes #410

🤖 Generated with Claude Code

)

The `burst` field was the actual bucket ceiling while `capacity` went
unused in bucket math. This collapses both into a single `capacity`
field that serves as the bucket ceiling, simplifying the mental model.

- Remove `burst` from Limit and `burst_milli` from BucketState
- Remove `BUCKET_FIELD_BX` and `LIMIT_FIELD_BX` from schema
- Rename `burst_milli` → `capacity_milli` in refill_bucket()
- Replace `burst` with `refill_amount`+`refill_period_seconds` in exception dict
- Update migration to map old burst → new capacity (ceiling preservation)
- Update CLI, examples, aggregator, and all documentation

Closes #406

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sodre sodre added this to the v1.0.0 milestone Feb 20, 2026
@sodre sodre added the area/limiter Core rate limiting logic label Feb 20, 2026
@codecov

codecov Bot commented Feb 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.78%. Comparing base (55bb4c0) to head (c889d38).
⚠️ Report is 24 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #408      +/-   ##
==========================================
+ Coverage   91.76%   91.78%   +0.01%     
==========================================
  Files          33       33              
  Lines        7333     7349      +16     
==========================================
+ Hits         6729     6745      +16     
  Misses        604      604              
Flag Coverage Δ
doctest 29.33% <23.07%> (-0.19%) ⬇️
e2e 42.49% <25.64%> (-0.19%) ⬇️
integration 51.84% <71.79%> (-0.01%) ⬇️
unit 91.52% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

sodre and others added 6 commits February 19, 2026 22:50
The `per_second`, `per_minute`, `per_hour`, and `per_day` factory
methods now accept an optional `burst` keyword. When set, `capacity`
is set to `burst` while `refill_amount` stays at `rate`, allowing
temporary spikes above the sustained rate.

The CLI also supports `name:rate:burst` format (e.g., `-l tpm:10000:15000`).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…t_limit

Cover the burst parsing path (name:rate:burst format) and the burst
display branch (capacity != refill_amount) to satisfy patch coverage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add inline period support to the -l/--limit flag: name:rate[/period][:burst]
where period is /[N]sec, /[N]min, /[N]hour, or /[N]day. Defaults to /min
when omitted, preserving full backward compatibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…over

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…n examples

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ning

Reword --limit help text to use 'name:rate[/period]:burst' instead of
'name:rate[/period][:burst]' so mkdocs-autorefs does not interpret
[:burst] as a Python cross-reference target in strict mode.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sodre sodre marked this pull request as ready for review February 20, 2026 08:24
@sodre sodre merged commit b8800bb into main Feb 20, 2026
25 checks passed
@sodre sodre deleted the refactor/406-burst-field branch February 20, 2026 08:46
sodre added a commit that referenced this pull request Feb 20, 2026
Align with the Limit model refactor (PR #408) that removed the
redundant `burst` field — `capacity` now serves as the bucket ceiling.

- Remove `burst` from LimitDecl (accept it in YAML for backwards
  compat, treating it as capacity override)
- Stop writing `bx` attribute to DynamoDB in applier
- Remove Burst from CFN template generation and handler parsing
- Update docs to remove burst references from YAML examples

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/limiter Core rate limiting logic

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ Support period suffix in CLI -l flag syntax ♻️ Remove redundant burst field from Limit model

1 participant