Skip to content

wip: preserve DB graph files on CLI reopen - #15

Merged
e-zz merged 1 commit into
privfrom
fix/issue-12-cli-open-wip
Oct 10, 2026
Merged

e-zz merged 1 commit into
privfrom
fix/issue-12-cli-open-wip

Conversation

@e-zz

@e-zz e-zz commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Scope (WIP)

Preserves the five built-in DB-graph file entities when @logseq/cli opens an existing graph: logseq/config.edn, logseq/custom.css, logseq/custom.js, logseq/publish.css, and logseq/publish.js. The initialization transaction now omits files whose :file/path already exists. Fresh graphs still receive defaults; a partial graph receives defaults only for missing files. Also uses the platform classpath delimiter so the config template path works on Windows.

This is a narrow file-content protection slice for #12, not a full CLI reopen-safety fix. The PR targets priv because that is the branch from which the isolated worktree was created. Keep this PR draft; do not merge or close #12 yet.

Verified

  • Disposable DB graph with distinct non-default content in all five files: two CLI init-conn reopens preserve their :file/content values and an unrelated block.
  • Disposable partial graph: three existing file values survive two reopens; the two missing files receive defaults. A query failure propagates rather than silently disabling the guard.
  • bb dev:run-test-namespaces -n logseq.outliner.cli-issue12-test — 3 tests, 13 assertions, 0 failures/errors.
  • bb dev:run-test-namespaces -n logseq.db.sqlite.create-graph-issue12-test — 1 test, 5 assertions, 0 failures/errors.
  • bb dev:run-test-namespaces -n logseq.api.db-based.cli-test — 6 tests, 17 assertions, 0 failures/errors.
  • git diff --check — clean.

Known gap / merge blocker

init-conn still runs the broader initial-data transaction on every open. A disposable-graph probe observed :logseq.kv/local-graph-uuid regenerated and :logseq.kv/graph-created-at reset on reopen. The same transaction reasserts :logseq.kv/schema-version and :logseq.kv/graph-initial-schema-version to the compiled version, which is unsafe for older graphs without a migration. These KV fields are outside this file-content slice and are not fixed here. Do not interpret passing file tests as whole-graph reopen idempotence.

The tests compare Datascript :file/content strings, not raw SQLite bytes. Export/script caller paths were inspected but not exercised end-to-end in this PR. No existing graph content was recovered or migrated. No user graph was opened for verification.

Before ready for review

@e-zz
e-zz merged commit 2255fa7 into priv Oct 10, 2026
1 check failed
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