Skip to content

feat: backend-agnostic data layer with a NoKV journal backend - #11

Merged
wchwawa merged 1 commit into
mainfrom
feat/nokv-data-migration
Aug 5, 2026
Merged

feat: backend-agnostic data layer with a NoKV journal backend#11
wchwawa merged 1 commit into
mainfrom
feat/nokv-data-migration

Conversation

@wchwawa

@wchwawa wchwawa commented Aug 5, 2026

Copy link
Copy Markdown
Member

Summary

Migrates the entire data access behind a JournalDataRepository interface with two backends, per docs/nokv-data-migration-design.md (workflow-designed against NoKV main, source-verified):

  • SupabaseJournalRepository — behavior-preserving consolidation of every inline query (default; rollback path)
  • NokvJournalRepository — one workbench per user (jr-{userId}): per-entry create-only docs, day docs with block-level optimistic edits, monthly append-only ledger folded into the read model, keyword sidecar via workbench_grep, create-only edit-protection latches, audio blobs over the CLI collect/materialize channel

Also in this PR:

  • All 12 DB routes + reflections/agent libs now consume the repository
  • Browser anon Supabase reads eliminated (audited risk paid off): new /api/mood/today, /api/journals/today, /api/journals/stats; supabase/queries.ts + client.ts deleted
  • Timezone unification through timezone.ts (fixes the bare date-string day bounds in aggregate.ts)
  • DATA_BACKEND=supabase|nokv factory: nokv reads fall back to Supabase on transport failure; writes surface 503
  • 21 new tests incl. a contract suite against an in-memory workbench honoring NoKV semantics (create-only, exact-string edit, ordered append, grep)

Checks: typecheck ✅ · 51/51 vitest ✅ · production build ✅

🤖 Generated with Claude Code

Migrates EchoJournal's entire data access behind JournalDataRepository
(design: docs/nokv-data-migration-design.md), with two implementations:

- SupabaseJournalRepository: behavior-preserving consolidation of the
  previous inline queries (default backend, rollback path)
- NokvJournalRepository: one NoKV workbench per user (jr-{userId}) —
  per-entry create-only documents, day documents with block-level
  optimistic edits, monthly append-only ledger folded into the read
  model, keyword sidecar via workbench_grep, create-only edit-protection
  latches, audio blobs over the CLI collect/materialize channel

Also:
- All 12 DB routes + reflections/agent libs consume the repository
- Browser anon Supabase reads eliminated: hooks/modal now use new
  /api/mood/today, /api/journals/today, /api/journals/stats routes;
  supabase queries.ts + client.ts deleted
- Timezone unification: every day boundary goes through timezone.ts
- DATA_BACKEND=supabase|nokv factory; in nokv mode reads fall back to
  Supabase on transport failure, writes surface 503
- 21 new tests: serialization discipline, ledger fold, and a contract
  suite against an in-memory workbench honoring NoKV semantics

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@wchwawa
wchwawa merged commit 149924d into main Aug 5, 2026
@wchwawa
wchwawa deleted the feat/nokv-data-migration branch August 5, 2026 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant