Skip to content

Self-hosted workflows for coding-agent delivery. Orchestrate CodeBuddy, Codex and Claude Code with scripts and human approval gates. Includes Local workflows for coding assistants.

fix(deploy): update Go security patch and install missing prerequisites (#179)

Robert0622a529e256b2ad
diff --git a/Dockerfile b/Dockerfile
index 48591483..41483680 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -9,7 +9,7 @@ RUN --mount=type=cache,target=/root/.npm npm --prefix chatbot ci --include=dev -
COPY chatbot/ chatbot/
COPY web/app/ web/app/
RUN npm --prefix chatbot run build && test -f web/native-chat/index.html
-FROM --platform=$BUILDPLATFORM golang:1.26.10-bookworm AS build
+FROM --platform=$BUILDPLATFORM golang:1.26.11-bookworm AS build
ARG TARGETOS
ARG TARGETARCH
WORKDIR /src
diff --git a/Makefile b/Makefile
index 6caf32f4..44e1d02d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
.PHONY: run test test-mysql clean-mysql build build-chatbot build-gate-mcp coverage coverage-go coverage-chatbot coverage-web coverage-e2e
GOCACHE ?= /tmp/agentflow-gocache
-# Use the local toolchain; go.mod requires go >= 1.26.10.
+# Use the local toolchain; go.mod requires go >= 1.26.11.
run:
GOCACHE=$(GOCACHE) go run ./cmd/agentflow
diff --git a/README.md b/README.md
index d4ec28d9..8181543b 100644
--- a/README.md
+++ b/README.md
@@ -67,7 +67,7 @@ Ask a coding agent to "fix this bug" and the result depends on that run. It migh
## Quick start
-Requires **Git, curl, Docker (with Compose)** and **Python 3**. On a fresh Ubuntu host, start with `sudo apt-get update && sudo apt-get install -y git curl python3`. The installer offers to install Docker if it is missing. Ordinary Linux users are supported through Docker group access or sudo.
+Install **Git** and clone the repository first. The installer checks Docker, Compose, Python 3 and curl and offers to install missing components. Python/curl installation supports apt, dnf and yum on Linux; the Compose plugin supports x86_64/arm64 and verifies the official release SHA-256. macOS needs a working Python 3 and Docker Desktop; Homebrew can install missing components. Ordinary Linux users are supported through Docker group access or sudo. Set `LOOPFORGE_YES=1` to accept installation prompts. Package and image downloads require internet access.
```bash
git clone https://github.com/Tencent/LoopForge.git
@@ -75,7 +75,7 @@ cd LoopForge
./start.sh
```
-`./start.sh` pulls the GHCR release image pinned in `compose.yaml` without building locally (`bash scripts/install.sh` does the same). Use `./start.sh logs`, `stop`, `restart` or `pull` to manage it, and `./start.sh dev` to build the checkout from source.
+`./start.sh` pulls the GHCR release image pinned in `compose.yaml` without building locally (`bash scripts/install.sh` does the same). It creates the MySQL and platform services, generates configuration and session secrets, and installs the built-in sandboxes, starter SOPs and welcome project. Host Go and Node.js installations are not required. Configure model API keys and GitHub authorization after startup. Use `./start.sh logs`, `stop`, `restart` or `pull` to manage it, and `./start.sh dev` to build the checkout from source.
Open the address printed by the installer and create your account; the first one becomes the administrator. The service listens on `0.0.0.0:8090` by default. On a cloud host, the installer reads the public IP from the provider's metadata service and prints it; allow the port in your security group, or put an HTTPS reverse proxy in front. Restrict access to your own IP until the administrator account exists. The home page's quick-access guide walks you through adding a model key, connecting a repository and choosing an SOP.
@@ -100,13 +100,13 @@ New accounts join the **LoopForge demo project**, which includes an SOP made onl
<br>
-- **Executors.** Pick **CodeBuddy, Codex or Claude Code** beside the home composer, then a model. Each executor uses its own credentials from personal settings, and every SOP role can choose its executor independently (built-in roles default to CodeBuddy). Requirement clarification, scheduled assistant tasks and AI notification summaries currently use CodeBuddy. The Docker image ships all three CLIs; [native deployments](docs/deployment.md#workers-and-runners) need the CLI for the executor you choose.
+- **Executors.** Pick **CodeBuddy, Codex or Claude Code** beside the home composer, then a model. Each executor uses its own credentials from personal settings, and every SOP role can choose its executor independently (built-in roles default to CodeBuddy). Requirement clarification, scheduled assistant tasks and AI notification summaries currently use CodeBuddy. The Docker image ships CodeBuddy and Codex; Claude Code installs from npm on first use and is cached, so that first run requires npm access; [native deployments](docs/deployment.md#workers-and-runners) need the CLI for the executor you choose.
- **GitHub is optional.** All built-in generic SOPs run without a repository: product SOPs deliver documents, and new frontend/backend projects deliver source files in the task workspace. Bug fixes still need source code and reproduction details. Connect a repository when you work on existing code or want PRs.
- **Delivering to a repository.** Choose **Connect GitHub** in personal settings, approve the device code on GitHub and pick your repository (the LoopForge OAuth App is built in; no PAT required, manual PAT entry still works). Set executor credentials (or bind a local execution machine), then either run a project SOP or ask Main Bot to change the code and submit a PR/MR.
- **Sandboxes.** In the default Compose installation, SOP runs and conversation workspaces both use Docker sandbox containers started through the host Docker socket. Default sandboxes reuse the installed runtime image, so nothing extra is built after installation; custom Dockerfiles still build their own images. Docker socket access grants control of the host daemon, so this setup is for trusted teams, not untrusted multi-tenant isolation. See [deployment boundaries](docs/deployment.md#accounts). Re-running the installer keeps your data.
- **Accounts and access.** New installations listen on all interfaces (existing bind settings are kept) and are designed for a trusted team: signed-in users can read project data across the instance, and teammates can sign up from the login page (`AGENTFLOW_ALLOW_SIGNUP=false` in `.env` turns that off). Read the [account and access model](docs/deployment.md#accounts) before exposing it beyond your team.
- **Remote access, HTTPS, separate workers.** See [Deployment](docs/deployment.md).
-- **Hacking on LoopForge itself?** `bash scripts/dev.sh` runs it natively (Go 1.26.10+).
+- **Hacking on LoopForge itself?** `bash scripts/dev.sh` runs it natively (Go 1.26.11+).
</details>
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 5be02db8..443b4885 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -67,7 +67,7 @@ https://github.com/user-attachments/assets/10b8ae2e-d7e7-4b78-8876-c45818d4a08f
## 快速开始
-需要 **Git、curl、Docker(含 Compose)** 和 **Python 3**。全新 Ubuntu 可先运行 `sudo apt-get update && sudo apt-get install -y git curl python3`。没装 Docker 时,安装脚本会询问并帮你安装。支持普通用户运行,需要时通过 docker 组或 sudo 操作 Docker。
+先准备 **Git** 并克隆仓库。安装脚本会检查 Docker、Compose、Python 3 和 curl,并在获得确认后补装缺少的组件:Linux 的 Python/curl 支持 apt、dnf、yum,Compose 插件支持 x86_64/arm64 并校验官方发行文件的 SHA-256;macOS 需要可运行的 Python 3 和 Docker Desktop,可通过 Homebrew 补装缺少的组件。支持普通用户运行,需要时通过 Docker 组或 sudo 操作 Docker。设置 `LOOPFORGE_YES=1` 可接受安装提示;安装和拉取镜像需要可用的外网连接。
```bash
git clone https://github.com/Tencent/LoopForge.git
@@ -75,7 +75,7 @@ cd LoopForge
./start.sh
```
-`./start.sh` 直接拉取 `compose.yaml` 中 pin 的 GHCR 发布镜像,不在本地构建(`bash scripts/install.sh` 效果相同)。用 `./start.sh logs`、`stop`、`restart`、`pull` 管理服务;需要从源码构建时用 `./start.sh dev`。
+`./start.sh` 直接拉取 `compose.yaml` 中 pin 的 GHCR 发布镜像,不在本地构建(`bash scripts/install.sh` 效果相同)。安装流程会创建 MySQL 和平台服务,生成配置与会话密钥,并导入内置沙箱、通用 SOP 和体验项目;无需在宿主机安装 Go 或 Node.js。模型 API Key 和 GitHub 授权在启动后由用户配置。用 `./start.sh logs`、`stop`、`restart`、`pull` 管理服务;需要从源码构建时用 `./start.sh dev`。
打开安装脚本输出的地址创建账号,第一个账号自动成为管理员。服务默认监听 `0.0.0.0:8090`;在云主机上,安装脚本会从云厂商的元数据服务读取公网 IP 并直接打印出来,放通安全组端口即可访问,或配置 HTTPS 反向代理;管理员账号创建前,建议只允许你的 IP 访问。首页的「快速接入」会带你配置模型凭据、绑定仓库并选好默认 SOP。
@@ -100,13 +100,13 @@ cd LoopForge
<br>
-- **执行器。** 在首页输入框旁选择 **CodeBuddy、Codex 或 Claude Code**,再选择模型;不同执行器分别使用个人设置里的对应凭据。每个 SOP 角色都可以独立选择执行器(内置角色默认 CodeBuddy)。需求澄清、定时助手任务和通知 AI 汇总目前使用 CodeBuddy。Docker 镜像内置三个 CLI;[原生部署](docs/deployment.md#workers-and-runners)需安装所选执行器的 CLI。
+- **执行器。** 在首页输入框旁选择 **CodeBuddy、Codex 或 Claude Code**,再选择模型;不同执行器分别使用个人设置里的对应凭据。每个 SOP 角色都可以独立选择执行器(内置角色默认 CodeBuddy)。需求澄清、定时助手任务和通知 AI 汇总目前使用 CodeBuddy。Docker 镜像内置 CodeBuddy 和 Codex;Claude Code 在首次使用时从 npm 安装并缓存,需要能访问 npm;[原生部署](docs/deployment.md#workers-and-runners)需安装所选执行器的 CLI。
- **GitHub 可选。** 所有内置通用 SOP 都可以不绑定仓库运行:产品方案交付文档,前后端新项目在任务工作区交付源码;缺陷修复仍需提供待修代码和复现材料。需要修改已有代码或提交 PR 时再绑定仓库。
- **交付到仓库。** 在个人设置中点击「连接 GitHub」,用设备码授权后选择自己的仓库(已内置 LoopForge 授权应用,无需申请 PAT,仍可手动填写 PAT),再配置执行器凭据(或绑定本机执行机器),之后既可以运行一条项目 SOP,也可以直接让 Main Bot 修改代码并提交 PR/MR。
- **沙箱。** 默认 Compose 安装中,SOP 运行和对话工作区都使用 Docker 沙箱容器,由平台通过宿主机 Docker socket 启动;默认沙箱复用已安装的运行镜像,安装后无需再构建;自定义 Dockerfile 仍单独构建。Docker socket 赋予平台控制宿主机 Docker 的权限,因此只适用于可信团队,不构成不可信多租户隔离边界;详见[部署边界](docs/deployment.md#accounts)。重复执行安装脚本会保留已有数据。
- **账号与访问。** 新安装默认监听所有网卡(已有安装保留原配置),面向可信团队:已登录用户可以读取实例内各项目的数据,团队成员可在登录页自助注册(在 `.env` 中设置 `AGENTFLOW_ALLOW_SIGNUP=false` 可关闭)。对团队以外开放前,请先阅读[账号与访问边界](docs/deployment.md#accounts)。
- **远程访问、HTTPS、独立 Worker。** 见[部署指南](docs/deployment.md)。
-- **参与 LoopForge 本身的开发?** 用 `bash scripts/dev.sh` 原生运行(需要 Go 1.26.10+)。
+- **参与 LoopForge 本身的开发?** 用 `bash scripts/dev.sh` 原生运行(需要 Go 1.26.11+)。
</details>
diff --git a/docs/deployment.md b/docs/deployment.md
index f0da1d7b..2baa8b1b 100644
--- a/docs/deployment.md
+++ b/docs/deployment.md
@@ -31,7 +31,7 @@ Use `AGENTFLOW_MYSQL_DSN` for your own MySQL deployment. A fresh account command
./start.sh release # switch a source build back to the published image
```
-The installer checks Docker, Compose and Python (and offers to install Docker when it is missing; set `LOOPFORGE_YES=1` to accept without prompting), generates `.env` with unique secrets, pulls and starts the containers, installs the observability columns and applies `migrations/seed/*.sql`. It is safe to re-run. Set `AGENTFLOW_HTTP_PORT` or `LOOPFORGE_MYSQL_PORT` in the environment before the first run (or edit `.env` later) when the default ports are taken.
+The installer checks Docker, Compose, Python 3 and curl. It offers to install missing Python/curl packages using apt, dnf or yum on Linux (Homebrew on macOS), Docker using its official installer, and the missing Linux x86_64/arm64 Compose plugin using the pinned official release with SHA-256 verification. A plugin is installed for the active Docker user, or system-wide when Docker requires sudo. macOS Compose comes from Docker Desktop. Set `LOOPFORGE_YES=1` to accept installation prompts; internet access and package-manager/administrator permissions are still required. The installer generates `.env` with unique secrets, pulls and starts the containers, installs the observability columns and applies `migrations/seed/*.sql`. It is safe to re-run. Set `AGENTFLOW_HTTP_PORT` or `LOOPFORGE_MYSQL_PORT` in the environment before the first run (or edit `.env` later) when the default ports are taken.
Run it as the installation owner, including an ordinary Linux user. If that user cannot access Docker directly, the installer validates sudo and uses `sudo -n docker` consistently for Compose, schema installation and seeds. Before each operation it checks whether sudo credentials expired during a long build, prompting again in a terminal or failing with instructions in unattended mode. It does not require adding the user to the Docker group or logging out. For unattended installations run `sudo -v` first; `LOOPFORGE_YES=1` accepts installation prompts but does not bypass operating-system permissions. Without sudo or Docker access it fails immediately with instructions. Rootless Docker uses its active context's Unix socket; remote Docker contexts need a separately configured deployment because sandbox workspaces are local bind mounts.
diff --git a/go.mod b/go.mod
index 07caa4ce..a267673c 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module agentflow
-go 1.26.10
+go 1.26.11
require (
github.com/creack/pty v1.1.24
diff --git a/scripts/install-compose.py b/scripts/install-compose.py
new file mode 100644
index 00000000..ebdadcfa
--- /dev/null
+++ b/scripts/install-compose.py
@@ -0,0 +1,45 @@
+"""Download a pinned, checksum-verified official Linux Compose CLI plugin."""
+import hashlib
+from pathlib import Path
+import sys
+import urllib.request
+
+
+VERSION = 'v5.6.1'
+SHA256 = {
+ 'x86_64': '47737f4236e6d3ccea7291995203f8f018058783b4c3a9469119811a0b5db8c0',
+ 'aarch64': '42cfa75f51ad0ccf290bad37899e0038a8c10a0069e85233ecc1d53e3ff1347d',
+}
+
+
+def download(destination, architecture, opener=urllib.request.urlopen):
+ architecture = {'amd64': 'x86_64', 'arm64': 'aarch64'}.get(architecture, architecture)
+ if architecture not in SHA256:
+ raise ValueError('Automatic Compose installation supports Linux x86_64 and aarch64. Install the Docker Compose plugin for this architecture, then rerun the installer.')
+ destination = Path(destination)
+ partial = destination.with_suffix('.download')
+ url = 'https://github.com/docker/compose/releases/download/{}/docker-compose-linux-{}'.format(VERSION, architecture)
+ try:
+ digest = hashlib.sha256()
+ with opener(url, timeout=120) as response, partial.open('wb') as output:
+ while True:
+ chunk = response.read(1024 * 1024)
+ if not chunk:
+ break
+ digest.update(chunk)
+ output.write(chunk)
+ if digest.hexdigest() != SHA256[architecture]:
+ raise ValueError('Docker Compose checksum mismatch; the downloaded file will not be installed.')
+ partial.replace(destination)
+ finally:
+ try:
+ partial.unlink()
+ except FileNotFoundError:
+ pass
+
+
+if __name__ == '__main__':
+ try:
+ download(sys.argv[1], sys.argv[2])
+ except (OSError, ValueError) as error:
+ raise SystemExit('Could not install Docker Compose: ' + str(error))
diff --git a/scripts/install.sh b/scripts/install.sh
index 9493e54e..deb553d7 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -2,7 +2,8 @@
# One-command container installation from the published GHCR image pinned in
# compose.yaml (LOOPFORGE_BUILD_FROM_SOURCE=1 builds this checkout instead).
# Installs Docker when it is missing (Linux, or macOS with Homebrew) and needs
-# Python 3. Re-running is safe: secrets, data and catalog edits are kept.
+# Python 3 and curl (apt/dnf/yum, or Homebrew). Re-running is safe: secrets,
+# data and catalog edits are kept.
set -euo pipefail
cd "$(dirname "$0")/.."
@@ -17,6 +18,62 @@ confirm() {
[[ -z "$answer" || "$answer" =~ ^[Yy] ]]
}
+usable_python() {
+ command -v python3 >/dev/null && python3 -c 'import sys; sys.exit(sys.version_info < (3, 6))' >/dev/null 2>&1
+}
+
+install_prerequisites() {
+ local missing=()
+ usable_python || missing+=(python3)
+ command -v curl >/dev/null || missing+=(curl ca-certificates)
+ [[ ${#missing[@]} -gt 0 ]] || return 0
+ confirm "Required packages are missing: ${missing[*]}. Install them now?" \
+ || fail 'Install Python 3 and curl, then rerun this script; or rerun with LOOPFORGE_YES=1 to accept installation.'
+ if command -v apt-get >/dev/null; then
+ as_root apt-get update
+ if [[ ${LOOPFORGE_YES:-0} == 1 ]]; then
+ as_root env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a \
+ apt-get -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold install -y "${missing[@]}"
+ else
+ as_root apt-get install -y "${missing[@]}"
+ fi
+ elif command -v dnf >/dev/null; then
+ as_root dnf install -y "${missing[@]}"
+ elif command -v yum >/dev/null; then
+ as_root yum install -y "${missing[@]}"
+ elif [[ $(uname -s) == Darwin ]] && command -v brew >/dev/null; then
+ brew install "${missing[@]}"
+ else
+ fail 'Automatic prerequisite installation requires apt, dnf, yum or Homebrew. Install Python 3 and curl, then rerun this script.'
+ fi
+ usable_python && command -v curl >/dev/null \
+ || fail 'A working Python 3 or curl is still unavailable after package installation. Check the package manager output and rerun.'
+}
+
+install_compose() (
+ [[ $(uname -s) == Linux ]] \
+ || fail 'Docker Compose is unavailable. Install or update Docker Desktop, then rerun this script.'
+ confirm 'Docker Compose is missing. Install the official checksum-verified plugin now?' \
+ || fail 'Docker Compose is required. Install the plugin or rerun with LOOPFORGE_YES=1.'
+ local temporary plugin_dir
+ temporary=$(mktemp -d)
+ trap 'rm -rf "$temporary"' EXIT
+ if ! python3 scripts/install-compose.py "$temporary/docker-compose" "$(uname -m)"; then
+ fail 'Docker Compose download failed. Check access to GitHub, or install the Compose plugin manually and rerun.'
+ fi
+ if [[ ${LOOPFORGE_DOCKER_USE_SUDO:-0} == 1 || $(id -u) -eq 0 ]]; then
+ plugin_dir=/usr/local/lib/docker/cli-plugins
+ if ! { as_root install -d "$plugin_dir" && as_root install -m 0755 "$temporary/docker-compose" "$plugin_dir/docker-compose"; }; then
+ fail "Could not install Docker Compose in $plugin_dir. Check directory permissions and rerun."
+ fi
+ else
+ plugin_dir="${DOCKER_CONFIG:-$HOME/.docker}/cli-plugins"
+ if ! { install -d "$plugin_dir" && install -m 0755 "$temporary/docker-compose" "$plugin_dir/docker-compose"; }; then
+ fail "Could not install Docker Compose in $plugin_dir. Check directory permissions and rerun."
+ fi
+ fi
+)
+
install_docker() {
case "$(uname -s)" in
Linux)
@@ -45,14 +102,7 @@ wait_for_docker() {
}
step 'Checking prerequisites'
-if ! command -v python3 >/dev/null; then
- if command -v apt-get >/dev/null && confirm 'Python 3 is required. Install it now?'; then
- as_root apt-get update
- as_root apt-get install -y python3
- else
- fail 'Install Python 3, then rerun this script. No deployment has been started.'
- fi
-fi
+install_prerequisites
command -v docker >/dev/null || install_docker
if ! select_docker_access; then
case "$(uname -s)" in
@@ -61,7 +111,8 @@ if ! select_docker_access; then
esac
wait_for_docker || fail 'Docker is installed but not running, or this user cannot access it (try: sudo usermod -aG docker "$USER", then log in again).'
fi
-docker_access compose version >/dev/null 2>&1 || fail 'Docker Compose v2 is required (the "docker compose" command).'
+docker_access compose version >/dev/null 2>&1 || install_compose
+docker_access compose version >/dev/null 2>&1 || fail 'Docker Compose is still unavailable. Check the Docker CLI plugin configuration and rerun.'
requested_public_url="${LOOPFORGE_PUBLIC_URL:-}"
[[ ! -e .env || -r .env ]] || fail 'The existing .env is not readable by this user. Use the installation owner or ask an administrator to correct its ownership.'
diff --git a/scripts/test-install-live.sh b/scripts/test-install-live.sh
index 06a75347..4b647ddd 100644
--- a/scripts/test-install-live.sh
+++ b/scripts/test-install-live.sh
@@ -9,18 +9,19 @@ docker_socket="${LOOPFORGE_DOCKER_SOCKET:-/var/run/docker.sock}"
cleanup() {
for fixture in "$task_dir"/*; do
[[ -f "$fixture/.env" ]] || continue
+ docker ps -aq --filter "network=lf-install-${fixture##*/}-$$_default" | xargs -r docker rm -f >/dev/null 2>&1 || true
docker compose -f "$root/compose.yaml" --env-file "$fixture/.env" --profile platform down --volumes --remove-orphans >/dev/null 2>&1 || true
done
rm -rf "$task_dir"
}
trap cleanup EXIT
-actors=(root nonroot)
+actors=(root nonroot without-compose)
[[ -z "${LOOPFORGE_INSTALL_SUDO_TEST_IMAGE:-}" ]] || actors+=(sudo)
for actor in "${actors[@]}"; do
fixture="$task_dir/$actor"
mkdir -p "$fixture/scripts" "$fixture/migrations/seed" "$fixture/user-home"
- cp scripts/{install.sh,configure.sh,docker-access.sh,install-address.py,install-observability-schema.sh} "$fixture/scripts/"
+ cp scripts/{install.sh,configure.sh,docker-access.sh,install-address.py,install-compose.py,install-observability-schema.sh} "$fixture/scripts/"
cp migrations/001_run_obs_generated_columns.sql "$fixture/migrations/"
cp migrations/seed/*.sql "$fixture/migrations/seed/"
cp compose.yaml "$fixture/"
@@ -36,6 +37,11 @@ PY
[[ $(id -u) == 0 ]] || { echo 'Non-root live check requires root to change only the fixture ownership and drop privileges.' >&2; exit 1; }
chown -R 65534:65534 "$fixture"
prefix=(setpriv --reuid=65534 --regid="$(stat -c %g "$docker_socket")" --clear-groups)
+ elif [[ "$actor" == without-compose ]]; then
+ # The platform runtime contains Docker CLI but no Compose plugin. Download
+ # and install the real verified plugin inside an ephemeral client container.
+ mkdir -p "$fixture/cli-plugins"
+ prefix=(docker run --rm --network host -v "$fixture:$fixture" -v "$docker_socket:$docker_socket" -v "$fixture/cli-plugins:/usr/local/lib/docker/cli-plugins" -w "$fixture" --entrypoint /usr/bin/env "$image")
elif [[ "$actor" == sudo ]]; then
chown -R 1000:1000 "$fixture"
prefix=(docker run --rm --network host --user 1000:1000 -v "$fixture:$fixture" -v "$docker_socket:$docker_socket" -v "${LOOPFORGE_TEST_COMPOSE_PLUGIN:-/usr/libexec/docker/cli-plugins/docker-compose}:/usr/local/lib/docker/cli-plugins/docker-compose:ro" -w "$fixture" --entrypoint /usr/bin/env "$LOOPFORGE_INSTALL_SUDO_TEST_IMAGE")
@@ -43,7 +49,7 @@ PY
fi
started=$SECONDS
for attempt in first repeat; do
- "${prefix[@]}" env HOME="$fixture/user-home" PATH=/usr/local/bin:/usr/bin:/bin COMPOSE_PROJECT_NAME="lf-install-${actor}-$$" LOOPFORGE_IMAGE="$image" LOOPFORGE_DATA_DIR="$fixture/data" LOOPFORGE_BIND=0.0.0.0 LOOPFORGE_PUBLIC_URL="http://192.0.2.10:$http_port" LOOPFORGE_DOCKER_SOCKET="$docker_socket" AGENTFLOW_HTTP_PORT="$http_port" LOOPFORGE_MYSQL_PORT="$mysql_port" bash "$fixture/scripts/install.sh" > "$fixture/$attempt.log" 2>&1 || { cat "$fixture/$attempt.log"; exit 1; }
+ "${prefix[@]}" env HOME="$fixture/user-home" PATH=/usr/local/bin:/usr/bin:/bin LOOPFORGE_YES=1 COMPOSE_PROJECT_NAME="lf-install-${actor}-$$" LOOPFORGE_IMAGE="$image" LOOPFORGE_DATA_DIR="$fixture/data" LOOPFORGE_BIND=0.0.0.0 LOOPFORGE_PUBLIC_URL="http://192.0.2.10:$http_port" LOOPFORGE_DOCKER_SOCKET="$docker_socket" AGENTFLOW_HTTP_PORT="$http_port" LOOPFORGE_MYSQL_PORT="$mysql_port" bash "$fixture/scripts/install.sh" > "$fixture/$attempt.log" 2>&1 || { cat "$fixture/$attempt.log"; exit 1; }
grep -q "Access: http://192.0.2.10:$http_port" "$fixture/$attempt.log"
curl -fsS "http://127.0.0.1:$http_port/api/health" >/dev/null
if [[ "$attempt" == first ]]; then
@@ -54,7 +60,7 @@ PY
done
docker compose -f "$fixture/compose.yaml" --env-file "$fixture/.env" --profile platform port platform 8080 | grep -q "0.0.0.0:$http_port"
python3 - "$http_port" <<'PY'
-import json,secrets,socket,sys,urllib.request
+import json,secrets,socket,sys,time,urllib.request
base='http://127.0.0.1:'+sys.argv[1]
setup=json.load(urllib.request.urlopen(base+'/api/auth/setup'))
assert setup['needsSetup'],setup
@@ -65,9 +71,42 @@ with socket.socket(socket.AF_INET,socket.SOCK_DGRAM) as probe:
direct=urllib.request.build_opener(urllib.request.ProxyHandler({}))
assert direct.open('http://'+address+':'+sys.argv[1]+'/api/health').status==200
request=urllib.request.Request(base+'/api/auth/register',data=json.dumps({'login':'install-test-admin','password':secrets.token_urlsafe(24)}).encode(),headers={'Content-Type':'application/json','Origin':base})
-result=json.load(urllib.request.urlopen(request))
+response=urllib.request.urlopen(request)
+cookie=response.headers['Set-Cookie'].split(';')[0]
+result=json.load(response)
assert result['admin'],result
-print('Verified non-loopback HTTP access, first-account creation and GitHub connection UI')
+
+def api(method, path, data=None):
+ request=urllib.request.Request(base+path, method=method, data=json.dumps(data).encode() if data is not None else None,
+ headers={'Cookie':cookie,'Origin':base,'Content-Type':'application/json'})
+ with urllib.request.urlopen(request, timeout=30) as response:
+ return json.load(response)
+
+catalog=api('GET','/api/bootstrap')
+def require_ids(collection, expected):
+ actual={item['id'] for item in catalog[collection]}
+ assert expected <= actual, (collection, expected-actual, actual)
+require_ids('sandboxes', {'local','generic-docker'})
+require_ids('executors', {'codebuddy','codex','claude'})
+require_ids('projects', {'welcome'})
+require_ids('workflows', {'welcome-workflow','generic-backend-delivery','generic-frontend-delivery','generic-product-delivery','issue-fix-production'})
+run=api('POST','/api/runs',{'projectId':'welcome','workflowId':'welcome-workflow','input':'Installer acceptance'})
+run_id=run['id']
+def wait_for(status):
+ deadline=time.monotonic()+90
+ while time.monotonic()<deadline:
+ current=api('GET','/api/runs/'+run_id)
+ assert current['status'] not in ('failed','cancelled'), current
+ if current['status']==status:
+ return current
+ time.sleep(0.5)
+ raise AssertionError('welcome SOP did not reach '+status)
+waiting=wait_for('waiting')
+assert waiting['nodes']['prepare']['status']=='succeeded',waiting
+assert any(item['name']=='welcome' for item in waiting['artifacts']),waiting
+api('POST','/api/runs/'+run_id+'/approve',{'nodeId':'approve'})
+wait_for('succeeded')
+print('Verified access, administrator creation, seeded sandboxes/templates/executors, and a real no-key welcome SOP through approval and completion')
PY
printf '%s install + repeat: %ss (UID %s)\n' "$actor" "$((SECONDS-started))" "$("${prefix[@]}" id -u)"
done
diff --git a/scripts/test-install.py b/scripts/test-install.py
index 2623fe2f..c6deec0b 100644
--- a/scripts/test-install.py
+++ b/scripts/test-install.py
@@ -1,10 +1,14 @@
import importlib.util
+import hashlib
+import io
import os
import pty
import select
+import shlex
from pathlib import Path
import shutil
import subprocess
+import sys
import tempfile
import threading
import time
@@ -16,6 +20,9 @@ ROOT = Path(__file__).resolve().parents[1]
spec = importlib.util.spec_from_file_location('install_address', ROOT / 'scripts/install-address.py')
address = importlib.util.module_from_spec(spec)
spec.loader.exec_module(address)
+compose_spec = importlib.util.spec_from_file_location('install_compose', ROOT / 'scripts/install-compose.py')
+compose_download = importlib.util.module_from_spec(compose_spec)
+compose_spec.loader.exec_module(compose_download)
class InstallerTests(unittest.TestCase):
@@ -25,7 +32,7 @@ class InstallerTests(unittest.TestCase):
self.root = Path(self.temp.name)
(self.root / 'scripts').mkdir()
(self.root / 'migrations/seed').mkdir(parents=True)
- for name in ('install.sh', 'configure.sh', 'docker-access.sh', 'install-address.py', 'install-observability-schema.sh'):
+ for name in ('install.sh', 'configure.sh', 'docker-access.sh', 'install-address.py', 'install-compose.py', 'install-observability-schema.sh'):
shutil.copyfile(ROOT / 'scripts' / name, self.root / 'scripts' / name)
shutil.copyfile(ROOT / 'start.sh', self.root / 'start.sh')
(self.root / 'migrations/seed/001_test.sql').write_text('SELECT 1;\n')
@@ -36,6 +43,7 @@ if [[ "$1" == info ]]; then
[[ "${MOCK_USER:-0}" == 0 || "${MOCK_PRIVILEGED:-0}" == 1 || "${MOCK_DIRECT:-0}" == 1 ]]
exit
fi
+if [[ "$*" == 'compose version' && "${MOCK_COMPOSE_MISSING:-0}" == 1 && ! -f "$MOCK_COMPOSE_INSTALLED" ]]; then exit 1; fi
if [[ "$*" == *'ps --status running'* ]]; then echo platform; fi
if [[ "${MOCK_EXPIRE_AFTER_BUILD:-0}" == 1 && "$*" == *'build platform'* ]]; then touch "$MOCK_SUDO_EXPIRED_FILE"; fi
if [[ "$*" == *'exec -T mysql'* ]]; then
@@ -140,6 +148,111 @@ exec "$@"
self.assertNotIn('build platform', log)
self.assertIn('--no-build --wait --wait-timeout 180', log)
+ def test_missing_python_and_curl_are_installed_with_supported_package_managers(self):
+ state = self.root / 'packages'
+ state.mkdir()
+ shell_env = self.root / 'package-env.sh'
+ shell_env.write_text('''command() {
+ if [[ "$1" == -v ]]; then
+ case "$2" in
+ python3|curl) [[ -e "$MOCK_PACKAGE_STATE/$2" ]] || return 1 ;;
+ apt-get|dnf|yum) [[ "$2" == "$MOCK_PACKAGE_MANAGER" ]] || return 1 ;;
+ esac
+ fi
+ builtin command "$@"
+}
+''')
+ for manager in ('apt-get', 'dnf', 'yum'):
+ self.executable(manager, '''#!/usr/bin/env bash
+printf 'package-manager %s %s\\n' "${0##*/}" "$*" >> "$MOCK_LOG"
+printf 'package-environment %s %s\\n' "${DEBIAN_FRONTEND:-}" "${NEEDRESTART_MODE:-}" >> "$MOCK_LOG"
+if [[ "$*" == *'install'* ]]; then touch "$MOCK_PACKAGE_STATE/python3" "$MOCK_PACKAGE_STATE/curl"; fi
+''')
+ for manager in ('apt-get', 'dnf', 'yum'):
+ with self.subTest(manager=manager):
+ for item in state.iterdir():
+ item.unlink()
+ self.assert_success(self.install(BASH_ENV=str(shell_env), MOCK_PACKAGE_STATE=str(state), MOCK_PACKAGE_MANAGER=manager, LOOPFORGE_YES='1'))
+ self.assertTrue((state / 'python3').exists())
+ self.assertTrue((state / 'curl').exists())
+ log = (self.root / 'docker.log').read_text()
+ self.assertIn('install -y python3 curl ca-certificates', log)
+ if manager == 'apt-get':
+ self.assertIn('package-environment noninteractive a', log)
+ self.assertIn('-o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold', log)
+
+ def test_unusable_macos_python_is_replaced_before_configuring(self):
+ ready = self.root / 'python-ready'
+ self.executable('python3', '#!/usr/bin/env bash\n[[ -f "$MOCK_PYTHON_READY" ]] || exit 1\nexec ' + shlex.quote(sys.executable) + ' "$@"\n')
+ self.executable('uname', '#!/usr/bin/env bash\nif [[ "$1" == -s ]]; then echo Darwin; else echo x86_64; fi\n')
+ self.executable('brew', '#!/usr/bin/env bash\nprintf "brew %s\\n" "$*" >> "$MOCK_LOG"\ntouch "$MOCK_PYTHON_READY"\n')
+ shell_env = self.root / 'macos-env.sh'
+ shell_env.write_text('''command() {
+ if [[ "$1" == -v && "$2" =~ ^(apt-get|dnf|yum)$ ]]; then return 1; fi
+ builtin command "$@"
+}
+''')
+ self.assert_success(self.install(BASH_ENV=str(shell_env), MOCK_PYTHON_READY=str(ready), LOOPFORGE_YES='1'))
+ self.assertIn('brew install python3', (self.root / 'docker.log').read_text())
+
+ def mock_compose_install(self, fail_download=False):
+ # Exercise the shell wiring without writing a plugin to the host.
+ (self.root / 'scripts/install-compose.py').write_text(
+ "raise SystemExit('simulated download failure')\n" if fail_download else
+ "import pathlib,sys; pathlib.Path(sys.argv[1]).write_text('test plugin')\n")
+ self.executable('install', '''#!/usr/bin/env bash
+printf 'plugin-install %s\\n' "$*" >> "$MOCK_LOG"
+if [[ "${MOCK_PLUGIN_FAIL_OPERATION:-}" == "$1" ]]; then exit 1; fi
+if [[ "${!#}" == */docker-compose ]]; then touch "$MOCK_COMPOSE_INSTALLED"; fi
+''')
+ home = self.root / 'home'
+ home.mkdir()
+ return dict(HOME=str(home), MOCK_COMPOSE_MISSING='1', MOCK_COMPOSE_INSTALLED=str(self.root / 'compose-installed'), LOOPFORGE_YES='1')
+
+ def test_missing_compose_is_installed_where_root_and_sudo_docker_find_it(self):
+ values = self.mock_compose_install()
+ self.assert_success(self.install(**values, MOCK_USER='1000'))
+ self.assertIn('plugin-install -m 0755', (self.root / 'docker.log').read_text())
+ self.assertIn('/usr/local/lib/docker/cli-plugins/docker-compose', (self.root / 'docker.log').read_text())
+
+ def test_missing_compose_uses_user_config_with_direct_docker_access(self):
+ values = self.mock_compose_install()
+ config = self.root / 'custom-docker-config'
+ self.assert_success(self.install(**values, MOCK_USER='1000', MOCK_DIRECT='1', MOCK_SUDO_DENIED='1', DOCKER_CONFIG=str(config)))
+ self.assertIn(str(config / 'cli-plugins/docker-compose'), (self.root / 'docker.log').read_text())
+
+ def test_failed_compose_download_stops_before_creating_deployment_config(self):
+ temporary = self.root / 'plugin temporary'
+ temporary.mkdir()
+ result = self.install(**self.mock_compose_install(fail_download=True), TMPDIR=str(temporary))
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn('Docker Compose download failed', result.stderr)
+ self.assertFalse((self.root / '.env').exists())
+ self.assertNotIn('pull --policy', (self.root / 'docker.log').read_text())
+ self.assertEqual(list(temporary.iterdir()), [])
+
+ def test_failed_compose_copy_cleans_download_and_reports_plugin_directory(self):
+ values = self.mock_compose_install()
+ temporary = self.root / 'plugin temporary'
+ temporary.mkdir()
+ for direct in ('0', '1'):
+ for operation in ('-d', '-m'):
+ with self.subTest(direct=direct, operation=operation):
+ result = self.install(**values, TMPDIR=str(temporary), MOCK_USER='1000', MOCK_DIRECT=direct, MOCK_PLUGIN_FAIL_OPERATION=operation)
+ self.assertNotEqual(result.returncode, 0)
+ directory = str(Path(values['HOME']) / '.docker/cli-plugins') if direct == '1' else '/usr/local/lib/docker/cli-plugins'
+ self.assertIn('Could not install Docker Compose in ' + directory, result.stderr)
+ self.assertEqual(list(temporary.iterdir()), [])
+ self.assertFalse((self.root / '.env').exists())
+
+ def test_declining_compose_install_does_not_start_deployment(self):
+ values = self.mock_compose_install()
+ values['LOOPFORGE_YES'] = '0'
+ result = self.install(**values)
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn('Docker Compose is required', result.stderr)
+ self.assertFalse((self.root / '.env').exists())
+
def test_invalid_public_url_fails_before_build(self):
result = self.install(LOOPFORGE_PUBLIC_URL='javascript:alert(1)')
self.assertNotEqual(result.returncode, 0)
@@ -235,5 +348,47 @@ class AddressTests(unittest.TestCase):
self.assertIn('published port', note)
+class ComposeDownloadTests(unittest.TestCase):
+ def test_pinned_download_verifies_checksum_for_both_architectures(self):
+ payload = b'verified compose fixture'
+ checksum = hashlib.sha256(payload).hexdigest()
+ for architecture, asset in (('amd64', 'x86_64'), ('arm64', 'aarch64')):
+ with self.subTest(architecture=architecture), tempfile.TemporaryDirectory() as root:
+ calls = []
+ def fetch(url, timeout):
+ calls.append((url, timeout))
+ return io.BytesIO(payload)
+ target = Path(root) / 'docker-compose'
+ with patch.dict(compose_download.SHA256, {asset: checksum}):
+ compose_download.download(target, architecture, fetch)
+ self.assertEqual(target.read_bytes(), payload)
+ self.assertEqual(calls, [('https://github.com/docker/compose/releases/download/' + compose_download.VERSION + '/docker-compose-linux-' + asset, 120)])
+
+ def test_bad_checksum_preserves_existing_plugin_and_removes_partial_file(self):
+ with tempfile.TemporaryDirectory() as root:
+ target = Path(root) / 'docker-compose'
+ target.write_bytes(b'existing plugin')
+ with self.assertRaisesRegex(ValueError, 'checksum mismatch'):
+ compose_download.download(target, 'x86_64', lambda *a, **kw: io.BytesIO(b'corrupt download'))
+ self.assertEqual(target.read_bytes(), b'existing plugin')
+ self.assertFalse(target.with_suffix('.download').exists())
+
+ def test_failed_transfer_removes_partial_download(self):
+ class BrokenTransfer(io.BytesIO):
+ def read(self, *args):
+ raise OSError('connection lost')
+ with tempfile.TemporaryDirectory() as root:
+ target = Path(root) / 'docker-compose'
+ with self.assertRaisesRegex(OSError, 'connection lost'):
+ compose_download.download(target, 'aarch64', lambda *a, **kw: BrokenTransfer())
+ self.assertFalse(target.exists())
+ self.assertFalse(target.with_suffix('.download').exists())
+
+ def test_unsupported_architecture_does_not_download(self):
+ with tempfile.TemporaryDirectory() as root:
+ with self.assertRaisesRegex(ValueError, 'architecture'):
+ compose_download.download(Path(root) / 'docker-compose', 'unknown', lambda *a, **kw: self.fail('unexpected download'))
+
+
if __name__ == '__main__':
unittest.main()