Skip to content

fix(watcher): cursor table grows without bound — no pruning of stale entries #740

Closed

Description

@Sinity

Problem

The live_cursor table stores one row per unique JSONL file path ever encountered. No pruning or eviction occurs. After 6 months of Claude Code sessions (each creating a new UUID.jsonl), the table accumulates hundreds of thousands of rows.

On daemon restart, _catch_up iterates ALL files and calls _fingerprint_file which reads every file into memory for SHA-256 hashing. With 487,000 cursor rows and no mtime-based fast path, restart catch-up takes hours. With mtime-based fast path (see #736), the cursor table size determines the O(n) scan cost.

Additionally, there's no cleanup for files that no longer exist on disk — they remain in the cursor table forever.

Acceptance criteria

  • Add retention policy: prune cursor entries for files not modified in N days (e.g., 90 days)
  • OR automatically remove cursor entries when the corresponding file no longer exists on disk
  • OR add a manual polylogue status --prune-cursors command
  • Test: insert 10,000 cursor rows, run prune, verify stale entries removed

Found by

2026-05-03 pre-mortem analysis (wave 7). Related to #736 (catch-up performance) and #733 (file exclusion).

Activity

  1. Sinity commented on May 3, 2026

    @Sinity
    OwnerAuthor

    Scope absorbed into #620 (live cursor/freshness). File exclusion, pending dict eviction, and cursor table pruning are all watcher robustness concerns.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions