Execution Engines & Jobs
ContextWorker uses pluggable execution engines and a job orchestration layer to run background tasks.
Execution Engines
Worker supports multiple execution backends via the engines/ package:
TemporalEngine
Production-grade durable workflows using Temporal.io:
from contextunity.worker.engines.temporal_engine import TemporalEngine
engine = TemporalEngine(config)await engine.start()Temporal workflows survive process restarts, network failures, and server crashes with automatic state persistence and retry.
HueyEngine
Lightweight task queue using Huey for simpler deployments:
from contextunity.worker.engines.huey_engine import HueyEngine
engine = HueyEngine(config)await engine.start()Both engines implement the BaseEngine protocol from engines/base.py. The engine is selected via configuration.
Built-in Jobs
Worker includes several built-in job types in jobs/:
| Module | Purpose |
|---|---|
orchestrator.py | Job orchestration and coordination |
retention.py | Data retention policies and cleanup |
scrum_master.py | Automated task management and scheduling |
Module Registry
Domain-specific plugins register their workflows and activities via the WorkerRegistry:
from contextunity.worker.core.registry import WorkerRegistry, ModuleConfig
registry = WorkerRegistry()registry.register(ModuleConfig( name="harvest", workflows=[HarvestWorkflow], activities=[fetch_products, transform_data],))Modules are discovered at startup and can be filtered via --modules flag.