Skip to content

⚙️ FEATURE-#281: on_input_change policy for resume workflows#282

Open
FernandoCelmer wants to merge 32 commits intodevelopfrom
feature/281
Open

⚙️ FEATURE-#281: on_input_change policy for resume workflows#282
FernandoCelmer wants to merge 32 commits intodevelopfrom
feature/281

Conversation

@FernandoCelmer
Copy link
Copy Markdown
Member

@FernandoCelmer FernandoCelmer commented Apr 27, 2026

Closes #281

Description

  • dotflow/core/fingerprint.py (new): SHA-256 fingerprint helpers (fingerprint_of, fp_key, read_fingerprint, write_fingerprint) and VALID_POLICIES constant for the three supported policies.
  • dotflow/core/workflow.py: Manager.__init__ gains on_input_change: str = "reuse" and calls _enforce_input_fingerprint on resume when storage is configured.
  • dotflow/abc/storage.py: New non-abstract clear(workflow_id) method; default implementation raises NotImplementedError.
  • dotflow/providers/storage_default.py: clear() deletes in-memory keys whose name starts with workflow_id.
  • dotflow/providers/storage_file.py: clear() removes files in the tasks directory whose name starts with workflow_id.
  • dotflow/providers/storage_s3.py: clear() delegates to S3.delete_prefix(workflow_id).
  • dotflow/cloud/aws/services/s3.py: delete_prefix(sub_prefix) paginates and batch-deletes S3 objects; rejects empty sub_prefix to prevent bucket-wide wipes.
  • dotflow/core/exception.py: InputChangedError and InvalidOnInputChange exceptions with descriptive messages.
  • docs_src/checkpoint/checkpoint_input_change.py (new): End-to-end usage example.
  • tests/core/test_fingerprint.py (new): Unit tests for fingerprint helpers.
  • tests/core/test_workflow_input_change.py (new): Policy integration tests (reuse / reset / raise / invalid / no-resume).
  • tests/providers/test_storage_default.py, test_storage_file.py, test_storage_s3.py: clear() coverage.

Motivation and Context

Resuming a workflow with a different initial_context silently reused stale checkpoints, making it impossible to detect or handle input drift. Closes #281.

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

@FernandoCelmer FernandoCelmer self-assigned this Apr 27, 2026
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.

placeholder

Comment thread dotflow/core/fingerprint.py
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.

placeholder

Comment thread dotflow/core/fingerprint.py
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: 1

# Severity Comment
1 [Blocking] fingerprint_of: default=str produces unstable fingerprints

@FernandoCelmer FernandoCelmer added the enhancement New feature or request label Apr 27, 2026
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: 4

# Severity Comment
1 [Blocking] Prefix collision in clear() deletes sibling workflow data
2 [Blocking] TOCTOU race in StorageFile.clear()
3 [Blocking] Unstable fingerprints from default=str + dead except branch
4 [Suggestion] clear() should be abstract or have a better error path

Comment thread dotflow/providers/storage_default.py
Comment thread dotflow/providers/storage_file.py
Comment thread dotflow/core/fingerprint.py Outdated
Comment thread dotflow/abc/storage.py
@FernandoCelmer FernandoCelmer added edge-case Edge case handling race-condition Race condition / thread safety labels Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

edge-case Edge case handling enhancement New feature or request race-condition Race condition / thread safety

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants