<!-- source: https://docs.dreamlake.ai/lakeshore/hosts/native-cartpole-demo @ 0.1.192 b2f973b1 -->
# Native Cartpole terminal demo

This development-only demonstration is unreleased until its backend, native
queue routing and configured worker installation have been verified together.
It evaluates four fixed Cartpole policies with deterministic replay; it does
not train a model. EC2 uses one existing enrolled machine. Slurm uses an
existing enrolled controller and a bounded two-node CPU allocation.

The Compute development action prepares a short-lived grant, opens a fresh
terminal for that exact enrollment, then executes an inline Python launcher.
The launcher submits and reads one native Lakeshore invocation. Namespace
credentials stay on the backend. The grant can only launch the fixed demo on
its configured enrollment and read that invocation; it cannot submit arbitrary
code, change resources or inspect other jobs. Results are printed in the
terminal and are not automatically indexed.

The authenticated preparation endpoint is
`POST /namespaces/:slug/native-demos/cartpole/prepare`, with
`{backend: "ec2" | "slurm", enrollmentId, requestId}`. Its response contains
`target: {hostId, enrollmentId, machineId, unixUser, name}`, `command`,
`expiresAt`, `queue` and `invocationId`. Preparation does not enqueue work.
The returned command sends its grant in a JSON request body to
`POST /native-demos/cartpole/launch`, then polls
`POST /native-demos/cartpole/status`. Never put the grant in URLs or browser
history. Launch grants expire after two minutes; result access expires after
ten minutes. Ownership and namespace permission are checked on every request.
Repeated launches reuse the native invocation ID and cannot create another
job. Reusing a request ID for a different payload conflicts.

The invocation is submitted with native worker affinity for the exact enrollment.
The backend also verifies the completed invocation's worker receipt before
returning results. Slurm's two compute-node shards execute inside that native
invocation using `srun`; they do not start another task queue.

Deployment requires a dedicated signing key, a non-admin namespace credential,
and an explicit allowlist of installed demo targets. Each target has a dedicated
native queue with only that enrolled worker as a member. Its existing default
membership stays intact. Missing installation, stale enrollment, unexpected
membership or a removed permission fails closed. No instance is provisioned.
Stopping terminal polling does not cancel an invocation: retain its printed ID
to inspect it in Compute. The UDF enforces a five-minute wall deadline, with up
to five additional seconds for child cleanup. The Slurm allocation is limited
to five minutes. Current Nymph process workers do not support cancelling a
running native invocation through Compute; do not assume closing the terminal
stops execution.

These internal development endpoints do not change a public CLI/SDK workflow.
The generated docs reference describes the development boundary; no public
skill action guide or installer changes are required.
