diff --git a/.github/scripts/install-openshell.sh b/.github/scripts/install-openshell.sh index 15e0cf380b..6d06985142 100755 --- a/.github/scripts/install-openshell.sh +++ b/.github/scripts/install-openshell.sh @@ -13,6 +13,25 @@ source "${SCRIPT_DIR}/openshell-version.sh" echo "Installing OpenShell ${OPENSHELL_VERSION} (${OPENSHELL_SHA})" +# A persistent runner may still carry OpenShell 0.0.x, whose gateway state +# 0.1 cannot read. Stop that gateway and move its state aside first; the +# installer then needs the explicit ack to replace a pre-0.1 install. +installed="$(openshell --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n1 || true)" +case "${installed}" in + 0.0.*) + echo "Replacing OpenShell ${installed}: stopping its gateway and moving its state aside" + systemctl --user stop openshell-gateway 2>/dev/null || true + state_root="${XDG_STATE_HOME:-${HOME}/.local/state}/openshell" + stamp="$(date +%s)" + for d in gateway tls; do + if [[ -d "${state_root}/${d}" ]]; then + mv "${state_root}/${d}" "${state_root}/${d}.pre-0.1.${stamp}" + fi + done + ;; +esac +export OPENSHELL_ACK_BREAKING_UPGRADE=1 + # Retry the entire install pipeline (curl | sh) with exponential backoff. # The upstream install.sh internally downloads the .deb from GitHub Releases, # which can fail on transient CDN errors. Retrying only the outer curl would @@ -26,6 +45,8 @@ while true; do | OPENSHELL_VERSION="v${OPENSHELL_VERSION}" sh; then break fi + # The installer starts the gateway service; show why it did not come up. + journalctl --user -u openshell-gateway --no-pager -n 40 2>/dev/null || true if (( attempt >= max_attempts )); then echo "::error::OpenShell install failed after ${max_attempts} attempts" >&2 exit 1 diff --git a/.github/scripts/openshell-version.sh b/.github/scripts/openshell-version.sh index 927fcaff32..ecf25ca96f 100755 --- a/.github/scripts/openshell-version.sh +++ b/.github/scripts/openshell-version.sh @@ -14,8 +14,8 @@ # Usage: # source .github/scripts/openshell-version.sh -OPENSHELL_VERSION=0.0.116 -OPENSHELL_SHA=d1155aa70042d3e2ee49dbfa15346b108b7c1d92 +OPENSHELL_VERSION=0.1.2 +OPENSHELL_SHA=6648bd0c290efbc41ba131ee9831ee45cd431f94 export OPENSHELL_VERSION OPENSHELL_SHA diff --git a/.github/workflows/functional-tests.yml b/.github/workflows/functional-tests.yml index fb693dfae5..d0453450e9 100644 --- a/.github/workflows/functional-tests.yml +++ b/.github/workflows/functional-tests.yml @@ -166,24 +166,6 @@ jobs: if: steps.changes.outputs.relevant != 'false' run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH" - - name: Configure OpenShell gateway - if: steps.changes.outputs.relevant != 'false' - run: | - source .github/scripts/openshell-version.sh - mkdir -p "$HOME/.config/openshell" - echo "OPENSHELL_BIND_ADDRESS=0.0.0.0" > "$HOME/.config/openshell/gateway.env" - cat > "$HOME/.config/openshell/gateway.toml" << EOF - [openshell] - version = 1 - - [openshell.gateway] - supervisor_image = "ghcr.io/nvidia/openshell/supervisor:${OPENSHELL_VERSION}" - EOF - - - name: Install OpenShell CLI - if: steps.changes.outputs.relevant != 'false' - run: .github/scripts/install-openshell.sh - - name: Install Podman if: steps.changes.outputs.relevant != 'false' run: .github/scripts/install-podman.sh @@ -209,6 +191,30 @@ jobs: [ -S "${SOCKET_PATH}" ] || { echo "::error::Podman socket not ready"; exit 1; } fi + # After Podman: the gateway pins compute_driver = "podman" and does not + # start without the Podman API socket. + - name: Configure OpenShell gateway + if: steps.changes.outputs.relevant != 'false' + run: | + source .github/scripts/openshell-version.sh + mkdir -p "$HOME/.config/openshell" + echo "OPENSHELL_BIND_ADDRESS=0.0.0.0" > "$HOME/.config/openshell/gateway.env" + cat > "$HOME/.config/openshell/gateway.toml" << EOF + [openshell] + version = 2 + + [openshell.gateway] + compute_driver = "podman" + + [openshell.drivers.podman] + supervisor_image = "ghcr.io/nvidia/openshell/supervisor:${OPENSHELL_VERSION}" + health_check_interval_secs = 10 + EOF + + - name: Install OpenShell CLI + if: steps.changes.outputs.relevant != 'false' + run: .github/scripts/install-openshell.sh + - name: Install validation dependencies if: steps.changes.outputs.relevant != 'false' run: pip install --quiet "jsonschema>=4.18.0" diff --git a/action.yml b/action.yml index 9ed38708da..61986e3823 100644 --- a/action.yml +++ b/action.yml @@ -387,10 +387,14 @@ runs: EOF cat > $HOME/.config/openshell/gateway.toml << EOF [openshell] - version = 1 + version = 2 [openshell.gateway] + compute_driver = "podman" + + [openshell.drivers.podman] supervisor_image = "ghcr.io/nvidia/openshell/supervisor:${OPENSHELL_VERSION}" + health_check_interval_secs = 10 EOF - name: Install OpenShell CLI diff --git a/docs/ADRs/0030-openshell-sandbox-interaction-model.md b/docs/ADRs/0030-openshell-sandbox-interaction-model.md index 4f18b95631..7f08573610 100644 --- a/docs/ADRs/0030-openshell-sandbox-interaction-model.md +++ b/docs/ADRs/0030-openshell-sandbox-interaction-model.md @@ -77,6 +77,12 @@ ssh-config`, use standard `ssh`/`scp`/`rsync`. Supports stdout streaming. file transfer. No SSH binary or config needed — all communication goes through the gateway's gRPC API. +> **Note (2026-09, [#7229](https://github.com/fullsend-ai/fullsend/issues/7229)):** +> `sandbox exec` cannot deliver a signal to the process it started, and +> `sandbox stop` never sends SIGINT — but a *second* `sandbox exec` +> that runs `kill -INT ` against a known guest PID does work. See +> [Signal and lifecycle semantics](#signal-and-lifecycle-semantics). + ### Credential delivery **A. OpenShell providers with bare-key form.** Register providers on the gateway @@ -160,6 +166,54 @@ entry command (`true`) exits; fullsend explicitly deletes after extraction. > `--detach -- sleep infinity` instead of `-- true`. The rest of the sequence, > and the reason `--keep` is passed, are unchanged. +### Signal and lifecycle semantics + +> **Note (2026-09, [#7229](https://github.com/fullsend-ai/fullsend/issues/7229)):** +> Annotation of a constraint discovered after this ADR was accepted; the +> Commands decision above is unchanged. +> +> `openshell sandbox exec` is fire-and-forget with respect to the process it +> started: it does not return an exec id, does not propagate host-side +> signals into that invoked process tree, and closing the client does not +> stop the in-sandbox command. Upstream declined to add a per-exec kill +> ([NVIDIA/OpenShell#3159](https://github.com/NVIDIA/OpenShell/issues/3159), +> closed as not planned) — its stated position is that callers should not +> expect exec'd processes to exit when the caller does, the same contract as +> `podman exec` / `kubectl exec`. +> +> This does not make signal delivery impossible: a *second*, independent +> `sandbox exec` that runs `kill -INT ` against a known guest PID does +> deliver the signal, because it targets the guest PID directly rather than +> relying on the original exec channel to propagate anything. [PR +> #7208](https://github.com/fullsend-ai/fullsend/pull/7208) E2E-verified this +> path (`total_cost_usd: 0.7879`, was `0`), and production already relies on +> the same second-exec-plus-in-guest-kill pattern in +> `killStrayProcessesTemplate` (`internal/runtime/stray_processes.go`) to +> send TERM/KILL to known guest PIDs. +> +> `openshell sandbox stop` is not a graceful alternative to either exec path: +> it never sends SIGINT. On OpenShell 0.0.x it waited ~45s for a SIGTERM +> that never arrived (`CAP_KILL` dropped, +> [NVIDIA/OpenShell#2855](https://github.com/NVIDIA/OpenShell/issues/2855)) +> and then SIGKILLed the container. From 0.1.0 +> ([NVIDIA/OpenShell#3036](https://github.com/NVIDIA/OpenShell/pull/3036)) +> it SIGTERMs the canonical process group and returns in under a second +> (0.15–0.28s measured on 0.1.1 with podman). Each exec'd process tree now +> runs in its own process group rather than the supervisor's; whether stop +> signals those trees gracefully has not been measured. +> +> Token-count persistence is the accepted partial fix for cancelled-run +> telemetry ([#6936](https://github.com/fullsend-ai/fullsend/issues/6936) / +> [PR #6938](https://github.com/fullsend-ai/fullsend/pull/6938)). +> [PR #7208](https://github.com/fullsend-ai/fullsend/pull/7208) added a +> second-exec SIGINT side-channel to also capture `total_cost_usd` on +> cancellation, and signal delivery itself worked. It was closed unmerged +> anyway: the side-channel bypasses OpenShell's supported stop lifecycle, the +> PID-file mechanism it depends on only reliably targets the runtime process +> for callers that `exec` into it (Claude) and not the others (Codex, Pi), +> and `total_cost_usd` is a list-price estimate rather than an authoritative +> billing figure — not worth the added complexity and risk. + ## Consequences - Fullsend depends only on the OpenShell CLI, `ssh`, `scp`, and `rsync` — no diff --git a/docs/guides/infrastructure/gate-binaries.md b/docs/guides/infrastructure/gate-binaries.md index a7d7f13067..0cb0299f4a 100644 --- a/docs/guides/infrastructure/gate-binaries.md +++ b/docs/guides/infrastructure/gate-binaries.md @@ -207,15 +207,11 @@ Create a provider definition that references the profile by its `id`: ```yaml # providers/gate-query.yaml +# The gate binary handles its own authentication or needs no credentials, so +# the provider carries none: it exists only to attach the profile's network +# policy. name: gate-query type: gate-query -# The gate binary handles its own authentication or needs no credentials. -# This placeholder credential exists only to satisfy OpenShell's requirement -# that every provider declares at least one credential key. The provider -# definition's sole purpose is to attach the network policy from the profile. -# See: https://github.com/NVIDIA/OpenShell/issues/1978 -credentials: - _PLACEHOLDER_GATE_QUERY: "" ``` ### Harness configuration @@ -253,7 +249,7 @@ If both the gate binary and a general-purpose binary need the same credential en Until OpenShell#2330 lands, use one of these workarounds: -- **Credential-less provider with a placeholder key.** When the gate binary handles its own authentication — or needs no credentials at all — the provider definition exists only to attach the network policy from the profile. OpenShell requires every provider to declare at least one credential key, so you supply a placeholder (as in the `_PLACEHOLDER_GATE_QUERY` example above) that carries no real secret. This avoids colliding with credential keys declared by other providers. +- **Credential-less provider.** When the gate binary handles its own authentication — or needs no credentials at all — the provider definition exists only to attach the network policy from the profile. Omit `credentials:` entirely, as in the `gate-query` example above, so it cannot collide with credential keys declared by other providers. - **Single provider for both binaries.** If both binaries must share the same credential, use a single provider with a `binaries` list that includes both. This means the `binaries` field cannot differentiate between them — the gate binary's validation logic is the only enforcement. ## What the proxy enforces vs. what the binary enforces diff --git a/docs/guides/user/bring-your-own-agent.md b/docs/guides/user/bring-your-own-agent.md index a95b9f066f..24d39736b3 100644 --- a/docs/guides/user/bring-your-own-agent.md +++ b/docs/guides/user/bring-your-own-agent.md @@ -168,10 +168,11 @@ timeout_minutes: 15 ```yaml name: vertex-ai type: fullsend-vertex-ai -credentials: - _NOOP_VERTEX_AI: "" ``` +A provider that carries a token lists it under `credentials:` (for example `GH_TOKEN: "${GH_TOKEN}"`), +and its profile must declare that key; OpenShell refuses a credential the profile does not declare. + **`profiles/fullsend-vertex-ai.yaml`** — profile definition (tells OpenShell what endpoints the `fullsend-vertex-ai` type grants access to). `agent new` writes this; by hand, copy it from [fullsend-ai/agents](https://github.com/fullsend-ai/agents), which holds the fleet's copy: ```yaml id: fullsend-vertex-ai diff --git a/docs/guides/user/running-agents-locally.md b/docs/guides/user/running-agents-locally.md index b032823d9e..a5eb87bd43 100644 --- a/docs/guides/user/running-agents-locally.md +++ b/docs/guides/user/running-agents-locally.md @@ -53,11 +53,65 @@ fullsend is pinned to — the source of truth is in the fullsend repo at your release tag (also printed on Fullsend workflow runs). ```bash -export OPENSHELL_VERSION=0.0.116 # check the pin file for the current version +export OPENSHELL_VERSION=0.1.2 # check the pin file for the current version curl -LsSf https://raw.githubusercontent.com/NVIDIA/OpenShell/v${OPENSHELL_VERSION}/install.sh | OPENSHELL_VERSION=v${OPENSHELL_VERSION} sh openshell --version ``` +The gateway reads a schema v2 config. With podman, pin the compute driver and the supervisor image +that matches the CLI: + +```toml +# ~/.config/openshell/gateway.toml (Homebrew on macOS: /opt/homebrew/var/openshell/gateway.toml +# is used when this file does not exist) +[openshell] +version = 2 + +[openshell.gateway] +compute_driver = "podman" + +[openshell.drivers.podman] +supervisor_image = "ghcr.io/nvidia/openshell/supervisor:0.1.2" # match your openshell --version +health_check_interval_secs = 10 +``` + +Restart the gateway after editing it (`brew services restart openshell` on macOS). `openshell sandbox +list` answering `No sandboxes found.` means the CLI reaches it. + +**Upgrading from OpenShell 0.0.x.** 0.1 cannot read 0.0.x gateway state or a schema v1 config, and +its installer refuses to replace 0.0.x unless `OPENSHELL_ACK_BREAKING_UPGRADE=1` is set. Clean up +while the 0.0.x CLI is still installed, and write the new config before installing: the installer +starts the gateway straight away. + +```bash +# 1. With the 0.0.x CLI: delete your sandboxes (they do not carry over) +openshell sandbox delete --all + +# 2. Stop the 0.0.x gateway +systemctl --user stop openshell-gateway + +# 3. Move the old config and gateway state aside +cfg="${XDG_CONFIG_HOME:-$HOME/.config}/openshell" +state="${XDG_STATE_HOME:-$HOME/.local/state}/openshell" +ts="$(date +%s)" +if [ -f "$cfg/gateway.toml" ]; then mv "$cfg/gateway.toml" "$cfg/gateway.toml.pre-0.1"; fi +for d in gateway tls; do + if [ -d "$state/$d" ]; then mv "$state/$d" "$state/$d.pre-0.1.$ts"; fi +done + +# 4. Write the schema v2 config shown above to "$cfg/gateway.toml", then install +curl -LsSf https://raw.githubusercontent.com/NVIDIA/OpenShell/v${OPENSHELL_VERSION}/install.sh \ + | OPENSHELL_ACK_BREAKING_UPGRADE=1 OPENSHELL_VERSION=v${OPENSHELL_VERSION} sh +openshell sandbox list # "No sandboxes found." means the new gateway is up +``` + +The paths are the XDG defaults, which a Homebrew install (what the installer uses on Apple Silicon +macOS) also uses for the gateway state. With Homebrew, stop the gateway in step 2 with +`brew services stop openshell` instead, and start it with `brew services start openshell` after +installing. The rest is unchanged: `$cfg/gateway.toml` takes precedence over Homebrew's +`$(brew --prefix)/var/openshell/gateway.toml`, and the installer manages Homebrew's TLS under that +directory. fullsend recreates its providers and profiles on the next run. + ## Get Google Cloud Platform credentials Fullsend uses GCP's VertexAI to run inference, so you need a GCP project. After authenticating on `gcloud` run: diff --git a/hack/gitlab-runner-vm/create-gcp-vm.sh b/hack/gitlab-runner-vm/create-gcp-vm.sh index 535e6da313..a7d4cc9fce 100755 --- a/hack/gitlab-runner-vm/create-gcp-vm.sh +++ b/hack/gitlab-runner-vm/create-gcp-vm.sh @@ -130,7 +130,8 @@ if [ -f "${_openshell_version_sh}" ]; then # shellcheck source=../../.github/scripts/openshell-version.sh source "${_openshell_version_sh}" fi -OPENSHELL_VERSION="${OPENSHELL_VERSION:-0.0.116}" +# Fallback only when the pin file is absent; keep in step with openshell-version.sh. +OPENSHELL_VERSION="${OPENSHELL_VERSION:-0.1.2}" PREFIX="fullsend-gitlab-runner" # Validate GCP_USE_IAP early — it controls flag construction below, so an diff --git a/hack/gitlab-runner-vm/create-openshift-vm.sh b/hack/gitlab-runner-vm/create-openshift-vm.sh index cb0766be50..88486d7584 100755 --- a/hack/gitlab-runner-vm/create-openshift-vm.sh +++ b/hack/gitlab-runner-vm/create-openshift-vm.sh @@ -103,7 +103,8 @@ if [ -f "${_openshell_version_sh}" ]; then # shellcheck source=../../.github/scripts/openshell-version.sh source "${_openshell_version_sh}" fi -OPENSHELL_VERSION="${OPENSHELL_VERSION:-0.0.116}" +# Fallback only when the pin file is absent; keep in step with openshell-version.sh. +OPENSHELL_VERSION="${OPENSHELL_VERSION:-0.1.2}" TEMPLATE="${SCRIPT_DIR}/vm.yaml" PREFIX="fullsend-gitlab-runner" diff --git a/hack/gitlab-runner-vm/executor/gateway.sh b/hack/gitlab-runner-vm/executor/gateway.sh index e188ddbd26..f889c190a6 100755 --- a/hack/gitlab-runner-vm/executor/gateway.sh +++ b/hack/gitlab-runner-vm/executor/gateway.sh @@ -321,21 +321,56 @@ start_fresh_openshell_gateway() { echo "OpenShell gateway is running with an empty profile registry" } +# Packaged schema-v2 default (OpenShell >= 0.1 RPM). Overridable for tests. +OPENSHELL_PACKAGED_GATEWAY_TOML="${OPENSHELL_PACKAGED_GATEWAY_TOML:-/usr/share/openshell-gateway/gateway.toml.default}" + +gateway_toml_is_v2() { + grep -Eq '^[[:space:]]*version[[:space:]]*=[[:space:]]*2[[:space:]]*(#.*)?$' "$1" +} + +# Pin supervisor_image under [openshell.drivers.podman] in a schema-v2 +# gateway.toml. OpenShell 0.1 rejects v1 and version-less files at startup, +# so such a file (written for 0.0.x) is moved aside to gateway.toml.pre-0.1. +# A missing file is seeded from the packaged default so compute_driver is +# kept (without it the gateway auto-detects Kubernetes before Podman); the +# literal fallback mirrors that default and action.yml. pin_supervisor_image() { local ver="$1" local gateway_toml="${HOME}/.config/openshell/gateway.toml" local supervisor_image supervisor_image="$(openshell_supervisor_image "${ver}")" mkdir -p "${HOME}/.config/openshell" - if [ -f "${gateway_toml}" ] && grep -q "supervisor_image" "${gateway_toml}"; then - sed -i "s|supervisor_image = .*|supervisor_image = \"${supervisor_image}\"|" "${gateway_toml}" - elif [ -f "${gateway_toml}" ] && grep -q '^\[openshell\.gateway\]' "${gateway_toml}"; then - sed -i "/^\[openshell\.gateway\]/a supervisor_image = \"${supervisor_image}\"" "${gateway_toml}" - elif [ -f "${gateway_toml}" ]; then - printf '\n[openshell.gateway]\nsupervisor_image = "%s"\n' "${supervisor_image}" >> "${gateway_toml}" + + if [ -f "${gateway_toml}" ] && ! gateway_toml_is_v2 "${gateway_toml}"; then + echo "Moving pre-0.1 OpenShell gateway config aside to ${gateway_toml}.pre-0.1" + mv -f "${gateway_toml}" "${gateway_toml}.pre-0.1" + fi + + if [ ! -f "${gateway_toml}" ]; then + if [ -f "${OPENSHELL_PACKAGED_GATEWAY_TOML}" ] && gateway_toml_is_v2 "${OPENSHELL_PACKAGED_GATEWAY_TOML}"; then + install -m 0644 "${OPENSHELL_PACKAGED_GATEWAY_TOML}" "${gateway_toml}" + else + printf '[openshell]\nversion = 2\n\n[openshell.gateway]\ncompute_driver = "podman"\n\n[openshell.drivers.podman]\nhealth_check_interval_secs = 10\n' > "${gateway_toml}" + fi + fi + + if grep -q '^[[:space:]]*supervisor_image[[:space:]]*=' "${gateway_toml}"; then + sed -i "s|^[[:space:]]*supervisor_image[[:space:]]*=.*|supervisor_image = \"${supervisor_image}\"|" "${gateway_toml}" + elif grep -q '^\[openshell\.drivers\.podman\]' "${gateway_toml}"; then + sed -i "/^\[openshell\.drivers\.podman\]/a supervisor_image = \"${supervisor_image}\"" "${gateway_toml}" + else + printf '\n[openshell.drivers.podman]\nsupervisor_image = "%s"\n' "${supervisor_image}" >> "${gateway_toml}" fi } +# Run before any OpenShell install: install.sh (re)starts the gateway unit, +# and 0.1 refuses a v1 gateway.toml and cannot use 0.0.x state. Tear the +# old gateway down with the still-installed CLI and write the v2 config. +prepare_openshell_upgrade() { + teardown_openshell_gateway + pin_supervisor_image "$1" +} + # Install the OpenShell version the job pins, but only when that version is # the Renovate-tracked pin (OPENSHELL_VERSION/OPENSHELL_SHA, sourced above # from .github/scripts/openshell-version.sh) — callers must verify that match @@ -360,8 +395,10 @@ install_openshell_at_version() { url="$(openshell_install_script_url "${sha}")" local max_attempts=3 attempt=1 delay=5 while true; do + # install.sh refuses a pre-0.1 -> 0.1 upgrade without the ack; the + # caller's prepare_openshell_upgrade has already migrated the host. if curl -LsSf --retry 3 --retry-delay 5 "${url}" \ - | OPENSHELL_VERSION="v${ver}" sh; then + | OPENSHELL_ACK_BREAKING_UPGRADE=1 OPENSHELL_VERSION="v${ver}" sh; then break fi if [ "${attempt}" -ge "${max_attempts}" ]; then @@ -405,8 +442,8 @@ ensure_job_openshell_gateway() { return 1 fi echo "OpenShell host ${host_ver:-none} != job image ${job_ver}; installing the pinned version" + prepare_openshell_upgrade "${job_ver}" install_openshell_at_version "${job_ver}" "${OPENSHELL_SHA:-}" || return 1 - pin_supervisor_image "${job_ver}" podman pull -- "$(openshell_supervisor_image "${job_ver}")" || return 1 elif [ -n "${job_ver}" ]; then echo "OpenShell ${job_ver} already matches the job image" diff --git a/hack/gitlab-runner-vm/executor/gateway_test.sh b/hack/gitlab-runner-vm/executor/gateway_test.sh index ebe64c2126..58dec48b80 100755 --- a/hack/gitlab-runner-vm/executor/gateway_test.sh +++ b/hack/gitlab-runner-vm/executor/gateway_test.sh @@ -16,6 +16,25 @@ fail() { FAILURES=$((FAILURES + 1)) } +# assert_v2_gateway_toml