# Service API Reference

Source: https://obsvra.com/docs/service-api-reference

> The Pro HTTP service: run SpiceGrinder models over a local, unauthenticated REST-style API. Endpoints, options and request formats.

> © 2026 Obsvra. This document describes SpiceGrinder and is provided to help you evaluate and use it. It is not a license to reproduce, adapt, or use this material to build a competing product or service. Full terms: the SpiceGrinder EULA.

`ModelServiceApp`

## NAME

ModelServiceApp — Pro-tier HTTP service exposing SpiceGrinder models over a REST-ish API (unauthenticated)

## SYNOPSIS

```
java -cp spicegrinder.jar com.obsvra.spicegrinder.pro.service.ModelServiceApp [options]
```

On a jpackage Pro install:

```
service [options]
```

Not present in a Free build — `ModelServiceApp` lives in the `pro.service` package. See also `docker/docker-entrypoint.sh` for the separate container-based distribution path.

## DESCRIPTION

`ModelServiceApp` starts an HTTP server (default `127.0.0.1:8085`) that lets a client register a model (optionally named), list what's already registered, start/stop a live session for it, and generate observations synchronously or as a chunked stream — see ENDPOINTS below for the full route reference.

Blocks the main thread once started; runs until the process is terminated (Ctrl+C or a signal), at which point the shutdown hook stops the HTTP server, deregisters this process from the shared store, and exits cleanly.

**Process cap, enforced before accepting any request**: each running service process is a license-capacity unit (`max.processes`, default 1 — see CONFIGURATION). Before binding the HTTP listener at all, this process checks the shared store's live process count against that cap and refuses to start — exiting with status 3 and an actionable message — if starting would exceed it. Raising the cap increases how many concurrent license sessions a deployment can consume; it's one explicit setting, not a decision to make by accident.

## OPTIONS

| Option | Meaning |
|---|---|
| `--port N` | HTTP port to bind (default 8085). |
| `--bind ADDR` | Interface to listen on (default `127.0.0.1`, loopback-only). A non-default value always prints a startup warning, so binding beyond loopback is an explicit operator choice — worded differently depending on whether `auth.token` (see CONFIGURATION below) is set, since a bearer token alone doesn't protect a plain-HTTP connection either way. Containers pass `0.0.0.0` explicitly via `docker/docker-entrypoint.sh`; this is not a change to the default. |

| `--db PATH` | Override the shared store's database base path (default `~/.spicegrinder/service/model-cache`). Mainly for testing/isolation — e.g. running more than one independent instance side by side. |
| `--trim-models` | Remove the registered models unused for `model.trim.after.days` (default 30; see CONFIGURATION), print what went, and exit without starting the server. A model that is live in any process, or was registered with `keepResident`, stays. Safe to run beside a running Service on the same store. |
| `--older-than-days N` | With `--trim-models`: N days (at least 1) instead of `model.trim.after.days`. |
| `--dry-run` | With `--trim-models`: list what would be removed and remove nothing. |
| `-h`, `--help` | Print usage and exit. |
| `--version` | Print the version (e.g. `1.0.0 (Build 1)`) and exit. |

**DNS-rebinding protection.** When the bind address is loopback (the default), every route, `/v1/health` included, rejects a request whose `Host` header is missing or is not `localhost`, `127.0.0.1` or `[::1]` (with or without a port) with `421 Misdirected Request`, and every route except `/v1/health` rejects a request carrying an `Origin` header that is not a loopback origin (including `Origin: null`) with `403`. Requests with no `Origin` header (curl, SDK clients) are accepted. This stops a web page from rebinding its hostname to `127.0.0.1` and driving the service from the user's browser. It runs before, and independently of, `auth.token`. When bound wider (`--bind 0.0.0.0`, as in the Docker image) no Host/Origin check is applied; that is left to the deployer or a reverse proxy.

## EXIT STATUS

| Code | Meaning |
|---|---|
| 0 | Not reached in normal operation — the process blocks until externally terminated. With `--trim-models`: the trim (or dry run) finished. |
| 1 | Could not open the shared store, bind the configured `--port`/`--bind`, or register this process. |
| 2 | Bad arguments — missing required value, or an unrecognized option; `--dry-run` or `--older-than-days` without `--trim-models`; `--trim-models` with `model.trim.after.days` at 0 and no `--older-than-days`. |
| 3 | Refused to start: the process cap (`max.processes`) was already reached. |

**After an unclean crash** (process killed rather than shut down cleanly), a restart attempt can hit exit code 3 even though no other process is actually running — the crashed process's registration doesn't get cleaned up until its heartbeat is recognized as stale. That window is governed by `heartbeat.stale.after.seconds` (default 90, see CONFIGURATION below); expect a restart to keep refusing for up to that long, then succeed on its own without intervention. Registered models and their generated data are unaffected either way — they live in the shared store, not the process. If a restart is refused well past that window, check for another live process instead (`max.processes` reached legitimately, or the registry itself is stuck).

## EXAMPLES

Start on the default port, loopback-only:

```
java -cp spicegrinder.jar com.obsvra.spicegrinder.pro.service.ModelServiceApp
```

Start on a custom port, bound for container use:

```
service --port 9000 --bind 0.0.0.0
```

Run an isolated instance against its own database, for testing:

```
service --db /tmp/spicegrinder-test-service
```

## Endpoints

| Method | Path | Purpose |
|---|---|---|
| POST | `/v1/models` | Register a model (body = model file text, XML or JSON) |
| POST | `/v1/list` | List every registered model's id, name, and metadata |
| POST | `/v1/models/{id}/start` | Make this model the process's live/resident model |
| POST | `/v1/models/{id}/stop` | Stop this model's session (if it's the live one) |
| POST | `/v1/models/{id}/generate` | Synchronous generate; full result in the response |
| POST | `/v1/models/{id}/stream` | Chunked streaming generate; optional `count` |
| DELETE | `/v1/models/{id}` | Delete a registered model |
| GET | `/v1/generate/{generationId}/data?offset&limit` | Page back through a `/generate` result |
| GET | `/v1/components?category&component` | List registered components and their parameters |
| GET | `/v1/allowlists` | Read this process's configured `FlatFile`/`Database`/`ServiceCall` allowlists |
| GET | `/v1/health` | Liveness check; not gated by `auth.token` |

Error shape (any 4xx/5xx): `{"error": "message"}`.

## POST /v1/models

Query params: `declare` (repeatable, URL-encoded `name=value`) — replaces that `<declare>`'s default before the model is stored, so the registered model is that scenario (a different `modelId` for each value set); an unknown name is a 400 that lists the declared names. `keepResident` (bool, default false) — pins this model's resident graph against LRU eviction. `name` (string, optional) — a caller-supplied label, stored alongside the model and returned by `POST /v1/list`. **Not unique** — no uniqueness check is performed. Recommended convention: shared/library models keep their normal model name; personal dev variants use something like `dev-<model_name>-<user>`.

Response 201:
```json
{"modelId": "m-<uuid>", "name": "widget-lib", "keepResident": false, "analysis": {
  "mode": "...", "nodeCount": N, "minDepth": N, "maxDepth": N, "score": N, "summary": "..."
}}
```
`name` is `null` in the response when the query param was omitted.

## File paths in submitted models

A node like `FlatFile` (`file` parameter), or `Email` (`wordListFile`), resolves that path on this server process, not on the caller's machine — against whatever filesystem this process sees, resolving a relative path against the *process's own* working directory (a submitted model has no folder of its own, so the model-folder and local-root steps a local run has do not apply). There's no client-side resolution step and no guarantee the caller and the server are even the same machine, so a `file` value that only makes sense on the machine that authored the model (e.g. a path under a developer's home directory) will simply not exist from the server's point of view, or worse, silently resolve to an unrelated file that happens to exist at that path on the server.

A relative path that resolves inside the working directory is accepted; set `project.root` in the server's `preferences.properties` to narrow that folder: a submitted model's relative `FlatFile` file or `Email` word list, its relative `Import` file and the MCP `compare_to_sample` `samplePath` must then stay inside `project.root` (still resolved from the working directory), unless the file is on `flatFile.path.allowlist` (FlatFile) or in a library folder (Import).

