Skip to content

add headless sync with ChronDB for block-level versioning#32

Merged
avelino merged 6 commits intomainfrom
avelino/sync-local
Apr 3, 2026
Merged

add headless sync with ChronDB for block-level versioning#32
avelino merged 6 commits intomainfrom
avelino/sync-local

Conversation

@avelino
Copy link
Copy Markdown
Owner

@avelino avelino commented Mar 31, 2026

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.

avelino added 6 commits March 30, 2026 22:17
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>
@avelino avelino changed the title WIP: Add headless sync with ChronDB for block-level versioning add headless sync with ChronDB for block-level versioning Apr 3, 2026
@avelino avelino merged commit d2e9626 into main Apr 3, 2026
4 checks passed
@avelino avelino deleted the avelino/sync-local branch April 3, 2026 22:00
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