Skip to content

Watcher can miss a live edit in a newly attached project (flaky lifecycle test removed) #1979

Open

Description

@phernandez

What happened

test-int/mcp/test_new_project_watch_lifecycle.py::test_new_project_copied_files_and_live_changes_are_searchable failed intermittently in CI with TimeoutError at line 83 (latest: main 1e8e64c, run 40970750756; earlier occurrences are noted in #1955). It is removed in the linked PR because it kept failing builds.

The test, through the real MCP lifespan and native watcher, with ignored .watch-noise writes every 50 ms:

  1. creates a project with bm_project(command="create")
  2. copies inbox/copied.md in and polls bm_search for unicorn — this passes: the attach backfill indexes the copied file
  3. rewrites the same file with narwhal and polls for 45 s — this times out

So the project was attached and indexed, and a later edit to the same file was not indexed within 45 s.

Open question

Is this only the test, or can the watcher drop a live edit after attach? Candidates:

Production impact, if real: an edit made in the first seconds after a project is added is not indexed until the file changes again or a reindex runs.

Coverage after removal

tests/index/test_watch_new_projects.py still covers attach backfill and live writes with the real native watcher (test_real_quiet_watcher_backfills_then_handles_live_writes) plus reload/restart/catch-up behavior. What is no longer covered end to end: attaching while ignored-file activity continues (the #1866 case) through the MCP lifespan. A replacement should be deterministic, e.g. wait on the watcher's batch-handled signal instead of polling search under a deadline.

Refs #1955, #1866, #1852.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8

Activity

  1. claude commented on Oct 29, 2026

    @claude
    Contributor

    Claude finished @phernandez's task in 14s —— View job


    Triage

    • Type: bug (suspected; it may turn out to be test-only, which is the open question in the issue)
    • Component: Database/sync (the file watcher and indexing, plus the MCP lifespan test). It isn't Cloud-specific.
    • Priority: Medium. If the bug is real, an edit made in the first seconds after a project is attached goes unindexed until the file changes again or a reindex runs. That is derived-state staleness, not loss of note content. It is also intermittent, and the flaky test is already removed.
    • Complexity: Medium to complex. It needs a deterministic reproduction of the race before any fix. The three candidate causes are the post-attach catch-up (watch_unfiltered / yield_on_timeout), a reload restart dropping a buffered edit, and a failed batch dropped until the next change.

    Duplicates: I searched for duplicates and found none. The issue is related to #1955, #1866, #1852 and #1967, which it already cites.

    Reproduction: The issue already describes how to reproduce it. The removed test is test-int/mcp/test_new_project_watch_lifecycle.py. It creates a project, copies a file in, rewrites it, and polls search for 45 s. It runs with watch_project_reload_interval = 1 and ignored writes every 50 ms.

    Suggested first step for whoever picks this up: Write a deterministic reproduction that waits on the watcher's batch-handled signal instead of polling search. Use it to tell apart "edit consumed or filtered during catch-up", "buffered edit lost on reload restart", and "failed batch logged and dropped". That will show whether this is a product bug or only a test problem.

    No code was changed.

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions