Skip to content

A schedule fires dispatch() when the workflow declares one - #266

Merged
czpython merged 1 commit into
mainfrom
commonzenpython/eng-854-schedule-dispatch
Aug 17, 2026
Merged

A schedule fires dispatch() when the workflow declares one#266
czpython merged 1 commit into
mainfrom
commonzenpython/eng-854-schedule-dispatch

Conversation

@czpython

@czpython czpython commented Aug 17, 2026

Copy link
Copy Markdown
Owner

A subject-backed workflow can't be scheduled: the cron fires run() with no subject, and a run about something needs one. Apps worked around it with a shim workflow whose whole body was Real.dispatch().

Now a schedule fires dispatch() when the class declares one — the policy resolves the subject and starts the real run. The tick runs no workflow of its own kind (no Run row for the tick); dispatch() runs at the scheduled workflow's body level with a session, because DBOS only allows the child-start inside start() from a workflow body — a step is forbidden it (dbos/_context.py asserts is_workflow() on child-start). A failed dispatch fails the .scheduled workflow; the next tick fires fresh.

A scheduled dispatch() fires with no arguments, so declaring one with a required parameter is a class-definition error. Detection is getattr, so a mixin-provided dispatch() schedules the same as a declared one.

The author guide's schedule section now shows the subject-backed shape instead of the shim pattern. The test drives the registered scheduled entry end to end: the tick reaches dispatch(), whose start() enqueues the real run about its subject.

ENG-854

A subject-backed workflow can't be scheduled: the cron fires run() with no
subject, and a run about something needs one. Apps worked around it with a
shim workflow whose whole body was Real.dispatch().

Now a schedule fires dispatch() when the class declares one — the policy
resolves the subject and starts the real run. The tick runs no workflow of
its own kind (no Run row); dispatch() runs at the scheduled workflow's body
level with a session, because DBOS only allows the child-start inside
start() from a workflow body. A scheduled dispatch is nullary, enforced at
class definition.
@czpython
czpython force-pushed the commonzenpython/eng-854-schedule-dispatch branch from b539994 to 8a29d0f Compare August 17, 2026 03:03
@czpython
czpython merged commit a4180fa into main Aug 17, 2026
1 check passed
@czpython
czpython deleted the commonzenpython/eng-854-schedule-dispatch branch August 17, 2026 07:57
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