Commit graph

59 commits

Author SHA1 Message Date
Snider
cde6443e4c docs: graduate TODO/FINDINGS into production documentation
Replace internal task tracking (TODO.md, FINDINGS.md) with structured
documentation in docs/. Trim CLAUDE.md to agent instructions only.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 15:01:55 +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
Snider
ab49f2207e docs: flesh out Phase 2 SQLite migration task specs
Detailed schema design, API changes, test matrix, and migration helper
following go-store's SQLite pattern (modernc.org/sqlite, WAL mode).

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 07:38:09 +00:00
Snider
db958f293a test: expand race coverage and benchmarks
Add 4 concurrent race tests: multi-model (5 models), Persist+Load
filesystem race, AllStats+RecordUsage, WaitForCapacity+RecordUsage.
Add 4 benchmarks: CanSendWithPrune, Stats, AllStats, Persist.
Total: 80 tests, 7 benchmarks, all pass under go test -race.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 04:30:54 +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
666deed718 docs: enrich TODO.md with Phase 0 hardening tasks
Add Phase 0: race condition tests, concurrent CanSend/RecordUsage,
sliding window edge cases, YAML persistence recovery, benchmarks.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 00:28:45 +00:00
Virgil
fb531af79a docs: add TODO.md and FINDINGS.md for fleet delegation
Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-19 21:36:13 +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