SIGN IN SIGN UP

test(retain): cover the retain.completed outbox across a split batch (#3767)

`_run_retain_execution` hands the outbox callback to exactly one sub-batch —
the last — so the webhook delivery rows commit inside that sub-batch's
transaction. Nothing tested that. The existing webhook tests cover boundaries
*within* one sub-batch (a chunk count landing on a batch boundary, a final
batch extracting zero facts); the split level had no coverage at all.

Both ways of getting it wrong are silent. Never firing loses every webhook
while the retain still reports success — no error, no retry, nothing in the
trace. Firing per sub-batch multiplies deliveries instead. Asserting the exact
count catches both directions, verified by mutation: forcing the callback to
None fails both tests, and passing it to every sub-batch fails both.

Two shapes, because "which sub-batch is last" is reached differently in each:
items packed across sub-batches (one event per document, from a whole-operation
callback fired once), and one oversized document sliced into several.

Both assert the batch actually split before asserting anything about delivery.
Without that the sliced case passed while producing a single sub-batch — slices
are cut on retain_chunk_size (3000 char) boundaries and never inside a chunk,
so a short body yields one slice however small the token budget is, and the
test proved nothing.
N
Nicolò Boschi committed
b84bd036f91aa8e5b01c70a5fe525da3c969aef6
Parent: e65973b
Committed by GitHub <noreply@github.com> on 8/24/2026, 4:19:43 PM