Commit graph

16 commits

Author SHA1 Message Date
Virgil
781e0ee3d6 fix(ratelimit): enforce negative token validation before quota lookup
Some checks failed
Security Scan / security (push) Has been cancelled
Test / test (push) Has been cancelled
2026-04-03 07:37:23 +00:00
Virgil
2ad4870bd0 fix(ratelimit): initialise state on invalid decides
Some checks failed
Security Scan / security (push) Successful in 8s
Test / test (push) Failing after 14m39s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 04:47:30 +00:00
Virgil
ed5949ec3a feat(ratelimit): add agent decision guidance
All checks were successful
Security Scan / security (push) Successful in 9s
Test / test (push) Successful in 2m19s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-30 08:16:44 +00:00
Virgil
1ec0ea4d28 fix(ratelimit): align module metadata and repo guidance
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-27 04:23:34 +00:00
Virgil
ed1cdc11b2 refactor(ratelimit): finish ax v0.8.0 polish
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-26 18:51:54 +00:00
Virgil
36cc0a4750 refactor(ratelimit): upgrade to core v0.8.0-alpha.1
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-26 15:41:11 +00:00
Virgil
d1c90b937d fix(ratelimit): harden audit edge cases
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-23 07:26:15 +00:00
Snider
d4d9d7a798 chore(ratelimit): migrate dependencies from forge.lthn.ai to dappco.re
All checks were successful
Security Scan / security (pull_request) Successful in 7s
Test / test (pull_request) Successful in 2m17s
Update go.mod require lines and .go import paths:
- forge.lthn.ai/core/go-io v0.1.7 → dappco.re/go/core/io v0.2.0
- forge.lthn.ai/core/go-log v0.0.4 → dappco.re/go/core/log v0.1.0

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 01:34:23 +00:00
Snider
4bb1cb96d4 refactor(ratelimit): replace all fmt.Errorf with coreerr.E from go-log
All checks were successful
Security Scan / security (push) Successful in 8s
Test / test (push) Successful in 1m7s
Replace all 41 remaining fmt.Errorf calls in production code (ratelimit.go
and sqlite.go) with coreerr.E() from forge.lthn.ai/core/go-log. Promotes
go-log from indirect to direct dependency in go.mod.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-16 20:38:06 +00:00
Snider
ee6c5aa69d refactor(ratelimit): replace os.ReadFile/WriteFile/MkdirAll with go-io
All checks were successful
Security Scan / security (push) Successful in 8s
Test / test (push) Successful in 2m24s
Swap all direct os I/O calls for coreio.Local equivalents:
- os.ReadFile  → coreio.Local.Read  (returns string; []byte cast at call sites)
- os.WriteFile + os.MkdirAll → coreio.Local.Write (creates parent dirs internally)

Affected: Load(), Persist(), MigrateYAMLToSQLite(). go.mod gains
forge.lthn.ai/core/go-io v0.1.2 as a direct dependency.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-16 18:31:35 +00:00
Snider
79448bf3f3 fix: improve error handling and test coverage
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:30:03 +00:00
Snider
d74811f2d0 feat: modernise to Go 1.26 — slices.DeleteFunc, iterators, range
Some checks failed
Security Scan / security (push) Successful in 7s
Test / test (push) Failing after 40s
- Use slices.DeleteFunc in prune() for cleaner time-window filtering
- Add Models() iter.Seq[string] and Iter() iter.Seq2[string, ModelStats]
- Use range over int in benchmarks and tests
- Update docs example to modern range syntax

Co-Authored-By: Gemini <noreply@google.com>
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-23 05:14:19 +00:00
Snider
2246fea10f refactor: apply go fix modernizers for Go 1.26
Automated fixes: interface{} → any, range-over-int, t.Context(),
wg.Go(), strings.SplitSeq, strings.Builder, slices.Contains,
maps helpers, min/max builtins.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 21:00:17 +00:00
Snider
1afb1d636a feat(persist): Phase 2 — SQLite backend with WAL mode
Add multi-process safe SQLite persistence using modernc.org/sqlite (pure
Go, no CGO). Follows the go-store pattern: single connection,
WAL journal mode, 5-second busy timeout.

New files:
- sqlite.go: sqliteStore with schema (quotas, requests, tokens, daily
  tables), saveQuotas/loadQuotas, saveState/loadState, close methods
- sqlite_test.go: 25 tests covering basic round-trips, integration,
  concurrency (10 goroutines, race-clean), migration, corrupt DB recovery

Wiring:
- Backend field added to Config ("yaml" default, "sqlite" option)
- Persist() and Load() dispatch to correct backend
- NewWithSQLite() and NewWithSQLiteConfig() convenience constructors
- Close() method for cleanup (no-op for YAML)
- MigrateYAMLToSQLite() helper for upgrading existing YAML state

All existing YAML tests pass unchanged (backward compatible).

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 07:50:48 +00:00
Claude
3c63b1022a
feat(ratelimit): generalise beyond Gemini with provider profiles and push coverage to 95%
Phase 0: Rewrite test suite with testify (77.1% -> 95.1% coverage).
Add boundary tests, concurrent access tests, benchmarks, error path
coverage for Load/Persist, Reset, Stats, and CountTokens.

Phase 1: Extract hardcoded Gemini quotas into provider-agnostic config.
Add Provider type, DefaultProfiles(), NewWithConfig(), SetQuota(), and
AddProvider(). Pre-configured profiles for Gemini, OpenAI, Anthropic,
and Local. New() retains exact backward compatibility via delegation.

Co-Authored-By: Charon <developers@lethean.io>
2026-02-20 01:07:57 +00:00
Snider
fa1a6fc030 feat: extract go-ratelimit from core/go pkg/ratelimit
Token counting, model quotas, sliding window rate limiter.
Zero external dependencies (stdlib only).
Module: forge.lthn.ai/core/go-ratelimit

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-19 16:09:13 +00:00