⚙️ FEATURE-#257: Managed-mode ServerAPI provider and task numbering#258
Merged
FernandoCelmer merged 90 commits intodevelopfrom Apr 14, 2026
Merged
⚙️ FEATURE-#257: Managed-mode ServerAPI provider and task numbering#258FernandoCelmer merged 90 commits intodevelopfrom
FernandoCelmer merged 90 commits intodevelopfrom
Conversation
Centralise the value "1" used as the first task_id of a workflow so abc/server.py, core/dotflow.py, core/task.py and the ServerAPI fallback paths share the same symbol.
Non-abstract method returning INITIAL_TASK_ID by default. Subclasses that talk to a real backend override it to resume task numbering from where a previous run stopped.
HTTP implementation of the Server ABC. Posts workflow/task events
to a remote API using Authorization: Bearer and swallows transient
RequestException so a network blip never crashes a running
workflow. Implements get_next_task_id via GET /workflows/{id}/
tasks/next-id with fallback to INITIAL_TASK_ID on any failure.
Make the new HTTP provider importable as ``from dotflow.providers import ServerAPI``, alongside the existing ServerDefault.
TaskBuilder now accepts initial_task_id (default INITIAL_TASK_ID) so callers resuming a workflow can continue task ids from where the previous run stopped instead of restarting at 1.
When the caller supplies a workflow_id (managed mode), skip create_workflow and pull the next task id from the Server provider via get_next_task_id. For auto-generated ids the behaviour is unchanged: create_workflow is fired and numbering starts at INITIAL_TASK_ID.
When SERVER_BASE_URL and SERVER_USER_TOKEN (plus optional WORKFLOW_ID) are set, the CLI builds a ServerAPI provider and reuses the externally supplied workflow id, enabling managed execution from CodeBuild/ECS without code changes to user workflows.
Verify Authorization: Bearer header, POST/PATCH for workflow/task events, and GET /tasks/next-id with success, RequestException and non-200 fallbacks returning INITIAL_TASK_ID.
External workflow_id calls get_next_task_id and task numbering starts at the returned value. Auto-generated id does not call get_next_task_id and numbering starts at INITIAL_TASK_ID.
Check that SERVER_BASE_URL + SERVER_USER_TOKEN configure a ServerAPI provider, that WORKFLOW_ID (when present) is forwarded as the external id, and that missing env vars fall back to the ServerDefault no-op behaviour.
Run ruff format with the project CI config (.code_quality/ruff.toml) so the code-quality check passes.
Run ruff format with the project CI config (.code_quality/ruff.toml) so the code-quality check passes.
Run ruff format with the project CI config (.code_quality/ruff.toml) so the code-quality check passes.
Run ruff format with the project CI config (.code_quality/ruff.toml) so the code-quality check passes.
Poetry 1.8 on CI reads dependencies from [tool.poetry.dependencies] and ignored cookiecutter (only declared in [project.dependencies]), breaking test collection for tests/cli/test_start_command.py with ModuleNotFoundError.
Reflect cookiecutter addition to [tool.poetry.dependencies] in the lock file so CI can install it via ``poetry install --with dev``.
FernandoCelmer
commented
Apr 12, 2026
Member
Author
There was a problem hiding this comment.
🔍 Code Review
Code issues found: 5
| # | Severity | Comment |
|---|---|---|
| 1 | [Blocking] | Unfiltered payload in update_task repeats BUG-#241 |
| 2 | [Blocking] | Silent task_id fallback to 1 risks collisions |
| 3 | [Blocking] | Blocking update calls contradict PR #244 pattern |
| 4 | [Suggestion] | HTTP 4xx/5xx errors silently swallowed |
| 5 | [Suggestion] | Stale docstrings for workflow_id and TaskBuilder |
FernandoCelmer
commented
Apr 13, 2026
Member
Author
FernandoCelmer
left a comment
There was a problem hiding this comment.
🔍 Code Review
Code issues found: 2
| # | Severity | Comment |
|---|---|---|
| 1 | [Blocking] | create_task/update_task field naming inconsistency |
| 2 | [Blocking] | Double ULID on class execution error path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #257
Enables managed execution: the CLI auto-wires a
ServerAPIprovider from env vars and DotFlow continues task numbering correctly when an externalworkflow_idis supplied.Modified files/modules:
dotflow/constants.py(new) — Constants likeINITIAL_TASK_ID = 1dotflow/abc/server.py(modified) — Abstract base class for Server providersdotflow/providers/server_api.py(new) — ServerAPI HTTP provider implementing authentication and task ID managementdotflow/core/dotflow.py(modified) — UpdatedDotFlow.__init__to handle externalworkflow_iddotflow/core/task.py(modified) —TaskBuilderacceptsinitial_task_idparameterdotflow/cli/commands/start.py(modified) — Auto-configures ServerAPI provider from env varsdotflow/cli/commands/cloud.py,dotflow/cli/commands/deploy.py(modified) — CLI updatesdotflow/__init__.py,dotflow/providers/__init__.py(modified) — Module exportstests/providers/test_server_api.py(new) — Tests for ServerAPI providertests/cli/test_start_command.py,tests/core/test_dotflow.py(modified) — Updated testspyproject.toml,poetry.lock,LAST_VERSION(modified) — Dependencies and versionMotivation and Context
Enables managed workflow execution where the CLI auto-wires a
ServerAPIprovider from environment variables. This allows DotFlow to continue task numbering correctly when an externalworkflow_idis supplied, supporting integration with dotflow-api for centralized workflow management.Types of changes
Checklist
Test plan
poetry run ruff check dotflow/ tests/poetry run pytest -x -q— 488 passed, 4 skippedWORKFLOW_ID,SERVER_BASE_URLandSERVER_USER_TOKENset against a staging dotflow-api and confirm task ids continue from the last run