A handler documented as idempotent since 2022, which was not, and a redelivery that proved it.
// the claim, in a docblock
/** Idempotency: keyed on message id. */
// the implementation
public function handle(StockAdjusted $m): void
{
$this->stock->increment($m->sku, $m->delta); // not idempotent
}
// what it needed, and now has
DB::transaction(function () use ($m) {
$claimed = DB::table('processed_messages')
->insertOrIgnore(['handler' => self::class, 'message_id' => $m->id]);
if ($claimed === 0) { return; }
$this->stock->increment($m->sku, $m->delta);
});
A docblock claiming idempotency is a claim and not a mechanism, and this one had been copied from a handler where it was true. The test that would have caught it is four lines — call the handler twice, assert the effect once — and it now exists for every consumer, which found one more.