Add py.typed marker, cap dependency versions, and validate task statu…#2
Conversation
|
Thanks for the contribution! Unfortunately we can't verify the commit author(s): Ajay Chinthalapalli Jayakumar <a***@s***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, refresh the status of this Pull Request. |
ce5e4b5 to
38245ba
Compare
38245ba to
1efe433
Compare
1efe433 to
79fdf98
Compare
demianbrecht
left a comment
There was a problem hiding this comment.
The dependency version caps and py.typed marker are fine. My concern is with the transition enforcement — see inline comment.
| # Valid status transitions. Keys are the current status; values are the set of | ||
| # statuses that may follow. Any transition not listed here is rejected. | ||
| _VALID_TRANSITIONS: dict[TaskStatus, frozenset[TaskStatus]] = { | ||
| TaskStatus.PENDING: frozenset({TaskStatus.RUNNING, TaskStatus.CANCELLED, TaskStatus.FAILED}), | ||
| TaskStatus.RUNNING: frozenset( | ||
| {TaskStatus.RUNNING, TaskStatus.COMPLETED, TaskStatus.FAILED, TaskStatus.CANCELLED, TaskStatus.INTERRUPTED} | ||
| ), | ||
| TaskStatus.INTERRUPTED: frozenset({TaskStatus.RUNNING, TaskStatus.FAILED, TaskStatus.CANCELLED}), | ||
| # Terminal states can only transition to PENDING (resume flow). | ||
| TaskStatus.COMPLETED: frozenset({TaskStatus.PENDING}), | ||
| TaskStatus.FAILED: frozenset({TaskStatus.PENDING}), | ||
| TaskStatus.CANCELLED: frozenset({TaskStatus.PENDING}), | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
This hardcodes a state machine directly in the persistence layer — every app built on Switchplane gets the same rigid transitions with no way to override or opt out.
Different apps may have legitimate reasons for different flows (e.g., synchronous tasks that skip RUNNING, custom intermediate states, domain-specific lifecycle rules). Transition policy is an application concern, not a framework storage concern.
If we want to offer transition validation as a convenience, it should be opt-in or configurable at the app/task level — not baked into Store.update_task() where it silently constrains every consumer.
refactor: implement status validation and update dependencies