ACTIVITY-WP-0032-T02 / ACT-ADR-006. ops_runs grows harness_profile_ref (text,
indexed) and execution_refs (jsonb), migration 0008, threaded through the
emission path, queue projection, and run artefacts.
The important part is the enforcement, not the columns. ACT-ADR-006 says
approach_hint must never override, synthesize, or fall back from an absent or
invalid harness_profile_ref — a silent fallback would reintroduce the
claim-time routing failure of 2026-08-17. resolve_execution_selector never
consults the hint: a malformed ref raises even when a hint is present, and
ACTIVITY_CORE_REQUIRE_HARNESS_PROFILE turns an absent ref into an error once
definitions have migrated.
Validation is structural only, since the glas-harness catalogue is
authoritative and must not be mirrored. Requiring the <id>@<version> pin is
worth doing locally: GlasProfiles.resolve matches an unpinned ref against every
version and refuses it as ambiguous, so the pin converts a late failure into an
emission-time error without knowing any profile id.
Migration verified on real PostgreSQL 16: upgrade, downgrade, re-upgrade, and a
legacy-shaped row still inserts and stays claimable.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Cron schedules always passed trigger_key="scheduled", so ops_run
idempotency collapsed every weekday into one key. After the first fire,
create_ops_run was a silent no-op, the claim loop starved, and dual-clock
host timers produced empty FI briefs.
Map scheduled fires to run_id (or scheduled:{iso}) via
emit_triggering_event_id; log duplicate skips; document the contract.
Add phase5_stabilization_check State Hub resolver with progress evidence
sinks, schedule projections for daily and closeout checks, custodian:// and
activity-core:// runtime path resolution, and Railiance mounts under /var/custodian.
When discover_kaizen_projects returns {"projects": [...]} bound to
context.projects, for_each can iterate the list directly. Multi-key
summaries (e.g. repo SBOM bulk) remain unchanged.
Add safe action interpolation and for_each binding for rule fan-out, update the weekly SBOM definition, cover the new evaluation path, and reconcile activity-core scope/workplans for the State Hub sync.
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>