Skip to content

Latest commit

 

History

History
205 lines (169 loc) · 8.05 KB

deployment.md

File metadata and controls

205 lines (169 loc) · 8.05 KB

Deployment

Uriel v1 is a local-first NixOS worker. It does not require a hosted coordination service. The worker owns job state, artifacts, Git worktrees, and QA evidence on the NixOS host.

1. Install The Worker

{
  services.uriel-worker = {
    enable = true;
    allowedRepos = [ "uriel-agent/uriel" ];
    maxConcurrentJobs = 1;
    androidAvds = [ "qa-1" ];
    androidBootTimeoutSeconds = 300;
    # Optional: install a checksum-pinned app before each Android harness.
    # androidApk = {
    #   url = "https://example.invalid/releases/qa.apk";
    #   sha256 = "<64 lowercase hex characters>";
    #   packageName = "com.example.qa";
    # };
    artifactRetentionDays = 14;
    environmentFiles = [
      "/run/secrets/uriel-worker.env"
    ];
  };
}

The environment file can be generated by sops-nix, agenix, or another NixOS secret mechanism:

URIEL_WORKER_TOKEN=...
GH_TOKEN=...
OPENCODE_MODEL=...
URIEL_ADAPTER_REPO_BOOTSTRAP=direnv
# Optional: run jobs with the Claude Code harness.
# URIEL_ADAPTER_HARNESS=claude-code
# ANTHROPIC_API_KEY=...
# Optional Codex selection knobs when URIEL_ADAPTER_HARNESS=codex.
# URIEL_CODEX_MODEL=gpt-5.6-sol
# URIEL_CODEX_EFFORT=high

Issue tracker, chat, and ingress integrations are optional adapters. Add their environment variables only when the deployment enables those adapters.

Claude Code Harness

Select the Claude Code harness globally with URIEL_ADAPTER_HARNESS=claude-code or per job with urielctl submit --harness claude-code. Headless authentication comes from environmentFiles: set ANTHROPIC_API_KEY, or a long-lived subscription token minted with claude setup-token (CLAUDE_CODE_OAUTH_TOKEN). The worker user's home is the state directory, so Claude CLI state lives under /var/lib/uriel.

Codex Harness

Select the Codex harness globally with URIEL_ADAPTER_HARNESS=codex or per job with urielctl submit --harness codex. The Codex CLI must be installed and authenticated for the worker user on the worker host; its authentication state lives under ~/.codex.

Useful NixOS module knobs:

  • allowedRepos: restricts the worker to specific GitHub URLs or owner/repo slugs.
  • maxConcurrentJobs: caps local worker concurrency.
  • callbackTimeoutSeconds: bounds each completion callback attempt (default 60 seconds).
  • artifactRetentionDays: enables tmpfiles cleanup for local artifacts.
  • enableBrowserQa / enableAndroidQa: include or disable QA toolchains.
  • androidAvds: provides exclusive per-job Android slots. Set maxConcurrentJobs no higher than the number of AVDs for an Android-only worker if every active job should start immediately.
  • androidBootTimeoutSeconds: bounds cold AVD boots (default 300 seconds).
  • androidApk: optionally downloads, verifies, caches, and installs a pinned QA APK before the coding harness starts. Its URL may use file:// for an operator-managed host-local artifact.
  • URIEL_ANDROID_APK_FINGERPRINT plus URIEL_ANDROID_COMPAT_FILE in an environment file: optionally fail Android jobs when the provisioned APK's 40-character fingerprint is absent from the repository-relative JSON compatibility file at the checked-out revision.
  • URIEL_ANDROID_APK_MANIFEST_FILE plus URIEL_ANDROID_APK_REFRESH_CMD: optionally let the worker refresh a stale APK itself instead of just failing the job. See "Automatic APK refresh" below.
  • extraPackages: adds repo-specific tools to the worker service PATH.

Automatic APK refresh

By default, an APK fingerprint that's absent from URIEL_ANDROID_COMPAT_FILE fails the job outright — the only way to recover is an operator manually re-provisioning the APK. Configuring URIEL_ANDROID_APK_REFRESH_CMD alongside URIEL_ANDROID_APK_MANIFEST_FILE lets the worker fix itself instead:

  1. On a compatibility mismatch, the worker runs the refresh command once (holding a lock file next to the manifest, so two concurrent jobs never run it at the same time) and re-reads the manifest.
  2. If the refreshed manifest's fingerprint is now in the compat file, the job proceeds with the refreshed APK.
  3. Only if the build is still incompatible after refreshing — or the refresh command exits non-zero, or no refresh command is configured — does the job fail. That failure message says whether a refresh was attempted and what it produced, so it's the last resort, not the first response.

