Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/architecture/data-format.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
sidebar_label: "📦 Data Format"
sidebar_position: 3
sidebar_position: 4
---

# Data Format
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/node-model.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
sidebar_label: "🧩 Node Model & Registration"
sidebar_position: 2
sidebar_position: 3
---

# Node Model & Feature Registration
Expand Down
143 changes: 143 additions & 0 deletions docs/architecture/orchestration-service.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
---
sidebar_label: "🧠 Orchestration Service"
sidebar_position: 2
---

# Orchestration Service

<Lead>

`continuum-orchestration-service` is the interpreter at the heart of the platform. It takes the graph you drew on the canvas — plain JSON nodes and edges — and executes it as a real, durable Temporal workflow: deciding what runs when, routing each node to the right worker, wiring outputs to inputs, and reporting every state change back to the browser.

</Lead>

<Badges>
<Badge color="pink">Temporal workflow worker</Badge>
<Badge color="purple">DAG interpreter</Badge>
<Badge color="amber">Kafka status publisher</Badge>
</Badges>

It is a standalone Spring Boot service (image `projectcontinuum/continuum-orchestration-service`) that registers two things with Temporal:

| Component | Task queue | Role |
|-----------|------------|------|
| `ContinuumWorkflow` | `WORKFLOW_TASK_QUEUE` | The workflow implementation — interprets the graph and drives the execution loop |
| `InitializeActivity` | `ACTIVITY_TASK_QUEUE_INITIALIZE` | Resolves which worker task queue runs each node type, via the API server's node registry |

:::info[It never runs node logic]
The orchestration service only *schedules* nodes. Every node's `execute()` runs inside a feature worker, as a Temporal activity. The orchestrator handles control flow and passes data *references* between nodes; the Parquet data itself goes straight between workers and MinIO.
:::

## Where it sits

```mermaid
flowchart TB
API["🌐 <b>API Server</b>"]
T{{"⏱️ <b>Temporal</b>"}}
O["🧠 <b>Orchestration Service</b><br/>ContinuumWorkflow<br/>InitializeActivity"]
W["🧩 <b>Feature Workers</b><br/>ContinuumNodeActivity"]
K[["📨 <b>Kafka</b>"]]

API ==>|"start / cancel / terminate"| T
T <==>|"workflow tasks"| O
O -->|"resolve node → task queue<br/>(REST)"| API
T <==>|"node activities"| W
W -.->|"progress signals"| T
O -.->|"WorkflowUpdateEvent"| K

classDef ui fill:#8b5cf633,stroke:#8b5cf6,stroke-width:2px
classDef core fill:#ec489933,stroke:#ec4899,stroke-width:2px
classDef stream fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px
classDef worker fill:#06b6d433,stroke:#06b6d4,stroke-width:2px
classDef store fill:#10b98133,stroke:#10b981,stroke-width:2px
classDef orch fill:#ec489955,stroke:#ec4899,stroke-width:4px
class API,T core
class O orch
class W worker
class K stream
```

The API server, workers and orchestrator never call each other to execute nodes. They all communicate through Temporal, which is why a crashed worker or orchestrator pod loses no progress.

## From graph to Temporal workflow

When the API server starts a `ContinuumWorkflow` with the workflow model (`ContinuumWorkflowModel`: nodes, edges, node properties), the orchestrator interprets it in four phases.

```mermaid
flowchart TB
S(["▶ start(workflowModel)"]) --> I["🔎 <b>Initialize</b><br/>resolve task queues,<br/>build one activity stub per node"]
I --> R{"Any nodes ready?<br/><i>all parents produced output<br/>on every connected port</i>"}
R -->|"yes"| D["🚀 <b>Dispatch</b><br/>mark BUSY, gather inputs,<br/>Async.function { run() }"]
D --> Wt["⏳ <b>Wait</b><br/>Promise.anyOf(pending)"]
R -->|"no, but nodes pending"| Wt
Wt --> C["✅ / ❌ <b>Record</b><br/>store outputs or $error,<br/>publish status"]
C --> R
R -->|"nothing ready,<br/>nothing pending"| F(["🏁 FINISHED / FAILED"])

classDef core fill:#ec489933,stroke:#ec4899,stroke-width:2px
classDef worker fill:#06b6d433,stroke:#06b6d4,stroke-width:2px
classDef stream fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px
class S,F core
class I,R,C core
class D,Wt worker
```

