Description
src/sequenceCache.ts manages cached sequence numbers with invalidation flags scattered across several boolean variables. The state transitions between valid, invalidated, and refreshing are implicit and hard to trace. Converting to an explicit state machine (type CacheState = 'valid' | 'invalidated' | 'refreshing') makes transitions auditable.
Acceptance Criteria
Context
- Target file:
src/sequenceCache.ts
- The public API (
getSequence, invalidate, refresh) must not change
Description
src/sequenceCache.tsmanages cached sequence numbers with invalidation flags scattered across several boolean variables. The state transitions betweenvalid,invalidated, andrefreshingare implicit and hard to trace. Converting to an explicit state machine (type CacheState = 'valid' | 'invalidated' | 'refreshing') makes transitions auditable.Acceptance Criteria
CacheStatetype union replaces the boolean flagstransition(newState)function that validates the transitionvalidtorefreshingwithout first going throughinvalidated) throw aStateTransitionErrorContext
src/sequenceCache.tsgetSequence,invalidate,refresh) must not change