feat: add store_versions.ts — localStorage schema versioning for ae_loc and ae_events_loc
Persistent stores grow and change over time. svelte-persisted-store deep-merges old localStorage values with new defaults, so stale values (e.g. hash_prefix_length: 1) silently survive schema changes and cause subtle bugs. - src/lib/stores/store_versions.ts: Single source of truth for AE_LOC_VERSION / AE_EVENTS_LOC_VERSION. Side-effect on import: reads raw localStorage and wipes if __version mismatches. Must be imported first in ae_stores.ts and ae_events_stores.ts so the wipe happens before persisted() hydrates from localStorage. - ae_stores.ts + ae_events_stores.ts: Import store_versions as first import; add __version to persisted store defaults. - documentation/TODO__Agents.md: Added stores refactor task — both store files need a cleanup pass. Bump AE_LOC_VERSION or AE_EVENTS_LOC_VERSION by 1 on breaking schema changes. Non-breaking changes (new optional fields, default value tweaks) do not need a bump. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
// store_versions MUST be first import — its side-effect wipes stale localStorage
|
||||
// before svelte-persisted-store hydrates from it.
|
||||
import { AE_EVENTS_LOC_VERSION } from '$lib/stores/store_versions';
|
||||
|
||||
import { persisted } from 'svelte-persisted-store';
|
||||
import { writable } from 'svelte/store';
|
||||
import type { Writable } from 'svelte/store';
|
||||
@@ -12,6 +16,7 @@ const ver_idb = '2025-10-16_2139';
|
||||
// Longer-term app data. This should be stored to *local* storage.
|
||||
// Updated 2024-03-06
|
||||
const events_local_data_struct: key_val = {
|
||||
__version: AE_EVENTS_LOC_VERSION, // Schema version gate — see store_versions.ts
|
||||
ver: ver,
|
||||
ver_idb: ver_idb,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user