Follow-up to #25. That PR fixed the BufferedWriteLayer pressure path
without including a failing test first — which is a workflow gap we
just codified in CLAUDE.md.
This test reproduces the 2026-05-28 monoscope dual-write symptom:
- Tight buffer budget so memory pressure trips after one batch
- Default 600s bucket_duration_secs so the current bucket is never
yet a 'completed' bucket
- Second insert with a near-now timestamp lands in the same current
bucket
Pre-#25: the second insert fails with 'Memory limit exceeded'
because the pressure-triggered flush_completed_buckets finds
nothing flushable.
Post-#25: it succeeds because flush_all_now drains the current
bucket and frees memory.
Follow-up to #25. That PR fixed the BufferedWriteLayer pressure path without including a failing test first — which is a workflow gap we just codified in the bug-fix section of CLAUDE.md.
This test reproduces the 2026-05-28 monoscope dual-write symptom:
max_memory_mb = 1) so memory pressure trips after one batchbucket_duration_secsso the current bucket is never yet a 'completed' bucketPre-#25 behavior: the second insert fails with
Memory limit exceededbecause the pressure-triggeredflush_completed_bucketsfinds nothing flushable.Post-#25 behavior: it succeeds because
flush_all_nowdrains the current bucket and frees memory.I verified the test would fail without the #25 fix by mentally tracing:
is_memory_pressure()returns true after the first insert → pre-fix callsflush_completed_buckets→get_flushable_buckets(current_bucket)returns[](current is not flushable) → no eviction →reserved_bytes + estimated_bytesstays at the post-insert level → second insert'stry_reserve_memoryexceedshard_limit→anyhow::bail!.