Skip to content

feat(knowledge): watch Claude Code memory folder for continuous auto-import #16661

Description

@mrveiss

Context

#16643 (importer for #16642) is admin-triggered on demand (POST /knowledge_base/import_claude_memory) — someone has to remember to call it. Claude Code continuously writes and updates memory files during sessions, so the knowledge_facts store drifts out of date between manual triggers.

Proposal

A folder watcher (e.g. watchdog/inotify) on get_claude_memory_dir() that calls the existing import_claude_memory() pipeline incrementally when a memory file is created or modified, instead of (or in addition to) the manual admin endpoint. Reuses the importer's existing idempotent upsert (fact_id_for) — a watched change just re-triggers import_memory_file for that one path, no full-directory rescan needed.

Acceptance Criteria

  • A background watcher process/task observes get_claude_memory_dir() for create/modify events on *.md files (excluding MEMORY.md)
  • On an event, the changed file is imported through the existing import_memory_file() path (same redaction, same owner/visibility metadata, same idempotent upsert)
  • Debounced/coalesced so rapid successive writes to the same file (e.g. a session updating a memory file repeatedly) don't cause redundant imports
  • Watcher lifecycle (start/stop) fits AutoBot's existing background-task/service patterns — no ad hoc while True loop
  • The manual POST /import_claude_memory endpoint stays available as a manual backfill/re-sync trigger

Depends on

#16643 (the importer this would wrap) landing first — currently blocked on #16507/#16654.

Owner idea, raised during #16643's review.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions