edition = "2023"; package workflows.v1; import "buf/validate/validate.proto"; import "google/protobuf/empty.proto"; import "opentelemetry/proto/logs/v1/logs.proto"; import "tilebox/v1/id.proto"; import "workflows/v1/core.proto"; import "workflows/v1/task.proto"; import "workflows/v1/workflows.proto"; // InitializeRunnerRequest is sent by the runner to a worker runtime to discover its capabilities. message InitializeRunnerRequest { // The id of the runner that this worker runtime is connected to. tilebox.v1.ID runner_id = 1; // The trace_parent that should be used for any traces emitted by this worker runtime (outside of task execution, // which has its own trace_parent propagation from jobs). This allows us to correlate any logs and traces emitted // by the worker runtime with the runner that it's connected to. string trace_parent = 2; // The cluster that the worker runtime is running on. workflows.v1.Cluster cluster = 3; // The workflow (and the release) that this worker was created from. workflows.v1.Workflow workflow = 4; // The storage locations that the worker runtime can access, for triggered automations. TileboxAPIConnection api_connection = 5; } // TileboxAPIConnection is a message containing the information needed for a worker runtime to connect to the Tilebox // API, to e.g. export observability data to (logs and traces). It's the credentials that the tilebox-cli locally // uses to connect to the Tilebox API, and is passed down to the worker runtimes so that they can also connect to the // Tilebox API in the same way. These credentials must only be sent over a trusted local runtime connection, // using a Unix socket or an authenticated loopback TCP connection, never an exposed network listener. message TileboxAPIConnection { // The API url to which the worker runtime can connect, to e.g. export observability data to (logs and traces). string url = 1; // The token to use for authenticating to the API. string token = 2; } // HandshakeResponse is the response to a handshake request, containing the task identifiers that the worker can execute. message InitializeRunnerResponse {} // ExecuteTaskResponse is the response of a worker runtime to a request to execute a task, after the task has // been executed. message ExecuteTaskResponse { option (buf.validate.message).oneof = { fields: [ "computed_task", "failed_task" ] }; // If the task execution succeeded, this field will be set with the computed task result. workflows.v1.ComputedTask computed_task = 1; // If the task execution failed, this field will be set with details about the failure. workflows.v1.TaskFailedRequest failed_task = 2; } // WorkerService defines the RPC interface between a runner and a a worker runtime that can execute workflow tasks. service WorkerService { // ListRegisteredTasks is called by the runner to discover the task identifiers that a worker runtime can execute. // These are local task definitions without workflow IDs. The managed runner binds them to its deployed workflow // and adds any enabled legacy aliases when advertising capabilities to the task service. rpc ListRegisteredTasks(google.protobuf.Empty) returns (workflows.v1.UnboundTaskIdentifiers); // InitializeWorker is called by the runner to initialize a worker runtime with some known metadata about the // runner. This allows us to add those metadata to any logs and traces emitted by the worker. rpc InitializeWorker(InitializeRunnerRequest) returns (InitializeRunnerResponse) {} // ExecuteTask is called by the runner to execute a task on the worker runtime. The worker runtime will execute the // task, and then respond with the result of the task execution, which can either be a computed task, or a failed // task. If the worker runtime crashes or becomes unreachable during task execution, the runner will treat the task // as failed with an unknown error. // The runner preserves the executing task's scope. Workers dispatch by local name/version and resolve child scopes // before returning them, defaulting to the executing task's scope rather than the release's workflow ID. // During migration, the managed runner fills missing child workflow IDs from the executing task's scope for legacy // workers, preserving explicit IDs. An explicit unscoped child of a scoped task cannot be expressed through this // adapter; it must be removed before supporting that override. The task service does not perform inheritance. rpc ExecuteTask(workflows.v1.Task) returns (ExecuteTaskResponse) {} // WatchLogs streams structured runtime logs to the local runner, independently of API log exports and raw // stdout/stderr. It is available before workflow import completes and before InitializeWorker is called. // The runner sends one request; the worker sends buffered startup records followed by live records in enqueue // order. The stream stays open until shutdown, cancellation, or a connection failure, even while no tasks run. // Only one subscriber is allowed per runtime; concurrent subscriptions fail with ALREADY_EXISTS. // Delivery is best-effort with bounded buffering: slow or disconnected subscribers must not block tasks. // Buffer overflow is reported as a warning record when delivery resumes. There is no acknowledgement or replay // of delivered records. Canceling this stream does not shut down the worker or disable its API log exports. // Messages use the log body, severity, trace/span IDs, and attributes from the OpenTelemetry log model; // exception details use exception.type, exception.message, and exception.stacktrace attributes. // buf:lint:ignore RPC_NO_SERVER_STREAMING rpc WatchLogs(google.protobuf.Empty) returns (stream opentelemetry.proto.logs.v1.LogRecord); // Gracefully shuts down the worker runtime. After receiving this request, the worker runtime will // finish task cleanup, flush API logs, and drain buffered WatchLogs records within a bounded deadline. // The log stream ends before the worker stops its RPC server; an open subscription must not prevent shutdown. rpc ShutdownWorker(google.protobuf.Empty) returns (google.protobuf.Empty) {} }