<Steps>

1. **Initialize.** `WorkflowActivityInitializer` collects the unique node types (the `NodeData.id` class names) and calls `InitializeActivity.getNodeTaskQueue()`. That activity calls `POST /api/v1/node-explorer/nodes/task-queues` on the API server. If any node type has no registered worker yet, the activity fails and Temporal retries it, so a workflow can be started before its workers come up. The orchestrator then builds a separate `IContinuumNodeActivity` stub for **each node instance**, routed to that node's task queue and carrying its own retry policy.
2. **Find ready nodes.** A node is ready when every parent has completed and produced output on every port this node is connected to, all of its input ports are wired, and it hasn't run or started yet. A node with an unconnected input port is marked `SKIPPED`.
3. **Dispatch in parallel.** For each ready node, the orchestrator maps each incoming edge's `sourceHandle` output to the node's `targetHandle` input, marks the node `BUSY` (animating its incoming edges on the canvas), and starts `IContinuumNodeActivity.run(node, inputs)` with `Async.function {}`. Independent branches of the DAG run concurrently.
4. **Wait and record.** `Promise.anyOf()` waits for whichever pending node finishes first. If the outputs contain the `$error` system port, the node is marked `FAILED` and recorded in the error map. Otherwise it is marked `SUCCESS` and its outputs become available to downstream nodes. The loop goes back to step 2 until no nodes are ready and none are pending.

</Steps>

:::tip[Data passes by reference]
A node's output `PortData` carries a remote reference to its Parquet file in MinIO, not the rows themselves. The orchestrator passes that reference to downstream nodes as their input, so Temporal history stays small no matter how much data a node produces. See [Data Format](./data-format.md).
:::

## Failure, retries & cancellation

| Situation | What the orchestrator does |
|-----------|----------------------------|
| A node activity throws, times out, or exhausts its retries | Converts the `ActivityFailure` into a `$error` output for that node only. Independent branches keep running; descendants of the failed node simply never become ready. |
| One or more nodes failed by the end | Publishes `FAILED` and ends the workflow with a non-retryable `ApplicationFailure` (`WorkflowExecutionFailed`) carrying `nodeErrors` and the successful `nodeToOutputsMap`. |
| User cancels | The API server first sends the `notifyCancelling` signal, which pins the status to `CANCELLED`, then issues Temporal `cancel()`. Nodes that are still `BUSY` are marked `CANCELLED` and a final event is published. |
| User terminates | The API server sends the `notifyTerminating` signal, which pins the status to `TERMINATED` and updates the search attribute, then issues Temporal `terminate()`. Workflow code can't run after a terminate, so the signal is the orchestrator's last chance to report. |

Default activity options per node stub:

- `startToCloseTimeout`: **60 days** (long-running nodes are expected)
- `heartbeatTimeout`: **5 minutes** (workers heartbeat in the background, every 60 s by default)
- Retry: exponential backoff (coefficient 2.0, max interval 100 s), up to **500 attempts**

A node can override any of these retry fields through `NodeData.retryOptions` (`initialIntervalSeconds`, `backoffCoefficient`, `maximumIntervalSeconds`, `maximumAttempts`, `doNotRetry`). Fields it doesn't set fall back to the defaults.

## Live status

The orchestrator is the **only** source of execution status events. Whenever a node starts, completes or reports progress, it publishes a `WorkflowUpdateEvent` to the Kafka topic `continuum-core-event-WorkflowExecutionSnapshot`, keyed by workflow ID. The event contains the full workflow model (node statuses, animated edges), every node's outputs and errors, overall progress (completed nodes ÷ total nodes), owner, and schedule ID. `continuum-message-bridge` consumes this topic, forwards each event to MQTT for the browser, and syncs it to the database.

