Skip to content

refactor(wfutils): one body behind Execute and ExecuteWithLowPrioQueue - #451

Merged
KillerX merged 1 commit into
refactor/remove-dynamic-trigger-rpcfrom
refactor/execute-shared-body
Aug 14, 2026
Merged

refactor(wfutils): one body behind Execute and ExecuteWithLowPrioQueue#451
KillerX merged 1 commit into
refactor/remove-dynamic-trigger-rpcfrom
refactor/execute-shared-body

Conversation

@KillerX

@KillerX KillerX commented Aug 13, 2026

Copy link
Copy Markdown
Member

12/n of a stack. Base: refactor/remove-dynamic-trigger-rpc (#450). Closes ExecuteWithLowPrioQueue has drifted from Execute.

The two differed only in the queue they pick, but each had its own copy of the scheduling code and the copies had drifted. Two of the three divergences the audit listed are already gone earlier in this stack — the ActivityWG bookkeeping no longer exists (#440) and both call activityOptionsWithDefaults (#443) — leaving the duplicated retry-policy switch. Both now call executeOnQueue with a queue.

Extracting it exposed a gap the duplication hid. The switch only names the worker, transcode and audio queues, so an activity on any other queue got no retry policy at all unless the workflow set one — and low-priority is by definition a queue the switch does not name, so ExecuteWithLowPrioQueue routed activities to exactly the case that falls through. Latent today because both callers pass GetDefaultActivityOptions, which carries a policy. retryPolicyForQueue now has a default branch: low priority and live ingest carry the same kind of work as the worker queue, so they get the same loose policy.

Two details worth keeping in mind when reading the diff, both about debug mode:

  • The low-priority remap compares against environment.QueueWorker, the constant, not GetWorkerQueue(). With QUEUE=debug the accessor returns the debug queue and the debug worker polls only that queue, so remapping there would leave the activity unscheduled. The asymmetry is deliberate.
  • Debug also collapses the worker, transcode and audio accessors onto one value, which made the original a switch with three identical cases where the first won. The extracted version keeps worker first for that reason, and retryPolicyForQueueNames takes the names as arguments so a test can exercise the collapsed arrangement — the QUEUE variable that decides them is read at package-var time, so t.Setenv cannot reach it.

Worth knowing while reviewing: the test environment here runs with QUEUE=debug, so anything asserting on the accessors is asserting the collapsed arrangement.

🤖 Generated with Claude Code

@KillerX
KillerX force-pushed the refactor/execute-shared-body branch from 971252a to e72258d Compare August 13, 2026 08:48
@KillerX
KillerX force-pushed the refactor/execute-shared-body branch from e72258d to 726653a Compare August 13, 2026 13:26
@KillerX
KillerX force-pushed the refactor/execute-shared-body branch from 726653a to 61e0540 Compare August 14, 2026 06:37
@KillerX
KillerX force-pushed the refactor/execute-shared-body branch from 61e0540 to 8f1630d Compare August 14, 2026 07:15
@KillerX
KillerX force-pushed the refactor/execute-shared-body branch from 8f1630d to a05aed2 Compare August 14, 2026 08:16
@KillerX
KillerX force-pushed the refactor/execute-shared-body branch from a05aed2 to 9339b07 Compare August 14, 2026 08:38
@KillerX
KillerX force-pushed the refactor/execute-shared-body branch from 9339b07 to 9307192 Compare August 14, 2026 08:54
@KillerX
KillerX force-pushed the refactor/execute-shared-body branch from 9307192 to 2129bc8 Compare August 14, 2026 09:18
@KillerX
KillerX force-pushed the refactor/execute-shared-body branch from 2129bc8 to 93ac5b2 Compare August 14, 2026 10:00
The two differed only in the queue they pick, but each had its own copy of the
scheduling code, and the copies had drifted. Two of the three divergences the
audit listed are already gone — the ActivityWG bookkeeping no longer exists,
and both call activityOptionsWithDefaults — leaving the duplicated
retry-policy switch. Both now call executeOnQueue with a queue.

Extracting it exposed a gap the duplication hid. The switch only names the
worker, transcode and audio queues, so an activity on any other queue got no
retry policy at all unless the workflow had set one — and low-priority is by
definition a queue the switch does not name, so ExecuteWithLowPrioQueue was
routing activities to exactly the case that falls through. It is latent today
because both callers set GetDefaultActivityOptions, which carries a policy.
retryPolicyForQueue now has a default branch: low priority and live ingest
carry the same kind of work as the worker queue, so they get the same loose
policy.

Two details worth keeping when reading this:

The low-priority remap compares against environment.QueueWorker, the constant,
not GetWorkerQueue(). In debug mode the accessor returns the debug queue and
the debug worker polls only that queue, so remapping there would leave the
activity unscheduled. The comparison is deliberate, not an oversight.

Debug mode also collapses the worker, transcode and audio accessors onto one
value, which made the original a switch with three identical cases where the
first won. The extracted version keeps worker first for that reason, and
retryPolicyForQueueNames takes the names as arguments so a test can exercise
the collapsed arrangement without the process-wide QUEUE variable that decides
it — a variable read at package-var time, so t.Setenv cannot reach it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@KillerX
KillerX force-pushed the refactor/execute-shared-body branch from 93ac5b2 to b2f8d27 Compare August 14, 2026 10:04
@KillerX
KillerX merged commit dc8d15e into master Aug 14, 2026
@KillerX
KillerX deleted the refactor/execute-shared-body branch August 14, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant