Repository navigation
fix(realtime): a failed attempt no longer leaves a dedup record that suppresses the next write - #508
Merged
HananKavitzAmat merged 1 commit intoNov 11, 2026
Conversation
…suppresses the next write The duplicate-event record (_recent_file_events) was popped only after a successful process_file. When process_file raised, the path stopped being active in the finally block but its record stayed, so a same-type write within the 2 s dedup window was suppressed in _consume_events (the active- path exception no longer applies) and nothing queued work for it. The newer content stayed unindexed until the file changed again. The pop moves into the processing finally block, beside the active-path release, so it runs whether or not processing succeeded. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
|
looks good |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After a failed processing attempt, the next write to that file can be dropped and never indexed.
_consume_events(chunkhound/services/realtime/pipeline.py, "Layer 3") suppresses an event whose type and path match the last recorded event for that path within_EVENT_DEDUP_WINDOW_SECONDS(2.0 s). Since fix(realtime): never drop a duplicate event while the path's change is being processed #507 acreated/modifiedduplicate still gets through while the path's change is active, becauseadd_filethen reserves a follow-up.self._recent_file_events.pop(str(file_path), None)) only afterprocess_filesucceeds.process_fileraises (any non-cancellation error, including the compaction-busy error that schedules a retry), thefinallyblock releases the active path, but the record stays.This only happens on the error path, so it is rare.
Fix
The pop moves from the success path into the processing
finallyblock, beside the release of the active path, so the record is cleared whether or not processing succeeded.Cost: after a failed attempt, the next same-type write inside the window is processed instead of suppressed, which is what already happens after a successful attempt. A failed attempt's own reads produce no event, so this cannot loop.
This change does not depend on any other open PR. It applies to
mainon its own.Evidence
Not reproduced end to end. Triggering it needs
process_fileto fail on a real file and a second write to land within 2 s, which takes fault injection. No end-to-end run was attempted against a realchunkhound mcp.Test
tests/test_realtime_functional.py::test_write_after_failed_processing_inside_dedup_window_is_indexed. Both events go through the realevent_queue,_consume_eventsand_process_loop, as the watcher's do. The firstprocess_fileraises. Once the loop's error handler has run (the path is no longer active), the file is rewritten and its event queued. The test asserts that the new content is processed. It widens_EVENT_DEDUP_WINDOW_SECONDSto 60 s on the service, so the second event is inside the window whatever the machine's speed.main: fails. It times out waiting for the second processing; the event was suppressed.finallyblock: fails.Run on Windows, Python 3.13, serially (
-n 0):tests/realtime,tests/test_realtime_functional.py,tests/test_realtime_failures.py,tests/test_debounce.py.main(with the new test)32 of the 34 skips need a native Watchman runtime this source install does not have; one is Windows-only and one is Linux-only.
🤖 Generated with Claude Code