Skip to content

perf: skip full-graph validate on MCP upsertNodes (#1265) - #13388

Merged
tiensonqin merged 4 commits into
masterfrom
logseq/perf-upsert-nodes-validate-scope-ebc1
Sep 23, 2026
Merged

tiensonqin merged 4 commits into
masterfrom
logseq/perf-upsert-nodes-validate-scope-ebc1

Conversation

@tiensonqin

@tiensonqin tiensonqin commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes logseq/db-test#1265

Problem

MCP upsertNodes imported through batch EDN and then ran validate-local-db! on every entity in db-after. On a large graph that made a single-block write take 60–140s while logseq-cli upsert block stayed under a second.

Change

  • validate-import-txs accepts :validate-scope.
    • :graph (default): keep full-graph validate-local-db! for file / graph / import-edn flows.
    • :tx: validate only entities touched by the import tx (d/with tx-report eids).
  • validate-local-db! accepts :entity-ids so scoped validation reuses the same error format and disallowed-key retry.
  • API/MCP upsert-nodes passes {:validate-scope :tx} automatically. No new MCP/API flag.
  • Unrelated file-import callers are unchanged.

Secondary

If a block page-id is a page name instead of a uuid (or the :id of a page added in the same call), upsertNodes now fails fast instead of reporting success and writing nothing.

Tests

  • validate-import-txs :tx does not invoke whole-db validation (spy + untouched invalid entity).
  • :tx still rejects invalid import txs.
  • Default :graph still validates the whole DB.
  • upsert-nodes calls validate-local-db! with :entity-ids (not the full graph).
  • Unresolved page-id names are rejected.
  • Existing file-import batch-import-edn tests still pass.

API / migration

No schema, protocol, or persisted-data migration. Existing import-edn / file import behavior is unchanged. MCP clients do not need to pass a new option.

Open in Web Open in Cursor 

@tiensonqin
tiensonqin force-pushed the logseq/perf-upsert-nodes-validate-scope-ebc1 branch from 45e1cbb to ca948a2 Compare September 23, 2026 07:59
@tiensonqin
tiensonqin marked this pull request as ready for review September 23, 2026 07:59
devin-ai-integration[bot]

This comment was marked as resolved.

@tiensonqin tiensonqin self-assigned this Sep 23, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Fixed in bc467fb: same-call page :ids are resolved first (and excluded from the existing-page path), and remaining UUID page-ids must resolve to an existing page entity (entity-util/page?), so block UUIDs are rejected.

cursoragent and others added 4 commits September 23, 2026 16:26
Validate only entities touched by the import tx for upsert-nodes.
File and graph imports keep full-graph validate-local-db!.

Co-authored-by: Tienson Qin <[email protected]>
Fail fast when a block page-id is a name instead of a page uuid
or the id of a page added in the same call.

Co-authored-by: Tienson Qin <[email protected]>
Assert validate-local-db! receives :entity-ids on the upsert-nodes
import path instead of wrapping validate-import-txs.

Co-authored-by: Tienson Qin <[email protected]>
@tiensonqin
tiensonqin force-pushed the logseq/perf-upsert-nodes-validate-scope-ebc1 branch from bc467fb to 2587c87 Compare September 23, 2026 08:26
@tiensonqin
tiensonqin merged commit 96b806f into master Sep 23, 2026
24 of 25 checks passed
@tiensonqin
tiensonqin deleted the logseq/perf-upsert-nodes-validate-scope-ebc1 branch September 23, 2026 09:41
devin-ai-integration Bot pushed a commit that referenced this pull request Sep 24, 2026
* perf: skip full-graph validate on MCP upsertNodes

Validate only entities touched by the import tx for upsert-nodes.
File and graph imports keep full-graph validate-local-db!.

Co-authored-by: Tienson Qin <[email protected]>

* fix: reject unresolved upsertNodes page-id

Fail fast when a block page-id is a name instead of a page uuid
or the id of a page added in the same call.

Co-authored-by: Tienson Qin <[email protected]>

* test: spy upsert-nodes scoped validation via entity-ids

Assert validate-local-db! receives :entity-ids on the upsert-nodes
import path instead of wrapping validate-import-txs.

Co-authored-by: Tienson Qin <[email protected]>

* fix: resolve upsertNodes page-id against same-call pages before existing page uuids

---------

Co-authored-by: Cursor Agent <[email protected]>
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 1, 2026
* perf: skip full-graph validate on MCP upsertNodes

Validate only entities touched by the import tx for upsert-nodes.
File and graph imports keep full-graph validate-local-db!.

Co-authored-by: Tienson Qin <[email protected]>

* fix: reject unresolved upsertNodes page-id

Fail fast when a block page-id is a name instead of a page uuid
or the id of a page added in the same call.

Co-authored-by: Tienson Qin <[email protected]>

* test: spy upsert-nodes scoped validation via entity-ids

Assert validate-local-db! receives :entity-ids on the upsert-nodes
import path instead of wrapping validate-import-txs.

Co-authored-by: Tienson Qin <[email protected]>

* fix: resolve upsertNodes page-id against same-call pages before existing page uuids

---------

Co-authored-by: Cursor Agent <[email protected]>
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 1, 2026
* perf: skip full-graph validate on MCP upsertNodes

Validate only entities touched by the import tx for upsert-nodes.
File and graph imports keep full-graph validate-local-db!.

Co-authored-by: Tienson Qin <[email protected]>

* fix: reject unresolved upsertNodes page-id

Fail fast when a block page-id is a name instead of a page uuid
or the id of a page added in the same call.

Co-authored-by: Tienson Qin <[email protected]>

* test: spy upsert-nodes scoped validation via entity-ids

Assert validate-local-db! receives :entity-ids on the upsert-nodes
import path instead of wrapping validate-import-txs.

Co-authored-by: Tienson Qin <[email protected]>

* fix: resolve upsertNodes page-id against same-call pages before existing page uuids

---------

Co-authored-by: Cursor Agent <[email protected]>
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 8, 2026
* perf: skip full-graph validate on MCP upsertNodes

Validate only entities touched by the import tx for upsert-nodes.
File and graph imports keep full-graph validate-local-db!.

Co-authored-by: Tienson Qin <[email protected]>

* fix: reject unresolved upsertNodes page-id

Fail fast when a block page-id is a name instead of a page uuid
or the id of a page added in the same call.

Co-authored-by: Tienson Qin <[email protected]>

* test: spy upsert-nodes scoped validation via entity-ids

Assert validate-local-db! receives :entity-ids on the upsert-nodes
import path instead of wrapping validate-import-txs.

Co-authored-by: Tienson Qin <[email protected]>

* fix: resolve upsertNodes page-id against same-call pages before existing page uuids

---------

Co-authored-by: Cursor Agent <[email protected]>
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 8, 2026
* perf: skip full-graph validate on MCP upsertNodes

Validate only entities touched by the import tx for upsert-nodes.
File and graph imports keep full-graph validate-local-db!.

Co-authored-by: Tienson Qin <[email protected]>

* fix: reject unresolved upsertNodes page-id

Fail fast when a block page-id is a name instead of a page uuid
or the id of a page added in the same call.

Co-authored-by: Tienson Qin <[email protected]>

* test: spy upsert-nodes scoped validation via entity-ids

Assert validate-local-db! receives :entity-ids on the upsert-nodes
import path instead of wrapping validate-import-txs.

Co-authored-by: Tienson Qin <[email protected]>

* fix: resolve upsertNodes page-id against same-call pages before existing page uuids

---------

Co-authored-by: Cursor Agent <[email protected]>
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 8, 2026
* perf: skip full-graph validate on MCP upsertNodes

Validate only entities touched by the import tx for upsert-nodes.
File and graph imports keep full-graph validate-local-db!.

Co-authored-by: Tienson Qin <[email protected]>

* fix: reject unresolved upsertNodes page-id

Fail fast when a block page-id is a name instead of a page uuid
or the id of a page added in the same call.

Co-authored-by: Tienson Qin <[email protected]>

* test: spy upsert-nodes scoped validation via entity-ids

Assert validate-local-db! receives :entity-ids on the upsert-nodes
import path instead of wrapping validate-import-txs.

Co-authored-by: Tienson Qin <[email protected]>

* fix: resolve upsertNodes page-id against same-call pages before existing page uuids

---------

Co-authored-by: Cursor Agent <[email protected]>
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 28, 2026
…ialog

Importing a one-page EDN through "Import EDN data" took about 11 seconds on a large graph.

The dialog called `batch-import-edn!` without a `:validate-scope`, so the import ran `validate-local-db!` over every entity of the graph. The MCP/CLI upsert path already passes `{:validate-scope :tx}` (logseq#13388) and the dialog was not changed with it.

The dialog now passes `{:validate-scope :tx}`, which validates the entities the import touched. The whole-graph EDN import keeps the full validation.

Test: `import-edn-data-dialog-validates-only-touched-entities-test` submits the dialog's EDN for a page with a tag and checks that `validate-local-db!` is called with `:entity-ids`.

The "Go to page" notification and the progress bar asked for in the issue are not part of this change.

Fixes logseq/db-test#994
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 29, 2026
…ialog

Importing a one-page EDN through "Import EDN data" took about 11 seconds on a large graph.

The dialog called `batch-import-edn!` without a `:validate-scope`, so the import ran `validate-local-db!` over every entity of the graph. The MCP/CLI upsert path already passes `{:validate-scope :tx}` (logseq#13388) and the dialog was not changed with it.

The dialog now passes `{:validate-scope :tx}`, which validates the entities the import touched. The whole-graph EDN import keeps the full validation.

Test: `import-edn-data-dialog-validates-only-touched-entities-test` submits the dialog's EDN for a page with a tag and checks that `validate-local-db!` is called with `:entity-ids`.

The "Go to page" notification and the progress bar asked for in the issue are not part of this change.

Fixes logseq/db-test#994
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 29, 2026
…ialog

Importing a one-page EDN through "Import EDN data" took about 11 seconds on a large graph.

The dialog called `batch-import-edn!` without a `:validate-scope`, so the import ran `validate-local-db!` over every entity of the graph. The MCP/CLI upsert path already passes `{:validate-scope :tx}` (logseq#13388) and the dialog was not changed with it.

The dialog now passes `{:validate-scope :tx}`, which validates the entities the import touched. The whole-graph EDN import keeps the full validation.

Test: `import-edn-data-dialog-validates-only-touched-entities-test` submits the dialog's EDN for a page with a tag and checks that `validate-local-db!` is called with `:entity-ids`.

The "Go to page" notification and the progress bar asked for in the issue are not part of this change.

Fixes logseq/db-test#994
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 31, 2026
…ialog

Importing a one-page EDN through "Import EDN data" took about 11 seconds on a large graph.

The dialog called `batch-import-edn!` without a `:validate-scope`, so the import ran `validate-local-db!` over every entity of the graph. The MCP/CLI upsert path already passes `{:validate-scope :tx}` (logseq#13388) and the dialog was not changed with it.

The dialog now passes `{:validate-scope :tx}`, which validates the entities the import touched. The whole-graph EDN import keeps the full validation.

Test: `import-edn-data-dialog-validates-only-touched-entities-test` submits the dialog's EDN for a page with a tag and checks that `validate-local-db!` is called with `:entity-ids`.

The "Go to page" notification and the progress bar asked for in the issue are not part of this change.

Fixes logseq/db-test#994
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 3, 2026
…ialog

Importing a one-page EDN through "Import EDN data" took about 11 seconds on a large graph.

The dialog called `batch-import-edn!` without a `:validate-scope`, so the import ran `validate-local-db!` over every entity of the graph. The MCP/CLI upsert path already passes `{:validate-scope :tx}` (logseq#13388) and the dialog was not changed with it.

The dialog now passes `{:validate-scope :tx}`, which validates the entities the import touched. The whole-graph EDN import keeps the full validation.

Test: `import-edn-data-dialog-validates-only-touched-entities-test` submits the dialog's EDN for a page with a tag and checks that `validate-local-db!` is called with `:entity-ids`.

The "Go to page" notification and the progress bar asked for in the issue are not part of this change.

Fixes logseq/db-test#994
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 11, 2026
…ialog

Importing a one-page EDN through "Import EDN data" took about 11 seconds on a large graph.

The dialog called `batch-import-edn!` without a `:validate-scope`, so the import ran `validate-local-db!` over every entity of the graph. The MCP/CLI upsert path already passes `{:validate-scope :tx}` (logseq#13388) and the dialog was not changed with it.

The dialog now passes `{:validate-scope :tx}`, which validates the entities the import touched. The whole-graph EDN import keeps the full validation.

Test: `import-edn-data-dialog-validates-only-touched-entities-test` submits the dialog's EDN for a page with a tag and checks that `validate-local-db!` is called with `:entity-ids`.

The "Go to page" notification and the progress bar asked for in the issue are not part of this change.

Fixes logseq/db-test#994
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 12, 2026
…ialog

Importing a one-page EDN through "Import EDN data" took about 11 seconds on a large graph.

The dialog called `batch-import-edn!` without a `:validate-scope`, so the import ran `validate-local-db!` over every entity of the graph. The MCP/CLI upsert path already passes `{:validate-scope :tx}` (logseq#13388) and the dialog was not changed with it.

The dialog now passes `{:validate-scope :tx}`, which validates the entities the import touched. The whole-graph EDN import keeps the full validation.

Test: `import-edn-data-dialog-validates-only-touched-entities-test` submits the dialog's EDN for a page with a tag and checks that `validate-local-db!` is called with `:entity-ids`.

The "Go to page" notification and the progress bar asked for in the issue are not part of this change.

Fixes logseq/db-test#994
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 16, 2026
…ialog

Importing a one-page EDN through "Import EDN data" took about 11 seconds on a large graph.

The dialog called `batch-import-edn!` without a `:validate-scope`, so the import ran `validate-local-db!` over every entity of the graph. The MCP/CLI upsert path already passes `{:validate-scope :tx}` (logseq#13388) and the dialog was not changed with it.

The dialog now passes `{:validate-scope :tx}`, which validates the entities the import touched. The whole-graph EDN import keeps the full validation.

Test: `import-edn-data-dialog-validates-only-touched-entities-test` submits the dialog's EDN for a page with a tag and checks that `validate-local-db!` is called with `:entity-ids`.

The "Go to page" notification and the progress bar asked for in the issue are not part of this change.

Fixes logseq/db-test#994
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 17, 2026
…ialog

Importing a one-page EDN through "Import EDN data" took about 11 seconds on a large graph.

The dialog called `batch-import-edn!` without a `:validate-scope`, so the import ran `validate-local-db!` over every entity of the graph. The MCP/CLI upsert path already passes `{:validate-scope :tx}` (logseq#13388) and the dialog was not changed with it.

The dialog now passes `{:validate-scope :tx}`, which validates the entities the import touched. The whole-graph EDN import keeps the full validation.

Test: `import-edn-data-dialog-validates-only-touched-entities-test` submits the dialog's EDN for a page with a tag and checks that `validate-local-db!` is called with `:entity-ids`.

The "Go to page" notification and the progress bar asked for in the issue are not part of this change.

Fixes logseq/db-test#994
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 18, 2026
…ialog

Importing a one-page EDN through "Import EDN data" took about 11 seconds on a large graph.

The dialog called `batch-import-edn!` without a `:validate-scope`, so the import ran `validate-local-db!` over every entity of the graph. The MCP/CLI upsert path already passes `{:validate-scope :tx}` (logseq#13388) and the dialog was not changed with it.

The dialog now passes `{:validate-scope :tx}`, which validates the entities the import touched. The whole-graph EDN import keeps the full validation.

Test: `import-edn-data-dialog-validates-only-touched-entities-test` submits the dialog's EDN for a page with a tag and checks that `validate-local-db!` is called with `:entity-ids`.

The "Go to page" notification and the progress bar asked for in the issue are not part of this change.

Fixes logseq/db-test#994
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 18, 2026
…ialog

Importing a one-page EDN through "Import EDN data" took about 11 seconds on a large graph.

The dialog called `batch-import-edn!` without a `:validate-scope`, so the import ran `validate-local-db!` over every entity of the graph. The MCP/CLI upsert path already passes `{:validate-scope :tx}` (logseq#13388) and the dialog was not changed with it.

The dialog now passes `{:validate-scope :tx}`, which validates the entities the import touched. The whole-graph EDN import keeps the full validation.

Test: `import-edn-data-dialog-validates-only-touched-entities-test` submits the dialog's EDN for a page with a tag and checks that `validate-local-db!` is called with `:entity-ids`.

The "Go to page" notification and the progress bar asked for in the issue are not part of this change.

Fixes logseq/db-test#994
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 18, 2026
…ialog

Importing a one-page EDN through "Import EDN data" took about 11 seconds on a large graph.

The dialog called `batch-import-edn!` without a `:validate-scope`, so the import ran `validate-local-db!` over every entity of the graph. The MCP/CLI upsert path already passes `{:validate-scope :tx}` (logseq#13388) and the dialog was not changed with it.

The dialog now passes `{:validate-scope :tx}`, which validates the entities the import touched. The whole-graph EDN import keeps the full validation.

Test: `import-edn-data-dialog-validates-only-touched-entities-test` submits the dialog's EDN for a page with a tag and checks that `validate-local-db!` is called with `:entity-ids`.

The "Go to page" notification and the progress bar asked for in the issue are not part of this change.

Fixes logseq/db-test#994
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 18, 2026
…ialog

Importing a one-page EDN through "Import EDN data" took about 11 seconds on a large graph.

The dialog called `batch-import-edn!` without a `:validate-scope`, so the import ran `validate-local-db!` over every entity of the graph. The MCP/CLI upsert path already passes `{:validate-scope :tx}` (logseq#13388) and the dialog was not changed with it.

The dialog now passes `{:validate-scope :tx}`, which validates the entities the import touched. The whole-graph EDN import keeps the full validation.

Test: `import-edn-data-dialog-validates-only-touched-entities-test` submits the dialog's EDN for a page with a tag and checks that `validate-local-db!` is called with `:entity-ids`.

The "Go to page" notification and the progress bar asked for in the issue are not part of this change.

Fixes logseq/db-test#994
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 19, 2026
…ialog

Importing a one-page EDN through "Import EDN data" took about 11 seconds on a large graph.

The dialog called `batch-import-edn!` without a `:validate-scope`, so the import ran `validate-local-db!` over every entity of the graph. The MCP/CLI upsert path already passes `{:validate-scope :tx}` (logseq#13388) and the dialog was not changed with it.

The dialog now passes `{:validate-scope :tx}`, which validates the entities the import touched. The whole-graph EDN import keeps the full validation.

Test: `import-edn-data-dialog-validates-only-touched-entities-test` submits the dialog's EDN for a page with a tag and checks that `validate-local-db!` is called with `:entity-ids`.

The "Go to page" notification and the progress bar asked for in the issue are not part of this change.

Fixes logseq/db-test#994
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.

MCP upsertNodes takes 60–140 s on a large DB graph: the batch EDN import validates the whole graph on every call

2 participants