Workers report fine-grained progress by sending the `updateNodeProgressSignal` signal to the running workflow. The orchestrator stores the progress on the node and publishes a fresh event.

The orchestrator also maintains two Temporal search attributes on every run, which the API server uses to list and filter executions:

- `Continuum:ExecutionStatus` (Int) — started / completed / failed / cancelled / terminated
- `Continuum:WorkflowFileName` (Keyword) — the workflow file the run came from

The `temporal-search-attributes-init` service in the local compose stack creates both attributes before the orchestrator starts.

## Determinism rules

`ContinuumWorkflow` is Temporal workflow code, so after a crash it is **replayed** from history, not re-run from scratch. That rules out:

- I/O, `Date.now()`, random values or static loggers in workflow code. Use `Workflow.getLogger()`, and put side effects in activities (as `InitializeActivity` does for the REST call).
- Publishing duplicate events during replay. The status reporter checks `WorkflowUnsafe.isReplaying()` and only publishes during live execution.

## Configuration

| Property / env var | Default | Purpose |
|--------------------|---------|---------|
| `TEMPORAL_SERVER_ADDRESS` | `localhost:7233` | Temporal frontend |
| `TEMPORAL_NAMESPACE` | `default` | Temporal namespace |
| `CONTINUUM_API_SERVER_BASE_URL` (`continuum.core.orchestration.api-server-base-url`) | `http://localhost:8081` | API server used to resolve node task queues |
| `CONTINUUM_KAFKA_MAIN_BROKER_LIST` | `localhost:39092,…` | Kafka brokers for status events |
| `CONTINUUM_KAFKA_MAIN_SCHEMA_REGISTRY` | `http://localhost:38080` | Schema Registry |
74 changes: 49 additions & 25 deletions docs/architecture/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ sidebar_position: 1

# System Overview

Continuum is split into a browser frontend, a core backend (API server + Temporal orchestration), and independent feature workers that provide the actual workflow nodes.
Continuum is split into a browser frontend, a core backend, and independent feature workers that provide the actual workflow nodes. The core backend has three parts: the API server, the **orchestration service**, which interprets the graph as a Temporal workflow, and the message bridge.

```mermaid
flowchart TB
subgraph Browser["🖥️ Browser: Continuum Workbench"]
UI(["🎨 Eclipse Theia IDE + React Flow canvas"])
end

API["🌐 <b>API Server</b>"]
Temporal{{"⏱️ <b>Temporal</b><br/>orchestration"}}
API["🌐 <b>API Server</b><br/>REST, node registry"]
Temporal{{"⏱️ <b>Temporal</b><br/>durable state & task queues"}}
Orch["🧠 <b>Orchestration Service</b><br/>interprets the graph<br/>as a Temporal workflow"]
Bridge["🔁 <b>Message Bridge</b><br/>Kafka → MQTT"]
Kafka[["📨 <b>Kafka</b><br/>events"]]

Expand All @@ -29,9 +30,11 @@ flowchart TB

UI ==>|"REST"| API
Bridge -.->|"MQTT / WebSocket<br/>live status"| UI
API ==> Temporal
Temporal ==>|"dispatches"| Workers
Workers -.->|"events"| Kafka
API ==>|"start workflow"| Temporal
Temporal <==>|"workflow tasks"| Orch
Orch -->|"resolve task queues"| API
Temporal ==>|"node activities"| Workers
Orch -.->|"status events"| Kafka
Kafka -.-> Bridge
Workers <-->|"read / write"| MinIO

Expand All @@ -41,25 +44,36 @@ flowchart TB
classDef worker fill:#06b6d433,stroke:#06b6d4,stroke-width:2px
classDef store fill:#10b98133,stroke:#10b981,stroke-width:2px
classDef hero fill:#06b6d433,stroke:#06b6d4,stroke-width:4px,stroke-dasharray:6 3
classDef orch fill:#ec489955,stroke:#ec4899,stroke-width:4px
class UI ui
class API,Temporal core
class Orch orch
class Kafka,Bridge stream
class Base,Chem,AI worker
class MinIO store
```

