Files
leleka/deploy

Deployment

Linux CI builds a statically linked musl CLI/control-plane preview and publishes it as a prerelease artifact on version tags. This is not yet a complete GPU runtime: the C++/CUDA engine is not linked into that executable. The host must have a compatible NVIDIA driver already installed (CUDA 13.0 GA baseline: 580.65.06 or newer). The strata-next doctor command checks the installed version. Model weights belong on an external volume. A complete GPU deployment image has not been built yet.

For a local static CLI image smoke test, build deploy/Dockerfile.static-cli with a Linux/musl target. The final image is scratch plus the CLI binary. It is a packaging test, not the deployment image for inference.

Worker recovery

Configure top-level JSON max_in_flight_requests or environment STRATA_MAX_IN_FLIGHT_REQUESTS to bound admitted HTTP inference requests (1–256; default 17). Environment overrides the file. At capacity, new Responses POSTs receive 429 runtime_overloaded and Retry-After: 1 before parsing; drain still returns 503. This covers queued requests and streaming bodies, not GPU concurrency. /admin/lifecycle exposes the limit and available request slots; check-config validates and reports the limit. See admission lifecycle for scope.

The Rust supervisor defaults to three lifetime restarts after a post-READY worker failure, with 2/4/8-second backoff. Configure engine.max_restarts or STRATA_MAX_WORKER_RESTARTS from 0 to 3; zero disables recovery. Failed and queued generations are not replayed. Readiness stays false until the new worker handshake completes. A startup failure or an exhausted budget leaves the service unhealthy for inference until an operator restarts it; /health remains available. See the API contract.

An optional engine.generation_timeout_s (or STRATA_GENERATION_TIMEOUT_S) sets an absolute active-command deadline, 1–86400 seconds. It is disabled when omitted. Select a budget that accommodates the model's longest prefill and output. The clock starts when the worker takes the command; HTTP parsing, tokenization and queue wait are excluded. Engine stdin writes, reading tokens and waiting on the streaming channel are included. Native check-config reports this value, or null when disabled/unconfigured.

On expiry the supervisor revokes readiness and kills/reaps that worker rather than attempting to reuse its unfinished protocol stream. The failed command and queued work are never replayed. The existing finite restart budget applies; model loading and caches must be rebuilt after restart. With zero restarts the worker remains failed. Connected clients receive the terminal failure described in the API contract.

Native Linux service lifecycle

strata-next service-unit renders a systemd user unit to stdout. It does not install, start, enable or replace a service. Provision the native executable, engine, tokenizer and private JSON configuration first; all supplied paths must be absolute and exist. Systemd disallows quotes and backslashes in the executable path; the renderer rejects these with a relocation instruction. For example, on the Linux host:

umask 077
mkdir -p "$HOME/.config/systemd/user"
/absolute/path/strata-next service-unit \
  --config /absolute/path/config.json \
  --working-dir /absolute/path/engine-workdir \
  --env-file /absolute/path/runtime.env > "$HOME/strata-next.service"
systemd-analyze --user verify "$HOME/strata-next.service"
# Review the generated unit before installing. Do not overwrite a live unit.
systemctl --user link "$HOME/strata-next.service"
systemctl --user start strata-next.service
systemctl --user status strata-next.service
journalctl --user -u strata-next.service -n 100

