diff --git a/backend/src/core/task_manager/manager.py b/backend/src/core/task_manager/manager.py index fa98daa..b12297f 100644 --- a/backend/src/core/task_manager/manager.py +++ b/backend/src/core/task_manager/manager.py @@ -6,6 +6,17 @@ # @RELATION: Depends on PluginLoader to get plugin instances. It is used by the API layer to create and query tasks. # @INVARIANT: Task IDs are unique. # @CONSTRAINT: Must use belief_scope for logging. +# @TEST_CONTRACT: TaskManagerModule -> { +# required_fields: {plugin_loader: PluginLoader}, +# optional_fields: {}, +# invariants: ["Must use belief_scope for logging"] +# } +# @TEST_FIXTURE: valid_module -> {"manager_initialized": true} +# @TEST_EDGE: missing_required_field -> {"plugin_loader": null} +# @TEST_EDGE: empty_response -> {"tasks": []} +# @TEST_EDGE: invalid_type -> {"plugin_loader": "string_instead_of_object"} +# @TEST_EDGE: external_failure -> {"db_unavailable": true} +# @TEST_INVARIANT: logger_compliance -> verifies: [valid_module] # [SECTION: IMPORTS] import asyncio @@ -28,7 +39,17 @@ from ..logger import logger, belief_scope, should_log_task_level # @INVARIANT: Task IDs are unique within the registry. # @INVARIANT: Each task has exactly one status at any time. # @INVARIANT: Log entries are never deleted after being added to a task. -class TaskManager: +# @TEST_CONTRACT: TaskManager -> { +# required_fields: {plugin_id: str, params: dict}, +# optional_fields: {user_id: str}, +# invariants: ["Task IDs are unique within the registry", "Each task has exactly one status at any time"] +# } +# @TEST_FIXTURE: create_valid_task -> {"plugin_id": "migration_plugin", "params": {"source": "A", "target": "B"}} +# @TEST_EDGE: missing_required_field -> {"plugin_id": null} +# @TEST_EDGE: empty_response -> {"params": {}} +# @TEST_EDGE: invalid_type -> {"params": "string_instead_of_dict"} +# @TEST_EDGE: external_failure -> {"plugin_not_found": true} +# @TEST_INVARIANT: single_status -> verifies: [create_valid_task, external_failure] """ Manages the lifecycle of tasks, including their creation, execution, and state tracking. """