Commit graph

4 commits

Author SHA1 Message Date
Snider
f202cfe218 feat(events): add reactive event hooks for store mutations
Watch/Unwatch API with buffered channels (cap 16) and wildcard matching,
OnChange callback hook for go-ws integration, non-blocking notify on
Set/SetWithTTL/Delete/DeleteGroup. ScopedStore events emit with full
prefixed group names. 16 new tests, race-clean, coverage 94.7% -> 95.5%.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-02-20 08:25:03 +00:00
Snider
175fd6bf83 feat(scope): add namespace isolation with quota enforcement
ScopedStore wraps Store and auto-prefixes groups with a namespace to
prevent key collisions across tenants. QuotaConfig enforces per-namespace
MaxKeys and MaxGroups limits (zero = unlimited). Upserts and expired
keys are excluded from quota counts.

New Store methods: CountAll(prefix) and Groups(prefix) for cross-group
queries. All 93 tests pass with race detector, coverage 94.7%.

Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 08:19:11 +00:00
Claude
b866dacdd2
feat(store): add TTL support and harden test coverage to 90.9%
Phase 0 -- Hardening:
- Fix SQLITE_BUSY under concurrent writes by setting SetMaxOpenConns(1)
  and PRAGMA busy_timeout=5000
- Add comprehensive tests: concurrent read/write (10 goroutines),
  edge cases (unicode, null bytes, SQL injection, long keys), error
  paths (closed store, invalid paths, corrupt files), group isolation,
  upsert verification, WAL mode verification, ErrNotFound wrapping
- Add benchmarks: Set, Get, GetAll (10K keys), file-backed Set

Phase 1 -- TTL Support:
- Add expires_at nullable column with schema migration for pre-TTL DBs
- SetWithTTL(group, key, value, duration) stores keys that auto-expire
- Lazy deletion on Get for expired keys
- Background purge goroutine (configurable interval, default 60s)
- Public PurgeExpired() method for manual cleanup
- Count, GetAll, Render all exclude expired entries
- Set clears TTL when overwriting a TTL key

Coverage: 73.1% -> 90.9% (48 tests, 0 races)

Co-Authored-By: Charon <developers@lethean.io>
2026-02-20 01:14:08 +00:00
Snider
9ebe581069 feat: extract go-store from core/go pkg/store
SQLite key-value store wrapper.
Zero external dependencies (stdlib only).
Module: forge.lthn.ai/core/go-store

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