Repository navigation
test(memory): seed the prompt-growth test in one transaction - #4750
Conversation
The memory-cap test timed out on loaded Windows runners because it seeded ~925 entries through MemoryStore.store(), which commits (and fsyncs the WAL) once per row and runs an FTS dedup search before each insert. Seeding now goes through seed_bulk(), one commit per store; the rendered prompt and the growth table are byte-identical to before. The dedup sanity test still stores through store(), so it keeps proving the generator never produces near-duplicates, which is what makes skipping dedup in the other tests safe.
|
Verdict: Approve This fixes a flaky timeout in the Windows unit job by seeding the memory prompt-growth test in a single save instead of hundreds. The test still checks the same things, and the author confirmed the growth table comes out identical to Real-world evidenceN/A: this PR only changes tests, and no evidence bundle was produced. The verdict rests on static review. I couldn't run pytest in this environment, so I'm relying on the author's local timings and the pending Windows CI check. 🔍 Technical detailsIssues found 🟢 The docstring claims more than the dedup check covers ( Strengths
|
The memory-cap test in the Windows unit job sometimes hit the 60 s pytest timeout, failing unrelated PRs (for example #4723) on a busy runner. It added about 925 memories one at a time, and every add saved to disk on its own, so a slow disk made the test crawl. It now adds each batch in one save. The checks are unchanged and the measured prompt sizes are byte-for-byte the same.
🔍 Technical details
MemoryStore.store()commits per row (one WAL fsync) and runs an FTS5 dedup query before each insert. Profiling showed commit ≈ 45% andexecute≈ 50% of runtime._seed_entriesnow callsMemoryStore.seed_bulk(): one transaction, no dedup. The prompt builder doesn't readsource/last_used, the two fields whereseed_bulkdiffers, so the rendered block is the same. I diffed the standalone growth table before and after: identical._make_entry()produces unique entries by construction.test_dedup_did_not_collapse_seeded_entriesstill goes throughstore()(new_store_entries), so it keeps proving that.--durations):test_memory_block_never_exceeds_hard_cap1.69 s → 0.24 s,test_print_growth_table1.61 s → 0.25 s, the two 500-entry tests 0.8 s → under 0.06 s. Module total: 6.5 s → 1.3 s.Test plan
python -m pytest tests/unit/test_memory_prompt_growth.py -v --durations=10passes three runs in a row (1.2 to 1.5 s)python tests/unit/test_memory_prompt_growth.pyprints a growth table identical tomain'spython util/lint.py --black --isort --flake8passesUnit Tests (Windows, py3.12)passes on this PR