Execution — fw-09-query-cache
Steps extracted from CONCEPTS.md. Read the concepts first; this file is the doing.
Record results in observation.md; tick checkpoints in verification.md.
3. Build order
- Key normalisation (structural equality, stable ordering).
- Cache with status:
fresh | stale | fetching | error. - Deduplication: N simultaneous subscribers, one request.
- Stale-while-revalidate.
- Retries with backoff; distinguish retriable from terminal errors.
- Cancellation on unsubscribe.
- Invalidation, exact and by key prefix.
- Background refetch (focus, reconnect, interval).
- Optimistic updates with rollback.
- Garbage collection of unobserved entries.
- Pagination and dependent queries.
4. Failure Lab — build every race
- Out-of-order responses. Request A then B for the same key; A resolves last. Show A's data winning. Fix with a sequence number; explain why timestamps are insufficient.
- Optimistic rollback onto a changed base. Apply an optimistic update, then a different server update arrives, then the optimistic one fails. Roll back to what?
- Dedup + cancellation. Three subscribers share one request; one unsubscribes. Does the request abort? Should it?
- Refetch storm. Window focus triggers refetch of 50 queries simultaneously.
- GC race. An entry is collected while a component is mid-mount.
- Cross-tab. Two tabs, same key, one mutates.