fix(run-engine): create message key when dequeuing V3 messages for execution

For V3 optimized format, we now create the message key when the run
is dequeued from the worker queue (ready to execute). This allows
ack/nack/readMessage to work correctly.

Storage savings come from not having message keys while messages are
PENDING in the queue backlog - only executing runs have message keys.

https://claude.ai/code/session_01AyzQp6tbj7th5QRTCYjJR5
This commit is contained in:
Claude
2026-02-01 11:50:20 +00:00
parent 7afe9ed865
commit 5ff7951e18
@@ -2373,6 +2373,12 @@ export class RunQueue {
const descriptor = this.keys.descriptorFromQueue(decoded.queueKey);
const message = reconstructMessageFromWorkerEntry(decoded, descriptor);
// For V3 format: create the message key now that the run is executing.
// This allows ack/nack to work (they read from message key).
// Storage savings come from not having message keys for PENDING runs (the backlog).
const messageKey = this.keys.messageKey(descriptor.orgId, message.runId);
await this.redis.set(messageKey, JSON.stringify(message));
// Update the currentDequeued sets (this is done in the Lua script for legacy)
const queueCurrentDequeuedKey = this.keys.queueCurrentDequeuedKeyFromQueue(decoded.queueKey);
const envCurrentDequeuedKey = this.keys.envCurrentDequeuedKeyFromQueue(decoded.queueKey);