Repository navigation
Description
Summary
RepositoryRelationResolutionRuntime.resolve_relations() can commit a newly resolved target before the affected source's search projection is refreshed. SearchService.index_entity_data() then deletes the source's existing search rows before index_entity_markdown() reads synchronized Markdown from storage.
If that file read raises—for example during a transient storage outage—the relation is no longer unresolved, the prior search rows are already gone, and the queued retry finds no affected source to refresh. The job can therefore succeed on retry while the note remains absent from search.
This was exposed while adopting the pending-content relation refresh fix from #1161 in Basic Memory Cloud.
Failure sequence
RepositoryRelationResolutionRuntime.resolve_relations()finds an unresolved relation.relation_repository.apply_resolved_targets(...)commits the newto_id.- The runtime asks
SearchService.index_entities(...)to refresh the affected source. SearchService.index_entity_data()callsdelete_by_entity_id(...), committing removal of the current entity/relation search rows.index_entity_markdown()reads the synchronized source throughfile_service.read_entity_content(...).- The storage read raises.
- A worker retry finds no unresolved relation, returns no affected entity IDs, and never rebuilds the deleted search rows.
A genuine missing synchronized file should still surface as an inconsistency. The defect is that the failure consumes the relation work and destroys the last valid projection without retaining retryable reconciliation state.
Impact
- A transient filesystem or object-storage read failure can remove an otherwise valid note from search indefinitely.
- Graph state and search projections diverge: the relation row is resolved while its entity/relation search rows are missing or stale.
- Queue retry semantics become misleading because the retry can report success without repairing the failed projection refresh.
- Hosted runtimes would need duplicate reconciliation policy to compensate unless Core preserves the retry invariant.
Constraints
- Keep accepted writes and Markdown materialization asynchronous.
- Preserve fix(core): refresh pending relations from accepted content #1161 behavior: non-synchronized sources refresh from accepted
NoteContent.markdown_contentwithout reading the file projection. - Synchronized and legacy file-read failures must remain visible; do not broadly swallow
FileNotFoundErroror other storage failures. - Keep pending-content selection and relation/search reconciliation policy in Core so local and hosted runtimes share one contract.
Suggested direction
Make the relation mutation and affected-source projection refresh retryable as one logical operation. Possible approaches include:
- persist affected entity IDs as durable pending projection-refresh work before considering the relation pass complete; or
- stage all required file content before destructive search changes, then retain enough durable state to retry the projection if a later write fails.
Regardless of implementation, SearchService should not delete the last valid search rows before the content needed to replace them has been acquired, and relation retries must not depend solely on rows remaining unresolved.
Acceptance criteria
- An injected first-attempt file read failure does not leave the entity permanently absent from search.
- After storage recovers, a retry rebuilds the entity and resolved-relation search rows even though the relation target was already resolved by the first attempt.
- The retryable work survives a worker/runtime restart; an in-memory affected-ID set is insufficient.
- Genuine missing synchronized files still raise a visible error.
- Pending accepted
NoteContentcontinues to bypass the file read and refresh from accepted Markdown. - Existing search rows are not destructively removed before replacement content is available, or equivalent transactional protection is proven.
- Regression coverage exercises failure on the first refresh and success on a later attempt.
- The solution remains storage-neutral and works for local filesystem and hosted object-storage adapters.
References
- Core issue that introduced the state-aware pending-content requirement: Background relation resolution reads notes before async materialization #1159
- Core fix: fix(core): refresh pending relations from accepted content #1161 /
fe5f2e79 - Cloud adoption issue: basic-memory-cloud#1614
- Cloud PR and review evidence: basic-memory-cloud#1616, retryability review thread
- Relevant Core paths:
src/basic_memory/indexing/relation_resolution.pysrc/basic_memory/services/search_service.py
Activity
claude commentedon Jul 27, 2026
Claude encountered an error after 0s —— View job
I'll analyze this and get back to you.