| Component | Role |
|-----------|------|
| `continuum-api-server` | REST entry point for the workbench, node registry, starts/cancels/terminates workflow runs |
| `continuum-orchestration-service` | Temporal workflow worker that interprets the canvas graph and drives execution. It schedules nodes, routes them to workers, wires outputs to inputs, and publishes status. See [Orchestration Service](./orchestration-service.md). |
| Temporal | Persists every step of the run and delivers workflow and activity tasks through task queues |
| Feature workers | Run the actual node logic (`execute()`) as Temporal activities |
| `continuum-message-bridge` | Forwards Kafka status events to the browser over MQTT, and maintains the node registry |

## Execution flow

<Steps>

1. You design a workflow in the browser (React Flow canvas) and hit **Execute**.
2. `continuum-api-server` receives the REST call and starts a Temporal workflow (`ContinuumWorkflow`, on `WORKFLOW_TASK_QUEUE`).
3. `InitializeActivity` resolves which task queue (= which worker) handles each node, via `POST /api/v1/node-explorer/nodes/task-queues` against the API server's node registry.
4. For each DAG node, `IContinuumNodeActivity.run()` is dispatched to the resolved worker's task queue (`ACTIVITY_TASK_QUEUE`). The worker downloads input Parquet from MinIO, runs `execute()`, and uploads output Parquet.
5. Nodes run in parallel where the DAG allows — `ContinuumWorkflow` waits for the first pending node to complete, then schedules newly unblocked nodes.
6. Each node sends progress signals; `ContinuumWorkflow` publishes a `WorkflowUpdateEvent` to Kafka.
7. `continuum-message-bridge` consumes the Kafka event and republishes it to Mosquitto (MQTT).
8. The browser receives the update over MQTT-over-WebSocket and lights up the corresponding node in real time.
2. `continuum-api-server` validates the node properties, records a `PENDING` run, and starts a `ContinuumWorkflow` on `WORKFLOW_TASK_QUEUE`, passing the graph (nodes + edges) as input.
3. `continuum-orchestration-service` picks up the workflow task and begins interpreting the graph. Its `InitializeActivity` resolves which task queue (= which worker) handles each node type, via `POST /api/v1/node-explorer/nodes/task-queues` against the API server's node registry.
4. The orchestrator finds every node whose parents have all produced output and dispatches `IContinuumNodeActivity.run()` for each one to the resolved worker's task queue. Each node's inputs are wired from its parents' outputs along the graph's edges.
5. The worker downloads input Parquet from MinIO, runs `execute()`, uploads output Parquet, and returns references to the output files.
6. Nodes run in parallel where the DAG allows. The orchestrator waits for the first pending node to complete, records its outputs (or error), and schedules newly unblocked nodes, repeating until the graph is exhausted.
7. On every state change, and whenever a worker sends a progress signal, the orchestrator publishes a `WorkflowUpdateEvent` to Kafka.
8. `continuum-message-bridge` consumes the Kafka event and republishes it to Mosquitto (MQTT).
9. The browser receives the update over MQTT-over-WebSocket and lights up the corresponding node in real time.

</Steps>

Expand All @@ -71,42 +85,52 @@ sequenceDiagram
participant B as 🖥️ Browser
participant A as 🌐 API Server
participant T as ⏱️ Temporal
participant O as 🧠 Orchestration Service
participant W as 🧩 Worker
participant S as 🗄️ MinIO
participant K as 📨 Kafka → MQTT

rect rgba(139, 92, 246, 0.10)
Note over B,T: 🚀 Start
Note over B,O: 🚀 Start
B->>+A: Execute workflow (REST)
A->>+T: Start ContinuumWorkflow
T->>A: InitializeActivity: resolve task queues
A->>T: Start ContinuumWorkflow(graph)
deactivate A
T->>+O: Workflow task
O->>A: InitializeActivity: resolve task queues
A-->>O: node type → task queue
end

