The Offloadr runner: the agent that executes GPU work for the Offloadr control plane, and the container images it ships in. The same images serve personal runners (users' own GPUs) and hosted runners (GPUs Offloadr rents). Licensed AGPL-3.0-only.
contracts/: protobuf for the runner protocol, copied from the control plane. Seedocs/contracts-sync.md.src/Offloadr.Runner.Contracts: C# generated fromcontracts/at build time (Grpc.Tools), plus small shared helpers.src/Offloadr.Runner.Core: transport, authentication, registration backoff, logging relays, model transfer (aria2), status file. Must not depend on Linux-only code.src/Offloadr.Runner.Linux: the in-container session runtime: command loop, per-session Linux users, editor child process, model VFS shim and its IPC, demand-aware hydration, workspace/artifact mirroring.src/Offloadr.Runner.Agent: the container entry point (assemblyRunnerAgent) andDockerfile.src/Offloadr.Runner.Supervisor: runs the runner container on a desktop (settings, Docker CLI, launch plans, supervision). Never shipped in the image.src/Offloadr.Runner.UI: Razor class library with the app's pages (MudBlazor). No logic beyond presentation; it readsRunnerSupervisor.src/Offloadr.Runner.Desktop: Windows MAUI Blazor Hybrid host (assemblyOffloadrRunner). Built fromrunner.desktop.slnx, which needs themaui-windowsworkload;runner.slnxbuilds everything else on any OS.build/:test-linux.sh(full suite in a container),publish-windows.ps1(desktop app and installer),verify-windows-signatures.ps1(its signatures) andverify-published-image.sh(post-push registry proof for image releases).docker-bake.hcl: the four published image variants.tests/Offloadr.Runner.Tests: NUnit suite. Linux-native tests live inLinux/and need root,gccandaria2c.tests/Offloadr.Runner.Supervisor.Tests: supervisor tests with fakes; they run on any OS.RUNNER_REAL_DOCKER_IMAGE=<image>enables one test against the real Docker engine, andRUNNER_REAL_API_ORIGINwithRUNNER_REAL_KEYone against a real control plane.docs/: architecture, hosting guide, contracts sync, and the manual GPU release checklist (release-checklist.md), since CI has no GPUs.
- Follow the existing style of the file you edit. Keep changes scoped to the task.
- Do not hand-edit generated code; change
contracts/instead. - Core must not reference Offloadr.Runner.Linux. Supervisor, UI and Desktop must never reference Offloadr.Runner.Linux.
- Never log secrets, signed URLs, plaintext artifact keys or bearer metadata.
- One current protocol (
RunnerProtocol.RUNNER_PROTOCOL_CURRENT). Coordinated protocol changes raise it and update both sides directly; an outdated runner is refused and told to update. Do not add backward-compatibility shims or preserve superseded wire layouts. Seedocs/contracts-sync.md. - A runtime is named by
RuntimeRef(runtime_id,runtime_order). The Stop acknowledgement usescommand_id = 3, stringinstance_id = 4and the echoedup_to_runtime_order = 11. Earlier layouts are intentionally unsupported. - Keep all five shared definitions identical with the control plane and regenerate affected consumers as described in
docs/contracts-sync.md.
- The agent is an authenticated external executor of exact control-plane commands. It does not own durable allocation, lifecycle, restart, Stop, prompt or metering decisions.
- Heartbeat registration (
RegisterRunner) is the authoritative liveness lane; other traffic does not silently refresh liveness. - The agent registers as
RUNNER_ROLE_EXECUTOR. The desktop app may register the same runner asRUNNER_ROLE_LAUNCHER: that heartbeat means only "can start these editors". It never stands in for executor liveness or protects a session, and the launcher starts a container only for the launch the latestLauncherStateon a connected stream names (docs/contracts-sync.md, Launchers). Shared registration code lives in Core (RunnerRegistrationLoop). - Keep long-running status, command, event, artifact/workspace and operational lanes independently cancellable and reconnectable.
- Validate and retain exact runner, session, command and runtime (
RuntimeRef) identity through execution and acknowledgement. Two runtimes are the same when theirruntime_idis; the higherruntime_orderis newer, across sessions.lifecycle_generationonly matches GPU power commands. - A start is refused when its order is at or below its session's Stop cutoff or the eviction floor, below the newest start adopted, or equal to it with another id; any start but a repeat of the adopted runtime is also refused at or below the settled order. A repeated start of the adopted runtime joins its startup or replays its recorded acknowledgement; it never launches twice. A newer start replaces: it cancels the startup in flight, stops the session's older child (or pre-empts another session), then launches.
- A Stop compares once: a runtime, child or startup of its session above its cutoff makes it superseded, and it does nothing. Otherwise it records the cutoff before cleanup.
- The settled order (
RuntimeStatus.settled_runtime_order) rises when a start is adopted, when a start ends not ready (before its acknowledgement is sent) and when a Stop records its cutoff. It never reaches a start that is admitted and not yet adopted, and it is read in one snapshot with the session. Nothing starts at or below a value a status carried. - Never apply an older command to a newer runtime or logical session.
- Retry acknowledgements with the same result and identity without re-executing a completed action.
- Distinguish host shutdown cancellation, workflow cancellation, Stop and command failure. Host shutdown is never a successful acknowledgement.
- Preserve the logical runner session through an intentional child-runtime restart. A relaunch keeps the session's sealing and may not weaken it.
- Clear matching logical session and runtime identity state after failed start cleanup or unexpected child exit, so heartbeats do not protect a dead process.
- Cleanup tolerates partially started sidecars, already-stopped processes and repeated calls.
- Gate runtime-specific probes and behavior explicitly by runtime kind (ComfyUI, Forge Neo, future runtimes).
- Preserve Linux-only assumptions in Offloadr.Runner.Linux unless adding explicit multi-platform support.
- Cover duplicate and stale commands, acknowledgement replay, reconnect ordering, cancellation classes, and Stop during startup or restart.
- Cover the start and Stop orderings: a Stop before an older delayed start, an older Stop after a newer start, a repeated start while launching and after it finished, a newer start for the same session, an evicted Stop cutoff, and a start for an older assignment. Cover the settled order for each: refused, failed before adoption, admitted and not yet adopted, a cutoff with no session held, and a superseded Stop.
- Verify failed start and unexpected-exit cleanup clears only the matching logical session and runtime identity.
- Test runtime-kind gating, native connection bridge state and reconnects, the heartbeat's runtime status, and idempotent process/download/workspace/artifact cleanup.
- Linux-native tests call
LinuxTestPrerequisitesand are ignored elsewhere;RUNNER_NATIVE_TESTS_REQUIRED=1turns a missing prerequisite into a failure (CI sets it).
- Build:
dotnet build runner.slnx -warnaserror - Format:
dotnet format runner.slnx --verify-no-changes - Tests on Linux:
dotnet test runner.slnx - Full suite from Windows (runs in a Linux container):
./build/test-linux.sh - Contracts lint:
buf lint contracts - One image:
docker buildx bake comfyui-latest --load - Desktop app (Windows):
dotnet build runner.desktop.slnx -warnaserror; setOFFLOADR_RUNNER_DATA_DIRECTORYto a scratch folder when trying it, so your own settings and runner key are untouched.
- Commit as the identity configured in this checkout. Keep subjects imperative and short.
- Do not reference private repositories, internal plans or internal environments in commits, code or docs.