Omit --env-file if unnecessary. The file uses systemd EnvironmentFile syntax, not shell commands; it can set LD_LIBRARY_PATH and engine tuning variables. Its path cannot contain glob characters (*, ?, [), backslashes or trailing whitespace, because systemd interprets that directive as a filename pattern. serve --config FILE selects the explicit config even if STRATA_CONFIG is also set; other documented environment overrides still apply. Keep the API bound to loopback and use SSH forwarding; optional bearer authentication does not provide transport encryption. Set STRATA_API_KEY_FILE to a private key file to enable the native auth gate.

Systemd process startup is not model readiness: check the configured /ready endpoint before connecting the console harness. Restart=no preserves the supervisor's finite worker restart policy. SIGTERM goes to the supervisor; remaining processes in its cgroup are killed after the 45-second stop deadline. No model or logs are copied into a release by rendering the unit. Journald retention is managed by the host; model and capture paths should remain private.

To stop and remove an explicitly installed service:

systemctl --user stop strata-next.service
systemctl --user disable strata-next.service
systemctl --user daemon-reload

The service is not enabled at login/boot by these instructions. A running user manager is required. The existing trial endpoint remains externally launched; these instructions do not migrate it. Use the existing connect strata-native command once a provisioned service is ready.

Console controller

Install the opt-in controller commands on the laptop after the native Responses launcher integration (the installer preserves the selected connection):

python3 scripts/install-qwen-native.py
python3 scripts/install-qwen-native-service.py
qwen-codex-ctl native-service status --host rnr5090 --unit strata-next.service
qwen-codex-ctl native-service start --host rnr5090 --unit strata-next.service
qwen-codex-ctl native-service logs --host rnr5090 --unit strata-next.service
qwen-codex-ctl native-service stop --host rnr5090 --unit strata-next.service

These operate on an already provisioned systemd user unit through SSH; they never install, enable, migrate or switch a model. The host defaults to the launcher's configured SSH alias, and the unit to strata-next.service. Optional unit names must follow strata-next-NAME.service. Start/stop are idempotent; SSH calls time out after 90 seconds. Logs show the selected unit's last 100 entries. No service credentials are copied or stored by this helper.

The JSON status describes the process; model_readiness: not_checked is explicit. Model initialization can continue after process startup. The separate qwen-codex-ctl connect strata-native --url http://127.0.0.1:18084 --no-auth checks inference readiness through the existing SSH tunnel before switching the console connection. Tunnel setup remains separate. The existing plain start/stop commands retain their previous behavior; use native-service explicitly for a managed native unit. The currently running external trial has no such unit, so these commands safely report it as not provisioned.

Native API commands in the console controller

Install the API helper after the native launcher integration:

python3 scripts/install-qwen-native-api.py
qwen-codex-ctl native-api status
qwen-codex-ctl native-api metrics
qwen-codex-ctl native-api lifecycle
qwen-codex-ctl native-api drain --wait 60
# Explicitly reopen admission when maintenance is abandoned or complete:
qwen-codex-ctl native-api resume

These use the selected strata-native connection and its private key file. An explicit URL requires an explicit authentication choice and does not change the selected connection:

qwen-codex-ctl native-api status --url http://127.0.0.1:18084 --no-auth
qwen-codex-ctl native-api metrics --url http://127.0.0.1:18084 --key-file /private/path/api.key

The helper verifies native /status identity before any admission mutation. It uses direct loopback HTTP, ignoring proxy environment variables, refuses redirects, and bounds each JSON response to 64 KiB. Socket operations time out after eight seconds; this is not a hard total deadline for a server that keeps sending partial bytes. Credentials are never command-line token arguments.

drain --wait SECONDS polls lifecycle for up to the requested interval (0–3600 seconds, subject to in-flight HTTP I/O). Without a positive wait it returns the initial snapshot. Timeout, interruption or a concurrent resume produces an error; the client never automatically stops or resumes the runtime. Inspect lifecycle after any uncertain mutation result. Serialize operator actions. No service, SSH tunnel or model is created or switched by these commands.

The retained GPU trial supports native-api status; metrics and admission controls require the newer feature preview and return HTTP 404 on that older trial. The helper does not upgrade a runtime automatically. Client Python is part of the existing laptop harness; native production serving remains Rust.

Verification without GPU inference:

python3 scripts/smoke-service-unit.py /absolute/path/strata-next --lifecycle

This creates and removes an isolated CPU-only service on an unused loopback port. It checks real systemd path parsing (spaces, quotes, backslashes, $ and %), config precedence, environment loading, health, false readiness without a worker and process removal. Without --lifecycle, only unit syntax and rejected path checks run, as wired into Linux CI. Hosted CI execution remains pending.

Drain before maintenance

The feature preview exposes process-local admission controls (protected by the configured API key, if enabled):

curl -fsS -X POST http://127.0.0.1:18082/admin/drain
curl -fsS http://127.0.0.1:18082/admin/lifecycle
# Wait for drained: true, then perform an intentional stop using your service manager.
# To abandon maintenance and accept new work again:
curl -fsS -X POST http://127.0.0.1:18082/admin/resume

Use the configured endpoint port and bearer header when enabled. These calls only change admission; they do not stop, restart, migrate or switch the engine. They are not installed on the preserved GPU user trial yet.

Drain is idempotent. It rejects new Responses admissions with HTTP 503 runtime_draining and makes /ready return 503 (/status.ready is false). Previously admitted JSON/SSE requests, including requests waiting for the command queue, continue normally. Health, metrics and admin endpoints remain available. Resume is idempotent and restores admission, subject to ordinary worker readiness.

GET /admin/lifecycle reports draining, requests_in_flight, generation_jobs, worker and drained. Request tracking starts before body parsing and lasts until the response body is consumed or dropped. Generation tracking includes queue waits, queued commands, execution and worker protocol cleanup. Client disconnect does not declare a generation drained while STOP is still being processed. Frames and trailers pass through unchanged.

drained: true requires drain mode, zero tracked requests and commands, no active generation, and a ready or unconfigured worker. Startup, restart, stopping or failed worker states report false. A stalled client or worker can hold drain indefinitely; the existing STOP timeout and finite restart policy still apply. No deadline triggers a forced stop. Investigate a stuck drain or explicitly choose to stop, accepting interruption, using the service manager.

Serialize maintenance operations: another operator can resume admission after a status snapshot. The state is not a deployment lock or evidence that a client received/processed all bytes. It resets to accepting after a control-plane restart. CPU protocol tests cover the controls; managed GPU maintenance and long-running user workloads require separate qualification.

Optional embedded engine preview

A private build can carry a pinned Linux engine executable inside strata-next:

export STRATA_EMBED_ENGINE_PATH=/absolute/path/to/verified/strata
export STRATA_EMBED_ENGINE_SHA256=THE_64_HEX_DIGIT_ENGINE_SHA256
export STRATA_EMBED_ENGINE_REVISION=THE_FULL_40_HEX_DIGIT_SOURCE_COMMIT
cargo build --manifest-path control-plane/Cargo.toml --locked --release \
  --target x86_64-unknown-linux-musl

Use an actual engine digest and its declared source revision. The build requires all three variables together, verifies the digest, limits the payload to 1 GiB with a 64 KiB copy/hash buffer and checks an ELF64 little-endian executable header matching the target CPU. This is not a complete ELF dependency audit or proof that the declared revision produced that binary; retain the build/provenance record alongside the digest. Normal builds without these variables remain control-plane-only builds. The copy/hash stage uses a fixed buffer; Rust compilation/linking still process the full payload and require memory and disk space proportional to its size.

strata-next engine-info reports payload identity without executing it. strata-next engine-help materializes the embedded worker and runs its --help with no GPU visible; this checks loading and help output, not model readiness. strata-next --engine-license prints the imported Strata MIT license. The upstream record in docs/upstream.md remains authoritative and unchanged. Select the embedded worker explicitly in the usual configuration:

{
  "bind": "127.0.0.1:18082",
  "model": "your-model-id",
  "engine": {
    "executable": "@embedded",
    "args": ["--pack", "/absolute/path/to/pack"],
    "tokenizer_dir": "/absolute/path/to/tokenizer"
  }
}

Keep the actual engine arguments from the qualified model profile. An external executable path continues to work even in a payload build. Missing payload or unsupported platforms fail before the HTTP listener opens when @embedded is selected. The Linux supervisor copies the embedded bytes into an anonymous executable memfd, seals content and size changes, and retains its descriptor through worker restarts. The descriptor is released after worker shutdown; there is no persistent extraction directory. This consumes RAM proportional to engine size in addition to the executable's mapped pages. /proc access and an OS policy allowing executable memfds are required; the runtime does not change kernel policy. See the Linux memfd documentation and executable memfd policy.

One packaged executable does not yet mean a fully static GPU runtime. The current qualified engine still needs host libcudart.so.13, libcublas.so.13, C++/C runtime libraries and the NVIDIA driver. These are not embedded, and the engine's existing library search paths remain unchanged. Model/tokenizer assets also remain external. Do not deploy this preview to a clean host assuming a driver alone suffices, or replace a running user trial to test packaging. The synthetic CPU packaging check exercises supervisor behavior without GPU qualification. A production single-file package still needs library/linking, clean-node, real-model and license/distribution gates.

Validate configuration before switching a service

strata-next check-config --config /absolute/path/to/native.json

This native command reads the same configuration, environment overrides, key file and tokenizer assets as serve. It checks that an external engine resolves to an accessible executable file (including PATH lookup), or that the selected embedded engine is present in a Linux build. Bare executable names require PATH; an explicit executable path avoids lookup ambiguity. Run it with the same user, working directory and environment as the intended service.

The existing laptop controller can run this check over SSH after installing its updated helper:

python3 scripts/install-qwen-native-service.py
qwen-codex-ctl native-service check-config --host rnr5090 \
  --binary /absolute/path/to/candidate/strata-next \
  --config /absolute/path/to/native.json \
  --working-dir /absolute/path/to/engine-workdir

All three paths refer to the remote host. This uses the SSH login environment; it does not source a systemd environment file, upload files, install a unit or change the selected connection. The candidate must already support check-config. The client filters the returned JSON and suppresses raw remote errors. SSH stdout is capped at 64 KiB with a 30-second local deadline; on failure the local SSH process is terminated, which is not a guarantee that a remote process has exited. Only invoke an explicitly chosen, trusted candidate executable.

Success prints JSON with configuration_valid, engine, tokenizer_validated, authentication_enabled and inference_configured. The last field means both engine and tokenizer are configured. A control-plane-only config can also pass. Keys, engine arguments and raw file contents are not printed; failures identify the config/key, executable or tokenizer stage and return nonzero.

The check does not execute the worker, extract the embedded payload, bind the configured port, contact a running server or inspect model weights. Files and permissions may change after it runs. readiness_checked is always false: shared libraries, driver compatibility, model loading, available ports and real generation still require deployment qualification. An already occupied port is allowed so the candidate can be checked while the current service keeps running.

Linux engine with static CUDA toolkit libraries

STRATA_CUDA_STATIC=ON is an optional Linux/GNU C++ build profile. It selects CMake's static CUDA runtime and cuBLAS targets and statically links the engine's GNU C++ runtime. The default CUDA profile continues to use shared toolkit libraries. HIP and non-Linux/GNU configurations reject this option.

On a Linux builder with the toolkit and CMake already installed:

export CUDACXX=/absolute/path/to/cuda/bin/nvcc
export CUDAToolkit_ROOT=/absolute/path/to/cuda
# Optional existing pinned llama.cpp checkout; otherwise CMake fetches its pinned source:
export STRATA_GGML_DIR=/absolute/path/to/llama.cpp
BUILD_JOBS=2 scripts/build-static-cuda.sh

The script builds only strata, using SM 120 and portable AVX2 GGML defaults; CUDA_ARCHITECTURES and STRATA_BUILD_DIR can override the build target/path. It audits ELF dependencies and runs only --help with no GPU visible. It does not install anything, serve a model, change a service, or run a speed test. CMake's imported targets provide the static dependency closure; see the FindCUDAToolkit reference.

The measured CUDA 13.2 build has only libm.so.6, libc.so.6 and the host loader in DT_NEEDED, with no RPATH/RUNPATH. It is 593,942,184 bytes. This host's GNU build requires glibc 2.43; build against an older supported glibc baseline before targeting older distributions. The audit reports this symbol-version minimum. NVIDIA's installed driver remains required. ELF direct dependencies do not establish whether runtime-selected CUDA paths use additional dlopen components; real-model and clean-host qualification are still necessary.

This private candidate has not replaced the user's running engine. The bounded large-payload path can now include it in one executable under the 1 GiB cap. The combined static-CUDA preview is 611,277,088 bytes. On Linux it passed embedded identity verification and engine-help with LD_LIBRARY_PATH unset and no GPU visible. The outer musl executable has no ELF interpreter or DT_NEEDED entries; the embedded engine retains the glibc/driver requirements above. The earlier 63 MB combined preview remains a separate fallback containing the dynamic engine. See the packaging report. No quality, numerical parity, speedup or production-ready claim follows from linking successfully. Keep the default profile until the model gates pass.

The optional static_cuda_package workflow-dispatch job performs the build and ELF audit on the private CUDA runner without inference. It publishes no package and cleans its private build directory. The runner must have the required compiler/toolkit in its environment; hosted execution has not yet occurred.