Add instruction report sinks

This commit is contained in:
2026-05-19 18:36:58 +02:00
parent 0dc342eb1b
commit 3110399b11
5 changed files with 390 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ with workflow.unsafe.imports_passed_through():
evaluate_instructions,
load_activity_definition,
log_run,
persist_instruction_reports,
persist_task_instance,
resolve_context,
)
@@ -137,6 +138,7 @@ class RunActivityWorkflow:
"condition": rule.get("condition", ""),
})
report_dicts: list[dict] = []
if defn.get("instructions"):
instruction_result: dict = await workflow.execute_activity(
evaluate_instructions,
@@ -149,14 +151,29 @@ class RunActivityWorkflow:
retry_policy=_RETRY_POLICY,
)
task_spec_dicts.extend(instruction_result.get("task_specs", []))
report_dicts.extend(instruction_result.get("reports", []))
# ── 4. Emit tasks via IssueSink ───────────────────────────────────────
if trigger_key == SCHEDULED_TRIGGER_KEY:
dedup_source = workflow.info().workflow_id
else:
dedup_source = f"{activity_id}:{trigger_key}"
run_id = str(uuid.uuid5(uuid.NAMESPACE_URL, dedup_source))
# ── 4. Persist reports and emit tasks ────────────────────────────────
if report_dicts:
await workflow.execute_activity(
persist_instruction_reports,
{
"reports": report_dicts,
"activity_id": activity_id,
"run_id": run_id,
"scheduled_for": scheduled_for,
"version_used": defn["version"],
},
start_to_close_timeout=_ACTIVITY_TIMEOUT,
retry_policy=_RETRY_POLICY,
)
if task_spec_dicts:
await workflow.execute_activity(
emit_tasks,