add headless sync with ChronDB for block-level versioning#32
Merged
Conversation
Roam's API has no change timestamps, so detecting what changed requires pulling every page on each sync — flooding the API for large graphs. Introduced `roam sync` (feature-gated behind `chrondb`) that uses a two-query differential strategy: one lightweight fingerprint query fetches all block UIDs+content in a single call, diffs locally against ChronDB, and only pulls full page trees for pages that actually changed. A stable 500-page graph now costs 2 API calls instead of 501. Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
Full re-sync on every run was flooding the Roam API. Pages already synced were being skipped, but content updates to existing pages were never picked up. Uses Roam's :edit/time attribute to query only pages modified since the last sync timestamp. Daily notes and regular pages are pulled in priority order (updates first, then new dailies, then new pages). Ctrl+C triggers a graceful shutdown that flushes progress to ChronDB. Git remote support commits and pushes markdown files after each sync when configured. Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
ChronDB's native push was sending its internal bare repo (metadata) to the remote instead of the actual markdown files users expect. Moved git operations to the sync output directory so `roam sync` commits and pushes the markdown pages/daily notes directly. ChronDB stays local for state tracking only, git CLI handles the remote via SSH. Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
Sync was one-way only — edits made in local markdown files had no way to flow back to Roam. Added a markdown parser that reconstructs the block tree from exported files and diffs it against Roam's current state by position. Push sync now handles content updates, block creation with recursive children, and block deletion. Uses :page/edit-time for more accurate change detection on pull. Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
Bidirectional sync, ChronDB integration, and incremental change detection are shipping as a minor release. Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Roam's API has no change timestamps, so detecting what changed requires pulling every page on each sync — flooding the API for large graphs.
Introduced
roam sync(feature-gated behindchrondb) that uses a two-query differential strategy: one lightweight fingerprint query fetches all block UIDs+content in a single call, diffs locally against ChronDB, and only pulls full page trees for pages that actually changed. A stable 500-page graph now costs 2 API calls instead of 501.