Skip to content

⚙️ FEATURE-#257: Managed-mode ServerAPI provider and task numbering#258

Merged
FernandoCelmer merged 90 commits intodevelopfrom
feature/257
Apr 14, 2026
Merged

⚙️ FEATURE-#257: Managed-mode ServerAPI provider and task numbering#258
FernandoCelmer merged 90 commits intodevelopfrom
feature/257

Conversation

@FernandoCelmer
Copy link
Copy Markdown
Member

@FernandoCelmer FernandoCelmer commented Apr 12, 2026

Description

Closes #257

Enables managed execution: the CLI auto-wires a ServerAPI provider from env vars and DotFlow continues task numbering correctly when an external workflow_id is supplied.

Modified files/modules:

  • dotflow/constants.py (new) — Constants like INITIAL_TASK_ID = 1
  • dotflow/abc/server.py (modified) — Abstract base class for Server providers
  • dotflow/providers/server_api.py (new) — ServerAPI HTTP provider implementing authentication and task ID management
  • dotflow/core/dotflow.py (modified) — Updated DotFlow.__init__ to handle external workflow_id
  • dotflow/core/task.py (modified) — TaskBuilder accepts initial_task_id parameter
  • dotflow/cli/commands/start.py (modified) — Auto-configures ServerAPI provider from env vars
  • dotflow/cli/commands/cloud.py, dotflow/cli/commands/deploy.py (modified) — CLI updates
  • dotflow/__init__.py, dotflow/providers/__init__.py (modified) — Module exports
  • tests/providers/test_server_api.py (new) — Tests for ServerAPI provider
  • tests/cli/test_start_command.py, tests/core/test_dotflow.py (modified) — Updated tests
  • pyproject.toml, poetry.lock, LAST_VERSION (modified) — Dependencies and version

Motivation and Context

Enables managed workflow execution where the CLI auto-wires a ServerAPI provider from environment variables. This allows DotFlow to continue task numbering correctly when an external workflow_id is supplied, supporting integration with dotflow-api for centralized workflow management.

Types of changes

  • New feature (change which adds functionality)
  • Bug fix (change that fixes an issue)
  • Documentation

Checklist

  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the CHANGELOG
  • I have updated the documentation accordingly

Test plan

  • poetry run ruff check dotflow/ tests/
  • poetry run pytest -x -q — 488 passed, 4 skipped
  • Manually run the CLI with WORKFLOW_ID, SERVER_BASE_URL and SERVER_USER_TOKEN set against a staging dotflow-api and confirm task ids continue from the last run

FernandoCelmer and others added 19 commits April 12, 2026 15:26
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``.
Copy link
Copy Markdown
Member Author

@FernandoCelmer FernandoCelmer left a comment

Choose a reason for hiding this comment

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

Comment thread dotflow/providers/server_api.py Outdated
Comment thread dotflow/providers/server_api.py Outdated
Comment thread dotflow/providers/server_api.py Outdated
Comment thread dotflow/providers/server_api.py Outdated
Comment thread dotflow/core/dotflow.py
@FernandoCelmer FernandoCelmer added enhancement New feature or request in progress Fix merged to develop, pending release to master labels Apr 12, 2026
@FernandoCelmer FernandoCelmer changed the base branch from develop to release/1.0.0-dev-1 April 13, 2026 17:26
@FernandoCelmer FernandoCelmer changed the base branch from release/1.0.0-dev-1 to release/develop-1.0.0 April 13, 2026 17:26
@FernandoCelmer FernandoCelmer changed the base branch from release/develop-1.0.0 to develop April 13, 2026 17:27
Copy link
Copy Markdown
Member Author

@FernandoCelmer FernandoCelmer left a comment

Choose a reason for hiding this comment

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

🔍 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

Comment thread dotflow/providers/server_api.py Outdated
Comment thread dotflow/core/engine.py
@FernandoCelmer FernandoCelmer self-assigned this Apr 13, 2026
@FernandoCelmer FernandoCelmer merged commit 67c9dbe into develop Apr 14, 2026
@FernandoCelmer FernandoCelmer deleted the feature/257 branch April 14, 2026 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request in progress Fix merged to develop, pending release to master

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants