Commit graph

4 commits

Author SHA1 Message Date
Virgil
d1c90b937d fix(ratelimit): harden audit edge cases
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-23 07:26:15 +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