# CLI Sync Upload Graph UUID Alignment Implementation Plan Goal: Make `logseq sync upload` persist local graph UUID metadata so CLI and web app upload flows leave the graph in the same sync-ready state. Architecture: Keep `:thread-api/db-sync-upload-graph` as the single upload contract used by both CLI and web app. Architecture: Align identity persistence inside `frontend.worker.sync` so every resolved graph id is written to both client-op storage and graph KV metadata. Architecture: Use web app graph identity persistence semantics from `frontend.handler.db_based.sync/` succeeds, local graph metadata must contain a stable `:logseq.kv/graph-uuid` value in graph KV and the same graph id in client-op storage. The persistence rule must be enforced by worker sync code so both CLI and web app callers inherit identical behavior. When upload finds graph id from client-op fallback, worker must backfill missing graph KV UUID before returning success. Repeated uploads must be idempotent and must not create a new graph id or rewrite to a different value unexpectedly. ## Architecture and integration points ```text CLI path logseq.cli.command.sync/execute-sync-upload -> logseq.cli.transport/invoke POST /v1/invoke -> frontend.worker.db_worker_node /v1/invoke -> :thread-api/db-sync-upload-graph in frontend.worker.db_core -> frontend.worker.sync/ frontend.worker.sync/upload-graph! Web app path frontend.handler.db_based.sync/ state/ frontend.worker.sync/ frontend.worker.sync/upload-graph! Web app source-of-truth identity persistence reference frontend.handler.db_based.sync/ ldb/transact! with :logseq.kv/graph-uuid ``` ## Testing Plan I will add worker unit tests that fail first when upload identity resolution does not persist `:logseq.kv/graph-uuid` into the graph database. I will add worker unit tests that fail first for the three identity branches, which are graph id from remote create, graph id from remote name match, and graph id from client-op fallback. I will add regression assertions that verify the persisted graph UUID is readable through `logseq.db/get-graph-rtc-uuid` and matches `client-op/get-graph-uuid`. I will add a CLI-facing regression check that validates upload success is followed by graph info data containing `logseq.kv/graph-uuid` in real or staged integration coverage. I will run targeted tests after each micro-change, then run broad lint and test commands before final review. NOTE: I will write *all* tests before I add any implementation behavior. ## Implementation plan ### Phase 1. Add failing worker tests for UUID persistence parity. 1. Add a failing assertion in `/Users/rcmerci/gh-repos/logseq/src/test/frontend/worker/db_sync_test.cljs` for remote-create upload bootstrap to assert `ldb/get-graph-rtc-uuid` is set after `