Skip to content

Add py.typed marker, cap dependency versions, and validate task statu…#2

Open
ajaycj wants to merge 1 commit into
salesforce-misc:mainfrom
ajaycj:contrib/py-typed-dep-caps-status-transitions
Open

Add py.typed marker, cap dependency versions, and validate task statu…#2
ajaycj wants to merge 1 commit into
salesforce-misc:mainfrom
ajaycj:contrib/py-typed-dep-caps-status-transitions

Conversation

@ajaycj
Copy link
Copy Markdown

@ajaycj ajaycj commented Apr 20, 2026

refactor: implement status validation and update dependencies

  • src/switchplane/py.typed: Add PEP 561 marker for type checking.
  • pyproject.toml: Update version caps for aiosqlite, langgraph, prompt_toolkit, structlog, langchain-core, and mcp.
  • src/switchplane/persistence.py: Add _VALID_TRANSITIONS table and enforce validation in update_task.
  • tests/test_persistence.py: Fix PENDING->COMPLETED transition and add TestStatusTransitions suite (6 tests).
  • tests/test_control_plane.py: Fix PENDING->COMPLETED shortcut logic.

@salesforce-cla
Copy link
Copy Markdown

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.

@ajaycj ajaycj force-pushed the contrib/py-typed-dep-caps-status-transitions branch from ce5e4b5 to 38245ba Compare April 20, 2026 23:01
@ajaycj ajaycj force-pushed the contrib/py-typed-dep-caps-status-transitions branch from 38245ba to 1efe433 Compare April 20, 2026 23:03
@ajaycj ajaycj force-pushed the contrib/py-typed-dep-caps-status-transitions branch from 1efe433 to 79fdf98 Compare April 20, 2026 23:07
Copy link
Copy Markdown
Contributor

@demianbrecht demianbrecht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependency version caps and py.typed marker are fine. My concern is with the transition enforcement — see inline comment.

Comment on lines +13 to 27
# 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}),
}


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants