Skip to content

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

Open
KillerX wants to merge 2 commits into
refactor/remove-dynamic-trigger-rpcfrom
refactor/execute-shared-body
Open

refactor(wfutils): one body behind Execute and ExecuteWithLowPrioQueue#451
KillerX wants to merge 2 commits 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 and others added 2 commits August 13, 2026 15:24
…stry

GET /schemas published the full JSON Schema of every triggerable workflow's
param struct, and POST /trigger-dynamic executed any of them by name through
reflection — including scheduled.CleanupTemp and
scheduled.MediabankenPurgeTrash, on a service with no authn or authz of its
own. Nothing in this repository calls either endpoint.

They were also the only reader of TriggerableWorkflows, the second of the two
hand-maintained registration lists. Rather than derive one list from the other
and add a test to keep them in step, both endpoints and the list go, which
closes the drift by construction: a workflow is either in WorkerWorkflows or it
cannot run.

That also settles the six workflows the audit found missing from the
triggerable list — BulkExportShorts, ExportShort, GenerateShort, IsilonExport,
AssetJSON and ImportSubtitles. They were not reachable through /trigger-dynamic
and now there is nothing for them to be missing from.

/trigger/:job is untouched. That is the named-job endpoint the FileCatalyst and
watcher integrations post to, and it has an explicit case per job rather than
reflecting over a registry.

Also removed: httpin's own copy of getFunctionName, which only the schema
handler used, and the invopop/jsonschema dependency. The jsonschema struct tag
on VXExportParams.Destinations went with it — the valid values are the
AssetExportDestination enum, which VXExport already validates against.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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/remove-dynamic-trigger-rpc branch from 10c2de2 to ccc6e9a Compare August 13, 2026 13:26
@KillerX
KillerX force-pushed the refactor/execute-shared-body branch from e72258d to 726653a Compare August 13, 2026 13:26
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