Skip to content

feat: git object identity + repo state model with IndexedDB storage - #107

Draft
mitschabaude wants to merge 4 commits into
data-layer-v2from
data-layer-v2-git-storage
Draft

mitschabaude wants to merge 4 commits into
data-layer-v2from
data-layer-v2-git-storage

Conversation

@mitschabaude

Copy link
Copy Markdown
Member

What

Foundation for the data layer V2 rebuild. Two independent pieces built in parallel:

Git object identity library (src/git/)

Pure functions for blob/tree/commit SHA computation, byte-for-byte compatible with real Git. Includes flat-path-map → nested tree reconstruction. 38 tests oracle-verified against git CLI.

Repo state model + IndexedDB storage (src/storage/repo-*.ts)

TypeScript types for the full repo state model (three-snapshot model: BASE/REMOTE/LOCAL, flat path maps, merge state, refs). IndexedDB persistence with clean async API. 29 tests.

Design doc

docs/vibenote-git-sync-design.md — captures the full design direction for the local git model and sync flow.

Next steps

  • Sync engine (task 3)
  • Wire into useAppDataV2 (task 4)
  • Storage pruning (task 5)

Builds on #104.

…torage

- src/git/: pure functions for blob/tree/commit SHA computation, byte-for-byte
  compatible with real Git. 38 oracle tests against git CLI.
- src/storage/repo-types.ts: TypeScript types for the full repo state model
  (three-snapshot model, flat path maps, merge state, refs).
- src/storage/repo-db.ts: IndexedDB persistence layer with clean async API.
  29 tests covering roundtrip, multi-repo isolation, file ops.
- docs/vibenote-git-sync-design.md: design doc for the git sync rebuild.

Tasks: git-object-identity (done), repo-state-storage (done)
@vercel

vercel Bot commented Mar 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vibenote Ready Ready Preview, Comment Mar 6, 2026 3:27am

- src/sync/sync-engine.ts: New sync engine implementing the design from
  vibenote-git-sync-design.md. Operates on RepoState types with a clean
  GitHubRemote adapter interface.
- Sync flow: fetch remote → diff against BASE → three-way merge → commit → push → retry
- Merge policies: markdown (custom 3-way via Yjs), binary (theirs wins),
  other text (remote wins as fallback)
- Handles all cases: no-op, local-only push, remote-only pull, both-changed merge,
  race condition retry (max 3)
- 19 tests covering all sync scenarios with in-memory mock GitHub remote

Task: sync-engine (done)
- src/sync/github-adapter.ts: Implements GitHubRemote interface against
  GitHub REST API. Clean adapter bridging sync engine to real backend.
- src/data/repo-state-store.ts: Reactive in-memory store wrapping RepoState.
  Provides file operations (create, rename, move, delete, save) with React
  subscription model. V2 replacement for localStorage-based LocalStore.
- 21 tests for RepoStateStore (file ops, folders, subscriptions, state mgmt)
- All modules type-check cleanly, full test suite passes (279 tests)

Tasks: wire-app-data-v2 (done)
- src/data/storage-pruning.ts: Policy module that evicts locally-cached files
  that are fully synced with the remote and haven't been accessed recently.
- Supports maxFiles, maxBytes, minAgeMs, and pinnedPaths constraints.
- Only evicts files whose blob SHA matches the BASE snapshot (safe to re-fetch).
- Evicts oldest files first.
- 11 tests covering all pruning scenarios.
- Full suite: 290 tests pass, type check clean.

Task: storage-pruning (done)
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