Files
activity-core/workplans/custodian-WP-0001-temporal-backbone.md
Bernd Worsch cb7cf3bc8c feat(db): ORM models + Alembic migrations 0001–0003 — T09/T10/T11
SQLAlchemy ORM (src/activity_core/orm.py):
  - ActivityDefinition, ActivityRun, TaskInstance mapped to Base.metadata
  - Wired into migrations/env.py for autogenerate support

Migrations (chained 0001 → 0002 → 0003):
  - 0001: activity_definitions (id, name, enabled, trigger_type,
          trigger_config JSONB, context_sources JSONB, task_templates JSONB,
          dedupe_key_strategy, version, created_at, updated_at)
  - 0002: activity_runs (run_id, activity_id FK→activity_definitions,
          scheduled_for, fired_at, context_snapshot JSONB, tasks_spawned,
          version_used) + index on activity_id
  - 0003: task_instances (id, run_id FK→activity_runs CASCADE,
          type, params JSONB, status, created_at) + index on run_id

Apply with: ACTCORE_DB_URL=... alembic upgrade head

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 21:51:01 +00:00

6.7 KiB

id, type, domain, repo, status, state_hub_workstream_id, tasks
id type domain repo status state_hub_workstream_id tasks
custodian-WP-0001 workplan custodian activity-core active e22516cc-4fdf-4dad-a928-a9e04a9fa7c7
id title status state_hub_task_id
T01 Define event envelope schema done 3dc749eb-7a73-4199-9c8d-e8f31bac5372
id title status state_hub_task_id
T02 Write ActivityDefinition schema (Pydantic + JSON Schema) done 107115b0-4476-424d-84ff-03992a85d40b
id title status state_hub_task_id
T03 Document idempotency contract done aa638595-0bca-41ab-b140-b077d05994e1
id title status state_hub_task_id
T04 Define Temporal namespace and task queue naming conventions done a03c823e-5873-4586-912a-6d1370383c7b
id title status state_hub_task_id
T05 Stand up Temporal via docker-compose done 70e7f742-378f-4129-a0f4-f25ccaccffd0
id title status state_hub_task_id
T06 Add docker-compose.dev.yml to repo done 61cb7426-e0ec-4a52-870d-18a26b3c4f3e
id title status state_hub_task_id
T07 Smoke test Temporal cluster and UI done f28a405d-ddcc-44d8-b443-f26f3ab34eaa
id title status state_hub_task_id
T08 Choose and configure DB migration tool done d9fe3e54-ec1a-4e23-aa76-d8869f4e024d
id title status state_hub_task_id
T09 Write activity_definitions migration done 47774e01-1026-478e-9a46-7d676bfed45c
id title status state_hub_task_id
T10 Write activity_runs migration done 0a74f29f-c07d-4338-be90-e5cf4087261b
id title status state_hub_task_id
T11 Write task_instances migration done 491a6903-8189-43bb-958f-4d16abc84f8e
id title status state_hub_task_id
T12 Seed one example ActivityDefinition todo f24662ff-4a26-48bd-b997-57e7586c7f11
id title status state_hub_task_id
T13 Scaffold Python worker project todo e0205c56-1d40-4142-952b-e27ff6a44e1d
id title status state_hub_task_id
T14 Implement load_activity_definition activity todo b05f046f-a6ba-4d96-a298-a0bbea067427
id title status state_hub_task_id
T15 Implement resolve_context activity (stub) todo 2417912f-845d-489a-ace4-fb9280d3b679
id title status state_hub_task_id
T16 Implement evaluate_templates (pure function) todo b7decbb6-ad2b-4fa5-8efc-05a7eb435d76
id title status state_hub_task_id
T17 Implement log_run activity todo e019cb5a-adf0-4a5d-9410-c41810128190
id title status state_hub_task_id
T18 Implement RunActivityWorkflow todo fb6b3440-47d2-4b0a-97c1-6e780cc497c4
id title status state_hub_task_id
T19 Implement TaskExecutorWorkflow (stub) todo 70a7365f-3042-4770-b3cd-3c6724b0790d
id title status state_hub_task_id
T20 Wire up worker entrypoint todo 1da921f5-86a8-488f-a015-402079194e10
id title status state_hub_task_id
T21 Manual end-to-end test todo f72bba1a-eb24-496e-9498-f4676facc5c9

activity-core Foundation — Temporal Backbone

Workstream: activity-core Foundation — Temporal Backbone Hub ID: e22516cc-4fdf-4dad-a928-a9e04a9fa7c7

Purpose

Build the first working slice of activity-core: contracts, a self-hosted Temporal cluster, PostgreSQL schema, and the RunActivityWorkflow end-to-end. Deliverable: a manually-triggered workflow that loads an ActivityDefinition, resolves context, evaluates task templates, spawns child workflows, and writes a run log — all durable and observable via Temporal Web UI.

Architecture reference

wiki/ActivityCorePlan_chtgpt.md and wiki/ActivityCorePlan_grok.md — both converge on Temporal self-hosted · Python SDK · PostgreSQL.

Concept Implementation
ActivityDefinition Versioned Postgres record: trigger config, context sources, task templates
Activity Orchestrator RunActivityWorkflow — durable Temporal workflow
TaskInstance Child TaskExecutorWorkflow (stub in this workstream)
Idempotency Workflow ID = activity_id + ":" + scheduled_for

Open decisions (resolve before Phase 1)

  • Dev deployment target (hub: 9672adcc-da86-4038-9263-b556789c109e): Docker Compose vs K8s — proto-plans recommend Docker Compose for the initial dev slice.

Phase 0 — Contracts & Conventions

Task Priority Hub task ID
T01: Define event envelope schema high 3dc749eb-7a73-4199-9c8d-e8f31bac5372
T02: Write ActivityDefinition schema (Pydantic + JSON Schema) high 107115b0-4476-424d-84ff-03992a85d40b
T03: Document idempotency contract high aa638595-0bca-41ab-b140-b077d05994e1
T04: Define Temporal namespace + task queue naming conventions high a03c823e-5873-4586-912a-6d1370383c7b

Phase 1 — Temporal Cluster (dev)

Task Priority Hub task ID
T05: Stand up Temporal via docker-compose high 70e7f742-378f-4129-a0f4-f25ccaccffd0
T06: Add docker-compose.dev.yml to repo high 61cb7426-e0ec-4a52-870d-18a26b3c4f3e
T07: Smoke test Temporal cluster and UI high f28a405d-ddcc-44d8-b443-f26f3ab34eaa

Phase 2 — App DB Schema

Task Priority Hub task ID
T08: Choose and configure DB migration tool high d9fe3e54-ec1a-4e23-aa76-d8869f4e024d
T09: Write activity_definitions migration high 47774e01-1026-478e-9a46-7d676bfed45c
T10: Write activity_runs migration high 0a74f29f-c07d-4338-be90-e5cf4087261b
T11: Write task_instances migration high 491a6903-8189-43bb-958f-4d16abc84f8e
T12: Seed one example ActivityDefinition medium f24662ff-4a26-48bd-b997-57e7586c7f11

Phase 3 — RunActivityWorkflow

Task Priority Hub task ID
T13: Scaffold Python worker project medium e0205c56-1d40-4142-952b-e27ff6a44e1d
T14: Implement load_activity_definition activity medium b05f046f-a6ba-4d96-a298-a0bbea067427
T15: Implement resolve_context activity (stub) medium 2417912f-845d-489a-ace4-fb9280d3b679
T16: Implement evaluate_templates (pure function) medium b7decbb6-ad2b-4fa5-8efc-05a7eb435d76
T17: Implement log_run activity medium e019cb5a-adf0-4a5d-9410-c41810128190
T18: Implement RunActivityWorkflow medium fb6b3440-47d2-4b0a-97c1-6e780cc497c4
T19: Implement TaskExecutorWorkflow (stub) medium 70a7365f-3042-4770-b3cd-3c6724b0790d
T20: Wire up worker entrypoint medium 1da921f5-86a8-488f-a015-402079194e10
T21: Manual end-to-end test medium f72bba1a-eb24-496e-9498-f4676facc5c9

Completion criteria

Trigger RunActivityWorkflow manually → workflow completes in Temporal UI → activity_runs row written → task_instances rows written. Zero scheduler or queue infrastructure required.