Gateway Reference
This reference documents the current public lemline-runner-gateway API: RPC surface, cursor and watch semantics, start idempotency, security rules, and configuration required to run the gateway.
Overview
lemline-runner-gateway is Lemline's public gRPC ingress and read API for:
workflow definition catalog access
definition-level execution statistics
workflow instance start and listing
per-instance lifecycle event timelines
The gateway is not started as a standalone module. It is loaded by lemline-runner and started with:
It shares the same .lemline.yaml configuration model as the runner and depends on:
runner database configuration for gateway outbox persistence
runner messaging configuration to publish workflow start commands
analytics configuration for read-side queries and watch streams
For a first request, follow Start and follow an order through the gRPC gateway. For a shared installation, see Deploy the gRPC gateway.
The dashboard is an optional web client. See Connect the dashboard to the gateway for browser transport and authentication.
Service Contract
Service: lemline.gateway.v1.GatewayService
Common Conventions
List*RPCs return finite snapshots.Get*RPCs return exactly one resource.Watch*RPCs return live streams.Cursors are opaque and scoped to one RPC plus the exact filter set that produced them.
When a paginated list response includes
watch_cursor, every page from that snapshot returns the same cursor. Consume the final page before using that cursor with the correspondingWatch*RPC.All time windows use
[from, to)semantics: inclusive lower bound, exclusive upper bound.page_size = 0lets the server choose a default page size.
RPC Surface
RPC | Request | Response | Current behavior |
|---|---|---|---|
|
|
| Returns a finite catalog snapshot ordered by |
|
|
| Returns one full definition. If |
|
|
| Returns finite definition-level counters for a time window. |
|
|
| Delta stream of |
|
|
| Starts a workflow instance asynchronously. If |
|
|
| Returns the current instance summary and, when known, a |
|
|
| Returns a finite instance snapshot ordered by |
|
|
| Delta stream of |
|
|
| Returns finite ordered history for one instance, in ascending event-cursor order. |
|
|
| Streams one instance timeline. If |
|
|
| Returns the configuration the gateway runs with, where each value comes from, and the configuration file as read at startup. Secret values are never returned. |
StartInstance Request and Response
StartInstanceRequest:
Field | Required | Description |
|---|---|---|
| yes | Target definition namespace |
| yes | Target definition name |
| no | Concrete definition version; omitted means latest |
| no | Caller-supplied UUIDv7 string for idempotent starts |
| no | Workflow input as |
| no | IANA time zone ID; omitted or blank defaults to |
StartInstanceResponse:
Field | Description |
|---|---|
| Created or reused instance identifier |
| Resolved definition namespace |
| Resolved definition name |
| Resolved definition version actually started |
|
|
Resource Shapes
WorkflowDefinitionreturns the stored definitionsource, the resolvedversion, andavailable_versionsordered newest first.DefinitionStatsreturnsstarted_count,completed_count,faulted_count, andrunning_count_at_time_to(running attime_to, or at the latest lifecycle event whentime_tois omitted) for onenamespace/name/version.InstanceSummaryreturns the resolved definition identity, lifecycle status, timestamps, optionalduration, and optional structurederror.InstanceEventreturns an opaque per-instancecursor, normalizedevent_type, optionalevent_time, and canonicalcloud_event_json.
Execution Semantics
Start Idempotency
StartInstance is idempotent when the caller supplies instance_id.
First accepted request for an
instance_id: returnsSTART_INSTANCE_RESULT_ACCEPTED_NEWSame
instance_idwith the same effective start parameters: returnsSTART_INSTANCE_RESULT_ACCEPTED_EXISTINGSame
instance_idwith different effective parameters: rejected withALREADY_EXISTS
Current conflict detection compares:
resolved workflow identity (
namespace,name, resolvedversion)normalized workflow input
schedule zone when schedule-based persistence is involved
Additional request behavior:
If
instance_idis omitted, the gateway generates a UUIDv7 identifier.If
inputis omitted, the server behaves as if{}was supplied.If
inputis present but does not contain a JSON value, the request is rejected.If
zone_idis invalid, the request is rejected withINVALID_ARGUMENT.
List and Watch Pairing
For definition stats and instances, the intended no-gap client pattern is:
call the corresponding
List*RPCconsume all pages from that snapshot
pass the returned
watch_cursorinto the matchingWatch*RPC
Current watch semantics differ by resource:
WatchDefinitionStats: delta stream, future-only whenafter_cursoris omittedWatchInstances: delta stream, future-only whenafter_cursoris omittedWatchInstanceEvents: replay-first stream, replays from the first event whenafter_cursoris omitted
Instance Event Access
GetInstance, ListInstanceEvents, and WatchInstanceEvents authorize read access by namespace.
Current implementation resolves that namespace from:
the latest instance summary when available
otherwise the first lifecycle event for the instance
If neither exists, the gateway returns NOT_FOUND.
Security Model
Transport security and request authentication are configured separately:
TLS is controlled by
lemline.gateway.tls.*client certificate mode is controlled by
lemline.gateway.tls.client-auth(none,request,required)bearer JWT authentication and authorization are controlled by
lemline.gateway.authentication.*
Validation and runtime rules:
lemline.gateway.authentication.enabled=truerequireslemline.gateway.tls.enabled=truewhen TLS is enabled,
certificateandprivate-keyare requiredwhen client auth is
requestorrequired,trust-storeis requiredwhen authentication is enabled,
jwt.issuerandjwt.jwks-urlare requiredwhen authentication is enabled and no authenticated principal is available, the RPC fails with
UNAUTHENTICATEDwhen authentication is disabled, the gateway allows all scopes. It serves the namespaces configured for the process, or all namespaces when none are configured.
Current scope requirements:
lemline.startforStartInstancelemline.watchforWatchDefinitionStatslemline.watchforWatchInstanceslemline.watchforWatchInstanceEventslemline.configforGetGatewayConfig
Current namespace rules:
other non-streaming read RPCs do not require a scope
namespace authorization is still enforced for read RPCs when authentication is enabled
List*calls without an explicit namespace are automatically limited to the caller's allowed namespaces*in the namespaces claim allows access to all namespaces
Default claim names:
scopes claim:
scopenamespaces claim:
lemline_namespaces
Supply the scope and namespace claims as strings. Separate multiple values with spaces or commas.
Error Mapping
Condition | gRPC status |
|---|---|
Missing authenticated principal when authentication is enabled |
|
Invalid request fields, invalid UUIDv7, invalid timezone, invalid cursors, or invalid time ranges |
|
Missing definition or instance |
|
Duplicate |
|
Missing scope or namespace authorization |
|
Unhandled internal failure |
|
Configuration
Config File Resolution
Gateway startup uses the same config resolution order as lemline-runner:
--config=<path>or-c <path>LEMLINE_CONFIG./.lemline.yaml~/.config/lemline/config.yaml~/.lemline.yaml
Gateway Keys
Property | Default | Required | Description |
|---|---|---|---|
|
| no | Enables gateway server startup |
|
| no | gRPC bind host |
|
| no | gRPC bind port |
|
| no | Enables CORS for browser and gRPC-Web clients |
|
| no | Allowed CORS origins |
|
| no | Allowed CORS methods |
|
| no | Allowed CORS request headers |
|
| no | Enables TLS for the gRPC server |
| - | yes if | Server certificate path |
| - | yes if | Server private key path |
|
| no | mTLS mode: |
| - | yes if | Trust store used for client certificate validation |
| - | depends on store | Trust store password |
|
| no | Enables JWT authentication and authorization |
| - | yes if | Expected JWT issuer |
| - | yes if | JWKS URL used for JWT validation |
|
| no | JWT claim name for scopes |
|
| no | JWT claim name for allowed namespaces |
|
| no | Watch polling interval in milliseconds |
|
| no | Maximum rows fetched per watch poll |
Notes:
lemline gateway startsetslemline.gateway.enabled=trueautomatically; keeping it in config is still fine.Authentication cannot be enabled on plaintext transport.
Analytics Keys for Read APIs
Definition stats, instance reads, and instance-event timelines are backed by the analytics lifecycle-event store.
The gateway can read from PostgreSQL, SQLite on the JVM, and H2 in Lemline's test suite.
Property | Default | Description |
|---|---|---|
|
| Analytics backend selector |
|
| SQLite analytics file shared with the runner on the same host |
|
| Analytics migration toggle |
|
| PostgreSQL analytics Flyway baseline toggle |
|
| PostgreSQL host |
|
| PostgreSQL port |
|
| PostgreSQL database name |
|
| PostgreSQL user |
|
| PostgreSQL password |
|
| Lifecycle-events schema |
The gateway requires a reachable analytics datasource at startup. Lemline configures the datasource when either the gateway or the lifecycle event consumer is enabled.
For PostgreSQL analytics, configure
lemline.analytics.type=postgresqland thelemline.analytics.postgresql.*settings.For SQLite analytics, configure
lemline.analytics.type=sqliteand pointlemline.analytics.sqlite.pathat the lifecycle analytics file. The gateway prepares the SQLite schema at startup whenmigrate-at-startis enabled, including with the analytics consumer disabled. See Lifecycle Analytics Reference.
Minimal Local Development Example
Use this only on trusted local networks:
Build and Run
Build:
Run the JVM package:
Build a native package:
Run the native binary: