Problem
build_context can return empty results for notes that are retrievable via read-note, especially when callers pass path-like identifiers that are valid from user perspective but not exact permalink matches.
Related downstream issue: basicmachines-co/openclaw-basic-memory#17
Why this looks upstream
ContextService.build_context performs exact permalink lookup for non-wildcard URLs and currently has no fallback resolution path:
src/basic_memory/services/context_service.py
src/basic_memory/mcp/tools/build_context.py
src/basic_memory/mcp/project_context.py (resolve_project_and_path)
Requested fix
Improve context identifier resolution and empty-result diagnostics:
- If exact permalink lookup returns 0 primaries, try a fallback resolver path:
- alternate project-prefix normalization (with/without project prefix), and/or
- resolve via entity resolver (same strategy family used by read tooling).
- Include normalized/resolved lookup path in JSON metadata when results are empty.
- Return a machine-readable "no primary match" reason (not just empty list) so clients can distinguish "no relations" from "lookup miss".
Acceptance criteria
build_context finds primary note for common memory URL forms when note exists.
- Empty result payload includes enough diagnostics to debug path mismatch quickly.
- Backward compatibility: existing successful exact lookups behave unchanged.
Problem
build_contextcan return empty results for notes that are retrievable viaread-note, especially when callers pass path-like identifiers that are valid from user perspective but not exact permalink matches.Related downstream issue: basicmachines-co/openclaw-basic-memory#17
Why this looks upstream
ContextService.build_contextperforms exact permalink lookup for non-wildcard URLs and currently has no fallback resolution path:src/basic_memory/services/context_service.pysrc/basic_memory/mcp/tools/build_context.pysrc/basic_memory/mcp/project_context.py(resolve_project_and_path)Requested fix
Improve context identifier resolution and empty-result diagnostics:
Acceptance criteria
build_contextfinds primary note for common memory URL forms when note exists.