activities.py — persist_task_instance (new):
Idempotent INSERT ... ON CONFLICT (id) DO NOTHING on task_instances.
task_id passed in from workflow (derived from workflow_id via uuid5).
Registered on task-execution-tq.
workflows.py — TaskExecutorWorkflow (T19):
Derives stable task_id = uuid5(NAMESPACE_URL, workflow_id).
Calls persist_task_instance → status=done, returns immediately.
Real execution logic to replace stub in a later workstream.
worker.py — T20:
Registers persist_task_instance on task-execution-tq Worker.
Both queues fully wired: orchestrator-tq and task-execution-tq.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Inserts an ActivityRun row via the shared session factory.
Accepts run_payload dict with activity_id, scheduled_for (ISO-8601 or
None), context_snapshot, tasks_spawned, version_used.
Returns run_id as a str UUID.
fired_at is set server-side to now(UTC).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
activities.py:
- init_session_factory(url): module-level async_sessionmaker init,
called once from worker.py before workers start
- load_activity_definition(activity_id): queries activity_definitions
by UUID, returns JSON-serialisable dict; raises ApplicationError
(non_retryable=True) if row not found
worker.py:
- reads ACTCORE_DB_URL at startup, fails fast if missing
- calls init_session_factory() before connecting to Temporal
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
src/activity_core/seed.py: inserts one example ActivityDefinition
('example-heartbeat', cron every minute, static context source,
log_message task template). Idempotent — skips by name on re-run.
Run with:
ACTCORE_DB_URL=postgresql+asyncpg://actcore:actcore@localhost:5433/actcore \
python -m activity_core.seed
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>