Skip to content

Expose transaction-local previous path in accepted move results #1072

Closed

Description

@phernandez

Summary

Expose the authoritative previous note path from the accepted move transaction even when the old note version was never materialized to storage.

Regression context

Basic Memory Cloud issue basicmachines-co/basic-memory-cloud#1500 and PR basicmachines-co/basic-memory-cloud#1506 need to publish a canonical note.moved activity event with previousNotePath.

The accepted move runner already captures entity.file_path as existing_file_path inside the same transaction that loads and commits the move. However, the accepted result only exposes that path through cleanup_after_write, and cleanup_after_write is intentionally absent when the old object was never materialized.

Cloud cannot recover the missing path safely with a separate pre-read: another accepted move can land between that read and the core move transaction, causing activity to report a stale source path.

Ownership

This is a Basic Memory accepted-mutation contract gap, not a Cloud routing or persistence bug. The authoritative value exists in basic_memory.indexing.accepted_note_mutation_runner._run_accepted_note_move and must be carried out of that transaction.

Suggested fix

  • Add an optional previous_file_path field to the accepted write/move result contract, preferably RuntimePendingNoteMaterialization or RuntimeAcceptedNoteChange.
  • In _run_accepted_note_move, set it from the transaction-local existing_file_path regardless of whether previous_file_delete is planned.
  • Preserve cleanup_after_write for storage deletion only; do not overload cleanup presence as move provenance.
  • Propagate the field through response replacement and queue-neutral runtime helpers without changing non-move behavior.
  • Add regressions for:
    • materialized move: previous_file_path and cleanup are both present;
    • never-materialized move: previous_file_path is present and cleanup is absent;
    • update/create: previous_file_path remains absent.

Cloud follow-up

After the Basic Memory dependency is updated, Cloud PR #1506 should consume this accepted-result field, remove its separate pre-read, and keep committed cleanup metadata only as backward-compatible deployment handling if needed.

Activity

  1. added
    bug
    on Jul 16, 2026
  2. claude commented on Jul 16, 2026

    @claude
    Contributor

    Claude finished @phernandez's task in 6m 5s —— View job


    Implementation complete — push blocked by permissions

    Todo list:

    • Gather context: read issue body and relevant source
    • Locate _run_accepted_note_move and result contracts (RuntimePendingNoteMaterialization / RuntimeAcceptedNoteChange)
    • Design minimal change to carry previous_file_path out of the transaction
    • Implement change + propagate through response replacement / queue-neutral runtime helpers
    • Add regression tests (materialized move, never-materialized move, update/create)
    • Run lint/typecheck/tests — could not run (see note below)
    • Commit — could not push (see note below)

    What changed

    • src/basic_memory/runtime/note_content.py
      • Added an optional previous_file_path field to RuntimePendingNoteMaterialization, threaded through plan_pending_note_materialization, plan_accepted_note_materialization_change, and plan_accepted_note_write_change.
      • Mirrored the field onto the queue-neutral RuntimeNoteMaterializationJobRequest / plan_note_materialization_job_request, so a job rebuilt from a persisted payload still carries it.
    • src/basic_memory/indexing/accepted_note_mutation_runner.py
      • _run_accepted_note_move now sets previous_file_path=existing_file_path unconditionally (not derived from cleanup_after_write), so the transaction-local previous path is always exposed on the accepted result — even when the old note was never materialized to storage.
      • Create/update/edit paths are untouched, so previous_file_path stays absent for those operations.
    • Tests added/updated in tests/runtime/test_pending_note_materialization.py, tests/runtime/test_accepted_note_response_planning.py, tests/indexing/test_accepted_note_mutation_runner.py, and tests/test_runtime.py covering:
      • materialized move → previous_file_path and cleanup_after_write both present
      • never-materialized move → previous_file_path present, cleanup_after_write absent
      • create/update → previous_file_path remains absent

    This gives Cloud (basicmachines-co/basic-memory-cloud#1506) a safe way to read accepted.materialization.previous_file_path directly off the accepted move result instead of racing a separate pre-read.

    Blockers I hit

    • No test/lint permissions: just fast-check, uv run ..., python3 -m pytest, and even pip show all required approval that wasn't grantable in this session, so I could not run just fast-check / just fast-test / just doctor to verify. Please re-run these locally or update --allowedTools if you'd like me to verify directly.
    • Push denied: the commit (81dee7c) is made locally on claude/issue-1072-20260716-0555, but pushing failed with Permission to basicmachines-co/basic-memory.git denied to github-actions[bot] (403). This looks like a token/permission-scope issue with this workflow run rather than something in my control — the branch on GitHub does not yet have this commit. Someone with push access may need to either re-run with a token that has write access, or I can retry if permissions are adjusted.
  3. added this to the v0.23 milestone on Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions