Skip to content

Self-improving AI Employees for everyone

docs(events): correct Temporal lifecycle, rollback and trigger-wait docs

trohitgb0b32e6342fe
diff --git a/docs-internal/TEMPORAL_ARCHITECTURE.md b/docs-internal/TEMPORAL_ARCHITECTURE.md
index 5fe939d3..6f46b482 100644
--- a/docs-internal/TEMPORAL_ARCHITECTURE.md
+++ b/docs-internal/TEMPORAL_ARCHITECTURE.md
@@ -14,7 +14,7 @@ Each workflow node executes as a **Temporal activity** with its own isolated con
|---|---|---|
| **Legacy single activity** (`execute_node_activity`) | `TEMPORAL_PER_TYPE_DISPATCH=false` | Every node routed through one dispatcher activity. WebSocket round-trip back to the FastAPI server. Stable since Wave 11; kept as the fallback path. |
| **Per-type activity** (`node.{type}.v{version}`) | `TEMPORAL_PER_TYPE_DISPATCH=true` (production default) | Each plugin gets its own `@activity.defn`. Per-plugin retry / timeout / heartbeat configs apply. With `TEMPORAL_WORKER_POOL_ENABLED=true` (default since Wave 16.4) the activity also carries `task_queue=cls.task_queue`, landing it on its specialised `TemporalWorkerPool` worker (browser / code-exec / ai-heavy / ...). Shipped in F4.A (commit `8261b05`); queue routing activated in Wave 16. |
-| **Agent-as-child-workflow** (`AgentWorkflow`) | `TEMPORAL_AGENT_WORKFLOW_ENABLED=true` | AI Agents (aiAgent, chatAgent, 11 specialized agents, 2 team leads) run as Temporal child workflows. Each LLM turn = activity; each tool call = per-type activity. Mirrors Temporal's AI Cookbook canonical pattern. F4.B infrastructure shipped (commit `a4d009e`); per-agent migrations follow. |
+| **Agent-as-child-workflow** (`AgentWorkflow`) | `TEMPORAL_AGENT_WORKFLOW_ENABLED=true` | AI Agents (every type in `AGENT_WORKFLOW_TYPES` in `services/temporal/workflow.py`: aiAgent, chatAgent, the specialized agents and the team leads) run as Temporal child workflows. Each LLM turn = activity; each tool call = per-type activity. Mirrors Temporal's AI Cookbook canonical pattern. F4.B infrastructure shipped (commit `a4d009e`); per-agent migrations follow. |
`rlm_agent`, `claude_code_agent` and `vertex_managed_agent` are intentionally excluded from AgentWorkflow — their externalised loops (RLM REPL / Claude CLI `--resume` / Vertex Interactions API `previous_interaction_id` chaining) require single-process state continuity. The authoritative list is `AGENT_WORKFLOW_TYPES` in `services/temporal/workflow.py`; any agent type outside it runs as an ordinary per-type activity.
@@ -39,7 +39,7 @@ company stop # Stops all services including Temporal
(`bun run start` / `bun run dev` / `bun run stop` are thin wrappers over the same `company` verbs.)
-The embedded Temporal worker runs **inside the Python backend** — registered in the `main.py` lifespan via `TemporalWorkerManager`, not as a separate process.
+The embedded Temporal worker runs **inside the Python backend**, not as a separate process. `main.py` only schedules `run_temporal_lifecycle` (task `temporal-init`); [services/temporal/lifecycle.py](../server/services/temporal/lifecycle.py) `_start_execution_engine` creates the `TemporalWorkerManager` and then the `TemporalWorkerPool`.
**Standalone worker** (for horizontal scaling — add more pollers against the same task queue):
@@ -346,7 +346,7 @@ Env overrides: `TEMPORAL_<QUEUE>_CONCURRENCY` (int) and `TEMPORAL_<QUEUE>_RATE_L
### Agent-as-child-workflow (F4.B)
-When `TEMPORAL_AGENT_WORKFLOW_ENABLED=true` and the node type is in the migrating set (`aiAgent` / `chatAgent` / 11 specialized agents / 2 team leads), the orchestrator schedules `AgentWorkflow` as a child workflow instead of an activity. Inside the workflow:
+When `TEMPORAL_AGENT_WORKFLOW_ENABLED=true` and the node type is in `AGENT_WORKFLOW_TYPES` (`aiAgent`, `chatAgent`, the specialized agents and the team leads; `rlm_agent`, `claude_code_agent` and `vertex_managed_agent` are excluded), the orchestrator schedules `AgentWorkflow` as a child workflow instead of an activity. Inside the workflow:
```
AgentWorkflow.run(context):
@@ -385,7 +385,8 @@ AgentWorkflow.run(context):
child_context = {**tool_payload,
"parent_node_id": <self>,
"invocation": {"task": …, "context": …}}
- id = f"{parent_workflow_id}-delegate-{child_node_id}-{iter}"
+ id = _delegation_child_id(...)
+ # "{agent_workflow_id}-delegate-{tool_node_id}-{iteration+1}-{call_index+1}"
else:
execute_activity(f"node.{tool_node_type}.v{version}")
emit_phase("tool_completed", tool_name=...)
@@ -531,9 +532,10 @@ CONFIG_HANDLES = {
}
# Trigger node types - event listeners, never scheduled as blocking activities
-# Authoritative list: server/constants.py WORKFLOW_TRIGGER_TYPES (frozenset,
-# 17 entries at the time of writing). Omitting a trigger there is a silent
-# failure: find_trigger_nodes filters on this set, so deploy ignores the node.
+# Authoritative list: server/constants.py WORKFLOW_TRIGGER_TYPES (frozenset;
+# the copy below can fall behind it). Omitting a trigger there
+# is a silent failure: find_trigger_nodes filters on this set, so deploy
+# ignores the node.
WORKFLOW_TRIGGER_TYPES = frozenset([
"start", "cronScheduler",
"webhookTrigger", "whatsappReceive",
@@ -545,8 +547,7 @@ WORKFLOW_TRIGGER_TYPES = frozenset([
])
# Android service types (connect directly to agent input-tools) -- authoritative list
-# in server/constants.py ANDROID_SERVICE_NODE_TYPES (16 entries since
-# Wave 11.I).
+# in server/constants.py ANDROID_SERVICE_NODE_TYPES.
```
Config nodes are:
@@ -661,10 +662,10 @@ The Temporal binary + persistence are managed in-process by the plugin-folder pa
**WS surface**: `_handlers.py` registers `temporal_status` / `temporal_start` / `temporal_stop` via `services.ws_handler_registry.register_ws_handlers`. `_refresh.py` registers a WS-connect callback via `services.status_broadcaster.register_service_refresh` so the FE health indicator stays current.
-**Months-long durability contract**: running and paused deployments survive backend restarts, are never auto-terminated, and keep executing for months. Mechanisms, each replay-patch-guarded where it changes recorded commands:
+**Months-long durability contract**: running and paused deployments survive backend restarts, are never auto-terminated, and keep executing for months. None of the mechanisms below carries a `workflow.patched` marker: the lifetime-cap removal and the poll-interval floor apply unconditionally, including when an older history is replayed.
-- **No lifetime caps on new child runs.** Trigger/cron-spawned `MachinaWorkflow` runs, agent children, and delegated-task runners previously carried 1-2h `execution_timeout`/`run_timeout` — Temporal's timeout timers keep ticking through a cooperative pause, so any pause longer than the cap silently terminated the run (and a timed-out delegated runner skipped its compensation: leaked permit + stuck task row). New executions start children unbounded (no patch marker was retained for this change; the live `workflow.patched` markers in the tree are `machina-conditional-edges-v1` and `machina-run-record-v1` in `services/temporal/workflow.py` and `machina-trigger-listener-node-filter` in `services/temporal/trigger_listener_workflow.py` — verify with `grep -rn "workflow.patched(" server/services/temporal`. `machina-run-record-v1` gates the `workflow_runs.record_completion` activity that trigger-spawned runs schedule when they finish, for Normal mode's "done today"; see [normal_mode.md](./normal_mode.md#done-today)). Liveness is the activity layer's job: node activities heartbeat every 30s against a 2-minute `heartbeat_timeout`; their `start_to_close` is a generous 24h ceiling, not 10 minutes. The subagent-permit wait uses `PERMIT_WAIT_RETRY` (unlimited attempts) so a queued delegation waits as long as admission takes instead of failing after ~3h.
-- **History-pressure continue-as-new everywhere.** Temporal terminates any workflow around ~51,200 history events. `WorkflowControlWorkflow` (which multiplexes all of a deployment's triggers into one history) now rolls over on `is_continue_as_new_suggested()` / a 10K-event soft cap, carrying trigger specs, per-trigger provider `seen_ids` (written back into the spec after every poll cycle), queued push events, the bounded dedup baseline, and the control state — a rollover works mid-pause too, since a paused controller still accretes signal history. `TriggerListenerWorkflow`/`PollingTriggerWorkflow` gained the same pressure check (the old `_processed_count >= 16_000` gate was unreachable: real spawns cost ~15-25 events each, and polling counted only emitted events while a quiet mailbox burned ~11 events/cycle — dead in ~3 days at the 60s default). Poll intervals are clamped to a 30s floor on the patched path. Because run ids change on rollover, **controller handles are addressed by workflow id only, never run_id-pinned** (`_controller_handle`, manager `register_trigger`).
+- **No lifetime caps on new child runs.** Trigger/cron-spawned `MachinaWorkflow` runs, agent children, and delegated-task runners previously carried 1-2h `execution_timeout`/`run_timeout` — Temporal's timeout timers keep ticking through a cooperative pause, so any pause longer than the cap silently terminated the run (and a timed-out delegated runner skipped its compensation: leaked permit + stuck task row). New executions start children unbounded (no patch marker was retained for this change). The live `workflow.patched` markers are `machina-conditional-edges-v1` and `machina-run-record-v1` in `services/temporal/workflow.py`, `machina-trigger-listener-node-filter` in `services/temporal/trigger_listener_workflow.py`, and `workspace-task-activity-policy-v1` in `services/temporal/agent_workflow.py`; the list grows, so check it with `grep -rn "workflow.patched(" server/services/temporal`. `machina-run-record-v1` gates the `workflow_runs.record_completion` activity that trigger-spawned runs schedule when they finish, for Normal mode's "done today"; see [normal_mode.md](./normal_mode.md#done-today)). Liveness is the activity layer's job: node activities heartbeat every 30s against a 2-minute `heartbeat_timeout`; their `start_to_close` is a generous 24h ceiling, not 10 minutes. The subagent-permit wait uses `PERMIT_WAIT_RETRY` (unlimited attempts) so a queued delegation waits as long as admission takes instead of failing after ~3h.
+- **History-pressure continue-as-new everywhere.** Temporal terminates any workflow around ~51,200 history events. `WorkflowControlWorkflow` (which multiplexes all of a deployment's triggers into one history) now rolls over on `is_continue_as_new_suggested()` / a 10K-event soft cap, carrying trigger specs, per-trigger provider `seen_ids` (written back into the spec after every poll cycle), queued push events, the bounded dedup baseline, and the control state — a rollover works mid-pause too, since a paused controller still accretes signal history. `TriggerListenerWorkflow`/`PollingTriggerWorkflow` gained the same pressure check (the old `_processed_count >= 16_000` gate was unreachable: real spawns cost ~15-25 events each, and polling counted only emitted events while a quiet mailbox burned ~11 events/cycle — dead in ~3 days at the 60s default). Poll intervals are clamped to a 30s floor (`_MIN_POLL_INTERVAL_S` in `polling_trigger_workflow.py` and `workflow_control_workflow.py`), with no patch gate. Because run ids change on rollover, **controller handles are addressed by workflow id only, never run_id-pinned** (`_controller_handle`, manager `register_trigger`).
- **dispatch.emit controller narrowing.** Controllers advertise their push event types via the `ControlEventTypes` keyword-list Search Attribute (upserted as triggers register); `dispatch.emit` skips controllers with no matching trigger instead of signalling every running controller with every platform event (each unmatched signal was ~4 immutable history events — one busy deployment burned every other controller's rollover budget). Controllers without the attribute (pre-upgrade histories) keep match-all behaviour.
- **Boot-time reconcile** (`reconcile_active_controls_on_boot`, called from the lifecycle module after workers start): runs the lazy `_reconcile_control` over every active control row, converges `starting` rows a crash left behind (controller alive with triggers registered → `running`; alive-but-empty for a graph that declares triggers → `failed` + controller closed; vanished → `failed`), and re-arms the process-local half of running/paused generations from the persisted graph snapshot — DeploymentManager state, in-process collectors for non-canary trigger types, cron pause posture. Idempotent by construction (controller `register_trigger` keyed by listener id, legacy starts use `USE_EXISTING`, cron creation preserves server-owned pause state).
diff --git a/docs-internal/errors.md b/docs-internal/errors.md
index 2446b901..dc814f49 100644
--- a/docs-internal/errors.md
+++ b/docs-internal/errors.md
@@ -256,7 +256,7 @@ Failed to check auth status (attempt 4/6): TypeError: Failed to fetch
**Root cause**: An older version of the FastAPI lifespan blocked on Temporal client connection for up to 30 seconds before yielding to uvicorn. During that window, uvicorn was not accepting HTTP connections, so the frontend retry window could exhaust before the backend started serving.
-**Status**: fixed. Temporal initialization runs in a background `asyncio.create_task()` ([server/main.py:_init_temporal_background](../server/main.py)) so the lifespan yields immediately. WorkflowService falls back to parallel/sequential execution until Temporal connects in the background.
+**Status**: fixed. The `main.py` lifespan schedules `run_temporal_lifecycle` ([server/services/temporal/lifecycle.py](../server/services/temporal/lifecycle.py)) as a background `asyncio.create_task()` named `temporal-init`, so the lifespan yields immediately. Until Temporal connects, WorkflowService falls back to sequential execution (the parallel executor runs only with `REDIS_ENABLED=true`).
---
diff --git a/docs-internal/event_framework.md b/docs-internal/event_framework.md
index eae822ac..c9dfb4c4 100644
--- a/docs-internal/event_framework.md
+++ b/docs-internal/event_framework.md
@@ -35,7 +35,7 @@ phase plan lives in `~/.claude/plans/properly-fix-the-tech-dreamy-tarjan.md`.
| D5 — Auto-gen `DEFAULT_TOOL_NAMES` from `ToolNode` ClassVars | ✅ commits `a01f590` / `07906f0` / `899771c` (78 plugin classes + golden fixture + 3 invariant tests; 75 passed) |
| B11 — FE `plugin_connection_status` envelope handler | ✅ commit `899771c` |
| D4 — Drop legacy `*_status` raw frames (status-only round) | ✅ commit `5ea4e90` (whatsapp/android/telegram status retired; FE consumes typed channel) |
-| Canary flag default flip + invariant lock | ✅ this commit (default `True`; `EVENT_FRAMEWORK_ENABLED=false` is the rollback) |
+| Canary flag default flip + invariant lock | ✅ shipped (default `True`; the `EVENT_FRAMEWORK_ENABLED=false` rollback no longer works, see "Rollback (known gap)" below) |
| Wave 13 — EventType SA mismatch fix + canary-only emit path + trigger status lifecycle + polling OOM + template resolution + cancel sweep | ✅ shipped (see "Wave 13 fixes" below) |
### Dropped / Deferred / Pending
@@ -45,23 +45,15 @@ phase plan lives in `~/.claude/plans/properly-fix-the-tech-dreamy-tarjan.md`.
| D2 — Custom `event_dlq` SQLModel table | ❌ **dropped** (commit `89b15bd`, docs only). Temporal Event History + Visibility queries cover the ops-inspection use case; reinventing them would contradict Wave 12's "Temporal-native, no custom infra" thesis. See § "Failure inspection — no separate DLQ table". |
| D2b — Retire `event_waiter.py` Redis-Streams branch | ✅ shipped as Wave 15.3 (see [TEMPORAL_CLEANUP_AND_RESILIENCE_PLAN.md](./ARCHIVE/TEMPORAL_CLEANUP_AND_RESILIENCE_PLAN.md)). `event_waiter` is memory-mode-only now; Temporal owns durable delivery. The in-memory collector still backs canvas-Run + non-canary (Twitter) triggers. |
| D4 — Drain the last legacy `event_waiter.dispatch` dual-emit | ⏳ pending — only `nodes/twitter/_events.py` remains (twitterReceive is not canary-registered). The whatsapp message/newsletter/history wire keys are now one-way legacy WS frames for FE readers, not dual-emit. |
-| WorkflowEnvironment integration smoke test | ⏳ pending — full 7-canary in-process Temporal cluster. Existing unit tests + per-canary producer tests + `TestCanaryRegistryCoverage` cover the static surface; the integration smoke would catch real-cluster regressions only. |
+| WorkflowEnvironment integration smoke test | ⏳ pending — every canary type against an in-process Temporal cluster. Existing unit tests + per-canary producer tests + `TestCanaryRegistryCoverage` cover the static surface; the integration smoke would catch real-cluster regressions only. |
-**Test surface: 256 passed + 1 xfail** across 18 event-framework test files.
+`Settings.event_framework_enabled` gates the new dispatch path. **Default flipped to `True` on 2026-05-15** — the Temporal-Signal consumer fan-out is now production-default. With the flag off, `services.events.dispatch.emit` is a pass-through no-op (logged at DEBUG as `event-framework disabled — emit no-op`), and `DeploymentManager._canary_listener_enabled_for` sends canary trigger types back to the in-process collector (`trigger_manager.setup_event_trigger`).
-`Settings.event_framework_enabled` gates the new dispatch path. **Default flipped to `True` on 2026-05-15** — the Temporal-Signal consumer fan-out is now production-default. The env var `EVENT_FRAMEWORK_ENABLED=false` is the rollback channel; when set, `services.events.dispatch.emit` reverts to a pass-through no-op and the legacy `event_waiter.dispatch` path keeps working unchanged for non-canary triggers.
+### Rollback (known gap)
-### Rollback procedure
+`EVENT_FRAMEWORK_ENABLED=false` is **not** a working rollback any more. The in-process collector fires only on `event_waiter.dispatch(...)`, and most canary producers no longer call it: their `_events.py` calls `dispatch.emit(...)` alone (chat, webhook and email say so in their module docstrings). With the flag off, those deployed triggers never fire, and the in-process WebSocket broadcast that `emit` also performs stops too. The only remaining `event_waiter.dispatch` callers are `nodes/twitter/_events.py`, `StatusBroadcaster.send_custom_event`, and the plugin `WebhookSource` intake in `services/events/webhook.py`. Restoring a rollback would mean a dual-dispatch in `emit` itself; nothing does that today, so leave the flag on.
-If the canary fan-out causes regressions in production:
-
-1. Set `EVENT_FRAMEWORK_ENABLED=false` in `.env` (or the process environment).
-2. Restart the server (`company start` / `uvicorn` reload). Pydantic Settings re-reads on startup.
-3. Confirm pass-through: `dispatch.emit()` logs `event-framework disabled — emit no-op` at DEBUG.
-
-No DB migrations, no schema changes — the rollback is one env var + restart. The legacy `event_waiter` collector/processor keeps trigger nodes firing because plugin producers still call `event_waiter.dispatch(...)` alongside `dispatch.emit(...)` (the dual-dispatch pattern stays for the in-memory canvas-Run path; the Redis-Streams branch itself was retired in Wave 15.3).
-
-Locked by `tests/test_event_framework_phase_a.py::TestEventFrameworkEnabledDefault::test_event_framework_enabled_defaults_true` (source-introspection check that the `Field(default=True, ...)` declaration is present) and `TestCanaryRegistryCoverage::test_seven_canary_types_registered` (every canary plugin opted in via `register_canary_trigger_type`).
+Locked by `tests/test_event_framework_phase_a.py::TestEventFrameworkEnabledDefault::test_event_framework_enabled_defaults_true` (source-introspection check that the `Field(default=True, ...)` declaration is present) and `TestCanaryRegistryCoverage::test_seven_canary_types_registered`, which asserts that the seven original canary types are registered. It is a floor, not the full list: later plugins register too. For the live set, run `grep -rn "register_canary_trigger_type(" server/nodes`.
## What this framework does
@@ -103,9 +95,9 @@ chatTrigger. The scoping DECISION lives in the core call site
session stays unscoped) and the narrowing in core dispatch — plugin
`_events.py` factories only plumb the field of their own wire shape.
-Worker is embedded in the FastAPI process (`main.py:321-332` schedules
+Worker is embedded in the FastAPI process (the `main.py` lifespan schedules
`run_temporal_lifecycle` from `services/temporal/lifecycle.py` as one
-`asyncio.create_task()`; that module owns the connect loop and the
+`asyncio.create_task()` named `temporal-init`; that module owns the connect loop and the
`TemporalWorkerManager` / `TemporalWorkerPool` start). Activities
and the WebSocket connection pool share memory + event loop, so the fan-out
to FE clients is a direct in-process call — no Redis Streams hop required.
diff --git a/docs-internal/event_waiter_system.md b/docs-internal/event_waiter_system.md
index c83fef15..2c92f0a1 100644
--- a/docs-internal/event_waiter_system.md
+++ b/docs-internal/event_waiter_system.md
@@ -2,7 +2,7 @@
> **Scope note.** This document describes the live in-memory waiter that backs the canvas-Run path. Node authoring happens on the backend: each node is a Python plugin folder under `server/nodes/<category>/<node>/__init__.py` that emits a `NodeSpec`. The frontend reads specs via [client/src/lib/nodeSpec.ts](../client/src/lib/nodeSpec.ts) + [adapters/nodeSpecToDescription.ts](../client/src/adapters/nodeSpecToDescription.ts). See [plugin_system.md](./plugin_system.md) and [server/nodes/README.md](../server/nodes/README.md) for the authoring model.
-Trigger nodes in OpenCompany suspend workflow execution until an external event arrives (WhatsApp message, webhook request, Telegram message, chat input, delegated task completion, etc.). The Event Waiter system is the in-memory (`asyncio.Future`) primitive that backs push-based triggers on the canvas-Run path. In a controlled deployment, trigger definitions, push Signals, polling activities, pause state, and queued events live in `WorkflowControlWorkflow`; only a real graph invocation starts `MachinaWorkflow`. `TriggerListenerWorkflow` / `PollingTriggerWorkflow` are legacy replay/compatibility paths. The Redis-Streams backend that previously offered cross-restart waiter persistence was retired because Temporal owns deployed-trigger durability.
+Trigger nodes in OpenCompany suspend workflow execution until an external event arrives (WhatsApp message, webhook request, Telegram message, chat input, delegated task completion, etc.). The Event Waiter system is the in-memory (`asyncio.Future`) primitive that backs push-based triggers on the canvas-Run path; deployed canary triggers do not use it (see "Deployed Triggers vs Canvas Run"). In a controlled deployment, trigger definitions, push Signals, polling activities, pause state, and queued events live in `WorkflowControlWorkflow`; only a real graph invocation starts `MachinaWorkflow`. `TriggerListenerWorkflow` / `PollingTriggerWorkflow` are legacy replay/compatibility paths. The Redis-Streams backend that previously offered cross-restart waiter persistence was retired because Temporal owns deployed-trigger durability.
Source file: `server/services/event_waiter.py`
@@ -71,7 +71,7 @@ Filter closures capture parameter values at registration time. For example, `bui
## Execution Flow
```
-Deployment starts
+Canvas Run (or a trigger type deployed without a canary registration)
|
v
Trigger node encountered in execution layer
@@ -108,22 +108,27 @@ Single in-memory backend using `asyncio.Future` with a module-level `_waiters` d
Durability note: waiter state does NOT survive a process restart — that is by design. Controlled deployed triggers get restart durability from `WorkflowControlWorkflow`; cron uses Temporal Schedules. The event waiter only backs interactive canvas-Run waits and legacy uncontrolled deployments, where a dead process means the canvas session is gone. (The Redis-Streams backend that previously covered this was retired in Wave 15.3.)
-## Polling Triggers vs Event Triggers
+## Deployed Triggers vs Canvas Run
-Some triggers do not fit the push model because the upstream service has no webhook or long-polling API. These use a different primitive in `TriggerManager`:
+When a workflow is deployed, a trigger type registered with `register_canary_trigger_type` (live list: `grep -rn "register_canary_trigger_type(" server/nodes`) does not use this module. It runs under the Temporal controller, and its producer delivers events with `services.events.dispatch.emit`. The event waiter is involved only for canvas Run and for trigger types that are not canary-registered:
-| Trigger Type | Mechanism | Location |
+| Trigger Type | Deployed | Canvas Run |
|---|---|---|
-| `whatsappReceive` | Event (push) | `event_waiter.py` |
-| `webhookTrigger` | Event (push via FastAPI router) | `event_waiter.py` |
-| `chatTrigger` | Event (push via WebSocket) | `event_waiter.py` |
-| `taskTrigger` | Event (push via delegation) | `event_waiter.py` |
-| `telegramReceive` | Event (push via long-polling) | `event_waiter.py` + `TelegramService` |
-| `twitterReceive` | **Polling** | `deployment/triggers.py` + `asyncio.Queue` |
-| `googleGmailReceive` | **Polling** | `WorkflowControlWorkflow` polling activity (controlled); `PollingTriggerWorkflow` legacy compatibility |
-| `cronScheduler` | Temporal Schedule | `services/temporal/schedules.py` |
+| `whatsappReceive`, `telegramReceive`, `chatTrigger`, `webhookTrigger`, `taskTrigger`, `discordReceive`, `discordInteraction` | Canary push, delivered by `dispatch.emit` | `event_waiter` waiter; see the known gap below |
+| `whatsappBusinessReceive`, `whatsappBusinessStatus` | Canary push, delivered by `dispatch.emit` | `event_waiter` waiter, resolved by the `WebhookSource` intake in `services/events/webhook.py` |
+| `googleGmailReceive`, `emailReceive`, `msMailReceive` | Canary polling: the controller runs the plugin's `poll.{node_type}.v{version}` activity | The node polls from its own `execute`; no waiter |
+| `twitterReceive` | Not canary-registered. It is in `POLLING_TRIGGER_TYPES` but registers no polling factory, so deploy falls back to an in-process `event_waiter` collector | `event_waiter` waiter; see the known gap below |
+| `cronScheduler` | Temporal Schedule (`services/temporal/schedules.py`) | Not a waiter |
-Controlled polling triggers are registered with `WorkflowControlWorkflow`, which invokes the plugin-generated `poll.{node_type}.v{version}` activity and starts a graph only for deduplicated new events. Legacy uncontrolled polling still uses the deployment compatibility layer. See [temporal-execution-engine-rfc.md](ARCHIVE/temporal-execution-engine-rfc.md) for the deployment architecture.
+Controlled polling triggers are registered with `WorkflowControlWorkflow`, which starts a graph only for deduplicated new events. Legacy uncontrolled polling still uses the deployment compatibility layer. See [temporal-execution-engine-rfc.md](ARCHIVE/temporal-execution-engine-rfc.md) for the deployment architecture.
+
+### Known gap: canvas Run on canary push triggers
+
+Pressing Run on the push triggers in the first table row registers a waiter that no producer resolves. Their producers call only `dispatch.emit`, which signals Temporal consumers and broadcasts to WebSocket clients but never calls `event_waiter.dispatch`. `StatusBroadcaster.send_custom_event`, which does dispatch to waiters, has no production caller. The node stays in `waiting` until the user cancels it. Deployed runs of the same triggers are unaffected.
+
+### Known gap: `twitterReceive` never fires
+
+Nothing produces Twitter trigger events. `dispatch_twitter_event_received` in `nodes/twitter/_events.py` has no caller, and `TwitterReceiveNode` is a plain `TriggerNode`, not a `PollingTriggerNode`, so it registers no polling factory. Canvas Run and a deployment both wait on an `event_waiter` future that is never resolved; on deploy, `DeploymentManager._setup_event_trigger` also logs `No polling factory registered for trigger`. The `_events.py` module docstring describes the missing `PollingTriggerNode` refactor.
## Cancellation
@@ -185,7 +190,7 @@ Users can cancel a waiting trigger from the UI (Cancel button on the trigger nod
register_filter_builder('mqttTrigger', build_mqtt_filter)
```
-3. **Dispatch events** from the external service. For a canary (Temporal-routed) trigger, register the CloudEvents type with `register_canary_trigger_type(node_type, cloudevent_type)` and emit through `services.events.dispatch.emit(envelope, wire_routing_key=...)`; the canvas-Run path also accepts the legacy shape:
+3. **Dispatch events** from the external service. For a canary (Temporal-routed) trigger, register the CloudEvents type with `register_canary_trigger_type(node_type, cloudevent_type)` and emit through `services.events.dispatch.emit(envelope, wire_routing_key=...)`. `emit` does not reach this module, so canvas Run resolves only if the producer also calls `event_waiter.dispatch` (see the known gap above):
```python
from services import event_waiter
diff --git a/docs-internal/temporal-workflow-control.md b/docs-internal/temporal-workflow-control.md
index 4619eed8..e74f9421 100644
--- a/docs-internal/temporal-workflow-control.md
+++ b/docs-internal/temporal-workflow-control.md
@@ -165,7 +165,8 @@ the control plane is hardened against Temporal's per-run event-history ceiling
- **No lifetime caps.** Spawned graph runs, agent children, and delegated-task
runners no longer carry 1-2h execution/run timeouts (Temporal's timers keep
ticking through a pause, so the caps silently terminated paused work).
- Replay-patched; see TEMPORAL_ARCHITECTURE.md for the patch inventory.
+ The caps were removed unconditionally, with no `workflow.patched` marker;
+ TEMPORAL_ARCHITECTURE.md lists the markers that do exist.
## Recovery policies
diff --git a/server/main.py b/server/main.py
index 60a7c69d..651df1df 100644
--- a/server/main.py
+++ b/server/main.py
@@ -333,13 +333,14 @@ async def lifespan(app: FastAPI):
set_startup_time()
# Initialize Temporal in the background - do NOT block lifespan startup.
- # This lifespan owns the Temporal dev server (spawned below via
- # TemporalServerRuntime.ensure_started), and on fresh startup it may take
- # several seconds to become reachable. Blocking the lifespan here would
- # delay FastAPI HTTP serving and cascade into frontend
+ # This lifespan owns the Temporal dev server (the task scheduled below
+ # spawns it via TemporalServerRuntime.ensure_started), and on fresh
+ # startup it may take several seconds to become reachable. Blocking the
+ # lifespan here would delay FastAPI HTTP serving and cascade into frontend
# ERR_CONNECTION_REFUSED on /api/auth/status. Instead, yield fast and
# let Temporal init happen in a background task. WorkflowService falls back
- # to parallel/sequential execution until Temporal is ready.
+ # to sequential execution until Temporal is ready (the parallel executor
+ # is used only with REDIS_ENABLED=true).
app.state.temporal_worker_manager = None
app.state.temporal_pool = None
# Coarse readiness phase for /health/ready (the desktop splash reads
diff --git a/server/services/events/dispatch.py b/server/services/events/dispatch.py
index 26c1e145..37ee8f3e 100644
--- a/server/services/events/dispatch.py
+++ b/server/services/events/dispatch.py
@@ -19,9 +19,13 @@ No EventDispatchWorkflow, no Redis Streams, no DLQ table. Temporal's
Visibility + Signal API + Event History provide the durability primitives
this function depends on; everything else is a thin pass-through.
-Behind ``Settings.event_framework_enabled`` (default on since Wave 12;
-``EVENT_FRAMEWORK_ENABLED=false`` is the rollback). When disabled,
-:func:`emit` is a no-op pass-through that returns the envelope unchanged.
+Behind ``Settings.event_framework_enabled`` (default on since Wave 12).
+When disabled, :func:`emit` is a no-op pass-through that returns the
+envelope unchanged. That is no longer a working rollback: most canary
+producers call only :func:`emit` (no ``event_waiter.dispatch``), so with
+the flag off their deployed triggers never fire and the WS broadcast
+below stops too. See docs-internal/event_framework.md, "Rollback (known
+gap)".
"""
from __future__ import annotations
@@ -76,8 +80,9 @@ async def emit(
The envelope unchanged — callers may chain.
Behaviour when ``Settings.event_framework_enabled=False`` (the
- rollback setting; the default is True): pass-through no-op. Logged at
- DEBUG so a rolled-back process is observable.
+ default is True): pass-through no-op. Logged at DEBUG so a process
+ running with the flag off is observable. See the module docstring:
+ the flag no longer works as a rollback.
"""
if not Settings().event_framework_enabled:
logger.debug(