Skip to content

Self-improving AI Employees for everyone

feat(temporal): human-readable workflow IDs via <slug>-<node_label>

trohitgbf02bdcc00f8
diff --git a/CLAUDE.md b/CLAUDE.md
index d428ea1f..fe3fcd33 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -2055,9 +2055,23 @@ The workflow record carries three identity fields with strict separation:
|---|---|---|---|
| `Workflow.id` | opaque 32-hex UUID (`uuid.uuid4().hex`) | yes — never changes on rename | FK target (`Execution.workflow_id`), `EventWorkflowId` Search Attribute in Temporal Visibility, `WorkflowEvent.workflow_id` CloudEvents extension, `log_context(workflow_id=...)`, Redis cache keys, `DeploymentManager._deployments` dict key, frontend `useAppStore.currentWorkflow.id` |
| `Workflow.name` | free-form display ("AI Assistant") | mutable | sidebar, parameter panel, exported JSON |
-| `Workflow.slug` | `<Sanitized_Name>_<N>` (`AI_Assistant_1`) | mutable, recomputed on rename | `~/.machina/workspaces/<slug>/`, Temporal start id (`<slug>_<uuid8>` visible in Temporal Web UI), cron Schedule IDs, export filenames |
+| `Workflow.slug` | `<Sanitized_Name>_<N>` (`AI_Assistant_1`) | mutable, recomputed on rename | `~/.machina/workspaces/<slug>/`, Temporal workflow IDs (visible in Temporal Web UI), cron Schedule IDs, export filenames |
-Single source of truth: [`server/services/workflow_naming.py`](./server/services/workflow_naming.py) — `slugify_name` (via `python-slugify` for Unicode transliteration, emoji strip, case preservation, length cap), `next_available_slug(name, database, *, exclude_id=None)` (fill-gap counter; pass `exclude_id=workflow_id` on rename so the row doesn't bump itself), `new_workflow_id()` (bare hex UUID).
+Single source of truth: [`server/services/workflow_naming.py`](./server/services/workflow_naming.py) — `slugify_name` (via `python-slugify` for Unicode transliteration, emoji strip, case preservation, length cap), `next_available_slug(name, database, *, exclude_id=None)` (fill-gap counter; pass `exclude_id=workflow_id` on rename so the row doesn't bump itself), `new_workflow_id()` (bare hex UUID), `node_label_slug(node)` (sandbox-safe stdlib slug from `node.data.label` or `node.type`, used inside Temporal `@workflow.defn` modules where `python-slugify` can't import safely).
+
+**Temporal workflow ID convention** — uniform `<workflow_slug>-<node_label>` shape across every workflow type. The Temporal Web UI's "Workflow Type" column already distinguishes the kind (TriggerListenerWorkflow / PollingTriggerWorkflow / CronTriggerWorkflow / AgentWorkflow / MachinaWorkflow), so no middle `-trigger-` / `-agent-` tag in the id.
+
+| Surface | Format | Example |
+|---|---|---|
+| Trigger listener (push/poll) | `<slug>-<trigger_label>` | `AI_Assistant_1-chatTrigger` (or `AI_Assistant_1-Customer_Inbox` after F2 rename) |
+| Per-firing run (child of listener) | `<slug>-<trigger_label>-<event_id>` | `AI_Assistant_1-chatTrigger-evt-abc` |
+| Cron Schedule | `<slug>-<trigger_label>` | `AI_Assistant_1-cronScheduler` |
+| Cron firing (per-tick child) | `<slug>-<trigger_label>-<ScheduledStartTime>` | `AI_Assistant_1-cronScheduler-2026-05-27T12:00:00Z` |
+| Agent child workflow | `<slug>-<agent_label>` | `AI_Assistant_1-aiAgent` (or `AI_Assistant_1-Bot` after F2 rename) |
+| Direct MachinaWorkflow exec | `<slug>-<uuid8>` | `AI_Assistant_1-a1b2c3d4` |
+| Per-node activity (inside MachinaWorkflow) | `activity_id = <node_id>` | `chatTrigger-1779...-47c2f5` |
+
+`node_label` is `node.data.label` (the F2-renamed canvas label) when set, falling back to `node.type` (`chatTrigger` / `telegramReceive` / `aiAgent` / etc.). Computed once at deploy time via `node_label_slug(node)` and passed into Temporal workflows as `trigger_label` (in `listener_data` for the trigger path) or read directly from the node dict (in `MachinaWorkflow.run` for the agent path). Stable `TriggerNodeId` / `EventWorkflowId` Search Attributes still use the immutable node_id / UUID so admin queries don't break across rename.
**Rename path** — there is NO dedicated rename endpoint. The frontend's auto-save chain (`TopToolbar` inline edit → `updateWorkflow({name})` → debounced save → REST `POST /api/database/workflows` → `services.workflow_storage.handlers.handle_save_workflow`) IS the rename path. When `name` changes between saves, the handler (1) allocates a fresh slug via `next_available_slug`, (2) `database.rename_workflow` updates name + slug atomically (id UUID stays put), (3) renames the on-disk workspace dir via `Path.rename()`, (4) broadcasts a CloudEvents `workflow.renamed` envelope (`broadcaster.broadcast_workflow_lifecycle("renamed", workflow_id=..., name=..., slug=..., old_slug=...)`) so other tabs invalidate their workflows query.
diff --git a/server/nodes/scheduler/cron_scheduler/_workflow.py b/server/nodes/scheduler/cron_scheduler/_workflow.py
index ef8a6468..3f6c2afe 100644
--- a/server/nodes/scheduler/cron_scheduler/_workflow.py
+++ b/server/nodes/scheduler/cron_scheduler/_workflow.py
@@ -83,6 +83,11 @@ class CronTriggerWorkflow:
edges = listener_data["edges"]
session_id = listener_data.get("session_id", "default")
deployment_workflow_id = listener_data.get("workflow_id")
+ # Wave 14: human-readable id components — slug + trigger label
+ # set at deploy time. Both fall back to their UUID/id counterparts
+ # so older listener_data payloads still produce a valid id.
+ workflow_slug = listener_data.get("workflow_slug") or deployment_workflow_id
+ trigger_label = listener_data.get("trigger_label") or trigger_node_id
tenant_id = listener_data.get("tenant_id")
filtered_nodes, filtered_edges = _build_run_graph(
@@ -97,8 +102,11 @@ class CronTriggerWorkflow:
# WorkflowIDReusePolicy.ALLOW_DUPLICATE_FAILED_ONLY guards
# against a duplicate at the same instant (Temporal retry of
# the schedule action) double-spawning a successful run.
+ # Format: ``<slug>-<trigger_label>-<firing_iso>`` — same
+ # convention as push / poll triggers, with firing time as the
+ # per-tick uniqueness suffix.
firing_iso = trigger_output["timestamp"]
- child_id = f"cron-{deployment_workflow_id}-{trigger_node_id}-{firing_iso}"
+ child_id = f"{workflow_slug}-{trigger_label}-{firing_iso}"
await workflow.start_child_workflow(
"MachinaWorkflow",
@@ -108,6 +116,7 @@ class CronTriggerWorkflow:
"edges": filtered_edges,
"session_id": session_id,
"workflow_id": deployment_workflow_id,
+ "workflow_slug": workflow_slug,
"tenant_id": tenant_id,
}
],
diff --git a/server/services/deployment/manager.py b/server/services/deployment/manager.py
index 6a1958be..4e1c0238 100644
--- a/server/services/deployment/manager.py
+++ b/server/services/deployment/manager.py
@@ -131,6 +131,12 @@ class DeploymentManager:
"deployment_id": self._deployments[workflow_id].deployment_id,
}
+ # Human-readable slug for Temporal Web UI prefixing. Falls back
+ # to workflow_id when the DB row is missing OR slug is empty
+ # (one-off deploys / tests without a saved record).
+ wf = await self.database.get_workflow(workflow_id)
+ workflow_slug = (wf and wf.slug) or workflow_id
+
# Setup
deployment_id = f"deploy_{workflow_id}_{int(time.time() * 1000)}"
self._status_callbacks[workflow_id] = status_callback
@@ -155,6 +161,7 @@ class DeploymentManager:
self._deployments[workflow_id] = DeploymentState(
deployment_id=deployment_id,
workflow_id=workflow_id,
+ workflow_slug=workflow_slug,
is_running=True,
nodes=nodes,
edges=edges,
@@ -579,15 +586,17 @@ class DeploymentManager:
# =========================================================================
@staticmethod
- def _listener_workflow_id(workflow_id: str, node_id: str) -> str:
+ def _listener_workflow_id(workflow_slug: str, trigger_label: str) -> str:
"""Deterministic Temporal workflow_id for a canary listener.
- Mapped to the business entity (deployment workflow_id + trigger
- node_id) so re-deploy of the same workflow produces the same
- listener id. Pairs with ``WorkflowIDConflictPolicy.USE_EXISTING``
- for idempotent start.
+ Format: ``<workflow_slug>-<trigger_label>`` — workflow name leads,
+ trigger node's label is the suffix (``telegramReceive`` /
+ ``chatTrigger`` by default, or the F2-renamed label). The label
+ itself conveys the kind, so no middle ``trigger`` tag. Re-deploy
+ of the same (workflow, trigger label) pair reuses the existing
+ listener via ``WorkflowIDConflictPolicy.USE_EXISTING``.
"""
- return f"trigger-listener-{workflow_id}-{node_id}"
+ return f"{workflow_slug}-{trigger_label}"
@staticmethod
def _trigger_kind_for(node_type: str) -> str:
@@ -732,14 +741,24 @@ class DeploymentManager:
workflow_type_name = _POLLING_LISTENER_WORKFLOW_TYPE if is_polling else _PUSH_LISTENER_WORKFLOW_TYPE
trigger_kind = "polling" if is_polling else self._trigger_kind_for(node_type)
- listener_id = self._listener_workflow_id(workflow_id, node_id)
+ from services.workflow_naming import node_label_slug
+
+ trigger_label = node_label_slug(node)
+ # ``workflow_slug`` is populated by deploy(); falls back to
+ # workflow_id for tests / direct-call paths that bypass deploy.
+ slug = state.workflow_slug or workflow_id
+ listener_id = self._listener_workflow_id(slug, trigger_label)
- # Common payload shape for both workflow types (signal-driven
- # TriggerListenerWorkflow ignores poll-specific fields like
- # ``version`` / ``seen_ids``; polling workflow reads them).
+ # ``trigger_label`` flows into the per-firing run id
+ # (``<slug>-<label>-<event_id>``) inside both child workflows so
+ # the trigger's name surfaces on every firing in the Temporal
+ # Web UI. Polling workflow reads ``version`` / ``seen_ids``;
+ # signal-driven listener ignores them.
listener_args: Dict[str, Any] = {
"workflow_id": workflow_id,
+ "workflow_slug": slug,
"trigger_node_id": node_id,
+ "trigger_label": trigger_label,
"node_type": node_type,
"event_type": event_type,
"filter_params": params,
@@ -869,9 +888,16 @@ class DeploymentManager:
if state is None:
raise RuntimeError(f"No deployment state for workflow {workflow_id}")
+ from services.workflow_naming import node_label_slug
+
+ trigger_label = node_label_slug(node)
+ slug = state.workflow_slug or workflow_id
+
listener_data: Dict[str, Any] = {
"workflow_id": workflow_id,
+ "workflow_slug": slug,
"trigger_node_id": node_id,
+ "trigger_label": trigger_label,
"node_type": node.get("type", "cronScheduler"),
"cron_expression": cron_expr,
"frequency": frequency,
@@ -885,8 +911,10 @@ class DeploymentManager:
schedule_id = await create_cron_schedule(
wrapper.client,
- deployment_workflow_id=workflow_id,
+ workflow_id=workflow_id,
+ workflow_slug=slug,
node_id=node_id,
+ trigger_label=trigger_label,
cron_expression=cron_expr,
timezone=timezone,
listener_data=listener_data,
diff --git a/server/services/deployment/state.py b/server/services/deployment/state.py
index 58a75c0b..fe57c431 100644
--- a/server/services/deployment/state.py
+++ b/server/services/deployment/state.py
@@ -15,6 +15,12 @@ class DeploymentState:
nodes: List[Dict]
edges: List[Dict]
session_id: str
+ # Human-readable slug resolved from DB at deploy time. Used to
+ # prefix Temporal workflow IDs (listener + per-firing run) so
+ # operators browsing the Temporal Web UI can identify runs by
+ # name instead of by UUID. Falls back to ``workflow_id`` when the
+ # DB row is missing (one-off deploys, tests).
+ workflow_slug: str = ""
settings: Dict[str, Any] = field(default_factory=dict)
deployed_at: str = field(default_factory=lambda: datetime.now().isoformat())
@@ -22,6 +28,7 @@ class DeploymentState:
return {
"deployment_id": self.deployment_id,
"workflow_id": self.workflow_id,
+ "workflow_slug": self.workflow_slug,
"is_running": self.is_running,
"session_id": self.session_id,
"settings": self.settings,
diff --git a/server/services/temporal/agent_workflow.py b/server/services/temporal/agent_workflow.py
index 64dc448f..3bcd990d 100644
--- a/server/services/temporal/agent_workflow.py
+++ b/server/services/temporal/agent_workflow.py
@@ -159,6 +159,7 @@ class AgentWorkflow:
payload = await workflow.execute_activity(
"agent.prepare_payload.v1",
args=[context],
+ activity_id="prepare-payload",
start_to_close_timeout=PERSIST_TURN_TIMEOUT * 2, # 60s default
retry_policy=AGENT_ACTIVITY_RETRY,
)
@@ -258,6 +259,7 @@ class AgentWorkflow:
step_result = await workflow.execute_activity(
"agent.execute_llm_step.v1",
args=[llm_payload],
+ activity_id=f"llm-step-{iteration + 1}",
start_to_close_timeout=LLM_STEP_TIMEOUT,
retry_policy=AGENT_ACTIVITY_RETRY,
)
@@ -380,6 +382,7 @@ class AgentWorkflow:
tool_result = await workflow.execute_activity(
tool_activity_name,
args=[tool_payload],
+ activity_id=f"tool-{tool_info['tool_node_id']}-{iteration + 1}",
start_to_close_timeout=TOOL_STEP_TIMEOUT,
heartbeat_timeout=TOOL_HEARTBEAT_TIMEOUT,
)
@@ -435,6 +438,7 @@ class AgentWorkflow:
"model": payload["model"],
}
],
+ activity_id=f"compact-memory-{iteration + 1}",
start_to_close_timeout=COMPACT_MEMORY_TIMEOUT,
retry_policy=AGENT_ACTIVITY_RETRY,
)
@@ -491,6 +495,7 @@ class AgentWorkflow:
"result": result_payload,
}
],
+ activity_id="store-output",
start_to_close_timeout=PERSIST_TURN_TIMEOUT,
retry_policy=AGENT_ACTIVITY_RETRY,
)
diff --git a/server/services/temporal/executor.py b/server/services/temporal/executor.py
index b47b3809..0b829422 100644
--- a/server/services/temporal/executor.py
+++ b/server/services/temporal/executor.py
@@ -66,12 +66,13 @@ class TemporalExecutor:
Dict with success, outputs, execution_trace, and timing info
"""
start_time = time.time()
- # Temporal start ID surfaces in the Web UI — prefix with the
- # human-readable slug so an operator browsing the workflows
- # listing can find runs by name. The uuid8 suffix keeps per-run
- # uniqueness.
+ # Temporal start ID surfaces in the Web UI. Format:
+ # ``<workflow_slug>-<uuid8>`` — workflow name leads, short uuid
+ # disambiguates per-run uniqueness. No middle kind tag — the
+ # Temporal Web UI's "Workflow Type" column already shows
+ # MachinaWorkflow.
slug_prefix = workflow_slug or "workflow"
- execution_id = f"{slug_prefix}_{uuid.uuid4().hex[:8]}"
+ execution_id = f"{slug_prefix}-{uuid.uuid4().hex[:8]}"
logger.info(
"Starting Temporal workflow execution",
diff --git a/server/services/temporal/polling_trigger_workflow.py b/server/services/temporal/polling_trigger_workflow.py
index d03b7414..a000cbac 100644
--- a/server/services/temporal/polling_trigger_workflow.py
+++ b/server/services/temporal/polling_trigger_workflow.py
@@ -146,6 +146,7 @@ class PollingTriggerWorkflow:
result = await workflow.execute_activity(
activity_name,
cycle_payload,
+ activity_id=listener_data["trigger_node_id"],
start_to_close_timeout=timedelta(seconds=activity_timeout_s),
retry_policy=DEFAULT_ACTIVITY_RETRY,
)
@@ -206,6 +207,13 @@ class PollingTriggerWorkflow:
edges = listener_data["edges"]
session_id = listener_data.get("session_id", "default")
workflow_id = listener_data.get("workflow_id")
+ # Human-readable slug prefix for the Temporal Web UI listing.
+ # Set at deploy time from the workflow's display name.
+ workflow_slug = listener_data.get("workflow_slug") or workflow_id
+ # Trigger node's label (``gmailReceive`` / ``twitterReceive`` /
+ # F2-renamed). Pre-computed at deploy time so the workflow
+ # sandbox doesn't have to slugify.
+ trigger_label = listener_data.get("trigger_label") or listener_data.get("trigger_node_id")
tenant_id = listener_data.get("tenant_id")
# Polling activity returns plugin-native payload dicts (Gmail
@@ -226,8 +234,10 @@ class PollingTriggerWorkflow:
# Lazy fallback to workflow.uuid4() only when event.id is missing —
# eager-eval default-arg form would trip _NotInWorkflowEventLoopError
# in unit tests + waste entropy on the hot path.
+ # Format: ``<slug>-<trigger_label>-<event_id>`` — workflow name
+ # + trigger label (which conveys the kind) + per-firing event id.
event_id = event.get("id") or workflow.uuid4().hex
- child_id = f"run-{workflow_id}-{event_id}"
+ child_id = f"{workflow_slug}-{trigger_label}-{event_id}"
await _broadcast_trigger_idle(
node_id=trigger_node_id,
@@ -244,6 +254,7 @@ class PollingTriggerWorkflow:
"edges": filtered_edges,
"session_id": session_id,
"workflow_id": workflow_id,
+ "workflow_slug": workflow_slug,
"tenant_id": tenant_id,
}
],
diff --git a/server/services/temporal/schedules.py b/server/services/temporal/schedules.py
index 0014f1fb..ca048b50 100644
--- a/server/services/temporal/schedules.py
+++ b/server/services/temporal/schedules.py
@@ -43,35 +43,37 @@ from core.logging import get_logger
logger = get_logger(__name__)
-# Schedule ID prefix used by both create + cancel-sweep. Mirrors the
-# ``trigger-listener-{wf}-{node}`` deterministic-id shape that the C1
-# canary uses for its listener workflows — same locality + uniqueness
-# properties.
-def cron_schedule_id(deployment_workflow_id: str, node_id: str) -> str:
- """Deterministic Schedule ID for a (deployment, cron-node) pair.
-
- Mapped to the business entity so re-deploying the same MachinaOs
- workflow targets the same Schedule. Pairs with the create call's
+# Schedule + child-workflow IDs follow the ``<slug>-<trigger_label>``
+# shape — same convention as the push listener id in
+# DeploymentManager._listener_workflow_id. The label conveys the kind
+# (``cronScheduler`` / F2-renamed), so no middle tag.
+def cron_schedule_id(workflow_slug: str, trigger_label: str) -> str:
+ """Deterministic Schedule ID for a (workflow_slug, cron-node label) pair.
+
+ Re-deploying the same MachinaOs workflow (slug + label unchanged)
+ targets the same Schedule. Pairs with the create call's
``"already exists" → no-op`` semantics (per
:exc:`temporalio.client.ScheduleAlreadyRunningError`).
"""
- return f"cron-schedule-{deployment_workflow_id}-{node_id}"
+ return f"{workflow_slug}-{trigger_label}"
-# Child workflow ID prefix Temporal stamps onto each firing. The
+# Child workflow ID Temporal stamps onto each firing. The
# ``{{.ScheduledStartTime}}`` placeholder is substituted by Temporal
# server-side, so each tick produces a unique workflow_id without us
# needing per-tick code (per
# https://docs.temporal.io/develop/python/schedules#use-a-pre-generated-workflow-id).
-def cron_action_workflow_id(deployment_workflow_id: str, node_id: str) -> str:
- return f"cron-fire-{deployment_workflow_id}-{node_id}-{{{{.ScheduledStartTime}}}}"
+def cron_action_workflow_id(workflow_slug: str, trigger_label: str) -> str:
+ return f"{workflow_slug}-{trigger_label}-{{{{.ScheduledStartTime}}}}"
async def create_cron_schedule(
client: Client,
*,
- deployment_workflow_id: str,
+ workflow_id: str,
+ workflow_slug: str,
node_id: str,
+ trigger_label: str,
cron_expression: str,
timezone: str,
listener_data: Dict[str, Any],
@@ -81,14 +83,22 @@ async def create_cron_schedule(
"""Create-or-reuse a Temporal Schedule for a cron trigger.
Returns the Schedule's id. Idempotent: a re-deploy with the same
- ``(deployment_workflow_id, node_id)`` pair reuses the existing
- Schedule (Temporal raises
- :exc:`ScheduleAlreadyRunningError` which we swallow as a no-op).
+ ``(workflow_slug, node_id)`` pair reuses the existing Schedule
+ (Temporal raises :exc:`ScheduleAlreadyRunningError` which we swallow
+ as a no-op).
Args:
client: Connected Temporal client.
- deployment_workflow_id: MachinaOs deployment workflow_id.
- node_id: Cron-trigger node id.
+ workflow_id: Stable UUID for ``EventWorkflowId`` Search Attribute
+ (used by the cancel sweep + Visibility queries — must
+ survive workflow rename).
+ workflow_slug: Human-readable slug for the Schedule + child
+ workflow IDs visible in Temporal Web UI.
+ node_id: Canvas node id for the ``TriggerNodeId`` Search
+ Attribute (used by admin queries — stable, not label).
+ trigger_label: Cron-trigger node's label (``cronScheduler`` by
+ default, or F2-renamed). Forms the suffix of the Schedule
+ id and child workflow ids.
cron_expression: Crontab string (5 or 6 field).
timezone: IANA tz name (e.g. ``"America/New_York"``).
listener_data: Frozen action args for the workflow run
@@ -98,8 +108,8 @@ async def create_cron_schedule(
drops a firing if the prior run is still going; mirrors the
pre-Wave-12 APScheduler behaviour for slow workflows.
"""
- schedule_id = cron_schedule_id(deployment_workflow_id, node_id)
- action_workflow_id = cron_action_workflow_id(deployment_workflow_id, node_id)
+ schedule_id = cron_schedule_id(workflow_slug, trigger_label)
+ action_workflow_id = cron_action_workflow_id(workflow_slug, trigger_label)
schedule = Schedule(
action=ScheduleActionStartWorkflow(
@@ -126,7 +136,7 @@ async def create_cron_schedule(
[
SearchAttributePair(
SearchAttributeKey.for_keyword("EventWorkflowId"),
- deployment_workflow_id,
+ workflow_id,
),
SearchAttributePair(
SearchAttributeKey.for_keyword("TriggerNodeId"),
diff --git a/server/services/temporal/trigger_listener_workflow.py b/server/services/temporal/trigger_listener_workflow.py
index 5ea95653..55a8393c 100644
--- a/server/services/temporal/trigger_listener_workflow.py
+++ b/server/services/temporal/trigger_listener_workflow.py
@@ -153,6 +153,14 @@ class TriggerListenerWorkflow:
edges = listener_data["edges"]
session_id = listener_data.get("session_id", "default")
workflow_id = listener_data.get("workflow_id")
+ # Human-readable slug prefix for the Temporal Web UI listing.
+ # Set at deploy time from the workflow's display name; falls back
+ # to workflow_id for one-off deploys without a saved DB row.
+ workflow_slug = listener_data.get("workflow_slug") or workflow_id
+ # Trigger node's label (``telegramReceive`` / ``chatTrigger`` /
+ # F2-renamed). Pre-computed at deploy time so the workflow
+ # sandbox doesn't have to slugify.
+ trigger_label = listener_data.get("trigger_label") or trigger_node_id
tenant_id = listener_data.get("tenant_id")
# event.data is the producer-supplied payload (webhook body /
@@ -175,8 +183,10 @@ class TriggerListenerWorkflow:
# listener restart), Temporal rejects the duplicate start.
# Lazy fallback to workflow.uuid4() only if event.id is missing
# (shouldn't happen — on_event drops malformed payloads).
+ # Format: ``<slug>-<trigger_label>-<event_id>`` — workflow name
+ # + trigger label (which conveys the kind) + per-firing event id.
event_id = event.get("id") or workflow.uuid4().hex
- child_id = f"run-{workflow_id}-{event_id}"
+ child_id = f"{workflow_slug}-{trigger_label}-{event_id}"
await _broadcast_trigger_idle(
node_id=trigger_node_id,
@@ -193,6 +203,7 @@ class TriggerListenerWorkflow:
"edges": filtered_edges,
"session_id": session_id,
"workflow_id": workflow_id,
+ "workflow_slug": workflow_slug,
"tenant_id": tenant_id,
}
],
diff --git a/server/services/temporal/workflow.py b/server/services/temporal/workflow.py
index 8f05c67e..0753ccf5 100644
--- a/server/services/temporal/workflow.py
+++ b/server/services/temporal/workflow.py
@@ -17,6 +17,7 @@ from typing import Any, Dict, List, Optional, Set
from temporalio import workflow
from ._retry_policies import DEFAULT_ACTIVITY_RETRY
+from services.workflow_naming import node_label_slug
# Config handles - nodes connecting via these are config nodes (not executed)
# AI Agent handles: input-memory, input-tools, input-model, input-task, input-teammates
@@ -191,6 +192,10 @@ class MachinaWorkflow:
edges = workflow_data.get("edges", [])
session_id = workflow_data.get("session_id", "default")
workflow_id = workflow_data.get("workflow_id")
+ # Human-readable slug for child workflow IDs visible in the
+ # Temporal Web UI. Falls back to workflow_id when missing
+ # (one-off Runs without a saved DB row).
+ workflow_slug = workflow_data.get("workflow_slug") or workflow_id
tenant_id = workflow_data.get("tenant_id")
workflow.logger.info(f"Starting workflow orchestration: {len(nodes)} nodes, {len(edges)} edges")
@@ -300,6 +305,7 @@ class MachinaWorkflow:
"node_data": node.get("data", {}),
"inputs": self._get_node_inputs(node_id, deps, outputs),
"workflow_id": workflow_id,
+ "workflow_slug": workflow_slug,
"tenant_id": tenant_id,
"session_id": session_id,
"nodes": nodes, # Full list for tool/memory detection
@@ -321,9 +327,15 @@ class MachinaWorkflow:
# blocking on child completion). The handle is a
# Task-like with ``.done()`` so it slots into the same
# FIRST_COMPLETED loop as activity handles.
+ # Child id format: ``<slug>-<node_label>`` — same
+ # ``<workflow_slug>-<node_label>`` convention as the
+ # trigger ids. ``node_label`` is the user-renamed
+ # F2 label or the node type (``aiAgent`` / ``orchestrator_agent``
+ # / ...) — already conveys "agent" so no middle tag.
handle = await workflow.start_child_workflow(
dispatch["name"],
args=[context],
+ id=f"{workflow_slug}-{node_label_slug(node)}",
# Child workflow execution timeout: agent loops can run
# 10+ minutes with multiple LLM turns. Set generously.
execution_timeout=timedelta(hours=1),
@@ -334,9 +346,12 @@ class MachinaWorkflow:
else:
# F4.A activity path: per-type when the plugin class is
# registered AND the per-type flag is on; legacy
- # execute_node_activity otherwise.
+ # execute_node_activity otherwise. ``activity_id`` =
+ # node_id so the Temporal Web UI history tab labels
+ # each activity by the canvas node it ran.
start_kwargs: Dict[str, Any] = dict(
args=[context],
+ activity_id=node_id,
start_to_close_timeout=timedelta(minutes=10),
heartbeat_timeout=timedelta(minutes=2),
retry_policy=retry_policy,
diff --git a/server/services/workflow_naming.py b/server/services/workflow_naming.py
index 5c9994cf..d330224a 100644
--- a/server/services/workflow_naming.py
+++ b/server/services/workflow_naming.py
@@ -27,10 +27,9 @@ Temporal-safe up to 1000 chars).
from __future__ import annotations
+import re
import uuid
-from typing import Set
-
-from slugify import slugify
+from typing import Any, Dict, Set
from core.logging import get_logger
@@ -41,6 +40,17 @@ _SLUG_SEPARATOR = "_"
_SLUG_MAX_LEN = 50
_FALLBACK_SLUG = "Workflow"
+# Stdlib-only fallback regex for ``node_label_slug``. Plain ``re`` is on
+# Temporal's default sandbox allow-list, so Temporal workflows
+# (``MachinaWorkflow``, ``TriggerListenerWorkflow``,
+# ``PollingTriggerWorkflow``) can call ``node_label_slug`` directly to
+# build human-readable child workflow IDs from the user's F2-renamed
+# node labels. ``slugify_name`` (which uses ``python-slugify`` for full
+# Unicode transliteration) is deferred-imported so the workflow-side
+# import doesn't drag the heavier dep into the sandbox.
+_NODE_LABEL_PATTERN = re.compile(r"[^A-Za-z0-9]+")
+_FALLBACK_NODE_LABEL = "Node"
+
def slugify_name(name: str) -> str:
"""Sanitize a display name into a filesystem-safe slug base.
@@ -57,6 +67,11 @@ def slugify_name(name: str) -> str:
Always returns a non-empty ASCII string suitable as a slug BASE.
Callers append ``_<N>`` to dedupe via :func:`next_available_slug`.
"""
+ # Deferred import — ``python-slugify`` is heavy and Temporal
+ # workflows that only need :func:`node_label_slug` shouldn't pay
+ # the cost (or risk the sandbox tripping on transitive imports).
+ from slugify import slugify
+
slug = slugify(
name or "",
separator=_SLUG_SEPARATOR,
@@ -67,6 +82,19 @@ def slugify_name(name: str) -> str:
return slug or _FALLBACK_SLUG
+def node_label_slug(node: Dict[str, Any]) -> str:
+ """Sandbox-safe slug for a node's user-assigned label.
+
+ Returns the canvas label (set via F2 rename) sanitized to ASCII
+ alphanumerics + underscores, suitable for Temporal workflow IDs.
+ Falls back to the node type, then to ``"Node"`` for ill-formed
+ inputs. Stdlib-only — safe to call inside ``@workflow.defn``
+ sandboxes (no ``python-slugify`` / ``text-unidecode`` imports).
+ """
+ label = (node.get("data") or {}).get("label") or node.get("type") or _FALLBACK_NODE_LABEL
+ return _NODE_LABEL_PATTERN.sub(_SLUG_SEPARATOR, label).strip(_SLUG_SEPARATOR) or _FALLBACK_NODE_LABEL
+
+
async def next_available_slug(
name: str,
database,
@@ -122,6 +150,7 @@ def new_workflow_id() -> str:
__all__ = [
"slugify_name",
+ "node_label_slug",
"next_available_slug",
"new_workflow_id",
]
diff --git a/server/tests/test_cron_canary.py b/server/tests/test_cron_canary.py
index f80d556c..c8b84b14 100644
--- a/server/tests/test_cron_canary.py
+++ b/server/tests/test_cron_canary.py
@@ -110,9 +110,10 @@ class TestScheduleIdDerivation:
def test_deterministic_id(self):
from services.temporal.schedules import cron_schedule_id
+ # Wave 14: id = ``<workflow_slug>-<trigger_label>``.
a = cron_schedule_id("wf-1", "cron-1")
b = cron_schedule_id("wf-1", "cron-1")
- assert a == b == "cron-schedule-wf-1-cron-1"
+ assert a == b == "wf-1-cron-1"
def test_different_node_different_id(self):
from services.temporal.schedules import cron_schedule_id
@@ -138,16 +139,20 @@ class TestCreateCronSchedule:
"cron_expression": "*/5 * * * *",
}
+ # Wave 14: signature now takes workflow_id (Search Attribute) +
+ # workflow_slug (id prefix) + trigger_label (id suffix).
schedule_id = await create_cron_schedule(
client,
- deployment_workflow_id="wf-1",
+ workflow_id="wf-1",
+ workflow_slug="wf-1",
node_id="cron-1",
+ trigger_label="cron-1",
cron_expression="*/5 * * * *",
timezone="America/New_York",
listener_data=listener_data,
)
- assert schedule_id == "cron-schedule-wf-1-cron-1"
+ assert schedule_id == "wf-1-cron-1"
assert client.create_schedule.await_count == 1
passed_id, passed_schedule = client.create_schedule.call_args.args
@@ -169,14 +174,16 @@ class TestCreateCronSchedule:
schedule_id = await create_cron_schedule(
client,
- deployment_workflow_id="wf-1",
+ workflow_id="wf-1",
+ workflow_slug="wf-1",
node_id="cron-1",
+ trigger_label="cron-1",
cron_expression="0 * * * *",
timezone="UTC",
listener_data={},
)
- assert schedule_id == "cron-schedule-wf-1-cron-1"
+ assert schedule_id == "wf-1-cron-1"
class _FakeScheduleIterator:
@@ -362,17 +369,19 @@ class TestDeploymentCronCanaryRouting:
recorded: List[Dict[str, Any]] = []
- async def fake_create(client, *, deployment_workflow_id, node_id, cron_expression, timezone, listener_data, **kw):
+ async def fake_create(client, *, workflow_id, workflow_slug, node_id, trigger_label, cron_expression, timezone, listener_data, **kw):
recorded.append(
{
- "deployment_workflow_id": deployment_workflow_id,
+ "workflow_id": workflow_id,
+ "workflow_slug": workflow_slug,
"node_id": node_id,
+ "trigger_label": trigger_label,
"cron_expression": cron_expression,
"timezone": timezone,
"listener_data": listener_data,
}
)
- return f"cron-schedule-{deployment_workflow_id}-{node_id}"
+ return f"{workflow_slug}-{trigger_label}"
from services.temporal import schedules
@@ -395,7 +404,11 @@ class TestDeploymentCronCanaryRouting:
schedule_desc="Every 5 minutes",
)
- assert result == "cron-schedule-wf-1-cron-1"
+ # Wave 14: id = ``<workflow_slug>-<trigger_label>``.
+ # Slug + label both fall back to workflow_id / node.type when
+ # the test doesn't pre-populate DeploymentState.workflow_slug
+ # or set a custom node label.
+ assert result == "wf-1-cronScheduler"
assert len(recorded) == 1
call = recorded[0]
assert call["cron_expression"] == "*/5 * * * *"
diff --git a/server/tests/test_deployment_canary_listener.py b/server/tests/test_deployment_canary_listener.py
index e0c73243..97c35fdc 100644
--- a/server/tests/test_deployment_canary_listener.py
+++ b/server/tests/test_deployment_canary_listener.py
@@ -114,7 +114,7 @@ class TestDeterministicListenerId:
first = DeploymentManager._listener_workflow_id("wf-1", "wh-1")
second = DeploymentManager._listener_workflow_id("wf-1", "wh-1")
- assert first == second == "trigger-listener-wf-1-wh-1"
+ assert first == second == "wf-1-wh-1"
def test_id_differs_per_node_in_same_workflow(self):
from services.deployment.manager import DeploymentManager
@@ -255,11 +255,14 @@ class TestStartCanaryListener:
node = _node("wh-1", "webhookTrigger")
listener_id = await mgr._start_canary_listener(node, "wf-abc", params={"path": "hook"})
- assert listener_id == "trigger-listener-wf-abc-wh-1"
+ # Wave 14: listener id = ``<workflow_slug>-<trigger_label>``.
+ # Slug falls back to workflow_id ("wf-abc") when no DB row;
+ # label falls back to node.type ("webhookTrigger") when no F2 rename.
+ assert listener_id == "wf-abc-webhookTrigger"
assert len(recorded_start) == 1
call = recorded_start[0]
assert call["name"] == "TriggerListenerWorkflow"
- assert call["id"] == "trigger-listener-wf-abc-wh-1"
+ assert call["id"] == "wf-abc-webhookTrigger"
assert call["id_conflict_policy"] == WorkflowIDConflictPolicy.USE_EXISTING
assert call["task_queue"] == "machina-tasks"
@@ -338,7 +341,7 @@ class TestStartCanaryListener:
monkeypatch.setattr(container_mod.container, "temporal_client", lambda: wrapper)
listener_id = await mgr._start_canary_listener(_node("ct-1", "chatTrigger"), "wf-chat", params={"session_id": "default"})
- assert listener_id == "trigger-listener-wf-chat-ct-1"
+ assert listener_id == "wf-chat-chatTrigger"
sa = recorded[0]["search_attributes"]
attrs_by_name = {pair.key.name: pair.value for pair in sa}
@@ -381,7 +384,7 @@ class TestCancelCanaryListeners:
async def fake_list_workflows(query):
recorded_queries.append(query)
- for wf_id in ["trigger-listener-wf-1-wh-1", "trigger-listener-wf-1-wh-2"]:
+ for wf_id in ["wf-1-trigger-wh-1", "wf-1-trigger-wh-2"]:
yield MagicMock(id=wf_id)
handles_by_id: Dict[str, MagicMock] = {}
@@ -424,8 +427,8 @@ class TestCancelCanaryListeners:
assert cancelled == 2
assert sorted(cancelled_ids) == [
- "trigger-listener-wf-1-wh-1",
- "trigger-listener-wf-1-wh-2",
+ "wf-1-trigger-wh-1",
+ "wf-1-trigger-wh-2",
]
@pytest.mark.asyncio
@@ -460,12 +463,12 @@ class TestCancelCanaryListeners:
cancelled_ids: List[str] = []
async def list_two(query):
- for wf_id in ["trigger-listener-wf-1-wh-1", "trigger-listener-wf-1-wh-2"]:
+ for wf_id in ["wf-1-trigger-wh-1", "wf-1-trigger-wh-2"]:
yield MagicMock(id=wf_id)
def get_handle(wf_id):
handle = MagicMock()
- if wf_id == "trigger-listener-wf-1-wh-1":
+ if wf_id == "wf-1-trigger-wh-1":
async def boom():
raise RuntimeError("simulated handle.cancel failure")
@@ -492,7 +495,7 @@ class TestCancelCanaryListeners:
cancelled = await mgr._cancel_canary_listeners("wf-1")
# Only the second one succeeded.
assert cancelled == 1
- assert cancelled_ids == ["trigger-listener-wf-1-wh-2"]
+ assert cancelled_ids == ["wf-1-trigger-wh-2"]
@pytest.mark.asyncio
async def test_returns_zero_when_temporal_disconnected(self, monkeypatch):
@@ -689,4 +692,4 @@ class TestNoInstanceStateForCanaryListeners:
from services.deployment.manager import DeploymentManager
# Both helpers can be called on the class without an instance.
- assert DeploymentManager._listener_workflow_id("wf", "node") == "trigger-listener-wf-node"
+ assert DeploymentManager._listener_workflow_id("wf", "node") == "wf-node"
diff --git a/server/tests/test_polling_trigger_workflow.py b/server/tests/test_polling_trigger_workflow.py
index 21cda51d..142fc69f 100644
--- a/server/tests/test_polling_trigger_workflow.py
+++ b/server/tests/test_polling_trigger_workflow.py
@@ -430,8 +430,11 @@ class TestPollingTriggerWorkflowBody:
# Spawn called for 'c' (cycle 2), 'd' (cycle 3). The duplicate
# 'c' in cycle 3 is deduped via _seen_event_ids.
+ # Wave 14: child id = ``<workflow_slug>-<trigger_label>-<event_id>``.
+ # Both slug + label fall back to workflow_id / trigger_node_id
+ # when listener_data omits them (this test does).
spawn_ids = [c["id"] for c in spawn_calls]
- assert spawn_ids == ["run-wf-1-c", "run-wf-1-d"]
+ assert spawn_ids == ["wf-1-gm-1-c", "wf-1-gm-1-d"]
@pytest.mark.asyncio
async def test_cycle_failure_does_not_break_loop(self, monkeypatch):
diff --git a/server/tests/test_trigger_listener_workflow.py b/server/tests/test_trigger_listener_workflow.py
index 3e45a1ca..b00a4ce6 100644
--- a/server/tests/test_trigger_listener_workflow.py
+++ b/server/tests/test_trigger_listener_workflow.py
@@ -17,8 +17,10 @@ C1c — ``_build_run_graph`` produces the correct filtered (nodes, edges)
payload; sibling triggers carry ``_pre_executed=True`` +
``{not_triggered: True}``; downstream nodes are reachable;
cross-graph nodes are excluded.
-C1d — Spawned child workflows use a stable ``run-<workflow_id>-<event.id>``
- ID so server-side dedup catches producer retries.
+C1d — Spawned child workflows use a stable
+ ``<workflow_slug>-<trigger_label>-<event.id>`` ID (Wave 14) so the
+ Temporal Web UI surfaces the workflow + firing trigger by name
+ while server-side dedup catches producer retries.
"""
from __future__ import annotations
@@ -316,7 +318,10 @@ class TestSpawnChildRun:
assert len(recorded) == 1
call = recorded[0]
assert call["name"] == "MachinaWorkflow"
- assert call["id"] == "run-wf-abc-evt-42"
+ # Wave 14: ``<workflow_slug>-<trigger_label>-<event_id>``.
+ # workflow_slug falls back to workflow_id when listener_data
+ # doesn't carry it; trigger_label falls back to trigger_node_id.
+ assert call["id"] == "wf-abc-wh-1-evt-42"
# Trigger output carries both the user data AND the envelope for
# downstream introspection.
child_args = call["args"][0]