18 KiB
Shared node protocol (STRA-58/59)
Requirements for the first executable slice, 2026-10-04:
strata.node.v1.Nodeis the same authenticated gRPC API for local loopback and SSH-forwarded remote loopback. No public bind; no unauthenticated localhost.- Handshake requires protocol version 1 and returns an agent epoch, state cursor and advertised capabilities. Unsupported features are absent from capabilities.
- Hardware and memory planning use bounded JSON v1 payloads inside typed protobuf envelopes, preserving the existing inventory/planner contract.
- Snapshot subscriptions are replaceable state, not an audit log. Every connection gets a consistent full snapshot; subsequent snapshots carry epoch/sequence. Slow observers coalesce state; clients replace state and do not replay inference.
- Responses RPC sends HTTP status/content type followed by byte-preserving body chunks and an explicit end marker. A transport failure is never successful EOF. The existing gateway owns model routing, admission and protocol validation. Inference has no automatic retry. Dropping a stream uses the gateway's existing cancellation/quarantine rule; it is not an engine cancellation acknowledgement.
- Bound request messages to 2 MiB plus envelope, output chunks to 64 KiB, subscriptions to 16 and live Responses RPCs to 64. Hardware refresh is serialized and explicit; planning reuses a snapshot for at most five seconds. No prompts, response bodies, tokens or credentials enter diagnostics/state events.
- Desktop C# and Rust clients are generated from one
.proto. Standalone node may outlive UI; the owned desktop preview child is inventory/planning only and is shut down when that app exits. It cannot own active inference. - Real HTTP/2 tests must reject wrong credentials/version/public bind; exercise state reconnect, streaming tool bytes, resource release and concurrent control.
Not yet acceptance-complete: persistent model install/start/stop jobs, durable operation IDs, process restart reconciliation, automatic SSH provisioning, full inference resume, and real-model cross-platform backend qualification. These remain explicit STRA-58/59 and backend milestones, not advertised capabilities.
The local node-proxy command exposes authenticated Responses HTTP/SSE to the
harness and forwards only through the shared gRPC channel to a configured node.
It preserves status/content-type/retry-after and body bytes; requires headers,
then data, then exactly one end marker and successful gRPC completion. An error
or truncated stream fails the HTTP body. No redirects, proxies or automatic
inference retry. Both bind and node destination must be literal loopback IPs.
Run (development)
Build with cargo build --locked --manifest-path desktop-core/Cargo.toml.
Protobuf generation uses a build-only vendored protoc; deployed binaries do not
require protoc, Python or .NET. Use a fresh secret of at least 32 printable ASCII
bytes supplied through an environment variable from your credential store.
strata-desktop node --listen 127.0.0.1:18766 --token-env STRATA_NODE_TOKEN
# Explicitly attach only already managed, ready and exclusively assigned workers:
strata-desktop node --listen 127.0.0.1:18766 --token-env STRATA_NODE_TOKEN --pool /absolute/private/pool.json
# Harness-facing endpoint on the app host; --node may be an SSH-forwarded port:
strata-desktop node-proxy --listen 127.0.0.1:18765 --node 127.0.0.1:18766 --token-env STRATA_NODE_TOKEN
The first two commands are alternatives. Pool schema is described in POOL.md;
node and its embedded gateway use the node credential. Backend credentials remain
separate per-deployment environment references. The node only prints its public
loopback endpoint descriptor, never the credential. Standalone nodes keep running
when UI disconnects. --stdio-lifetime is reserved for the desktop-owned
inventory-only child and cannot be combined with --pool.
node-proxy requires the node Responses capability; an inventory-only node
correctly fails that handshake. The initial proxy uses the node credential for
its local harness endpoint too. Per-client authorization is a future extension.
active_responses counts transport requests including queue waits, not GPU slots;
a disconnected stream may leave a backend quarantined until verified recovery.
Snapshot events cover these transport counters, not a durable job history.
Verification
Real loopback HTTP/2 tests include auth/version/limits, independent control during streaming, new epoch snapshots, byte-identical tool-call SSE, incomplete terminal failure and quarantine, client disconnect, and HTTP→gRPC→HTTP adapter path. C# headless app self-check runs the actual Rust executable and generated client. No real model requests are sent by these tests. Durable lifecycle and remote install remain unqualified and unadvertised. The transport reconnect implementation is described below.
Verified on 2026-10-04, macOS Apple Silicon: all 33 Rust tests passed; strict Clippy and RustSec audit passed. .NET locked restore/build and C# self-check passed. Two separate C# app connections to one external test node completed; app exit left that node alive. Wrong credentials were rejected. Test node was removed afterward. NuGet reported no known vulnerable direct/transitive packages. Hosted CI, Windows/Linux native execution and real-model transport are not yet verified. Active user RTX5090 runtime was untouched.
Recovery requirements (STRA-59)
Each node has an independent owned connection monitor. States: connecting,
ready, disconnected, auth_error, protocol_error. ready means a fresh node
connection, not proof of model readiness. New proxy admission requires a snapshot
heard within 15 seconds and the advertised Responses capability. A 5-second
heartbeat, with a 5-second RPC deadline, detects an idle broken connection.
Reconnect uses capped 200ms→10s exponential backoff with jitter. Invalid auth or
protocol/sequence state stops retries until configuration changes. State events
replace snapshots; epoch changes reset the cursor, same-epoch regressions fail.
Observer loss never releases backend slots or reissues an inference request.
The proxy exposes authenticated /node/status with connection state and numeric
snapshot only. In-flight failures retain their explicit interruption behavior.
The desktop displays connection status separately from hardware/model status,
observes snapshot changes and reconnects independently of UI actions. Dropping
its observation cancels that monitor, not the external agent. Restarting the
owned inventory-only child is allowed; restarting external workers is not.
Acceptance: same-port agent crash/restart recovers with a fresh epoch, offline requests are rejected before inference dispatch, wrong credentials do not spin, one failed node does not block another, monitor drop ends its tasks/subscription, and existing streaming/tool integrity tests remain passing.
Recovery implementation verified 2026-10-04: Rust Connection and the desktop
observer automatically reconnect with bounded backoff/jitter and heartbeat.
The proxy's authenticated /node/status reports freshness, epoch, sequence,
transport request count and capabilities, never request bodies. It refuses new
work when the node state is stale/disconnected. Inference calls are never
application-retried. Subscription snapshots replace state, not durable job logs.
36 Rust tests passed, including actual child process kill/restart on the same
port, independent nodes, terminal auth errors, offline startup and releasing
20 successive observer subscriptions. C# recovered from an actual isolated node
restart; the repeatable CI fault test is python desktop/tests/reconnect.py.
Python is only a test orchestrator and is not part of serving or deployment.
Remaining switch gates: managed model/process lifecycle, durable operation reconciliation, verifying backend readiness after node restart (node connectivity alone is insufficient), real-model harness test, platform qualification and managed SSH tunnel recreation. An existing tunnel can recover and the gRPC client reconnects, but this slice does not create/restart SSH processes.
Managed worker profile (STRA-58)
Implemented CLI/gRPC slice: one trusted, operator-installed profile per node. It binds an absolute executable and bounded argv to a model identifier and loopback HTTP endpoint. gRPC exposes typed Start/Stop/Status with an operation UUID; no RPC can supply executable, shell text or arbitrary arguments. Spawn a direct child with restricted inherited environment, null logs, and no node credential inheritance.
Admission starts CLOSED. Start refuses an occupied endpoint, launches only its
configured process, polls bounded /health and requires status=ok, loaded=true,
model=expected while the child remains alive before opening admission. Child exit
closes admission. Stop closes admission first, waits for admitted work to drain,
and kills/reaps only its owned child. Drain timeout leaves admission closed and
reports failure; no implicit force termination of active inference.
An actor owns operations independently of RPC lifetime. Up to 256 operation IDs are retained for this process epoch, matching duplicate returns prior status, conflicting payload is rejected, and at capacity new IDs are refused (no unsafe eviction). This is process-local idempotency; durable restart reconciliation is not claimed. Agent restart starts closed and never adopts/kills an existing PID. An orphan still holding the endpoint causes Start to fail explicitly. Profile installation and orphan recovery remain separate provisioning/lifecycle gates. Tests launch synthetic local fixture processes only, without real model requests.
The profile is a JSON file on the node, installed by its operator:
{
"schema_version": 1,
"id": "my-model",
"model": "backend-model-identifier",
"executable": "/absolute/path/to/worker",
"args": ["--serve", "--port", "18090"],
"endpoint": "127.0.0.1:18090",
"startup_timeout_ms": 120000,
"capabilities": ["responses"]
}
The executable must remain in the foreground and expose HTTP Responses and the health contract described above. Configure its real supported arguments; the example is not a generic adapter for arbitrary engines. The profile ID is the public gateway model ID; the model field is sent to the backend and checked against health. Capabilities default to responses only; declare tools, reasoning, structured_output, image/audio/file only after adapter verification. One slot is reserved for the exclusive managed worker; the initial resource budget is a slot sentinel, not an estimate of memory or automatic hardware admission.
strata-desktop node --listen 127.0.0.1:18766 --token-env STRATA_NODE_TOKEN --worker-profile PROFILE.json
strata-desktop worker --node 127.0.0.1:18766 --token-env STRATA_NODE_TOKEN status
strata-desktop worker --node 127.0.0.1:18766 --token-env STRATA_NODE_TOKEN start OPERATION_UUID
strata-desktop worker --node 127.0.0.1:18766 --token-env STRATA_NODE_TOKEN operation OPERATION_UUID
strata-desktop worker --node 127.0.0.1:18766 --token-env STRATA_NODE_TOKEN stop ANOTHER_UUID
Supply a private credential through the environment; start/stop return accepted, not completed. Poll operation with the same UUID; never infer success from acceptance. CLI stop uses a 30-second drain grace. A lost connection can query the same ID in the same node epoch; unknown ID after node restart requires explicit reconciliation, not automatic resubmission. Node capability is worker.lifecycle.v1. Existing inventory-only UI children cannot own models; managed nodes stay independent of UI lifetime. Profile installation remains pending; the desktop now exposes lifecycle buttons for an explicitly configured persistent node.
The child receives STRATA_WORKER_ENDPOINT and STRATA_WORKER_MODEL alongside a restricted platform environment. Backend stdout/stderr are discarded. An owned process exit is observed within the 200 ms polling interval; runtime liveness beyond process exit is not yet supervised after startup. Starting a replacement clears previous_response_id ownership, preventing affinity to a lost conversation. No inference request is retried by lifecycle.
Validation on macOS: real Rust fixture children, real gRPC and CLI subprocesses; start/stop/auth/dedup/conflict, exact response bytes (zero tolerance), restart affinity rejection, wrong model/occupied endpoint fail-closed, child crash and explicit restart, drain timeout preserves active request. The ignored fixture entry is invoked as a subprocess by the tests, not an omitted quality check. These are synthetic protocol/process tests, not model quality or speed results.
Desktop lifecycle controls
A configured persistent node exposes model phase and explicit Start/Stop buttons. The inventory-only app-owned node cannot launch models. UI submits one UUID once, polls its outcome after reconnect, and never retries a mutation after uncertain delivery. Expected node epoch fences mutations; a changed epoch or missing operation requires explicit operator reconciliation. UI closure cancels only client observation, never stops the external worker. No automatic Start on app launch, no SSH provisioning or user runtime adoption in this slice.
The UI controller keeps one outstanding operation ID for the lifetime of that window. Start/Stop are disabled when state is unavailable, the worker is transitioning, or an operation remains unresolved. Each explicit command first reads fresh worker state. Acknowledgement loss triggers status queries only; the command is not resubmitted. Expected epoch is sent by both current CLI and desktop; the node rejects mismatching nonempty epochs before enqueueing. Empty epoch remains accepted for earlier v1 clients. This is additive protobuf compatibility, not durable cross-restart idempotency.
The UI polls managed status every second with bounded RPC deadlines, separately from the connection observer. A changed node epoch or missing operation retains the UUID and blocks new UI commands with a reconciliation message. Pending state is currently in memory: closing/reopening the app reads authoritative worker state but does not recover the previous UI operation journal. Auto-download/provision, profile selection and durable reconciliation are still outstanding.
Verification: python desktop/tests/lifecycle.py exercises the same desktop
controller and generated C# client against an actual isolated Rust node and
synthetic backend process. It injects lost acknowledgement after real commands,
confirms polling reaches completion with exactly one submit, closes/reconnects
the client without stopping the worker, checks exact synthetic Responses bytes,
and stops the owned worker. A deterministic replacement-epoch fixture verifies
that uncertain commands remain blocked. Rust gRPC tests additionally verify
rejection of a stale epoch with the worker still stopped. No active remote node
or user inference is involved. Python is only the offline test fixture/runner.
Durable node journal
Optional operator-supplied --journal PATH uses an exclusively locked private, bounded append-only file and binds history to a SHA-256 fingerprint of the installed profile (not stored command paths/arguments). Persist+sync accepted before returning acknowledgement; persist running before side effects and final outcome after execution. Reopening preserves terminal outcomes; accepted/running operations become indeterminate, never replayed. Unresolved recovery or journal I/O failure closes admission and blocks new commands for operator reconciliation. No automatic PID adoption, no promise of exactly-once external effects after a crash. Corrupt/torn records reject startup without truncating evidence.
Usage: append --journal /absolute/private-directory/operations.jsonl after
--worker-profile PROFILE.json. The parent directory must already exist.
Unix permissions are checked (directory 0700, regular single-link file 0600);
on Windows use an operator-owned directory with a private ACL. Windows ACL and
power-loss durability qualification are not yet complete. The node holds a
nonblocking exclusive OS file lock for its lifetime. The journal is limited to
4 MiB and 256 UUIDs; there is no automatic eviction/rotation. This limit is
intentional until archival/reconciliation can retain deduplication guarantees.
The journal contains profile fingerprint, UUID, action, drain grace, expected epoch, status and fixed reason codes. It stores no argv, paths, prompts, weights, credentials or backend logs. SHA-256 uses the same sha2 0.11 line as the existing control plane. The semantic duplicate check compares action and grace; transport epoch may differ on an explicit same-ID retry. Epoch fencing still happens first, and a stale epoch never executes a command.
With a journal the node advertises worker.journal.v1. Desktop may look up an
outstanding command in a replacement epoch that advertises durable history.
Terminal outcomes reconcile without resubmission. Missing/indeterminate history
blocks new UI actions; node recovery uncertainty also rejects new mutations.
The persisted result is historical and does not assert a model is still running:
current worker state/admission is closed after restart. No old PID is adopted.
Operators must reconcile orphan processes and uncertain side effects; automated
recovery resolution and durable desktop-window journal remain pending. Do not
delete/rotate the journal to bypass an unresolved operation.
Validation: five journal tests cover retained final outcomes, interrupted command conversion/no replay, exclusive lock, profile fingerprint mismatch, torn/invalid history, size bounds, failed append preserving evidence and blocked mutation. The desktop lifecycle test also kills/restarts an actual isolated node, queries the prior completed command, and retries that UUID to confirm history is returned. Synthetic Responses remain byte-exact. Mac-only evidence; no real-model, Windows/ Linux runtime, performance or sudden-power-loss claim.