Skip to content

Feat/gtp 5.3 codex rate limit violations batching#73

Open
kudroma404 wants to merge 10 commits into
mainfrom
feat/gtp-5.3-codex-rate-limit-violations-batching
Open

Feat/gtp 5.3 codex rate limit violations batching#73
kudroma404 wants to merge 10 commits into
mainfrom
feat/gtp-5.3-codex-rate-limit-violations-batching

Conversation

@kudroma404

@kudroma404 kudroma404 commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds batched tracking for rate-limit violations so we can observe abuse patterns without writing one DB row per 429.

What changed

  • Added a dedicated rate-limit violation tracking pipeline:
    • RateLimitViolationTracker + sink abstraction
    • in-memory aggregation by flush window
    • periodic flush to PostgreSQL
  • Added DB persistence support for aggregated violation records.
  • Wired tracking into HTTP rate-limit paths so limiter denials contribute to aggregates.
  • Threaded tracker through server/state startup so it is available in request handling.
  • Added integration test coverage for rate-limit violation tracking behavior.

Schema and config updates

  • Added new table: rate_limit_violations in dev-env/init-scripts/init-schema.sql.
  • Enabled required JSON handling for Postgres dependency in Cargo.toml / Cargo.lock.
  • Added new DB flush config:
    • db.violation_flush_interval_sec
  • Updated dev configs:
    • dev-env/config/config-single.toml
    • dev-env/config/config1.toml
    • dev-env/config/config2.toml
    • dev-env/config/config3.toml

Files of interest

  • Tracker + DB:
    • src/db/violation_tracker.rs
    • src/db/mod.rs
    • src/db/repository.rs
  • HTTP wiring:
    • src/http3/rate_limits.rs
    • src/http3/server.rs
    • src/http3/state.rs
  • Bootstrap/state wiring:
    • src/raft/mod.rs
    • src/test_support.rs
  • Tests:
    • tests/client_http_api/rate_limit_violations.rs
    • tests/client_http_api/support.rs
    • tests/event_tracker/support.rs

Test plan

  • cargo fmt
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test --all-targets --all-features
  • cargo test --tests --features test-support
  • Trigger repeated requests against a rate-limited endpoint and confirm rows are written to rate_limit_violations with aggregated details.

Notes

  • This design intentionally batches and aggregates violations to reduce write amplification.
  • Existing rate limiting behavior remains unchanged; this PR adds observability for denial events.

kudroma404 and others added 10 commits February 27, 2026 11:07
Persist rate-limit violations as periodic aggregates with per-client JSON details to avoid one-row-per-violation writes and reduce DB pressure.

Made-with: Cursor
Capture 429 events from middleware and distributed subject checks so every denial contributes to the batched violation aggregates.

Made-with: Cursor
Add integration coverage for distributed user limiter 429 behavior and unit coverage for per-client violation aggregation output.

Made-with: Cursor
Merge origin/main into feat/gtp-5.3-codex-rate-limit-violations-batching and resolve conflicts while preserving batched rate-limit violation tracking changes.

Made-with: Cursor
Ignore Cursor workspace files and fix rate-limit handler/test updates needed after syncing with main so local checks run against the new branch state.

Made-with: Cursor
@kudroma404 kudroma404 requested review from Deniskore and the-mx March 11, 2026 12:10
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.

2 participants