Skip to content

[BUG] Adding project with existing files does not build knowledge graph #224

@lemon1324

Description

@lemon1324

Bug Description

I have a collection of .md files in a folder, and the files have cross-reference links and appropriate frontmatter. Running basic-memory project add "notes" [location], follower by basic-memory project default "notes" and basic-memory sync reports no errors.
However, directly inspecting memory.db shows that all of the files

  1. have type "file", even though the frontmatter says "note"
  2. have NULL permalink
  3. have no relations, despite links in the text.

Running Claude desktop and specifically asking it to use the MCP tool to create a new note results in only that entry in the database having correct metadata, type, and permalink.

Based on your bug description and our investigation, here's a complete Steps To Reproduce section:

Steps To Reproduce

Steps to reproduce the behavior:

  1. Install version 0.14.2
  2. Create a folder with existing .md files containing:
    • Proper frontmatter with type: note and permalink: example-permalink
    • Cross-reference links using [[filename.md]] or [[folder/filename.md]] syntax
  3. Run command basic-memory project add "notes" /path/to/existing/folder
  4. Run command basic-memory project default "notes"
  5. Run command basic-memory sync
  6. Verify sync status with basic-memory status (reports success)
  7. Ask Claude Desktop to make a new note using the MCP tool.
  8. Inspect SQLite database directly

Expected Behavior

All files should have type: "note", proper permalinks, and detected relations

Actual Behavior

All pre-existing files show entity_type: "file", permalink: null, no relations
Only the MCP-added file shows entity_type: "note", and has correct metadata and permalink, and relations.

Additional Notes

  • Files are readable via read_note but not searchable/traversable
  • sync_status reports "All projects synced successfully" despite indexing problems
  • Knowledge graph features (build_context, relationship detection) non-functional for existing files

Environment

  • OS: Windows 11 Home, 10.0.26100
  • Python version: 3.12.4
  • Basic Memory version: 0.14.2
  • Installation method: uv
  • Claude Desktop version (if applicable): 0.11.6

Additional Context

Image

Possible Solution

This seems like a mismatch between actions taken by write_note when adding a file vs actions taken by add project and sync commands from the command line. It seems like adding the database logic from write_note to the logic for initial ingestion of a manually-added file should resolve the issue, assuming the database logic doesn't depend directly on any extra data passed by Claude in the write_note function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions