Skip to content

Feature: edit-note recovery when note exists on disk but is not indexed yet #581

Description

@phernandez

Problem

edit-note fails with "Entity not found" when a markdown file exists on disk but has not been indexed yet.

This breaks a common workflow:

  1. Write file directly to disk.
  2. Immediately call bm tool edit-note ....
  3. Edit fails even though file exists.

Related downstream issue: basicmachines-co/openclaw-basic-memory#19

Why this looks upstream

Current edit flow resolves identifier to entity ID first and fails hard when index is behind:

  • src/basic_memory/cli/commands/tool.py (_edit_note_json)
  • src/basic_memory/mcp/tools/edit_note.py (resolve_entity before patch)

Requested fix

Add an optional recovery path when identifier resolution fails:

  1. Attempt targeted sync/index for matching file candidate(s) when identifier looks like a permalink/path.
  2. Retry entity resolution once after sync.
  3. Return a structured error code when recovery fails (e.g. ENTITY_NOT_FOUND_AFTER_SYNC) so clients can handle it deterministically.

Alternative acceptable fix: explicit edit-note flag (for example --sync-if-missing) that enables this behavior.

Acceptance criteria

  • If note exists on disk but is temporarily unindexed, edit-note can recover without manual watcher restart.
  • CLI JSON mode returns machine-readable failure code for non-recoverable misses.
  • Behavior is opt-in or clearly documented to avoid unexpected expensive sync calls.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions