On-disk JSON metadata store for the local cache (closes #41) #58

Merged
clawbot merged 2 commits from issue-41-json-metadata-store into next 2026-09-22 12:52:51 +02:00
2 Commits
Author SHA1 Message Date
sneak 76141ae919 feat(library/store): on-disk JSON metadata store for the local cache
check / check (push) Successful in 13s
Add `MetadataStore` (src/library/store.ts): one metadata.json holding the
user id, schema version, collections cursor, and decrypted collection and
file records. Loaded whole into RAM with Maps for id lookups; rewritten
whole through the download layer's fsync atomic writer (temp, fsync,
rename, dir fsync). Binary keys are base64-encoded on disk. A missing,
unparseable, or wrong-schema file loads as an empty store, because the
file is only a cache the refresh unit repopulates. Directory 0700, file
0600, matching session.json. No lock file; no sync() beyond the writer.

This unit only stores; issue 42's refresh unit populates it. (closes #41)

Model: opus-4-8
2026-09-22 10:46:17 +00:00
sneak 15ceac857a test(library/store): metadata store round-trip, empty-on-corrupt, perms
Failing first: the on-disk JSON metadata store does not exist yet. These
tests fix its contract before the implementation lands — round-trip
fidelity including the binary keys, missing/corrupt files loading empty, a
schema-version mismatch discarded as stale cache, atomic writes leaving no
temp sibling, and directory 0700 / file 0600 permissions.

Model: opus-4-8
2026-09-22 10:46:02 +00:00