Hosted Runtime Image¶
The hosted runtime image packages cruxible (daemon included) for private runtime
containers. It starts the daemon (cruxible server start) as a non-root
cruxible user and uses /var/lib/cruxible as its explicit state root.
Build with any Docker-compatible backend. OrbStack works for local development:
Run with a mounted state root and a runtime-supplied bootstrap secret:
STATE_DIR="$(mktemp -d)"
chmod 0777 "${STATE_DIR}"
docker run --rm \
-e CRUXIBLE_RUNTIME_BOOTSTRAP_SECRET=bootstrap-secret \
-v "${STATE_DIR}":/var/lib/cruxible \
-p 127.0.0.1:8100:8100 \
cruxible-core-runtime:test
The image intentionally fails fast if /var/lib/cruxible is not an
external Docker mount, or if the non-root cruxible user cannot write to it.
This prevents hosted runtime state from being stored only in the container's
ephemeral filesystem layer.
The external Cloud control plane (the separate cruxible-cloud-api package, not
cruxible) is what prepares each runtime state root before
starting the runtime container. By default it applies mode 0777, matching the
local smoke-test pattern above so the non-root container user can write through
the bind mount on a normal Linux host. Tighter host-ownership modes are
configured on that control plane, not through any cruxible environment
variable an operator of this image sets directly.
Verify the server:
Expected response:
Do not bake bootstrap secrets or runtime credentials into the image. Provide them at container runtime through environment variables or the future deployment secret layer.
Provider lane precondition¶
The daemon runs Provider code in child processes it reaches over Unix control
sockets, and a Unix socket path holds at most 103 bytes. The daemon puts them
under <state-root>/c when that fits, which /var/lib/cruxible does;
otherwise it needs a private per-user runtime directory, XDG_RUNTIME_DIR on
Linux, which containers rarely set. A derived image or a run that moves the
state root to a longer path (about 80 bytes or more) without one comes up
with the Provider lane unavailable: server start prints
Warning: Provider lane unavailable; ... with the cause (byte counts and the
variable, never a path) and the repair, then serves everything that needs no
installed Provider code, and server status keeps reporting the lane code
provider_runtime_directory_unavailable. Kit add, provider install and
Provider-backed Procedure and Line runs refuse with that code (HTTP 503; an
operational_failed run). Repair: keep the state root short, or set
XDG_RUNTIME_DIR to a short directory owned by the cruxible user with mode
0700, and restart the container.
Publishing the image¶
.github/workflows/publish-runtime-image.yml is the supported way to publish
this image. It builds deploy/runtime/Dockerfile for linux/amd64 and pushes
it to GHCR under the repository namespace:
<version> is the pyproject.toml package version and <sha12> the first 12
characters of the built commit. The workflow never publishes or moves latest.
Dispatch from a reviewed SHA¶
- Pick the reviewed commit and copy its full 40-character SHA. A short SHA is rejected by the verification step, and a branch name builds whatever the branch points at today.
- Run the workflow: Actions -> Publish runtime image -> Run workflow, with
source_refset to that SHA. - The build job checks out exactly that ref and refuses to continue unless
git rev-parse HEADequals the requested SHA. - Read the run summary. It reports source SHA, version, tag, digest, and
whether the image was rebuilt, and prints the digest-pinned reference to copy
into a deployment. The same values are job outputs (
image,tag,version,source_sha,digest,image_ref,rebuilt).
Pushing a v* release tag runs the same publish for the tagged commit,
alongside the PyPI publish in publish.yml. On that trigger the tag must equal
v<package version>.
Immutability¶
A published tag is never overwritten:
- Before building, the workflow asks the registry for the tag. Only an explicit
"absent" response authorizes a push; an auth or transport failure fails the
job instead of being read as "unpublished". The lookup exchanges its
credential for a registry token first (
.github/scripts/ghcr-tag-digest.sh), becauseghcr.io/v2does not reject an unusable bearer token — it downgrades the request to anonymous access, which would make a private published tag look absent. - If the tag exists, nothing is built and nothing is pushed. The workflow reuses that digest, so re-dispatching the same commit is a cheap no-op that re-reports the same digest.
- Before reusing a tag, its
org.opencontainers.image.revisionandorg.opencontainers.image.versionlabels must match the requested source. A tag that was moved onto some other build fails the job; it is not adopted. - After pushing, the tag must still resolve to the digest this run produced, which closes the window between the existence check and the push.
Every image carries org.opencontainers.image.source, .revision, .version,
and .created.
Verification¶
A second job runs with packages: read, pulls the image by digest, checks
its revision and version labels, and runs tests/test_image against it — the
same suite CI runs against a locally built image. Setting
CRUXIBLE_RUNTIME_IMAGE_REF to an already-pulled reference makes the module
fixture use that image instead of building one, so the published artifact is
what gets checked for the non-root user, the bundled oras version, /health,
and the external-state-mount contract. The variable requires the image to be in
the local store already; the tests never pull it.
The same override works locally:
docker pull ghcr.io/<owner>/<repo>/runtime@sha256:<digest>
CRUXIBLE_RUN_DOCKER_TESTS=1 \
CRUXIBLE_RUNTIME_IMAGE_REF=ghcr.io/<owner>/<repo>/runtime@sha256:<digest> \
uv run pytest tests/test_image -m docker
Repository linkage and package visibility¶
These are two different settings on the package, changed in two different places, and neither one implies the other. Both are one-time setup after the first publish.
1. Repository linkage decides which repository's permissions govern the
package and makes the package show up on the repository page. The workflow
labels every image with
org.opencontainers.image.source=<server_url>/<owner>/<repo>, which is what
GHCR uses to link the package to this repository automatically. If a package
ever shows as unlinked, connect it by hand: GitHub -> the package page ->
Package settings -> Manage Actions access / Connect repository. Linking
grants the repository's collaborators and its workflows access to the package;
it does not change who outside the repository can pull it.
2. Package visibility (private / internal / public) decides whether a
credential is needed to pull at all. A newly published container package is
private, regardless of whether the repository that built it is public — a
public repository does not publish public packages, and linking a package to a
public repository does not change the package's visibility either. Change it
on the package's own settings page: Package settings -> Danger Zone ->
Change visibility -> Public. Anonymous docker pull then works with no
docker login.
Publishing always requires the workflow's packages: write token, whichever
visibility the package has.
Pull auth for a private package¶
While the package is private, every consumer needs a credential, including a deployment host:
echo "<personal-access-token>" \
| docker login ghcr.io -u <github-username> --password-stdin
docker pull ghcr.io/<owner>/<repo>/runtime@sha256:<digest>
The token must be a classic PAT with the read:packages scope, and its owner
must have access to the package — either through the linked repository or
directly (GitHub -> the package page -> Package settings -> Manage access).
read:packages is pull-only; never give a deployment host a token with
write:packages.
Pin the digest¶
Deployments reference .../runtime@sha256:<digest>, not the tag. The immutable
tag is a human-readable handle for finding the digest; the digest is what proves
which bytes are running. latest is never published, so nothing on a host can
drift by pulling it. Record the digest wherever the deployment ref is
configured, and re-run the workflow dispatch — not a manual docker build — to
obtain a new one.
Shared Profile Customer Code Policy¶
Set CRUXIBLE_HOSTED_SERVER_PROFILE=shared for runtimes that may host
untrusted or multi-tenant material. In this profile the daemon executes no
Provider code at all: procedure run, line run and provider install refuse
with the public-safe error code customer_code_execution_unsupported and the
detail isolation backend not implemented, and the refusal happens before any
tenant secret is resolved and before any child process exists.
Execution is permitted only when an isolated executor is REGISTERED in the
running build, not when one is merely named in the environment. Registration
goes through the typed seam in runtime/execution_policy.py:
register_isolated_executor() takes an object publishing an
IsolatedExecutorRegistration record -- a backend_id, the exact
implementation_digest doing the isolating, and its capabilities -- and
registered_isolated_executors() reports what this process has. Cruxible registers
none, so CRUXIBLE_HOSTED_ISOLATED_EXECUTION_BACKEND cannot re-enable execution
today. The variable is the selector: it names which REGISTERED
backend to use, and a value naming an unregistered backend refuses with that
backend named in the detail.
Packaging an executor for discovery¶
A tenant image ships its executor as an ordinary installed distribution that
advertises the entry-point group cruxible.isolated_executors:
[project.entry-points."cruxible.isolated_executors"]
container = "my_executor_package:ContainerExecutor"
The daemon iterates that group ONCE at start, before it serves anything, loads
each object — a class is constructed with no arguments; an instance is taken as
it is — and registers what it publishes. This is the path for an out-of-tree
executor; a distribution that is installed but does not advertise here is not
registered, because a backend nothing declares is a backend nothing audited.
register_isolated_executor() remains the in-process seam for an embedded host
that builds the executor itself.
Discovery FAILS CLOSED, and it is all-or-nothing. An entry point that cannot be
imported, an object that does not implement the seam, an executor that cannot be
constructed, and a backend_id that collides with one already registered are
the same outcome: the daemon refuses to start, with error code
isolated_executor_discovery_failed naming the entry point's name, its target,
its group and the distribution that advertises it, and nothing in the group is
registered — not even the executors whose entry points loaded first. A bad
advertisement is a startup failure to repair, not a Provider lane that comes up
degraded. server status reports the registered backend ids on
the Provider lane, so an operator can confirm what a started daemon discovered.
The trust boundary is installation, and nothing else. Any distribution on
the daemon's sys.path that writes this group into its entry-point metadata
gets its object loaded, and the IsolatedExecutorRegistration that object
reports about ITSELF becomes the evidence that unlocks Provider execution under
the shared profile. There is no provenance check, no allow-list, no signature
and no digest pin on a discovered executor. That is defensible because anyone
who can install a distribution into the daemon's environment can already replace
the daemon, and it matches the Cloud model where the executor ships inside the
tenant image — but it means the image build, not the daemon, is what decides
which executor is trusted.
A non-empty CRUXIBLE_HOSTED_SERVER_PROFILE this build does not declare —
a misspelling, or a profile from a newer image — refuses typed with
hosted_profile_unknown rather than being read as "not shared". Both refusals
reach HTTP as 403 and reconstruct as their typed client classes.
Runtimes that must execute Provider code run without
CRUXIBLE_HOSTED_SERVER_PROFILE set: that is the ordinary single-tenant
profile, and it is unchanged.
Evidence Uploads¶
A hosted runtime has no workspace mounts, so a scan or log reaches it as an
upload. The operator names a daemon-owned staging directory outside the state
root in daemon/provider-runtime.json:
Optional limits sit beside it: upload_max_bytes (default 8 MiB per file),
upload_session_seconds (default 3600) and upload_max_open_sessions (default
8 per instance). Without upload_root the daemon refuses uploads
(cruxible.upload.not_configured).
An upload is three kinds of request, each at GOVERNED_WRITE by a principal that
can write here: POST /api/v1/{instance}/uploads opens a session for an exact
length, sha256 and file name; POST .../uploads/{upload_id}/parts/{n} sends one
part of at most 512 KiB as raw application/octet-stream, so every request
stays under the edge's 1 MB body cap; POST .../uploads/{upload_id}/complete
names the acquire Procedure (procedure, its other input, and
input_path_field, relative_path by default). Completing runs that Procedure
exactly as a direct run, at the caller's tier for it, with a one-file uploads
workspace as its only readable root; the Capture, its receipt, replay and the
import Line that fires on it are the ordinary ones. The staged file and its parts
are deleted when the run returns or fails. A session belongs to the principal
that opened it, takes each part once (a retry must be the same bytes), and
expires unfinished. The client's upload_capture does all three.
Private Runtime Network¶
Hosted runtimes should not publish port 8100 on the public host interface.
Public traffic should enter through external/future Cloud components — the edge
proxy or cruxible-cloud-api, neither of which ships in this repo — and
Cloud/API should reach runtimes over a private Docker network.
For local development, create a writable state directory and run the private network proof:
STATE_DIR="$(mktemp -d)"
chmod 0777 "${STATE_DIR}"
CRUXIBLE_RUNTIME_STATE_DIR="${STATE_DIR}" \
docker compose -f deploy/local/private-runtime-network.compose.yml up \
--build --abort-on-container-exit runtime-probe
The runtime service uses expose: ["8100"] for same-network discovery but
does not publish 8100 to the host. The runtime-probe service can reach
http://runtime:8100/health because it joins the same private Docker network.
On a future Droplet or VM deployment, this same boundary should be reinforced
with firewall/VPC rules: public ingress is limited to the edge proxy ports
(80/443) and SSH, while runtime port 8100 remains private to Cloud/API or
the runtime network.