This guide helps AI agents implement and review db-sync features consistently across the client and the Cloudflare Worker. Keep changes scoped, follow the existing flow, and document any protocol or storage changes. Keep this document accurate (file names, paths, commands, and parameters).
src/main/frontend/config.cljssrc/main/frontend/worker/db_sync.cljssrc/main/frontend/worker/db_worker.cljssrc/main/frontend/handler/db_based/db_sync.cljsdeps/db-sync/src/logseq/db_sync/1) Define behavior: state the new capability, expected inputs/outputs, and compatibility requirements.
2) Update protocol first (if needed): change protocol.cljs and adjust server/client serialization in tandem.
3) Server changes: update worker.cljs, worker_core.cljs, storage.cljs, or cycle.cljs.
4) Client changes: update db_sync.cljs and thread APIs in db_worker.cljs.
5) Handler glue: add or adjust the entry points in handler/db_based/db_sync.cljs.
6) Function ordering: keep related ClojureScript fns together and ordered to minimize declare usage.
:db-sync/* keywords; add new keywords via logseq.common.defkeywords/defkeyword.log/error) and throw immediately.:t, :txs, :reason, :data).tx/reject or 400 errors for:
:txs not a sequence of strings).t/t_before values.docs/agent-guide/db-sync/protocol.md for request/response shapes.docs/agent-guide/db-sync/protocol.md for request/response shapes.bb dev:db-sync-start runs the db-sync watcher, wrangler dev, and yarn watch with ENABLE_DB_SYNC_LOCAL=truebb dev:db-sync-test:db-sync/* context keys.