Repository navigation
Description
Summary
Cloud-hosted write_note calls can successfully persist typed Markdown and return 202 while leaving the observation and relation tables empty. Graph rows appear only if a later index_file job happens to re-parse the materialized object. This makes schema inference and relation traversal nondeterministic after successful DB-first writes.
Classification: Basic Memory persistence/indexing regression. The incomplete accepted-write path is in basic_memory.indexing.accepted_note_write_runner, not Cloud MCP routing.
Development acceptance evidence
Environment: Basic Memory Cloud development
- Cloud revision:
4aa58632c32999b088efcfe61911c053b7a4ad89 - Basic Memory revision:
c616148fb0b30f1dfe492e273ec43706c0326759 - Tenant:
a5a774be-50e0-4c50-811d-42a2525faebc - Project external ID:
d71bee1e-69a4-4842-90de-fd93aa779a47 - Project DB ID:
3
The acceptance run wrote three notes with note_type=dev_accept_person:
## Observations
- [name] Ada Acceptance
- [role] Engineer
## Relations
- works_at [[XSYS Target 20260716T1110Z]]All three calls succeeded. note_content.markdown_content contains the exact [name], [role], and works_at Markdown, checksums match, and Tigris origin objects contain the same data. search_notes(note_types=["dev_accept_person"]) returns all three notes.
However, Neon shows no graph rows for entity IDs 13, 14, and 15:
observation: zero rowsrelation: zero rows
schema_infer(note_type="dev_accept_person", threshold=0.25) therefore returns:
{"error":"No schema pattern found for 'dev_accept_person' (threshold: 25%)"}A control note in the same project did acquire observations/relations, but only after Tigris notification enqueued index_file job trace 019f6aa0ae27f04fb3ea107af903cc84. The typed-note materialization jobs completed successfully but did not produce equivalent index_file jobs.
Root cause
run_accepted_note_create() prepares parsed Markdown, then create_accepted_pending_entity() writes only scalar entity fields. persist_accepted_note_write() writes note_content and search state. Neither persists the parsed observations or relations that are already present in the prepared write.
The Cloud DB-first path then materializes Tigris asynchronously. Graph correctness is accidentally dependent on a later object notification and index_file pass. Notifications are not a valid commit path for graph rows and may also no-op against matching accepted checksums.
Relevant code:
src/basic_memory/indexing/accepted_note_mutation_runner.py::_run_accepted_note_createsrc/basic_memory/indexing/accepted_note_write_runner.py::create_accepted_pending_entity- accepted update/edit paths should be audited for the same omission
Expected behavior
A successful accepted create/update/edit transaction atomically persists:
- entity scalar fields
- note content
- observations
- relations (with unresolved targets allowed)
- search state
Tigris materialization and object notifications should reconcile file state, not be required to make the knowledge graph correct.
Suggested fix
Extend the accepted mutation write transaction to replace observations and relations from the already parsed prepared Markdown before commit. Reuse the existing repository semantics used by EntityService.update_entity_and_observations() and update_entity_relations(), adapted to the accepted-write dependency protocols.
Add regression coverage for:
- create typed note -> observations and unresolved/resolved relations exist immediately;
- update/edit -> old graph rows are replaced atomically;
- schema inference succeeds immediately after typed MCP writes without any storage notification;
- relation traversal succeeds immediately after
write_note; - materialization or duplicate
index_filedoes not duplicate/remove graph rows; - missing/delayed Tigris notification does not affect DB graph correctness.
Activity
claude commentedon Jul 16, 2026
Claude finished @phernandez's task in 20m 51s —— View job
Root cause confirmed and fix implemented
The bug is exactly where the issue points:
run_accepted_note_create/_update/_editinbasic_memory/indexing/accepted_note_mutation_runner.pyalready parse observations/relations from the accepted markdown (prepared.entity_markdown), but the accepted-write path only ever persisted entity scalar fields (create_accepted_pending_entity),note_content, and search rows (persist_accepted_note_write) —observation/relationtables were never touched until a laterindex_filejob happened to reparse the materialized file.Todo List:
accepted_note_mutation_runner.py/accepted_note_write_runner.pyfor the accepted-write pathWhat changed
indexing/accepted_note_write_runner.py: extended theAcceptedPreparedMarkdownWriteSourceprotocol withobservations/relations, addedAcceptedNoteObservationRepository/AcceptedNoteRelationRepositorycapabilities toAcceptedNoteWriteRepositories, and addedreplace_accepted_note_graph()which replaces an entity's full observation/relation set atomically. Relation targets are written unresolved (to_id=None); the existing forward-reference resolution job reconciles them later, matching cloud's one-file materialization semantics — no new link-resolution logic needed.indexing/accepted_note_mutation_runner.py: wiredreplace_accepted_note_graph()into_run_accepted_note_create,_run_accepted_note_update, and_run_accepted_note_edit, right alongside the existingpersist_accepted_note_write()call, in the same transaction.repository/observation_repository.py/repository/relation_repository.py: addedreplace_accepted_observations()/replace_accepted_outgoing_relations()(delete-then-insert, matching the replace-not-merge semanticsEntityService.update_entity_and_observations/update_entity_relationsalready use for the local file-indexing path), plusAcceptedObservationWrite/AcceptedRelationWritewrite payloads.services/entity_service.py:PreparedEntityWritenow exposes.observations/.relations(delegating to the already-parsedentity_markdown) so the accepted-write path can reuse it without reparsing.index/local_notes.py: wired the new repository methods intoLocalAcceptedNoteRepositories(the local-runtime implementation of the write-repository protocol).Regression coverage added
tests/repository/test_observation_repository.py,test_relation_repository.py:replace_accepted_observations/replace_accepted_outgoing_relationsinsert the full set, replace an existing set atomically, and clear rows when the new set is empty; relations are asserted unresolved (to_id is None).tests/indexing/test_accepted_note_write_runner.py: unit tests for the new mapping helpers andreplace_accepted_note_graph().tests/indexing/test_accepted_note_mutation_runner.py: end-to-end orchestration tests proving create persists observations+relations immediately, update replaces the graph atomically, and edit clears graph rows when the markdown drops them — directly covering issue items 1 and 2.index_fileidempotency (issue items 3–6) aren't independently covered by new tests — they exercise services outside this runner's unit-test boundary, and the DB-cascade-on-delete/replace-not-merge semantics this fix reuses are already relied on by the existing file-indexing path.just fast-check/just fast-test/ pytest. This sandbox's Bash permission mode rejectedpython3 -c,uv,just, andpython3 -m pytestinvocations ("this command requires approval") with no interactive user available to approve them. I reviewed every diff manually (imports, protocol conformance, line lengths, blank-line formatting) but could not execute the test suite. Please runjust fast-check && just fast-test(or at leastpytest tests/indexing/test_accepted_note_write_runner.py tests/indexing/test_accepted_note_mutation_runner.py tests/repository/test_observation_repository.py tests/repository/test_relation_repository.py tests/index/test_local_accepted_note_repositories.py) before merging. If you'd like me to fix this for future runs, updating--allowedToolsto permitBash(uv:*)/Bash(just:*)would let me self-verify.git pushfailed withremote: Permission to basicmachines-co/basic-memory.git denied to github-actions[bot](403). The commit exists locally onclaude/issue-1076-20260716-1129(SHA20b69f1, signed off, on top ofc616148) but the GitHub App token this session was given lacks write access to the repo. This needs a maintainer to either grant push access or re-run with valid credentials — I can't work around it from here.Triage
buglabelhigh/mediumaren't in this repo's label set and I couldn't enumerate the actual set sincegh label listwas also blocked in this sandbox.)database/core/syncaren't recognized label names here.)