From 9459dad540218db927455a6f54b62dbcef2afbe1 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sun, 29 Nov 2026 06:39:55 +0530 Subject: [PATCH] The file-write test fails when a code_files insert keeps the round's cached file rows `test_a_file_write_ends_the_no_file_row_answer` read the path before it wrote the row. A per-path read answered from the round removes the cached rows it returns, so the insert had nothing left to drop, and the test passed with `code_files` removed from the tables whose insert drops a cache. The test now writes before the first read. With the cache dropped, the read writes the buffered row and asks the repository; with it kept, the read is answered from the prefetch with no statement and no write, and the test fails. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Lareb Zafar --- ...test_code_round_reads_backfill_statements.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/unit/test_code_round_reads_backfill_statements.py b/tests/unit/test_code_round_reads_backfill_statements.py index 8b5ca13a9d7..867ad1eba01 100644 --- a/tests/unit/test_code_round_reads_backfill_statements.py +++ b/tests/unit/test_code_round_reads_backfill_statements.py @@ -227,20 +227,19 @@ async def statements(reuse_from: str) -> int: def test_a_file_write_ends_the_no_file_row_answer() -> None: - async def go() -> tuple[_Repo, list[Any]]: + async def go() -> _Repo: repo = _Repo() reads = RoundReads(repo, ORG, NS) await reads.prefetch(SOURCES, embedding_model=MODEL) - before = await reads.live_files_for_path(ORG, NS, "logo.png") + # The write comes before any read of the path: a read answered from the round + # takes the cached rows with it, and the write would have nothing to drop. await reads.insert_rows("code_files", [{"path": "logo.png"}]) - return repo, [before, await reads.live_files_for_path(ORG, NS, "logo.png")] + await reads.live_files_for_path(ORG, NS, "logo.png") + return repo - repo, (before, after) = asyncio.run(go()) - assert before == [] and after == [] - # answered from the round's read, then read after the buffered row was written - assert [c for c in repo.calls if c.startswith("live_files_for_path:")] == [ - "live_files_for_path:logo.png" - ] + repo = asyncio.run(go()) + # read from the repository, after the buffered row was written + assert "live_files_for_path:logo.png" in repo.calls assert repo.inserted == ["code_files"]