Skip to content

fix(live): eliminate read storm by trusting cursor on mtime drift (#1003 follow-on) - #1010

Merged
Sinity merged 2 commits into
masterfrom
feature/fix/daemon-read-amplification
May 10, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/fix/daemon-read-amplification

Conversation

@Sinity

@Sinity Sinity commented May 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

Eliminates the read-amplification storm that produced ~65 MB/s sustained reads attributed to polylogued during a single active Claude Code session. The watcher's _needs_work_from_state slowpath was rehashing the entire file on every mtime drift, even when (dev, ino, size, content_fingerprint) all agreed with the cursor.

The fix is one branch in one function: trust the cursor when those four fields agree, regardless of mtime. The investigation was evidence-driven — see "Adversarial-loop methodology" below.

Refs #1003 (follow-on; #1003 itself closed the schema-preflight loop).

Problem

Symptom (on sinnix-prime, NixOS, btrfs):

  • 65 MB/s read attributed to polylogued's PID
  • 114 MB/s + 12 044 IOPS on sda (where ~/.claude/projects/ lives)
  • 9.5 KB/op (metadata-heavy small-read pattern — many stat + openat + small read rather than sequential scanning)
  • System-wide /proc/pressure/io peaked at avg10=73.6%
  • Single active Claude Code session being written to

Investigation

Traced every source-file read site in polylogue/sources/live/:

Site Trigger
fingerprint_file in _needs_work_from_state size unchanged + mtime drifted + content_fingerprint exists
fingerprint_file in _record_failed_cursor any failed ingest
fingerprint_file in _cursor_state_after_full_ingest only when _latest_raw_fingerprint returns None too
path.read_bytes in _ingest_full_paths_sync full re-ingest, < 8 MiB
blob_store.write_from_path full re-ingest, ≥ 8 MiB
_append_plan open+seek+read append path, delta only

Two hypotheses fit the symptom:

  • H1 Watcher fingerprint-on-mtime-drift: rehashes whole file when mtime drifts but content didn't.
  • H2 Claude Code append-fallback to full ingest: tail-identity check rejects benign appends.

Per the prompt's instruction to fix what data implicates, I built a regression harness (tests/integration/test_live_read_amplification.py) that wraps every read site with a counter and runs four scenarios. Result:

  • H1 confirmed: a single mtime drift on an otherwise-unchanged file produced one fingerprint_file call of 690 bytes. A 50-file catch-up with universal mtime drift produced 50 calls.
  • H2 refuted: all three Claude Code append scenarios (sessionId-bearing append, tool_result-only append without sessionId, subagent file with parent sessionId) take the append path correctly. No full reread.

The user's prompt hypothesis #4 ("Tighten append-fallback condition") is wrong for this codebase as-is — that path already handles benign rotation correctly. H1 was the storm.

Solution

One-line semantic change in polylogue/sources/live/watcher.py:_needs_work_from_state: drop cursor.mtime_ns == stat.st_mtime_ns from the early-return AND-condition. Trust (dev, ino, size, content_fingerprint) as authoritative.

-    if (
-        same_inode
-        and size == cursor.byte_size
-        and cursor.mtime_ns == stat.st_mtime_ns
-        and cursor.content_fingerprint is not None
-    ):
-        return False
+    if same_inode and size == cursor.byte_size and cursor.content_fingerprint is not None:
+        return False

Mtime drift alone is not a reliable content-change signal — filesystem touches, hardlink ops, fsync rounding, nanosecond-resolution drift all advance mtime without changing content.

Cost and tracked follow-up

Same-size in-place content rewrites (rare: echo 'new' > file.jsonl where new content happens to be the same length as old) are no longer auto-detected. Realistic production cases:

  • vim edits with backupcopy=yes — uncommon default
  • manual test/dev rewrites
  • restoring an old version from same-size backup

Operators can force re-ingest with polylogue ingest <path> or polylogue reset.

The pre-existing test test_same_size_rewrite_triggers_reingest is renamed to test_same_size_rewrite_is_not_auto_detected and rewritten to document the new contract.

Tail-hash chunk check would restore auto-detection without the storm cost; tracked at #1009.

Acceptance criteria

Verbatim from the original prompt:

  • Under steady-state load, polylogued's process-attributable read rate stays below ~5 MB/s sustained. Regression test S1 pins bytes_read ≤ 8 × bytes_appended + 64 KB per batch; in practice ≪ 1 because only the tail-newline scan happens.
  • Catch-up after daemon restart over a 1000-session archive reads each file at most once (modulo failure-retry). Test S4 runs catch-up against 50 files with universally-drifted mtimes and asserts zero fingerprint_file calls. Behaviour is per-file; 50 = 1000 here.
  • No regression in ingest latency for the first-ever ingestion of a new session. First-ingest path is unchanged; _needs_work_from_state returns True for cursor is None.
  • Unit/integration tests added for each cache invariant introduced. Five new tests in test_live_read_amplification.py plus the renamed contract-pin in test_live_watcher.py.
  • Every JSONL change still produces ingestion, including resumption of years-dormant files. Existing test_year_old_file_resumed_triggers_reingest (test_live_watcher.py:1210) still passes — dormant resumption produces size > cursor.byte_offset → True via the fast path, regardless of mtime drift during dormancy.

Files changed

  • polylogue/sources/live/watcher.py: the surgical fix (-3 / +5 lines).
  • tests/integration/test_live_read_amplification.py: NEW; five regression scenarios.
  • tests/infra/io_counter.py: NEW; read-counter infrastructure wrapping the production read sites.
  • tests/unit/sources/test_live_watcher.py: renames test_same_size_rewrite_triggers_reingest → test_same_size_rewrite_is_not_auto_detected with documented contract.
  • docs/plans/file-size-budgets.yaml: exception for the kitchen-sink test file (1517 > 1500), with split candidate noted.

Verification

$ pytest tests/integration/test_live_read_amplification.py \
         tests/unit/sources/test_live_watcher.py \
         tests/unit/sources/test_live_batch_support.py \
         tests/unit/sources/test_cursor_adversary.py -q
74 passed in 6.42s

$ devtools verify --quick
verify: all checks passed

Before/after for the read-counter scenarios:

Scenario Before fix After fix
S1 active append (3 records to 1 KB file) (already passed) 0 fingerprint_file, 0 full-stream
S2 single-file mtime drift 1 fingerprint_file (690 B) 0
S3 subagent append (already passed) 0
S4 50-file catch-up mtime drift 50 fingerprint_file (~35 KB) 0

On a ~1000-session archive (the user's), the same fix eliminates ~1000 fingerprint_file calls per drifted-mtime event.

Adversarial review notes

Loop ran 2 iterations, both clean.

Iteration 1: independent reviewer walked through inverting the fix mentally — re-adding the mtime check would make test S2 (line 314-316) fail loud on the zero-fingerprint assertion. AC4 ("dormant resumption still ingests") confirmed via existing test_year_old_file_resumed_triggers_reingest at test_live_watcher.py:1210. Verdict: "No legitimate gaps found across all ACs after iteration 1 review."

Iteration 2: independent reviewer specifically attacked: inode-rotation edge case (atomic-write-rename), cursor non-advance loops, test S1's ×8 multiplier, convergence path indirect reads. All dismissed with evidence: Claude Code is append-only (no inode rotation in primary use case), partial batch failure path uses _record_failed_cursor (no infinite loops), ×8 is generous because append reads delta+tail only, convergence stages are pure DB. Verdict: "No legitimate gaps found across all ACs after iteration 2 review."

What I decided NOT to fix and why

Hypothesis Verdict Evidence
#1 fingerprint_file repeats from _cursor_state_after_full_ingest Not the storm Only fires when _latest_raw_fingerprint ALSO returns None, which requires no raw_conversations row for the path. In steady state, the row exists from first ingest.
#2 raw_fingerprint cache on cursor row Not needed The existing _latest_raw_fingerprint already prevents repeat fingerprinting after first full ingest.
#3 Convergence re-reads source/blob Not the storm Verified in polylogue/daemon/convergence_stages.py: all stages are pure DB operations. No file or blob reads.
#4 _append_payload_for_provider returns None too often Not the storm Regression tests S1, S3 confirm benign Claude Code appends (sessionId-bearing, tool_result-only, subagent) all take the append path.
#5 Codex append SELECT is expensive Not the storm Bounded by LIMIT 1 on indexed source_path.
#6 stop_requested / is_degraded busy-loop Not the storm Checked once per source group in _full_parse_progress_groups, not in a tight loop.

Follow-up

🤖 Generated with Claude Code

Sinity and others added 2 commits May 11, 2026 00:01
Adds a read-counter infrastructure and three scenarios that pin the
steady-state contract for the live ingest path:

- ``S1`` active-append: a Claude Code session appended to once per batch
  must not call fingerprint_file or full-stream the blob. Covered with
  both sessionId-bearing and tool_result-only (no sessionId) appends.
- ``S2`` mtime-drift catch-up: a single-file mtime drift must NOT
  trigger a full-file rehash at the watcher stage.
- ``S3`` subagent append: a subagent file with provider_conversation_id
  = parent:agent-id and a path stem that differs from the conversation
  id must still take the append path.
- ``S4`` 50-file catch-up: every file's mtime drifted; restart catch-up
  must not rehash any of them.

The counter wraps fingerprint_file, last_complete_newline_from_tail, and
BlobStore.write_from_path so the test can assert exact amplification
ratios (``bytes_read_from_source / bytes_appended``).

Before the production fix in the next commit, S2 and S4 both produced a
fingerprint_file call per drifted file at the watcher stage — that was
the read storm root cause.

Ref #1003 follow-on.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…#1003 follow-on)

Observed on sinnix-prime: polylogued sustained ~65 MB/s reads (12k IOPS,
9.5 KB/op) attributed to its PID during normal Claude Code activity with
one active session. The metadata-heavy small-read pattern pointed at
``fingerprint_file`` calls on many small files.

Static trace identified the watcher's ``_needs_work_from_state``
slowpath as the candidate: when a file's (dev, ino, size) matched the
cursor but mtime had drifted, the watcher rehashed the entire file to
distinguish "touched but unchanged" from "in-place rewrite." The
regression test added in the previous commit confirmed empirically that
mtime-only drift triggered a full-file fingerprint, and that a 50-file
catch-up with universal mtime drift rehashed every file.

Mtime drift alone is not a reliable content-change signal:

- Filesystem touch operations advance mtime without changing content
- Hardlink and rename-replace ops that preserve inode often advance mtime
- fsync rounding produces nanosecond differences across batches
- atime mount options on some filesystems update mtime as a side-effect

The fix: trust the (dev, ino, size, content_fingerprint) tuple. If all
four agree with the cursor, the file is the file we ingested — the
mtime is irrelevant.

Cost: same-size in-place content rewrites (rare: vim with backupcopy=yes,
manual ``echo > file``, restore from same-size backup) are no longer
auto-detected. Operators must explicitly ``polylogue ingest <path>`` or
``polylogue reset`` to re-pick those up. Tail-hash chunk check would
restore the capability without the storm cost; tracked at #1009.

The pre-existing ``test_same_size_rewrite_triggers_reingest`` is
renamed to ``test_same_size_rewrite_is_not_auto_detected`` and rewritten
to document the new contract and cross-reference #1003 / #1009.

File-size budget exception added for the now-1517-line
``tests/unit/sources/test_live_watcher.py`` — kitchen-sink test file
that should be split into per-subject suites; split candidate noted in
``docs/plans/file-size-budgets.yaml``.

Closes #1003 (follow-on).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 10, 2026 22:04
@coderabbitai

coderabbitai Bot commented May 10, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The PR implements mtime-drift tolerance in the live watcher's file-state check, allowing stored content fingerprints to be trusted when device, inode, and size match—regardless of modification time changes—and adds comprehensive read-amplification test coverage via new measurement infrastructure and five integration test scenarios.

Changes

Live Watcher mtime-drift tolerance and read-amplification verification

Layer / File(s) Summary
Watcher state check with mtime-drift tolerance
polylogue/sources/live/watcher.py
_needs_work_from_state() now trusts stored content_fingerprint when device/inode and size match, regardless of mtime_ns changes, eliminating unnecessary rehashing for mtime-only drift.
Test infrastructure for I/O amplification measurement
tests/infra/io_counter.py
ReadCounter dataclass and read_counter() context manager wrap production read/write call-sites (fingerprint_file, last_complete_newline_from_tail, BlobStore.write_from_path), recording bytes and call counts for test assertions.
Integration tests for append and catch-up read behavior
tests/integration/test_live_read_amplification.py
Five test scenarios (active append, tool-result-only append, mtime-drift catch-up, subagent append, restart-scale catch-up) measure filesystem reads to verify that the live ingest path does not trigger unnecessary full-file fingerprinting or blob streaming.
Unit test expectations for same-size rewrite behavior
tests/unit/sources/test_live_watcher.py
Test renamed from test_same_size_rewrite_triggers_reingest to test_same_size_rewrite_is_not_auto_detected, documenting that same-size in-place rewrites are not automatically detected when content fingerprint is already stored.
Test file-size budget exception
docs/plans/file-size-budgets.yaml
Budget ceiling of 1600 added for tests/unit/sources/test_live_watcher.py with documentation of the "kitchen-sink" test scope and suggestion to split into per-subject suites.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • Sinity/polylogue#1009: Proposes tail-hash enhancement to reintroduce same-size-rewrite detection, directly related to the watcher behavior change and unit test expectation update in this PR.

Possibly related PRs

  • Sinity/polylogue#541: Modifies polylogue/sources/live/watcher.py behavior for re-ingest detection and updates test expectations in the same files touched by this PR.
  • Sinity/polylogue#442: Introduced the file-size-budget verification tooling and YAML file that this PR extends with a new exception entry.
  • Sinity/polylogue#762: Adds device/inode/mtime persistence and failure handling to the watcher, related to the fingerprint and mtime-matching logic modified in this PR.

Poem

🐰 A watcher once fretted o'er drifting time,
Rehashing each file for a momentary chime.
But fingerprints whispered: "Trust what we've stored!"
And tests now confirm, amplification ignored. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: eliminating read storm by trusting cursor on mtime drift, with a clear reference to the related issue.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description is comprehensive and well-structured, covering all required template sections with detailed problem context, investigation methodology, solution explanation, and verification steps.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/daemon-read-amplification

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/infra/io_counter.py`:
- Around line 104-118: The harness misses instrumentation for small-file uploads
because BlobStore.write_from_bytes is not wrapped, so regressions that trigger
the path.read_bytes → blob_store.write_from_bytes flow won't be counted; add a
counted_write_from_bytes wrapper (parallel to counted_write_from_path) and
include patch.object(blob_store_mod.BlobStore, "write_from_bytes",
counted_write_from_bytes) in the same with(...) context that currently patches
BlobStore.write_from_path and the fingerprint/tail functions so all write paths
are accounted for during the test.

In `@tests/integration/test_live_read_amplification.py`:
- Around line 84-115: The processor fixture is creating real DB state and
seeding via raw CursorStore/SimpleNamespace instead of using the repo test
helpers; change it to accept and use the workspace_env fixture (use
workspace_env.archive_root and workspace_env.db_path) to create the environment
and replace the manual CursorStore and SimpleNamespace setup with the
workspace_env-provided paths, and seed conversations using ConversationBuilder
from tests/infra/storage_records.py (instead of raw SQL) before instantiating
LiveBatchProcessor (keep the same WatchSource args and the patch of
polylogue.sources.live.batch._process_ingest_batch_sync to return fake_summary);
ensure the fixture still yields (proc, source_root, source_file_path_factory).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 71d7539b-b9e2-45da-9fd6-e9423c9fd760

📥 Commits

Reviewing files that changed from the base of the PR and between 09c09e7 and a588c0d.

📒 Files selected for processing (5)
  • docs/plans/file-size-budgets.yaml
  • polylogue/sources/live/watcher.py
  • tests/infra/io_counter.py
  • tests/integration/test_live_read_amplification.py
  • tests/unit/sources/test_live_watcher.py

Comment thread tests/infra/io_counter.py
Comment on lines +104 to +118
# ----- Wrap Path.read_bytes globally (only when used by batch.py) ----
# We don't monkeypatch Path.read_bytes itself (way too broad). Instead,
# the test's expectation is: in normal append-only steady state,
# `_ingest_full_paths_sync` shouldn't be called at all. If the suite
# observes a `fingerprint_file` or `write_from_path` call after the
# first ingest, the suite has its evidence.

with (
patch.object(batch_support, "fingerprint_file", counted_fingerprint),
patch.object(live_batch, "fingerprint_file", counted_fingerprint),
patch.object(live_watcher, "fingerprint_file", counted_fingerprint),
patch.object(batch_support, "last_complete_newline_from_tail", counted_tail),
patch.object(live_batch, "last_complete_newline_from_tail", counted_tail),
patch.object(blob_store_mod.BlobStore, "write_from_path", counted_write_from_path),
):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n -C3 'def _ingest_full_paths_sync|_STREAMING_FULL_INGEST_BYTES|read_bytes\(|write_from_bytes\(|write_from_path\(' \
  polylogue/sources/live/batch.py \
  polylogue/storage/blob_store.py \
  tests/unit/sources/test_live_watcher.py

Repository: Sinity/polylogue

Length of output: 10125


🏁 Script executed:

find tests -name "*test_live_read_amplification*" -type f

Repository: Sinity/polylogue

Length of output: 110


🏁 Script executed:

rg -n "_STREAMING_FULL_INGEST_BYTES\s*=" polylogue/sources/live/batch_support.py

Repository: Sinity/polylogue

Length of output: 110


🏁 Script executed:

head -100 tests/integration/test_live_read_amplification.py | grep -E "def test_|small|append|write_from"

Repository: Sinity/polylogue

Length of output: 433


🏁 Script executed:

cat -n tests/integration/test_live_read_amplification.py | head -200

Repository: Sinity/polylogue

Length of output: 9129


🏁 Script executed:

sed -n '1,103p' tests/infra/io_counter.py

Repository: Sinity/polylogue

Length of output: 3967


🏁 Script executed:

sed -n '165,230p' tests/integration/test_live_read_amplification.py

Repository: Sinity/polylogue

Length of output: 2863


Close the small-file instrumentation gap in the counter harness.

The test files in test_live_read_amplification.py are small (~500 bytes), well below the _STREAMING_FULL_INGEST_BYTES = 8 MB threshold. For files this small, batch.py uses the path.read_bytes() → blob_store.write_from_bytes() path (lines 736–740, 781–790), not write_from_path.

The harness currently wraps write_from_path but not write_from_bytes, so a regression that causes the full file to be re-read via write_from_bytes would not be counted. The test assertion counter.total_bytes <= max_allowed would still pass because only the tail scan and append payload contribute to the count.

Add a counted_write_from_bytes wrapper alongside counted_write_from_path:

Suggested fix
     real_write_from_path = blob_store_mod.BlobStore.write_from_path
+    real_write_from_bytes = blob_store_mod.BlobStore.write_from_bytes

     def counted_write_from_path(self, source, *, heartbeat=None):  # type: ignore[no-untyped-def]
         hash_hex, size = real_write_from_path(self, source, heartbeat=heartbeat)
         counter.record("blob_store.write_from_path", size)
         return hash_hex, size

+    def counted_write_from_bytes(self, data: bytes) -> tuple[str, int]:  # type: ignore[no-untyped-def]
+        hash_hex, size = real_write_from_bytes(self, data)
+        counter.record("blob_store.write_from_bytes", len(data))
+        return hash_hex, size

     with (
         patch.object(batch_support, "fingerprint_file", counted_fingerprint),
         patch.object(live_batch, "fingerprint_file", counted_fingerprint),
         patch.object(live_watcher, "fingerprint_file", counted_fingerprint),
         patch.object(batch_support, "last_complete_newline_from_tail", counted_tail),
         patch.object(live_batch, "last_complete_newline_from_tail", counted_tail),
         patch.object(blob_store_mod.BlobStore, "write_from_path", counted_write_from_path),
+        patch.object(blob_store_mod.BlobStore, "write_from_bytes", counted_write_from_bytes),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/infra/io_counter.py` around lines 104 - 118, The harness misses
instrumentation for small-file uploads because BlobStore.write_from_bytes is not
wrapped, so regressions that trigger the path.read_bytes →
blob_store.write_from_bytes flow won't be counted; add a
counted_write_from_bytes wrapper (parallel to counted_write_from_path) and
include patch.object(blob_store_mod.BlobStore, "write_from_bytes",
counted_write_from_bytes) in the same with(...) context that currently patches
BlobStore.write_from_path and the fingerprint/tail functions so all write paths
are accounted for during the test.

Comment on lines +84 to +115
@pytest.fixture
def processor(tmp_path: Path) -> Iterator[tuple[LiveBatchProcessor, Path, Path]]:
"""Real ``LiveBatchProcessor`` with mocked heavyweight ingest.

Returns ``(processor, source_root, source_file_path_factory)``.
The factory is a directory the caller can write JSONL files into.
"""
root = tmp_path / "projects"
root.mkdir()
db_path = tmp_path / "polylogue.db"
cursor = CursorStore(db_path)
polylogue = SimpleNamespace(archive_root=tmp_path, backend=SimpleNamespace(db_path=db_path), config=None)
proc = LiveBatchProcessor(
cast(Any, polylogue),
(WatchSource(name="claude-code", root=root),),
cursor=cursor,
parser_fingerprint=live_watcher._PARSER_FINGERPRINT,
)

# Mock the heavyweight ingest to a no-op success. File reads BEFORE this
# call (the ones we're measuring) still happen against the real FS.
fake_summary = SimpleNamespace(
failed_raw_ids=[],
parse_failures=0,
worker_count=1,
worker_progress_total=0,
worker_progress_in_flight=0,
worker_progress_completed=0,
)
with patch("polylogue.sources.live.batch._process_ingest_batch_sync", return_value=fake_summary):
yield proc, root, root

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Use the repo’s storage test fixtures/builders for this harness.

These tests create real cursor/database state and seed conversations with raw SQL, but they bypass workspace_env and ConversationBuilder. That makes the regression suite more brittle to XDG/archive-path and schema changes than the rest of the storage/pipeline tests.

As per coding guidelines, "tests/**/*.py: Use workspace_env fixture for tests that touch storage or pipeline. It provides isolated XDG paths and archive root in tmp_path. Use ConversationBuilder from tests/infra/storage_records.py for populating test databases with a fluent builder pattern."

Also applies to: 117-157

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/integration/test_live_read_amplification.py` around lines 84 - 115, The
processor fixture is creating real DB state and seeding via raw
CursorStore/SimpleNamespace instead of using the repo test helpers; change it to
accept and use the workspace_env fixture (use workspace_env.archive_root and
workspace_env.db_path) to create the environment and replace the manual
CursorStore and SimpleNamespace setup with the workspace_env-provided paths, and
seed conversations using ConversationBuilder from tests/infra/storage_records.py
(instead of raw SQL) before instantiating LiveBatchProcessor (keep the same
WatchSource args and the patch of
polylogue.sources.live.batch._process_ingest_batch_sync to return fake_summary);
ensure the fixture still yields (proc, source_root, source_file_path_factory).

@Sinity
Sinity merged commit 50f23b3 into master May 10, 2026
7 of 8 checks passed
@Sinity
Sinity deleted the feature/fix/daemon-read-amplification branch May 10, 2026 22:11
@Sinity
Sinity removed the request for review from Copilot May 10, 2026 22:28
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.

1 participant