Add query hooks for lore and bridge status with automatic invalidation
on lore-data-changed and sync-status events. Include mutations for
sync_now and reconcile operations that invalidate relevant queries.
- createQueryClient factory with appropriate defaults
- useLoreStatus hook with 30s staleTime and event invalidation
- useBridgeStatus hook with 30s staleTime and event invalidation
- useSyncNow mutation with query invalidation on success
- useReconcile mutation with query invalidation on success
- Centralized query keys for consistent invalidation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add InvariantError class and assertion utilities for runtime validation:
- invariant(condition, message) - throws if condition is falsy, acts as type guard
- assertNever(value) - for exhaustive switch statement checking
- Support for lazy message evaluation to avoid expensive string operations
These helpers enable defensive programming with clear error messages when
invariants are violated.
Closes bd-1w5
- Log swallowed errors in file watcher and window operations (lib.rs, watcher.rs)
- Propagate recovery errors from bridge::recover_pending to SyncResult.errors
so the frontend can display them instead of silently dropping failures
- Fix useTauriEvent/useTauriEvents race condition where cleanup fires before
async listen() resolves, leaking the listener (cancelled flag pattern)
- Guard computeStaleness against invalid date strings (NaN -> 'normal'
instead of incorrectly returning 'urgent')
- Strengthen isMcError type guard to check field types, not just presence
- Log warning when data directory resolution falls back to '.' (state.rs, bridge.rs)
- Add test for computeStaleness with invalid date inputs