Skip to content

perf(realtime): publish status for filtered events at most twice a second - #489

Merged
HananKavitzAmat merged 3 commits into
chunkhound:mainfrom
fstrasz:fix/realtime-filtered-status-throttle-main
Nov 12, 2026
Merged

HananKavitzAmat merged 3 commits into
chunkhound:mainfrom
fstrasz:fix/realtime-filtered-status-throttle-main

Conversation

@fstrasz

@fstrasz fstrasz commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Every filtered realtime event calls _emit_status_update(), which builds a full health snapshot and hands it to the status callback; the MCP daemon's _update_realtime_status deep-copies it. A burst of filtered events (an npm install, a junction to node_modules) therefore builds one snapshot per event. With the real service wiring and a deep-copying consumer, 5,000 handled events cost 1.31 ms each with the status callback and 0.73 ms without it: the snapshot was about 44% of a filtered event's cost.

Fix

A filtered event publishes status at most once per 0.5 s (_FILTERED_STATUS_INTERVAL_SECONDS).

  • The first filtered event after a quiet interval publishes at once.
  • Later filtered events in the same interval schedule one trailing publish. It waits out the rest of the interval, then publishes the counters the burst's last event left, so they still reach the consumer when the burst ends.
  • The trailing publish is a transient task on the event loop, supervised like the service's other transient tasks: stop() cancels it through cancel_all(), resets the throttle, and its own final update carries the same counters.
  • Only a filtered-event publish advances the throttle's last-publish time. Another status update in between does not, so a trailing publish can follow shortly after an unrelated one. That costs one extra snapshot, never a lost one.

The loop owns all of this state. The snapshot builder reads the event counters and the event-pressure map, and trims that map; the loop mutates them too. So the watchdog observer's source and filtered callbacks no longer run on the observer thread: forward_to_loop (in events.py, beside SimpleEventHandler) hands each one to the loop with call_soon_threadsafe. Callbacks run in the order they were scheduled, so a source event is still recorded before the same event is queued.

Behaviour change for every watchdog event, not just filtered ones: an exception raised inside the source/filtered bookkeeping used to be swallowed by SimpleEventHandler._record_* on the observer thread. It now surfaces in the loop's exception handler. If the loop is already closed, call_soon_threadsafe raises inside the handler, and that is still swallowed there.

Accepted events, processing transitions and every other status source are unchanged.

Measurements

Measured with the first revision of this change, which used a threading.Timer for the trailing publish; the throttle interval and the number of publishes are the same now. Setup: this change on top of #485 (the same change; this PR carries it on main), a real RealtimeIndexingService with a deep-copying status callback, Windows, 10-core CPU. A junction to a real node_modules tree (44,302 files) produced 48,255 filtered created events. Handler time is measured on the observer thread over the first 5,000 events.

Before With this change
Status snapshots published 5,000 16
Handler time, 5,000 events 6.68 s 4.01 s
Per event 1.335 ms 0.803 ms

