Skip to content

fix(activities): route activities to queues by lookup, and check the fallback - #452

Merged
KillerX merged 1 commit into
refactor/execute-shared-bodyfrom
fix/activity-queue-routing-map
Aug 14, 2026
Merged

fix(activities): route activities to queues by lookup, and check the fallback#452
KillerX merged 1 commit into
refactor/execute-shared-bodyfrom
fix/activity-queue-routing-map

Conversation

@KillerX

@KillerX KillerX commented Aug 13, 2026

Copy link
Copy Markdown
Member

13/n of a stack. Base: refactor/execute-shared-body (#451). Closes Activity→queue routing is stringly-typed with a silent fallback.

Directly related to #451: GetQueueForActivity is the one call executeOnQueue makes to decide a queue, so that extraction concentrated everything on this function.

It walked three slices with lo.Contains on every Execute call to answer a question with a fixed answer. It is a map built once now.

Building it once makes the collision case detectable. Two structs defining the same method name would make the answer depend on the order of the three loops; it panics instead. Not a new class of failure — activities are registered under the same short name, the worker runs with DisableRegistrationAliasing, and the debug queue registers every struct, so the worker would refuse to start anyway. Failing in the builder says why.

The silent fallback cannot be removed. A name says nothing about what an activity needs, so an ffmpeg activity hung on the wrong struct lands on the worker queue and fails there as an opaque timeout — the audit's point. TestEveryFFmpegActivityIsOnAnFFmpegQueue reads the package source instead: it finds every exported activity method whose body reaches into the ffmpeg or transcode packages and asserts it hangs off Audio or Video. 38 methods qualify today, and the test requires a known one to be found so it cannot pass by looking at nothing.

One activity is already in that trap. CropShortActivity calls ffmpeg.GetStreamInfo from UtilActivities to choose between 25 and 50 fps, on a queue whose image has no ffmpeg — and it discards the error, so it does not fail, it quietly crops 50 fps material at 25. Allowlisted and written up in potential_improvements.md rather than moved here, because moving it changes which worker runs it. Two ways out, both wanting your call: move the probe into the video activity that runs the resulting arguments, or move the whole activity to VideoActivities.

Also added the test the audit asked for: no activity name defined on two structs. There are 112 and they are unique today.

🤖 Generated with Claude Code

@KillerX
KillerX force-pushed the fix/activity-queue-routing-map branch from 014dd26 to 17ced97 Compare August 13, 2026 08:49
@KillerX
KillerX force-pushed the fix/activity-queue-routing-map branch from 17ced97 to 5e07d0f Compare August 13, 2026 13:26
@KillerX
KillerX force-pushed the fix/activity-queue-routing-map branch from 5e07d0f to 6fe109a Compare August 14, 2026 06:37
@KillerX
KillerX force-pushed the fix/activity-queue-routing-map branch from 6fe109a to cb685d1 Compare August 14, 2026 07:15
@KillerX
KillerX force-pushed the fix/activity-queue-routing-map branch from cb685d1 to 70f0c1e Compare August 14, 2026 08:16
@KillerX
KillerX force-pushed the fix/activity-queue-routing-map branch from 70f0c1e to 853461e Compare August 14, 2026 08:38
@KillerX
KillerX force-pushed the fix/activity-queue-routing-map branch from 853461e to 742135c Compare August 14, 2026 08:54
@KillerX
KillerX force-pushed the fix/activity-queue-routing-map branch from 742135c to 989de96 Compare August 14, 2026 09:18
@KillerX
KillerX force-pushed the fix/activity-queue-routing-map branch from 989de96 to c7aca07 Compare August 14, 2026 10:00
…fallback

GetQueueForActivity walked three slices with lo.Contains on every Execute call
to answer a question with a fixed answer. It is a map built once now, which
also gives the routing one place to live.

Building it once makes the collision case detectable: two structs defining the
same method name would make the answer depend on the order of the three loops.
It panics instead. That is not a new class of failure — activities are
registered under the same short name, the worker runs with
DisableRegistrationAliasing, and the debug queue registers every struct, so the
worker would refuse to start anyway. Failing in the builder says why.

The silent fallback cannot be removed. A name says nothing about what an
activity needs, so an ffmpeg activity hung on the wrong struct lands on the
worker queue and fails there as an opaque timeout — the audit's point.
TestEveryFFmpegActivityIsOnAnFFmpegQueue reads the package source instead: it
finds every exported activity method whose body reaches into the ffmpeg or
transcode packages and asserts it hangs off Audio or Video. Thirty-eight
methods qualify today, and the test requires a known one to be found so it
cannot pass by looking at nothing.

One is already in that trap, allowlisted and logged rather than moved here,
because moving it changes which worker runs it: CropShortActivity calls
ffmpeg.GetStreamInfo from UtilActivities to choose between 25 and 50 fps, on a
queue whose image has no ffmpeg, and discards the error — so it does not fail,
it quietly crops 50 fps material at 25.

Also added the test the audit asked for, that no activity name is defined on
two structs. There are 112 of them and they are unique today.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@KillerX
KillerX force-pushed the fix/activity-queue-routing-map branch from c7aca07 to 4bd6cc5 Compare August 14, 2026 10:04
@KillerX
KillerX merged commit dc8d15e into master Aug 14, 2026
@KillerX
KillerX deleted the fix/activity-queue-routing-map 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