loop 🔁 each unblocked DAG node
loop 🔁 until no nodes ready or pending
rect rgba(236, 72, 153, 0.10)
Note over O,T: 🧠 Interpret the graph
O->>T: Schedule run() for each ready node
end
rect rgba(6, 182, 212, 0.10)
Note over T,S: ⚙️ Run the node
T->>+W: IContinuumNodeActivity.run()
T->>+W: IContinuumNodeActivity.run(node, inputs)
W->>S: Read input Parquet
W-->>T: Progress signals
W->>S: Write output Parquet
W-->>-T: Progress signals
W-->>-T: Output port references
T->>O: Activity completed
O->>O: Record outputs, find newly ready nodes
end
rect rgba(245, 158, 11, 0.12)
Note over T,B: 📡 Live status
T-->>K: WorkflowUpdateEvent
Note over O,B: 📡 Live status
O-->>K: WorkflowUpdateEvent
K-->>B: Node status (MQTT over WebSocket)
end
end
deactivate T
deactivate O
```

## Why this survives crashes

:::tip[Crash-proof by design]
Temporal persists workflow state (in PostgreSQL) at every step. If a worker process dies mid-execution, the orchestration service simply redispatches the pending activity once a worker becomes available again — no data loss, no restart from scratch.
Temporal persists workflow state (in PostgreSQL) at every step. If a worker process dies mid-execution, Temporal retries the pending activity once a worker becomes available again — no data loss, no restart from scratch. If the orchestration service itself restarts, another instance replays the workflow's history and resumes where the DAG loop left off.
:::

This is the "crash-proof execution" promise: a failed Kafka broker, a restarted worker pod, or a dropped network connection doesn't lose workflow progress.
This is the "crash-proof execution" promise: a failed Kafka broker, a restarted worker or orchestrator pod, or a dropped network connection doesn't lose workflow progress.

## Task queues

Expand All @@ -118,4 +142,4 @@ Three Temporal task queues coordinate the system:
| `ACTIVITY_TASK_QUEUE` | `ContinuumNodeActivity` (feature workers) | Runs individual node logic — name overridable per worker via `continuum.core.worker.node-task-queue` |
| `ACTIVITY_TASK_QUEUE_INITIALIZE` | `InitializeActivity` (orchestration service) | Resolves node → task queue routing before dispatch |

See [Node Model & Registration](./node-model.md) for how a worker's nodes end up in that registry in the first place, and [Data Format](./data-format.md) for how data actually moves between nodes.
See [Orchestration Service](./orchestration-service.md) for how the graph is interpreted, [Node Model & Registration](./node-model.md) for how a worker's nodes end up in that registry in the first place, and [Data Format](./data-format.md) for how data actually moves between nodes.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,6 @@ You don't declare Spring, Temporal, Jackson or test dependencies. The three Cont
| `org.projectcontinuum.feature-java` | Java feature modules | The same, for Java. |
| `org.projectcontinuum.worker` | `worker/` | Spring Boot, the worker starter (Temporal polling and node registration), `bootRun`, and Jib for the container image. |

Add a `dependencies { }` block to a feature module only when your node needs an extra library; see [Add a library](./recipes.md#add-a-library). The plugin versions are the `continuumPlatformVersion` in `gradle.properties` (see the [version note in the overview](./overview.md#what-you-need)).
Add a `dependencies { }` block to a feature module only when your node needs an extra library; see [Add a library](./recipes.md#add-a-library). The plugin versions are the `continuumPlatformVersion` in `gradle.properties` (see the [version note in the overview](./overview.md#what-you-need)). For every setting and the other plugin IDs, see the [Gradle plugin reference](../../ecosystem/gradle-plugin.md).

Next: [rename the template](./step-3-make-it-yours.md).
Loading
Loading