Commit graph

9 commits

Author SHA1 Message Date
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
b0b686bd3f chore: sync go.mod dependencies
All checks were successful
Security Scan / security (push) Successful in 9s
Test / test (push) Successful in 2m22s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-15 15:36:21 +00:00
Snider
70b611e2a7 chore: refresh go.sum after upstream tag updates
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-23 06:35:19 +00:00
Claude
6d9075a3f2
chore: sync workspace dependency versions
Run go work sync to align dependency versions across workspace.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 21:41:59 +00:00
Snider
0afcf0fb64 chore: bump go directive to 1.26.0
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-22 20:33:48 +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
9b53632e3d fix: add yaml.v3 dependency
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-19 16:10:06 +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