Use a path the server can actually reach: a location already staged on the server's own disk, or a network-accessible path (shared/mounted filesystem, UNC path, etc.) that resolves to the same file from both where the model is authored and where the service runs. `Import` resolves a relative `file` the same way: a model submitted as text has no folder of its own, so the path is looked up in the organization's libraries (when an organization bundle is active), then the service's working directory, then the user library paths (`library.paths`). An absolute `Import` path is judged by the same rules as for a model loaded from a file.

**Absolute paths, and relative paths that escape their folder, require `flatFile.path.allowlist`.** A relative `file` resolves against the service's working directory and is accepted only if its real path (symlinks resolved) stays inside that folder; a `../` chain or a symlink that leaves it is checked against the allowlist like an absolute path. An absolute `file` names anywhere on the server's filesystem directly, so it's gated the same safe-by-default way `Database`/`ServiceCall`'s own URL allowlists already are: empty allowlist (the default) rejects every absolute `file` value, and every relative one that escapes its folder, outright. This matters specifically because SpiceGrinder's whole auth model assumes a trusted caller — there's no built-in authentication on `ModelServiceApp` itself; it's the deploying org's job to lock the service down (reverse proxy, network allowlists, etc.) if it's ever exposed beyond a fully trusted environment. `Database`/`ServiceCall` already gave the org a way to constrain what an untrusted or semi-trusted model author can reach even without a locked-down network perimeter; `FlatFile` didn't have the equivalent until now. See [Component-Library-Reference.md](https://obsvra.com/docs/component-library-reference#flatfile--pro) for the full detail, including how allowlist entries match (whole path segments, on real paths). The error for an unavailable `file` is the same whether it is missing or not permitted and names only the path as written, so a caller can't use it to probe which files exist; the detail is logged on the server.

## POST /v1/list

No request body (reserved for future filtering; currently ignored). Lists every model in the shared store, not just this process's own registrations.

Response 200:
```json
{"models": [
  {"modelId": "m-<uuid>", "name": "widget-lib", "format": "XML",
   "registeredAt": "2026-08-16T10:46:19.077929Z", "nodeCount": N,
   "complexityScore": N, "keepResident": false},
  ...
]}
```
`modelText` is deliberately omitted — use `POST /v1/models/{id}/generate` or a direct `ModelServiceStore.getModel` lookup to retrieve a specific model's full text.

## POST /v1/models/{id}/start

Response 200: `{"modelId": "...", "live": true, "continued": bool}` — `continued` = was already this process's live model.

## POST /v1/models/{id}/stop

Response 200: `{"modelId": "...", "live": false, "wasLive": bool}`.

## POST /v1/models/{id}/generate

Request body:
```json
{"count": N, "seed": N, "noSeed": bool, "format": "csv|tsv|plain|raw"}
```
`count` required, `>= 0`. `format` defaults to `csv`. The body must be a JSON object: a body that is not, or a field of the wrong type (`count` and `seed` whole numbers, `noSeed` true or false, `format` a string), gets 400.

The whole result is built in memory, so one call is capped at `max.generate.bytes` of output (default 512 MiB): past it the call stops with `413` and an error that points to `/stream`, which has no such limit beyond `max.stream.observations`.

Response 200:
```json
{"modelId": "...", "generationId": "g-<uuid>", "count": N, "seed": "...",
 "seedSource": "...", "rngContinued": bool, "format": "...", "durationMs": N,
 "data": "raw formatted rows"}
```

**A model that ends** (a `ProcessFlow` with `until` or `closes`) is not a failure: `count` in the response is the number of rows produced, `"endOfData": true` is added, and the cached graph is kept (a later call on it returns `count` 0 and `endOfData` true). A stream ends normally after the last row the model produces.

Seed/resident-graph resolution (no explicit seed, no `noSeed`): continues the process's resident graph for this model if one exists; otherwise builds fresh and caches it, subject to `max.resident.graphs` (LRU eviction, `keepResident` pins exempt from eviction).

If generation fails (for example a `Switch` with no branch for a value), the call returns HTTP 500 `generation failed: ...` with none of its rows, and the resident graph is dropped, so the next call without a seed builds a new graph instead of continuing from rows no client received. See [How a model runs](https://obsvra.com/docs/model-file-format-reference#how-a-model-runs).

**Large `count` values have a real memory ceiling this endpoint doesn't warn you about in advance.** `/generate` builds the *entire* response in memory before sending it — confirmed directly (2026-09-04): a 1,000,000-row request against a 1GB-RAM host failed with `{"error":"generation failed: Java heap space"}` (sometimes a clean 500, sometimes a raw connection drop depending on exactly when the `OutOfMemoryError` hit relative to response serialization) — not an OS-level crash, the process survives either way, just that one request. The identical request against `/stream` on the *same* host succeeded cleanly, because streaming sends chunks incrementally and never holds the whole response in memory at once. "SpiceGrinder runs on any hardware capable of Java 25" is true for running the engine — it is not a promise that `/generate` at an arbitrary row count fits in an arbitrary amount of heap. If you don't know in advance that a request's row count × row width comfortably fits in the process's heap, use `/stream` instead — this is exactly the situation it exists for, not a fallback for exotic cases.

**Sizing `count` for a single `/generate` call**: start at 2,000-4,000 rows and adjust from there based on your model's average row size — like `stream.batch.size` (above), it's really *bytes per call* that matters, not row count, so a narrow (few-column) row can comfortably go higher than that and a wide/complex one should go lower. The reason this is a *fairness* concern as much as a performance one: `/generate` (like `/stream`) actually runs on this process's single generation worker (see the class-level note on `ModelServiceHandler` — the same process-wide serialization that avoids a race on the shared random-number generator also means every call, regardless of caller, waits its turn on one worker), so one caller's oversized request holds that worker — and every other concurrent caller's request — for its full duration. A 2,000-4,000-row starting point keeps any single call's worst-case hold on the worker short enough that it doesn't become the next caller's problem.

Also reachable as an MCP tool call (`generate`, Proxy mode — a thin client of this same endpoint, not a second engine) via `McpServerApp` — see [McpServerApp.md](https://obsvra.com/docs/mcpserverapp#generate).

## POST /v1/models/{id}/stream

Same request body shape, but `count` is **optional** — omitted means unbounded, streaming until the client disconnects or `max.stream.observations` is hit. `count` exceeding `max.stream.observations` → 400 before any stream starts.

Two more fields, since 1.1, both optional (only on `/stream`):
```json
{"count": N, "seed": N, "format": "csv", "node": "NAME", "header": true}
```
* `node`: rows from the node of that name instead of the model's root, the rows `grind --node NAME` gives for the same seed. Each such call builds a fresh graph: it never continues, and never disturbs, the model's resident graph, so `X-SpiceGrinder-Rng-Continued` is `false`. Names are as the model loads them; a node of an `<Import name="L">` is `L.NAME`. A name the model lacks → 400 `node not found: NAME (names in this model: ...)`.
* `header`: a header row first, as `grind --header` writes it: the model's column names for the root when it names as many as there are dimensions, otherwise the names the node gives its own columns (a `Summarize` node's measure names), otherwise `dim0,dim1,...`. Only for `csv` and `tsv`; ignored for `plain` and `raw`.

A Service older than 1.1 ignores both fields and streams the root with no header row. A client can tell from the response headers below, which a 1.1 Service always sends: `grind --remote` refuses a stream that does not answer them.

Response: chunked transfer encoding, raw formatted rows, no JSON envelope. `Content-Type`: `text/csv` / `text/tab-separated-values` / `text/plain` per `format`.

Response headers (set before body starts):
| Header | Meaning |
|---|---|
| `X-SpiceGrinder-Model-Id` | Echo of `{id}` |
| `X-SpiceGrinder-Seed` | Resolved seed |
| `X-SpiceGrinder-Seed-Source` | Where the seed came from |
| `X-SpiceGrinder-Rng-Continued` | Whether this continued an existing resident graph |
| `X-SpiceGrinder-Count` | Only present when `count` was provided in the request |
| `X-SpiceGrinder-Node` | The node streamed; only present when `node` was given (since 1.1) |
| `X-SpiceGrinder-Header` | `true` when the body starts with a header row, else `false` (since 1.1) |

If generation fails partway, the stream just ends: the status is still 200 and the headers have already gone out, the error goes to the service's stderr, and the batch being generated when it failed is not sent. A client can only detect this by comparing the rows it received with the `count` it asked for. The resident graph is dropped, as for `/generate`. A client that disconnects doesn't drop it, and the rows generated but not delivered are skipped by the next call without a seed.

No `resultsById` entry is minted for a stream — `GET /v1/generate/{id}/data` does not apply to streamed output.

Not a broadcast mechanism: two concurrent no-seed streams against the same model split one continuing RNG sequence between them, they don't mirror each other. Use independent explicit `seed`s for independent, reproducing streams.

## DELETE /v1/models/{id}

Response 200: `{"modelId": "...", "deleted": true}`. 409 if the model is still live on another process. 404 if not found.

## GET /v1/generate/{generationId}/data

Query params: `offset` (default 0), `limit` (default = server's `DEFAULT_READ_LIMIT`).

Response 200:
```json
{"generationId": "...", "modelId": "...", "format": "...", "offset": N, "limit": N,
 "rowCount": N, "totalCount": N, "hasMore": bool, "data": "..."}
```
404 if the `generationId` was never produced on this process, or was evicted from the in-memory result cache (at most 100 results and `max.retained.result.bytes` in total, least recently used first).

Also reachable as an MCP tool call (`read_generation`) via `McpServerApp` — see [McpServerApp.md](https://obsvra.com/docs/mcpserverapp#read_generation).

## GET /v1/components

Lists every component registered and visible under this process's edition — the same data and the same JSON shape `ComponentLibraryApp --json` produces (see [ComponentLibraryApp.md](https://obsvra.com/docs/componentlibraryapp)); both share the same underlying JSON-building code, so a given component's entry is byte-for-byte identical whether it comes from this endpoint or the CLI tool. Hidden components (`ComponentDescriptor.hidden`) are never returned, by listing or by `component=`. The same data is also reachable as an MCP tool call (`list_components`) via `McpServerApp` — see [McpServerApp.md](https://obsvra.com/docs/mcpserverapp). `engineVersion`/`codename`/`schemaVersion` and each parameter's `allowedValues` are documented in full in [ComponentLibraryApp.md](https://obsvra.com/docs/componentlibraryapp#output-json) — `schemaVersion` is currently `1` and increments only on a breaking change to this JSON shape; `allowedValues` is descriptive (for UIs/docs/agents), not enforced by the engine.

Query params: `category` (`generator`|`filter`, optional) and `component` (short name, optional) — mirror `ComponentLibraryApp`'s `--category`/`--component` exactly, including the mutual-exclusivity rule.

Response 200 (no params, or `category` given):
```json
{"edition": "PRO", "engineVersion": "1.0.0 (Build 1)", "schemaVersion": 1, "totalCount": N, "components": [
  {"name": "Convert", "tier": "Pro", "category": "filter",
   "className": "com.obsvra.spicegrinder.pro.filters.Convert", "description": "...",
   "parameters": [{"name": "class", "type": "String", "required": true, "default": "",
     "aliases": [], "group": "Type", "multiple": false, "minOccurrences": 0,
     "maxOccurrences": 0, "attributes": [], "allowedValues": [], "description": "..."}]}
]}
```
Response 200 (`component` given): same shape, `components` has exactly one entry. 400 if `category` is neither `generator` nor `filter`, or if both `category` and `component` are given. 404 if `component` names a component that doesn't exist, or is hidden.

## GET /v1/allowlists

Reads this process's configured `FlatFile`/`Database`/`ServiceCall` allowlists straight from `UserPreferences` — the same boundaries `FlatFile.configure()`/`Database.configure()`/`ServiceCall` themselves enforce, surfaced so a caller can learn what's permitted without a failed real request first. No query params.

Response 200:
```json
{"flatFilePathAllowlist": ["/data/shared/"], "databaseUrlAllowlist": ["jdbc:h2:"],
 "databaseAllowQuery": false, "serviceUrlAllowlist": ["http://localhost:"]}
```
An empty array means that capability is disabled entirely on this process (empty allowlist = refuse everything, not "anything goes" — see `UserPreferences.requireAllowedFlatFilePath`/`requireAllowedDatabaseUrl`/`requireAllowedServiceUrl`'s own javadoc), not that it's unrestricted. The same data is also reachable as an MCP tool call (`get_allowlists`) via `McpServerApp` — see [McpServerApp.md](https://obsvra.com/docs/mcpserverapp).

## GET /v1/health

Liveness check for load balancers and orchestrators. It answers even when `auth.token` is set. No query params.

Response 200:
```json
{"status": "ok", "processId": "..."}
```

## Configuration (`ServiceConfig`)

Properties file key ↔ system property ↔ default. System property always wins over the properties file.

| Properties key | System property | Default | Meaning |
|---|---|---|---|
| `max.processes` | `spicegrinder.service.maxProcesses` | 1 | License-capacity unit: concurrent live sessions |
| `idle.timeout.seconds` | `spicegrinder.service.idleTimeoutSeconds` | 900 | Session idle-eviction threshold |
| `heartbeat.interval.seconds` | `spicegrinder.service.heartbeatIntervalSeconds` | 30 | |
| `heartbeat.stale.after.seconds` | `spicegrinder.service.heartbeatStaleAfterSeconds` | 90 | How long a missed heartbeat is tolerated before a process's registration is pruned — this is what bounds the post-crash restart-refusal window described in EXIT STATUS above |
| `max.resident.graphs` | `spicegrinder.service.maxResidentGraphs` | 20 | LRU cap on resident graphs per process |
| `max.stream.observations` | `spicegrinder.service.maxStreamObservations` | 10,000,000 | Safety cap on unbounded streams |
| `stream.batch.size` | `spicegrinder.service.streamBatchSize` | 2048 | Batched-mode submission size; also monolithic-mode flush size |
| `db.pool.max.connections` | `spicegrinder.service.dbPoolMaxConnections` | 20 | Max pooled `ModelServiceStore` JDBC connections |
| `streaming.mode` | `spicegrinder.service.streamingMode` | `batched` | `batched` (fair, per-batch worker submission) or `monolithic` (one job holds the worker for the whole stream) |
| `max.request.bytes` | `spicegrinder.service.maxRequestBytes` | 16777216 (16 MiB) | Largest request body accepted by `POST /v1/models`, `/generate` and `/stream`; a larger body (by `Content-Length`, or counted while reading a chunked body) is refused with `413 Payload Too Large` without being buffered. A non-positive or unparsable value is ignored with a warning and the default is used. Docker: `SPICEGRINDER_SERVICE_MAX_REQUEST_BYTES` |
| `max.retained.result.bytes` | `spicegrinder.service.maxRetainedResultBytes` | 268435456 (256 MiB) | Total size of the completed `/generate` results this process keeps for `GET /v1/generate/{generationId}/data` (also capped at 100 results). Past either cap the least recently used result is dropped; the newest is always kept, even when it alone is larger. A non-positive or unparsable value is ignored with a warning and the default is used. Docker: `SPICEGRINDER_SERVICE_MAX_RETAINED_RESULT_BYTES` |
| `max.generate.bytes` | `spicegrinder.service.maxGenerateBytes` | 536870912 (512 MiB) | Most output one buffered `/generate` call may build; past it the call stops with `413 Payload Too Large` and an error that points to `/stream`. Counted in characters as the rows are written. A non-positive or unparsable value is ignored with a warning and the default is used. Docker: `SPICEGRINDER_SERVICE_MAX_GENERATE_BYTES` |
| `model.trim.after.days` | `spicegrinder.service.modelTrimAfterDays` | 30 | Days a registered model may go unused before the Service removes it from the store; `0` never removes one. "Used" means a `/generate` or `/stream` call; a model that was never run counts from its registration. The Service checks a minute after it starts and every 6 hours, and logs what it removed. It keeps a model that is live in any process, one registered with `keepResident`, and one whose `/generate` results this process still holds for `GET /v1/generate/{generationId}/data`. Models pile up because a client that ends without deleting its own (`grind --remote` stopped hard, a script that never calls `DELETE`) leaves them behind. A client that registers once and runs the model by id (`grind --remote --model-id`) should use it at least once per period, or register it with `keepResident`. `ModelServiceApp --trim-models --dry-run` lists what a trim would remove. Docker: `SPICEGRINDER_SERVICE_MODEL_TRIM_AFTER_DAYS` |
| `db.base.path` | — | `~/.spicegrinder/service/model-cache` | |
| `auth.token` | `spicegrinder.service.authToken` | (empty — disabled) | If set, every route except `/v1/health` requires `Authorization: Bearer <token>`; a bearer token alone doesn't protect a plain-HTTP connection, so pair it with a TLS-terminating reverse proxy for anything beyond a trusted LAN |

**Tuning `stream.batch.size` for your payload shape**: the right value tracks *bytes per submission*, not row count — a real sweep (`ServiceLoadTester`, 16 sizes × both streaming modes × two payload widths × two observation counts) found the well-amortized zone lands around ~50-150KB per submission regardless of row shape, so a narrow (few-column) row needs proportionally more rows to reach it than a wide (many-column) one. 2048 is tuned for default-shaped rows; **if you're streaming wide/complex objects as the regular case (many columns, nested/long fields), consider lowering `stream.batch.size`** — a large row count at 2048 could mean holding several MB in one submission/flush, working against the low-latency point of streaming in the first place. Conversely, narrow single-column-ish streams can often go higher than 2048 with no downside. There's no universal right answer here independent of your actual row shape — measure with your own model if it matters to you.

## Using custom Pro components

`ModelServiceApp`'s classpath is fixed at launch, same as any other JVM process — no plugin directory, no hot-reload. A custom generator/filter reaches the Service the same way it reaches the CLI/GUI: be on the classpath when the process starts (`-cp` for a raw jar, or the `app.classpath` line in a jpackage install's generated `service.cfg` for a packaged one), then reference it by fully-qualified name or a `<definitions><custom .../></definitions>` alias in the model you register. A classpath change takes effect on the next process start, not mid-run — see the Customization Guide's "Using custom components with ModelServiceApp" section (included with the Pro download) for the exact commands.

`Convert`'s `class=""` attribute is bound by the exact same rule — the named `ISerializable` business object type has to already be on the Service process's own classpath at launch, same as a custom generator/filter. There's no separate allowance for it: naming an arbitrary class by string is the same operation whether it's a `<definitions><custom .../></definitions>` alias or `Convert`'s `class=""`, so it's gated and resolved the same way, and only takes effect on the next process start. See the Customization Guide (included with the Pro download) for a worked example.

## Concurrency model

Requests are accepted and handled in parallel, one virtual thread each, so a long stream doesn't hold up other requests: `/v1/health`, `/v1/list`, registration and the rest answer while it runs. Everything that touches a model's generators runs on a single-worker executor per process — loading a model (at registration or on first use), `/generate`, and each `/stream` — one job at a time. Two consequences follow. There's no guarantee that the first request to arrive runs first: concurrent requests can run in any order. And each model's output is deterministic for a given seed regardless of what else is running: every node of a model keeps its own random stream (the default `per-node` layout; see [Determinism](https://obsvra.com/docs/determinism)), and a concurrent request for another model doesn't disturb it. This isn't just a fairness/simplicity choice: concurrent `getNextObservation()` calls into one model's generators aren't safe (a graph has to be driven by one thread at a time), and loading a model sets process-wide random state, so loads have to be serialized too (see the Customization Guide, included with the Pro download, for the full detail) — the single-worker executor is what makes both safe here without touching core RNG code. `batched` streaming mode bounds how long any one stream can hold the shared worker; `monolithic` trades that fairness for lower per-call overhead (documented tradeoff, not a bug).

A running stream holds its own direct reference to the acquired `IGenerator` — cache eviction of the resident-graph map entry doesn't affect an in-flight stream, only future lookups.
