Skip to content

memory(qmd): collections never rebind when a collection's root path changes #91251

Description

@sasan1200

Summary

MemoryQmdManager.ensureCollections() is meant to rebind a managed qmd collection (remove + re-add) when its filesystem root changes — for example when an agent's workspace is repointed. The rebind never fires, so collections stay pinned to the stale root after a workspace move.

Root cause

The rebind decision in shouldRebindCollection(collection, listed) compares listed.path against the desired collection path. But listed.path is always undefined:

  • listCollectionsBestEffort() reads qmd collection list, whose output carries no filesystem path (only name / pattern / counts).
  • With listed.path undefined, shouldRebindCollection takes its defensive "incomplete metadata" branch and returns false → no rebind.

So a configured workspace move is invisible to the engine: memory reads keep resolving the old location while the agent writes to the new one.

qmd collection show <name> does expose the path:

Collection: memory-dir
  Path:     /.../workspace/memory
  Pattern:  **/*.md

Reproduction

  1. Point an agent at workspace A; let qmd index it.
  2. Repoint the agent's workspace to B (same content).
  3. Restart + memory index --force.
  4. Observe: qmd store_collections still reference A; recall resolves A, not B.

Proposed fix

Enrich listCollectionsBestEffort() with each managed collection's path via qmd collection show <name>, so shouldRebindCollection can detect a changed root and rebind. (PR incoming.)

Metadata

Metadata

Assignees

Labels

P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions