Repository navigation
feat: make plugin-cache Redis writes atomic and reads fail loudly - #94
Conversation
◈ PR LensPR Lens paused analysis for this repository — the fair-use limit was reached. It resumes automatically at 2026-09-25T18:00:00.000Z. |
There was a problem hiding this comment.
ℹ️ No critical issues — one nitpick inline, everything else checks out.
Reviewed changes
Reviewed the atomic-write/fail-loud rework of RedisEntityCache end to end: the new RedisTransactionLike/multi() contract, the CacheValueError wrapping, the prune-on-write logic, the moved FakeRedis fixture, and the new cross-store manager parity tests.
- Atomic
set/delete: value key and@indexsorted-set entry now go through oneMULTI(packages/plugin-cache/src/lib/redis.ts:130-158), closing the crash-between-two-commands gap the PR describes. - Prune on write: when a
ttlis configured, everyset()also runszremrangebyscorein the same transaction (redis.ts:139-143), bounding the index even if nothing ever enumerates it. CacheValueError:deserialize()wraps JSON/gunzip/brotli failures with the Redis key and original error ascause, while connection errors are deliberately left unwrapped (redis.ts:228-242).- Shared
FakeRedisfixture: moved totests/fixtures/FakeRedis.tswithfailure/abortTransactionstoggles that simulate an outage and aWATCH-aborted transaction; itsmulti()only runs queued commands when not aborted, matching real Redis semantics. - Manager parity tests: new
packages/plugin-gateway/tests/stores.test.tsruns the sameGatewayClientdispatch scenarios against the in-memory and Redis (FakeRedis) stores, including an outage scenario asserting the client'serrorevent fires and later dispatches still land.
I also verified two of the PR's load-bearing claims rather than trusting the description: installed real ioredis and ran tsc --noEmit -p packages/plugin-cache/tsconfig.consumption.json — it passes, confirming Redis/Cluster.multi() really does satisfy the new RedisTransactionLike without a cast. And ran packages/plugin-cache's vitest suite locally (30/30 passing), including the new outage, aborted-transaction, corrupt-value, and prune-on-write tests — each one would actually fail without the corresponding production code, not just theatre.
ℹ️ Nitpicks
packages/plugin-gateway/tests/stores.test.tsimportsFakeRedisfrom../../plugin-cache/tests/fixtures/FakeRedis.js— a sibling package'stests/directory rather than a published entry point. It works today (neither package'stsconfig.jsonincludestests/, so it doesn't affect the build), but it's the first cross-package test import of this shape in the repo and will silently break ifplugin-cacheever reorganizes its test layout. Worth considering a sharedtests/fixtureslocation (or exporting a test-only entry fromplugin-cache) if more packages end up needing it.
Claude Sonnet | 𝕏
❌ 5 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
@wolfstar/plugin-api
@wolfstar/plugin-cache
@wolfstar/plugin-gateway
@wolfstar/plugin-i18next
@wolfstar/plugin-logger
@wolfstar/plugin-subcommands-advanced
commit: |
c2ede54 to
be4f06b
Compare
|
Your Claude subscription has hit its usage limit. It resets at 7:20pm (UTC). Re-trigger Pullfrog after the reset, or add an Add repo secret → · Model settings → · Setup docs → · Ask in Discord →
|
Value and index writes/deletes go through one MULTI transaction, a ttl prunes expired index entries on every write, and unreadable values reject with a CacheValueError naming the key. Managers are now tested against both the memory and the Redis store, outage included. Refs #55
be4f06b to
64bcf00
Compare
|
Your Claude subscription has hit its usage limit. It resets at 7:20pm (UTC). Re-trigger Pullfrog after the reset, or add an Add repo secret → · Model settings → · Setup docs → · Ask in Discord →
|

Stacked on #93.
🔗 Linked issue
Related to #55 (phase 4, store hardening). Also covers the first acceptance check: managers behave the same with the memory and the Redis store.
🧭 Context
The status update on #55 listed a few Redis gaps. A value and its index entry were written with two separate commands, so a crash in between left one without the other. The TTL index was only pruned when something enumerated it, so a cache nobody lists grew forever. And a corrupt value surfaced as a bare
SyntaxErroror zlib error with no hint of which key was broken.📚 Description
Writes and deletes now go through one
MULTI, and with attlevery write also drops expired index entries. Unreadable values reject with aCacheValueErrorthat carries the Redis key, with the original error ascause. Connection errors are deliberately left unwrapped, so an outage and a corrupt value stay distinguishable.RedisClientLikegainsmulti().ioredisRedisandClusterstill satisfy it as they are, which the existing type test checks. A custom client without transactions would now need one: that is the only compatibility cost, and the package is unreleased.The test
FakeRedismoved to a shared fixture, so the gateway tests can run the same manager scenarios against both stores, a Redis outage included.Left for later in phase 4: a serialization version tag, and deciding whether
clear,getSizeand iteration stay mandatory onEntityCache.Key changes
RedisEntityCache.set/deleteMULTIfor value + index; prune on write with attlCacheValueErrorfor invalid JSON and corrupt gzip/brotli bytes; aborted transactions rejectType of Change
Pre-flight Checklist
pnpm changeset(orpnpm changeset add --emptyif no release is needed). See .changeset/README.md.