Reviewer flagged that prune was mutating pendingMessagingRequests under
index iteration. Concrete failure: if prune drops the entry at the
current idx, the seq shifts and `idx.inc()` skips the next slot.
Hoist the single prune call to after the outer loop. Prune is idempotent
on the final-state filter, so doing it once at the end is equivalent to
calling it per-error-path while keeping idx aligned.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Reviewer flagged that constructing MessageEnvelope/DeliveryTask, minting
the messagingReqId, poking deliveryTask.msg.meta, and calling
sendService.send directly all reach past the messaging API into its
internals — a layer-boundary violation.
Replace that block in onReadyToSend with `await self.waku.send(envelope)`
where `envelope.meta` carries the wire-format marker. The channel now
holds a `Waku` instead of a `DeliveryService`. waku.send already handles
requestId generation, subscription, and DeliveryTask construction.
`waku.send` isn't `(raises: [])` so the await is wrapped in try/except to
keep the listener annotation honest.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
PR review noted that an async proc captures parameters into the future's
env, deep-copying `seq[seq[byte]]`. `sink` tells the compiler the callee
consumes msgs, letting it move under arc/orc memory models. Under refc
the change is a no-op but documents intent at the boundary.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>