URIEL_ANDROID_APK_REFRESH_CMD is an operator-supplied shell command run via sh -lc with a cwd of <URIEL_STATE_DIR>/android-apk-refresh (created on demand) and a timeout of URIEL_ANDROID_APK_REFRESH_TIMEOUT_SECONDS (defaults to 300). Its job is to fetch the current build and write URIEL_ANDROID_APK_MANIFEST_FILE — a JSON manifest:

{
  "fingerprint": "<40 lowercase hex characters>",
  "apkPath": "<absolute path to the downloaded APK>",
  "sha256": "<64 lowercase hex characters, optional>"
}

Extra keys are tolerated. sha256 is optional but verified against the APK on disk whenever present — a checksum mismatch fails the job loud rather than installing a corrupt download. When the manifest is present and valid, its fingerprint/apkPath override the static URIEL_ANDROID_APK_FINGERPRINT/ URIEL_ANDROID_APK_URL for both the compatibility gate and the actual install (the manifest's apkPath is installed the same way a static file:// URIEL_ANDROID_APK_URL would be); an unset, missing, or unparseable manifest falls back to the static configuration exactly as if no manifest were configured at all. The static URIEL_ANDROID_APK_URL / URIEL_ANDROID_APK_SHA256 / URIEL_ANDROID_APP_PACKAGE provisioning trio is still required — the manifest is an override on top of an already-configured provisioner, not a replacement for it.

Example refresh command sketch (adapt the fetch step to your build's actual distribution channel — a generic release API is shown here):

URIEL_ANDROID_APK_REFRESH_CMD='
  set -euo pipefail
  curl -fsSL -H "Authorization: Bearer $BUILD_API_TOKEN" \
    "$BUILD_API_URL/latest?platform=android" -o ./latest-metadata.json
  fingerprint=$(jq -r .fingerprint ./latest-metadata.json)
  download_url=$(jq -r .apkDownloadUrl ./latest-metadata.json)
  curl -fsSL "$download_url" -o ./current.apk
  sha256=$(sha256sum ./current.apk | cut -d" " -f1)
  jq -n --arg fp "$fingerprint" --arg path "$(pwd)/current.apk" --arg sha "$sha256" \
    "{fingerprint: \$fp, apkPath: \$path, sha256: \$sha}" > "$URIEL_ANDROID_APK_MANIFEST_FILE"
'

(gh release download against a private release repo, or any other org-specific fetch, works the same way — the worker only cares that the command exits 0 and leaves a valid manifest behind.)

Deploy the host:

sudo nixos-rebuild switch --flake .#uriel-worker

For a complete Hetzner + Tailscale host flake deployable with nixos-anywhere, see examples/hetzner-tailscale.

2. Submit Jobs

From the host or a trusted network path:

export URIEL_WORKER_URL=http://127.0.0.1:8788
export URIEL_WORKER_TOKEN=...

nix run github:uriel-agent/uriel#urielctl -- submit \
  --repo https://github.com/uriel-agent/uriel.git \
  --prompt "Run a smoke test and report status" \
  --qa browser

Use SSH port forwarding, Tailscale, WireGuard, or your preferred reverse proxy if you need to submit from another machine.

3. Android Host Requirements

Use an x86_64 NixOS host with KVM available:

test -e /dev/kvm
ls -l /dev/kvm

The NixOS module adds the uriel user to kvm, video, render, and adbusers. Configure one AVD name per concurrent Android slot. The worker boots the leased AVD, resolves its exact adb serial, and passes that serial to the harness; it never relies on adb's ambiguous default-device selection. If no AVD pool is configured, Android jobs are serialized against one explicitly attached device.

4. Optional Ingress

Keep ingress outside Uriel core. Good options:

  • Tailscale or WireGuard for private API access
  • Caddy/nginx for HTTPS and auth
  • Hermes gateway for Discord/Slack/Telegram style orchestration
  • Any other adapter that can call the local worker API