Combined with the per-directory exclusion memo (#490), the same 5,000 events take 0.537 ms each. The full 48,255-event burst drops from 66.86 s to 27.52 s, and its status snapshots from 48,254 to 108.

Tests

tests/realtime/test_realtime_filtered_status_throttle.py sends 1,000 filtered events into a real RealtimeIndexingService with a deep-copying status callback. It freezes pipeline.time.monotonic only (every other time function stays real), so the number of publishes does not depend on how fast the machine runs the burst.

  1. test_filtered_burst_publishes_once_then_once_more_with_final_counts: exactly two publishes, with filtered counts [1, 1000]. Before the change: 1,000 publishes.
  2. test_trailing_publish_runs_on_loop_while_event_pressure_changes: while the trailing publish is pending, the loop keeps adding and trimming event-pressure entries until a 5 s wall-clock deadline. Both publishes happen on the loop thread, with counts [1, 1000].
  3. test_stop_cancels_pending_trailing_publish_and_carries_its_counts: stop() publishes the final counts, nothing publishes after it, and a later filtered event publishes at once.

🤖 Generated with Claude Code

…cond

Every filtered realtime event built a full health snapshot and handed it
to the status callback, which the MCP daemon deep-copies. In a burst of
filtered events (an npm install, a junction to node_modules) that cost
about 0.58 ms per event, 44% of what handling the event cost.

A filtered event now publishes at most once per 0.5 s. The first event
after a quiet interval publishes at once; the rest of the interval
schedules one trailing publish on a timer, so the counters left by the
burst's last event still reach the consumer when the burst ends. stop()
cancels a pending trailing publish, since its own final update carries
the same counters.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@HananKavitzAmat

Copy link
Copy Markdown
Collaborator

Summary: The throttle fixes a real hot-path cost. However, the trailing flush runs the snapshot builder on a threading.Timer thread that races the event-loop and watchdog threads, so it can silently drop the final update the PR promises to deliver.

I read the PR diff but not its description or comments. gh pr view 489 returned "Could not resolve to a PullRequest" for this account, and --comments printed nothing. I did not run the tests or review the changes through subagents. The change is small and tightly coupled, so I read it myself as a single group: throttle logic, service.py state, the stop() hook, and the test.

Strengths

  • The leading-plus-trailing publish design is sound. A burst of filtered events costs a few publishes, and the counters still converge.
  • Scope is tight: 4 files, with state kept alongside the other counters in service.py. stop() cancels the pending timer and then emits a final update.
  • The docstring explains why the throttle exists. The test checks a user-visible contract (bounded publishes plus a converged final count) rather than an internal helper.

Issues

Major

  • chunkhound/services/realtime/pipeline.py:~97 (_flush_filtered_status_update): the threading.Timer thread calls _emit_status_update(), which calls _build_health_snapshot() off the event-loop thread.
    • The snapshot builder (service.py:~751) iterates _event_pressure_by_path and calls _trim_event_pressure_state, which mutates that dict. The loop thread mutates it too.
    • A concurrent resize raises RuntimeError: dictionary changed size during iteration. _emit_status_update swallows every exception (pipeline.py:29), so the trailing flush is silently lost.
    • The next status update would eventually correct the counters, but the guarantee that the burst's last counters reach the status consumer fails exactly when load is high.
    • _filtered_status_lock protects only the throttle bookkeeping, not the state the snapshot reads.
    • Fix: marshal the flush onto the loop with loop.call_later or call_soon_threadsafe, and use the existing OwnedTaskSet supervision. Alternatively, drop the timer and flush from a loop-owned task.
  • _update_realtime_status in chunkhound/mcp_server/base.py:825 writes self._scan_progress["realtime"] from that thread. It is now called from a thread it never ran on before. Moving the flush onto the loop fixes this as well.

Minor

  • pipeline.py:~60: _filtered_status_last_emit is compared against time.monotonic() and updated on both the leading and the flush path. Nothing else resets it. Other _emit_status_update calls don't reset it, even though the docstring says "any other status update publishes the same counters". That is harmless, but the docstring overstates it.
  • pipeline.py:~97: _flush_filtered_status_update has no docstring, unlike its siblings. PEP 257 applies.
  • pipeline.py has no blank lines between methods around the new code. The surrounding code already has this problem, but the new methods should not copy it.
  • The import threading in pipeline.py was added in the wrong order for the file. It is only needed if the Timer stays, and the fix above removes that need.
  • Test: the len(published) <= burst // 20 bound depends on wall-clock timing. A slow CI machine stretches the burst and produces more publishes. That is flaky in the safe direction only, but the 5-second convergence wait is also timing-based. The test also never exercises the stop() cancel path.

Reusability

  • The loop-affine alternative above reuses OwnedTaskSet and the existing loop.call_soon_threadsafe pattern in events.py:254. That removes the new lock, the timer and the cancel method.
  • The throttle could be a small generic helper if other hot paths (_record_accepted_event, _record_source_event) need the same treatment.

Decision: REQUEST CHANGES. Run the trailing flush on the event loop, or make snapshot building thread-safe. Add a test that proves the flush survives concurrent event-pressure mutation.

Review on chunkhound#489: the trailing publish ran on a threading.Timer thread, so it
built the health snapshot while the loop and the watchdog observer thread
mutated _event_pressure_by_path. A RuntimeError from that race was swallowed
and the burst's final counters were lost; the MCP status callback also ran
on a thread it never ran on before.

The trailing publish is now a transient task under the existing
OwnedTaskSet: it sleeps out the interval and publishes on the loop, and
stop()'s cancel_all() cancels it. The lock, the Timer and the cancel method
are gone. stop() resets the throttle so the next filtered event after a
restart publishes at once.

The watchdog observer thread was the only caller that recorded source and
filtered events off the loop, and on main it already mutated event-pressure
state there. Its two bookkeeping callbacks now hop onto the loop through
call_soon_threadsafe, the same path _queue_event uses. Callbacks run in the
order scheduled, so a source event is still recorded before the event is
queued. SimpleEventHandler's own contract is unchanged.

Tests: the burst test freezes the pipeline clock, so it asserts exactly one
leading and one trailing publish instead of a wall-clock bound. New tests
cover the trailing publish running on the loop while event pressure
changes, and stop() cancelling a pending publish.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@fstrasz

fstrasz commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review, and for tracing the thread interleaving; the Timer thread was the wrong place for the flush. Everything below is fixed in 48bd1b1, a new commit on top of the reviewed head ab41e01.

Major: the trailing flush ran on a threading.Timer thread. The trailing publish is now a transient task under the existing OwnedTaskSet. It waits out the rest of the interval with asyncio.sleep, then publishes on the loop. So _build_health_snapshot and _update_realtime_status (and its write to _scan_progress) run on the loop thread, as they do for every other status update. stop() already calls _transient_tasks.cancel_all(), which cancels a pending flush, so the lock, the timer and _cancel_filtered_status_flush are gone. stop() also resets the throttle, so the first filtered event after a restart publishes at once.

The watchdog observer thread: this PR now widens on purpose. Moving the flush onto the loop was not enough on its own. The watchdog observer thread calls the service's _record_source_event and _record_filtered_event directly, and both mutate _event_pressure_by_path there. That predates this PR: on main, every watchdog event already mutated event-pressure state off the loop, racing any snapshot built on the loop. A loop-side flush would still have raced it. Watchman (which ingests from a loop coroutine) and polling (which never records filtered events) were already on the loop, so the watchdog observer was the only off-loop caller. In _bootstrap_fs_monitor, those two callbacks now reach the loop through call_soon_threadsafe, the same path _queue_event already uses (events.py:254). The loop runs call_soon_threadsafe callbacks in the order they were scheduled. For each event the handler schedules the source callback before the _queue_event call, so the source event is still recorded before the event is queued and before _handle_queue_result runs. Counters, event pressure and status snapshots for all three backends are now owned by the loop. SimpleEventHandler's contract is unchanged; tests that build a handler directly still get synchronous callbacks. The admission callback stays on the observer thread; it reads only the path filter and the database.

Docstring overstated "any other status update publishes the same counters". Removed. The docstring now describes only the leading and trailing publishes, and says the throttle runs on the loop.

_flush_filtered_status_update had no docstring. It has one now. The cancel method it sat next to is gone.

Blank lines between methods. The new and changed methods are separated by blank lines. I left the existing methods in pipeline.py alone to keep the diff to the change.

Import order. The threading import is gone along with the timer.

The test's bound depended on wall-clock timing, and stop() was not covered. The test now freezes the pipeline module's clock during the burst, so it checks exact counts rather than a bound: a burst of 1,000 filtered events publishes [1, 1000], one leading publish and one trailing publish. asyncio.sleep still uses the loop's clock, so the trailing publish fires normally. Two new tests:

  • test_trailing_publish_runs_on_loop_while_event_pressure_changes keeps adding event-pressure entries on the loop while the trailing publish is pending, then checks that both publishes ran on the loop thread with counts [1, 1000]. This is the test you asked for.
  • test_stop_cancels_pending_trailing_publish_and_carries_its_counts stops the service with a flush pending. It checks that the stop update carries the full count, that nothing publishes after it, and that the next filtered event publishes at once.

All three fail on ab41e01 and pass on 48bd1b1. On ab41e01 the timer fires during the burst, giving [1, 26, 56, 85, …] instead of [1, 1000], and after stop() the throttle is still armed, so the next filtered event does not publish.

Your reusability note. I did not extract a generic throttle helper. _record_accepted_event and _record_source_event don't need one yet, and I'd rather add it alongside the first caller that does.

Checks.

  • I ran the 29 test files that exercise the realtime pipeline, the event handler, the fs monitor bootstrap or the MCP status path, plus the smoke tests, serially on both revisions. 48bd1b1: 360 passed, 35 skipped, 4 failed. ab41e01: 354 passed, 35 skipped, 8 failed.
  • All but one of the failures are test_cli_help_commands cases timing out their 5 s limit: 3 of 8 cases on 48bd1b1 and 8 of 8 on ab41e01. uv run chunkhound --version takes about 5 s on this machine, as I noted on perf(duckdb): score embeddings before joining in semantic search #474.
  • The other is test_cleanup_timeout_does_not_hang_asyncio_run_shutdown, which failed once on 48bd1b1 with its 15 s subprocess timeout. The test's call phase takes 11.5–12.2 s on this machine, and it never starts the realtime service. It passed in 4 further runs on 48bd1b1 and 3 on ab41e01.
  • ruff: 4 findings on these files on both revisions, all in existing lines. mypy: 384 on 48bd1b1 against 390 on ab41e01, none in the new code beyond the mixin attribute pattern these files already use.

🤖 Generated with Claude Code

@HananKavitzAmat

Copy link
Copy Markdown
Collaborator

Summary: The new revision fixes the thread-race I raised earlier by moving the trailing flush and the watchdog bookkeeping onto the loop. The PR description is now stale, and one new test can fail on a fast machine. I read the diff and the surrounding events.py and startup.py. I did not run any tests; the pass counts below are the contributor's.

Review scope: I treated this as one logical group, because all four files share a single throttle design. They are the throttle logic in pipeline.py, its state in service.py, the stop() reset and _forward_to_loop wiring in startup.py, and the tests. This was a judgment call, not a mechanical rule. The gh CLI in this checkout resolves to a fork, so I used the full PR URL for every call.

Prior requested changes (verified in the diff)

  • The threading.Timer is gone. The trailing publish is now a transient task under OwnedTaskSet, so stop()'s cancel_all() cancels it (startup.py:626). The snapshot and _update_realtime_status now run on the loop.
  • Watchdog observer thread: _record_source_event and _record_filtered_event now reach the loop through call_soon_threadsafe (startup.py:86-100,823-824). This matches the events.py:254 pattern. The order of source record, then _queue_event, then queue result is preserved, because callbacks run in the order they were scheduled.
  • The overstated docstring is fixed, _flush_filtered_status_update now has a docstring, and the threading import is gone.

Strengths

  • The fix reuses the existing OwnedTaskSet and call_soon_threadsafe patterns. It adds no lock, timer or cancel method.
  • stop() resets _filtered_status_flush_pending and _filtered_status_last_emit, so a restart doesn't start with a stale throttle.
  • The tests assert exact counts ([1, 1000]) and check the thread identity of each publish.

Issues

Major

  • Stale PR description. It still describes ays "any other status update … publishes thesame counters", and describes a burst // 20 bound test. None of that matches the code now. It also doesn't mention
    that the observer callbacks are now marshaa behaviour change affecting all watchdogsource events. Please update it.

Minor

  • tests/realtime/test_realtime_filtered_stat(test_trailing_publish_runs_on_loop_while_event_pressure_changes): the loop is capped at 5000 sleep(0) iterations while it waits for the trailing publish atterations finish in under about 50 ms, theloop exits with one snapshot and the [1, _BURST] assertion fails. The deadline-based _wait_for_publishes helper would be safer, with the pressure mutation
  • test_realtime_filtered_status_throttle.py:182: monkeypatch.setattr(pipeline, "time", SimpleNamespace(monotonic=...)) replaces the whole time module in pipelineme.sleep() use there raises AttributeError.Patching pipeline.time.monotonic through a monkeypatch.setattr(pipeline.time, ...) shim, or injecting a clock, would be less brittle.
  • startup.py:823-824: before, an exception in these callbacks was swallowed by SimpleEventHandler.record*. Now, bookkeeping exceptions raised inside the l exception handler instead. That is probablyan improvement, but it is a behaviour change worth a line in the description. A closed loop still raises inside forward, and that is still swallowed.
  • startup.py:824: this line is likely over 88 characters (ruff E501), which would need a wrap. Run uv run ruff check/format to confirm.
  • pipeline.py _flush_filtered_status_update: other status updates in the meantime don't advance
    _filtered_status_last_emit. A trailing pubnt right after another publish. This isharmless but unrecorded.

Reusability

  • The throttle state (last_emit plus pending if _record_accepted_event and_record_source_event need it later. Deferring that is reasonable.
  • _forward_to_loop sits in startup.py, but itter next to SimpleEventHandler in events.py, which already owns the call_soon_threadsafe logic.

Test results (contributor's report, not verified by me)

  • Their latest run had 360 passed and 4 failes to the 5 s CLI-startup timeout on theirmachine and a 15 s subprocess timeout in a test that never starts the realtime service. CI should confirm.
    Decision: REQUEST CHANGES. The code design is sound and I would approve it after small fixes. Please update the PR description, make the second test deadline-b length at startup.py:824.

…arden throttle tests

Review follow-up on chunkhound#489 (HananKavitzAmat, 2026-11-10):
- forward_to_loop now lives in events.py beside SimpleEventHandler, which already
  owns the call_soon_threadsafe hand-off, and is public, so startup.py no longer
  imports a private helper. The rename also brings the call site under 88 columns.
- The tests freeze only pipeline.time.monotonic: the stand-in delegates every
  other name to the real time module, so a time.time() in pipeline no longer
  raises AttributeError under the fixture.
- The event-pressure test waits for the trailing publish against a wall-clock
  deadline instead of a 5000-iteration cap a fast machine can exhaust first.

No behaviour change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@fstrasz

fstrasz commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

@HananKavitzAmat thanks for the second pass. The fixes are in aa6f378, a new commit on top of 48bd1b1; nothing was rebased.

Major: stale description. Rewritten. It now describes the loop-owned trailing publish and stop()'s cancel and reset. It names the behaviour change that applies to every watchdog source and filtered event: the observer callbacks now run on the loop, so a bookkeeping exception surfaces in the loop's exception handler instead of being swallowed on the observer thread. It also says the measurements were taken with the Timer revision; the interval and publish counts are unchanged. The test section now matches the three tests.

Minor:

  1. Iteration-capped wait in test_trailing_publish_runs_on_loop_while_event_pressure_changes. Now bounded by a 5 s wall-clock deadline, taken after the burst. I couldn't reproduce the fast-machine failure here: on this box 5,000 iterations take longer than even a 3 s interval. With the deadline it no longer depends on machine speed, and if the deadline ran out, the exact [1, 1000] assertion would fail rather than pass vacuously.
  2. monkeypatch.setattr(pipeline, "time", SimpleNamespace(...)). Replaced with a stand-in whose monotonic() is frozen and which passes every other name through to the real time module, so pipeline.py's time.time() calls keep working under the fixture. Only pipeline's reference is patched; asyncio's loop clock is untouched.
  3. Exceptions in the observer callbacks now surface in the loop's handler. Agreed it's an improvement. It's now in the description, as above.
  4. startup.py:824 over 88 columns. Fixed by your reusability suggestion: _forward_to_loop moved to events.py beside SimpleEventHandler, as public forward_to_loop, so startup.py no longer imports a private helper. The call sites fit in 88 columns, and ruff --select E501 passes on the changed files.
  5. Other status updates don't advance _filtered_status_last_emit. Left as is and now stated in the description: at worst one extra snapshot follows an unrelated publish, never a lost one.

Reusability:

  • forward_to_loop moved as suggested.
  • A generic throttle helper for _record_accepted_event and _record_source_event: deferred, as you said is reasonable. Neither path builds a snapshot per event today.

Checks, run serially:

  • tests/realtime: 77 passed, 27 skipped, the same as before the commit.
  • test_realtime_backend_config.py, test_realtime_failures.py and test_realtime_functional.py: 64 passed, 7 skipped.
  • tests/test_smoke.py: 14 passed.
  • ruff check reports the same findings on the changed files as at 48bd1b1 (import order in events.py and pipeline.py, and one E501 in pipeline.py, all three also on main); mypy on events.py and startup.py is unchanged (121, all pre-existing).

🤖 Generated with Claude Code

@VakninAriel VakninAriel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review — PR #489

Verdict: ✅ Approve

Summary

Each filtered realtime event previously built and published a full health snapshot, making ignored-event bursts expensive for the daemon's deep-copying status consumer. This PR throttles filtered-event status publication to a half-second interval with a trailing update, and moves watchdog bookkeeping callbacks onto the service event loop.

What's good

  • The throttle preserves a trailing publication of the latest counters, so reducing snapshot frequency does not leave the consumer stuck at the first count in a completed burst.
  • Watchdog bookkeeping and the trailing flush are routed onto the event loop, and stop cancels the pending flush and resets throttle state while publishing the final counters.

Freshness warning: Package freshness checked 2026-11-11T15:38:58.574960+00:00: STALE: included heads/eligibility changed; see overview and freshness audit before posting. This report applies only to its pinned SHA.

Severity Count
🔴 Critical 0
🟠 High 0
🟡 Medium 0
🟢 Minor 0

Findings

No retained findings. This is not a guarantee that the code is defect-free.


Review metadata and audit

Draft review for human approval. Nothing has been posted to GitHub.

Pinned head SHA: aa6f378fc7ecfbe54b5769b6efe8647a18e7d248

Package freshness checked 2026-11-11T15:38:58.574960+00:00: STALE: included heads/eligibility changed; see overview and freshness audit before posting. This report applies only to its pinned SHA.

PR: #489

Title: perf(realtime): publish status for filtered events at most twice a second

Author: fstrasz · Branches: fix/realtime-filtered-status-throttle-main → main

Diff merge base: 42c5711

Review scope: Complete pinned merge-base 42c5711..aa6f378 diff: realtime/events.py, pipeline.py, service.py, startup.py and the new filtered-status-throttle tests. Reviewed event forwarding/order, Watchman ingestion, status counters, transient-task ownership and shutdown. No inherited #485 changes are present in this five-file PR diff.

Eligibility: Resource/correctness fix: limit filtered-event status churn and preserve thread ownership.

Overall assessment (audit only)

No confirmed actionable user-facing defect remains. Four introduced mypy diagnostics are verified nonblocking type-contract debt against an already-failing baseline, not a demonstrated runtime failure or newly-red enforced gate. Preserve them as observations rather than ready-to-post bugs. Native integration remains unverified.

Strength evidence

  • {"strength_index": 0, "path": "chunkhound/services/realtime/pipeline.py; tests/realtime/test_realtime_filtered_status_throttle.py", "source": "pr-489.pinned.diff", "detail": "_emit_filtered_status_update schedules one _flush_filtered_status_update; test_filtered_burst_publishes_once_then_once_more_with_final_counts asserts [1, 1000] for a 1000-event burst. This describes inspected code/assertions, not a native-backed test pass."}
  • {"strength_index": 1, "path": "chunkhound/services/realtime/events.py; chunkhound/services/realtime/startup.py", "source": "pr-489.pinned.diff", "detail": "forward_to_loop uses call_soon_threadsafe for source/filtered callbacks; stop resets _filtered_status_flush_pending and _filtered_status_last_emit after transient-task cancellation. The new test also checks loop thread IDs and no post-stop flush."}

Verification

  • Reconciler verified both runner jobs succeeded, valid/error-free settled provenance, pinned worktree HEAD and metadata head, SHA256 of each complete report, and all captured assistant-message provider/model/responseModel identities; the two backend response models are distinct.
  • Astra: git rev-parse HEAD and git merge-base 42c5711 HEAD matched the pins; git diff --full-index --binary 42c5711 aa6f378 > /tmp/chunkhound-pr-489-astra-a1-sxteiwqi/actual.diff followed by cmp against pr-489.pinned.diff exited 0. git diff --check 42c5711 HEAD exited 0; final status empty.
  • Astra: timeout 120s env UV_PROJECT_ENVIRONMENT=/home/e119870/views/g/my_chunkhound/.venv PYTHONDONTWRITEBYTECODE=1 uv run --no-sync mypy chunkhound --cache-dir=/tmp/chunkhound-pr-489-astra-a1-sxteiwqi/mypy-cache exited 1: 997 errors in 89 files (373 checked). Merge-base comparison extracted events, pipeline, service and startup via git show 42c5711:chunkhound/services/realtime/$f.py to /tmp/chunkhound-pr-489-astra-a1-sxteiwqi/base-$f.py. The same mypy command with --cache-dir=/tmp/chunkhound-pr-489-astra-a1-sxteiwqi/mypy-cache-base and four --shadow-file chunkhound/services/realtime/$f.py /tmp/chunkhound-pr-489-astra-a1-sxteiwqi/base-$f.py arguments exited 1: 993 errors in 89 files.
  • Sonnet: timeout 120s env UV_PROJECT_ENVIRONMENT=/home/e119870/views/g/my_chunkhound/.venv PYTHONDONTWRITEBYTECODE=1 uv run --no-sync mypy chunkhound --cache-dir=/tmp/chunkhound-pr-489-sonnet-a1-lqei3y0k/mypy-cache exited 1: 997 errors in 89 files; no baseline comparison reported.
  • Astra and reconciler each ran: timeout 20s env UV_PROJECT_ENVIRONMENT=/home/e119870/views/g/my_chunkhound/.venv PYTHONDONTWRITEBYTECODE=1 uv run --no-sync python /tmp/chunkhound-pr-489-astra-a1-sxteiwqi/isolated_checks.py. Both exited 0: threaded 1000-event burst published [1,1000] on loop thread with correct spacing; source/enqueue ordering passed; cancellation/final-count/reset sequence passed; no transient tasks without status callback. Reconciler inspected the script before rerun. It executes AST-extracted actual production definitions with lightweight collaborators, not a full service.

Limitations

  • Astra: timeout 90s env UV_PROJECT_ENVIRONMENT=/home/e119870/views/g/my_chunkhound/.venv PYTHONDONTWRITEBYTECODE=1 uv run --no-sync pytest tests/realtime/test_realtime_filtered_status_throttle.py -p no:cacheprovider --basetemp=/tmp/chunkhound-pr-489-astra-a1-sxteiwqi/pytest-throttle exited 2: 0 collected, 1 collection error because chunkhound_native.chunkhound_native is absent.
  • Sonnet reported timeout 300s env UV_PROJECT_ENVIRONMENT=… uv run --no-sync pytest -p no:cacheprovider --basetemp=/tmp/chunkhound-pr-489-sonnet-a1-lqei3y0k/bt tests/realtime/test_realtime_filtered_status_throttle.py tests/realtime/test_filter_consistency_realtime_cleanup.py -q: two collection errors from the same missing native extension, no tests ran. Ellipsis preserves the report’s abbreviation.
  • Isolated checks cannot establish real service/database integration, Windows watchdog behavior, full stop() behavior or benchmark claims; the stop sequence is reproduced with a lightweight collaborator. Full suite, native builds, network tests and environment repair were not performed. Existing typecheck baseline remains failing.
  • CI is a captured snapshot, not a fresh run or a guarantee of current branch status.
  • Model identities are verified declarations supplied by the reconciler; the renderer does not inspect raw reports or provenance events.

Disposition of discarded / merged findings

  • Rejected Sonnet’s low-confidence Minor callback-log flooding note: forwarding exceptions to asyncio’s exception handler is an intentional observability change and no realistic repeating exception trigger was substantiated. Pathological hypothetical failures and optional log hardening are insufficient for an actionable introduced bug.
  • Final audit reclassifies the verified four added mypy diagnostics as nonblocking observations, preserving original evidence above. Concrete service initialization supplies the fields; no runtime failure or enforced typecheck CI gate is demonstrated (workflow search has no mypy/typecheck step). The documented review command is still worth running, but extra diagnostics on an already-failing baseline alone do not justify Needs Work under meaningful-bug-only scope. This is consistent with #485, #509 and #510 typing dispositions.
  • No additional runtime issue was invented from native-module failures; those prevent integration verification rather than demonstrate a throttle defect.

Nonblocking observations (audit only)

  • {"title": "Declare the throttle attributes on the mixin’s typed contract", "severity": "Minor", "path": "chunkhound/services/realtime/pipeline.py", "line_start": 79, "line_end": 84, "description": "The new helper accesses four attributes whose types are not declared on RealtimePipelineMixin: _status_callback, _filtered_status_flush_pending, _filtered_status_last_emit and _FILTERED_STATUS_INTERVAL_SECONDS. Although the concrete service initializes them at runtime, mypy checks the mixin independently. Running the documented mypy chunkhound command adds four diagnostics versus the merge-base production files (997 versus 993 errors). This is an introduced typecheck regression, not a newly broken previously-green check, and no runtime failure is inferred.", "suggested_fix": "Declare the required attribute types on RealtimePipelineMixin or use an appropriately typed service contract so these accesses can be checked without new attr-defined/has-type diagnostics.", "evidence": ["Astra’s HEAD and four-production-file merge-base shadow runs exited 1 with 997 and 993 errors respectively, both in 89 files; after line normalization the four diagnostics at lines 79,79,83,84 are the only additions.", "Reconciler inspected /tmp/chunkhound-pr-489-astra-a1-sxteiwqi/mypy.log and mypy-base.log, confirmed those locations, and verified the attributes are initialized only on concrete service code. Sonnet also observed new diagnostics but classified them as baseline-pattern noise."], "reviewers": ["astra"], "id": 1}

Independent reviewer provenance

  • sonnet — provider: amat-tfy; requested model: standard-chat-dev/claude-sonnet-5.5; verified response model: aws-aidev-models/us.anthropic.claude-sonnet-5-5. Identity evidence · Raw report
  • astra — provider: amat-tfy; requested model: frontier-chat-dev/gpt-6-astra; verified response model: gpt-6-astra. Identity evidence · Raw report

CI snapshot

Captured: 2026-11-11T14:18:23.581921+00:00. Eligibility green: True. Counts: {"SKIPPED": 2, "SUCCESS": 23}

Reviewed by Ariel Vaknin via pi.dev

@HananKavitzAmat
HananKavitzAmat added this pull request to the merge queue Nov 12, 2026
Merged via the queue into chunkhound:main with commit b891cf0 Nov 12, 2026
25 checks passed
fstrasz added a commit to fstrasz/chunkhound that referenced this pull request Nov 17, 2026
fstrasz added a commit to fstrasz/chunkhound that referenced this pull request Nov 17, 2026
fstrasz added a commit to fstrasz/chunkhound that referenced this pull request Nov 17, 2026
Resolves the import conflict in realtime/startup.py with chunkhound#489's
forward_to_loop: both imports are kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants