Skip to content

Release 0.9.0

Choose a tag to compare

@tercel tercel released this 28 Dec 02:52
· 24 commits to main since this release

Added

  • Hook Execution Context for Database Access

  • New get_hook_repository() function allows hooks to access database within task execution context

  • New get_hook_session() function provides direct access to database session in hooks

  • Hooks now share the same database session/transaction as TaskManager (no need for separate sessions)

  • Auto-persistence for task.inputs modifications in pre-hooks (detected and saved automatically)

  • Explicit repository methods available for other field modifications (name, priority, status, etc.)

  • Thread-safe context isolation using Python's ContextVar (similar to Flask/Celery patterns)

  • Added set_hook_context() and clear_hook_context() internal functions for context management

  • Exported to public API: aipartnerupflow.get_hook_repository and aipartnerupflow.get_hook_session

  • Added comprehensive test coverage (16 tests):

  • Hook context basic operations and lifecycle

  • Multiple hooks sharing same session instance

  • Hooks sharing transaction context and seeing uncommitted changes

  • Hooks cooperating via shared session

  • Auto-persistence of task.inputs modifications

  • Explicit field updates via repository methods

  • Database Session Safety Enhancements

  • Added flag_modified() calls for all JSON fields (result, inputs, dependencies, params, schemas) to ensure SQLAlchemy detects in-place modifications

  • Added db.refresh() after critical status updates to ensure fresh data from database

  • Added concurrent execution protection: same task_tree cannot run multiple times simultaneously

  • Returns {"status": "already_running"} when attempting concurrent execution of same task tree

  • Added 12 new tests for concurrent protection and JSON field persistence

  • CLI Extension Decorator (cli_register)

  • New @cli_register() decorator for registering CLI extensions, similar to @executor_register()

  • Decorator supports name, help, and override parameters

  • Auto-derives command name from class name (converts _ to -)

  • New get_cli_registry() function to access registered CLI extensions

  • CLI extensions are loaded from decorator registry before entry_points discovery

  • Added comprehensive test coverage (18 tests) for CLI extension decorators

  • Exception Handling Architecture

  • New exception hierarchy based on FastAPI/production framework best practices

  • ApflowError base exception for all framework-specific errors

  • BusinessError for expected user/configuration errors (logged without stack traces)

  • ValidationError for input validation failures

  • ConfigurationError for missing configuration/dependencies

  • SystemError for unexpected system-level errors (logged with stack traces)

  • ExecutorError for executor runtime failures

  • StorageError for database/storage failures

  • Created core/execution/errors.py with comprehensive exception documentation

  • Created docs/development/exception-handling-standards.md with implementation guidelines

Changed

  • Executor Error Handling Refactoring

  • All executors now raise exceptions instead of returning error dictionaries

  • Technical exceptions (TimeoutError, ConnectionError, etc.) now propagate naturally to TaskManager

  • Executors validate inputs and raise ValidationError or ConfigurationError for expected failures

  • Updated executors: DockerExecutor, GrpcExecutor, RestExecutor, SshExecutor, CommandExecutor, LLMExecutor

  • TaskManager now catches all exceptions, marks tasks as failed, and logs appropriately based on exception type

  • BusinessError logged without stack trace (clean logs), other exceptions logged with full stack trace

  • CrewAI Executor/Batch Executor Renaming and Test Fixes

  • crewai/crew_manager.pycrewai/crewai_executor.py, with the class name updated to CrewaiExecutor

  • crewai/batch_manager.pycrewai/batch_crewai_executor.py, with the class name updated to BatchCrewaiExecutor

  • All related test cases (test_crewai_executor.py, test_batch_crewai_executor.py, etc.) have been batch-updated with corrected patch paths, mocks, imports, and class names to align with the new naming

  • Resolved AttributeError: module 'aipartnerupflow.extensions.crewai' has no attribute 'crew_manager' and similar test failures caused by the renaming