Skip to content

Migrated feedback-memory events carry the migration run's repo and cwd instead of the origin's #936

Description

@williamthorsen

Problem

migrate-feedback-memories captures each routed memory as an event through capture-event, which auto-fills cwd and repo from the invocation's working directory. The migration runs from one place while the memories originate in many repos, so every migrated event is stamped with the migration run's repo and cwd, never the origin's. The origin survives only in the body's Origin: line.

This corrupts recall. kb-retrieve-events derives its recurrence count (occurrences) by grouping events that share a repo. A migration batch stamps many origin-diverse lessons with one shared repo, producing a spurious recurrence cluster, and it severs each lesson from its true origin, so a later in-situ capture of the same lesson never groups with its migrated ancestor.

Context

capture-event reads the working directory for exactly two fields: cwd (from process.cwd()) and repo (the git remote at that directory). Store resolution, schema loading, and the write path are keyed on the store's absolute path from ~/.agents/kb.yaml, independent of the working directory. Running the capture from the origin repo therefore redirects cwd and repo to the origin and affects nothing else.

The origin directory is already in hand: The enumerator emits each memory's repoPath. session and captured-at are the same class of migration-run provenance but stay out of scope; they remain in the body's Origin: line.

Proposed solution

Run each capture from the origin repo's working directory (repoPath), rather than teaching capture-event a working-directory override. The fix is confined to migrate-feedback-memories' capture step, which wraps the existing capture-event invocation in a subshell that changes to repoPath first; the auto-filled cwd/repo then resolve to the origin. When repoPath is null, the capture runs from the migration run's directory as today, and the origin survives in the body's Origin: line.

Acceptance criteria

Must have

  • A migrated feedback event carries the origin project's cwd and repo in its structured fields, resolved by running capture-event from the origin repo's working directory (repoPath).
  • When a memory's repoPath is null, the capture runs from the migration run's directory as today, and the origin survives in the body's Origin: line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureAdded or improved external functionalityscope:agents

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions