namidb-vault 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/sync.mjs +12 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "namidb-vault",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Sync a local Obsidian/markdown vault to NamiDB Cloud as a queryable graph for AI coding agents (Claude Code, Cursor, Codex). Note nodes + LINKS_TO/EMBEDS/TAGGED edges; backlinks, n-hop, orphans, shared-tags and semantic search over MCP. Zero-dependency.",
5
5
  "type": "module",
6
6
  "bin": {
package/sync.mjs CHANGED
@@ -730,11 +730,21 @@ async function pruneRemoved(graph) {
730
730
  // Drop placeholder stubs that nothing references any more, and now-orphaned
731
731
  // tags (no :TAGGED edge left). Cheap idempotent cleanup so the graph stays a
732
732
  // faithful index after deletions.
733
+ //
734
+ // Written as OPTIONAL MATCH + count(r)=0 rather than `NOT EXISTS((n)<-[…]-())`
735
+ // on purpose: the engine's planner does not hoist an EXISTS pattern predicate
736
+ // to a SemiApply in this DELETE shape and rejects it at runtime
737
+ // ("EXISTS pattern predicates require storage access"). The degree-count form
738
+ // is equivalent and planned fine.
733
739
  await postCypher(
734
- `MATCH (n:${NOTE_LABEL}) WHERE n.placeholder = true AND NOT EXISTS((n)<-[:${LINKS_TO}|:${EMBEDS}]-()) DETACH DELETE n`,
740
+ `MATCH (n:${NOTE_LABEL}) WHERE n.placeholder = true ` +
741
+ `OPTIONAL MATCH (n)<-[r:${LINKS_TO}|:${EMBEDS}]-() ` +
742
+ `WITH n, count(r) AS inc WHERE inc = 0 DETACH DELETE n`,
735
743
  );
736
744
  await postCypher(
737
- `MATCH (t:${TAG_LABEL}) WHERE NOT EXISTS((t)<-[:${TAGGED}]-()) AND NOT EXISTS((t)<-[:${SUBTAG_OF}]-()) DETACH DELETE t`,
745
+ `MATCH (t:${TAG_LABEL}) ` +
746
+ `OPTIONAL MATCH (t)<-[r:${TAGGED}|:${SUBTAG_OF}]-() ` +
747
+ `WITH t, count(r) AS inc WHERE inc = 0 DETACH DELETE t`,
738
748
  );
739
749
  return deleted;
740
750
  }