Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(regression): pin build-base to the image-store project (#2300)

Call Whiteae479b7fe42b
diff --git a/docs/regression/README.md b/docs/regression/README.md
index fa16d97fa..bd0589e16 100644
--- a/docs/regression/README.md
+++ b/docs/regression/README.md
@@ -81,6 +81,8 @@ an SSH daemon or host ownership metadata.
The base image contains slow-changing dependencies such as Python, Node,
build tools, and agent CLIs. Normal code updates do not rebuild this image.
+ It is built and published in the Incus `default` project, where target
+ projects read images from, whatever project the Incus client has selected.
3. Copy the local env template:
diff --git a/scripts/incus_regression.py b/scripts/incus_regression.py
index a3b6c3921..b82c4ead0 100644
--- a/scripts/incus_regression.py
+++ b/scripts/incus_regression.py
@@ -62,6 +62,10 @@ SERVICE_NAME = "avibe-regression.service"
UI_NON_SOURCE_DIRS = ("node_modules", "dist", ".vite")
INTERNAL_DISPATCH_SOCKET = "/tmp/vibe_remote/dispatch.sock"
DEFAULT_IMAGE = "avibe-regression-base-current"
+# Target projects are created with `features.images=false`, so they read images
+# from Incus's `default` project. The base image is built and published there,
+# never in whatever project the client happens to have selected.
+IMAGE_STORE_PROJECT = "default"
DEFAULT_BASE_SOURCE_IMAGE = "images:ubuntu/24.04/cloud"
DEFAULT_NETWORK = "incusbr0"
DEFAULT_STORAGE_POOL = "default"
@@ -1349,6 +1353,11 @@ def regression_service_unit() -> str:
).rstrip()
+def cloud_init_wait_command() -> str:
+ """Wait for first boot, which brings up the network, before provisioning a new instance."""
+ return "if command -v cloud-init >/dev/null 2>&1; then cloud-init status --wait || true; fi"
+
+
def prepare_service_directories_command() -> str:
"""Establish writable roots without visiting existing runtime contents."""
directories = shlex.join((SERVICE_HOME, "/opt/avibe", SOURCE_DIR, VENV_DIR, METADATA_DIR, AVIBE_HOME))
@@ -1587,7 +1596,7 @@ def ensure_project_and_instance(
root_exec(
target,
(
- "if command -v cloud-init >/dev/null 2>&1; then cloud-init status --wait || true; fi; "
+ f"{cloud_init_wait_command()}; "
f"{prepare_service_directories_command()} && "
f"ln -sfn {AVIBE_HOME} {LEGACY_HOME} && "
"systemctl daemon-reload"
@@ -2547,7 +2556,8 @@ def cmd_build_base(args: argparse.Namespace) -> int:
def build_base_image(args: argparse.Namespace) -> int:
runner = Runner(dry_run=args.dry_run)
- runner.run(incus("delete", remote_ref(args.remote, args.temp_instance), "--force"), check=False)
+ project = IMAGE_STORE_PROJECT
+ runner.run(incus("delete", remote_ref(args.remote, args.temp_instance), "--force", project=project), check=False)
runner.run(
incus(
"launch",
@@ -2557,6 +2567,7 @@ def build_base_image(args: argparse.Namespace) -> int:
args.storage_pool,
"--network",
args.network,
+ project=project,
)
)
runner.run(
@@ -2567,8 +2578,10 @@ def build_base_image(args: argparse.Namespace) -> int:
"bash",
"-lc",
textwrap.dedent(
- """\
+ f"""\
set -euo pipefail
+ # `incus launch` returns before first boot has brought up the network.
+ {cloud_init_wait_command()}
apt-get update
apt-get install -y bash ca-certificates curl git build-essential python3 python3-pip python3-venv rsync sudo tmux
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
@@ -2605,6 +2618,7 @@ def build_base_image(args: argparse.Namespace) -> int:
npm --version
"""
),
+ project=project,
)
)
runner.run(
@@ -2615,16 +2629,17 @@ def build_base_image(args: argparse.Namespace) -> int:
"bash",
"-lc",
"cloud-init clean --logs || true",
+ project=project,
)
)
- runner.run(incus("stop", remote_ref(args.remote, args.temp_instance), "--force"), check=False)
- runner.run(incus("image", "delete", remote_ref(args.remote, args.image)), check=False)
- publish_command = incus("publish", remote_ref(args.remote, args.temp_instance))
+ runner.run(incus("stop", remote_ref(args.remote, args.temp_instance), "--force", project=project), check=False)
+ runner.run(incus("image", "delete", remote_ref(args.remote, args.image), project=project), check=False)
+ publish_command = incus("publish", remote_ref(args.remote, args.temp_instance), project=project)
if args.remote:
publish_command.append(remote_ref(args.remote))
publish_command.extend(["--alias", args.image])
runner.run(publish_command)
- runner.run(incus("delete", remote_ref(args.remote, args.temp_instance), "--force"))
+ runner.run(incus("delete", remote_ref(args.remote, args.temp_instance), "--force", project=project))
return 0
diff --git a/tests/test_incus_regression.py b/tests/test_incus_regression.py
index 166f02cd8..8ead5a89e 100644
--- a/tests/test_incus_regression.py
+++ b/tests/test_incus_regression.py
@@ -844,7 +844,7 @@ def test_build_base_uses_publishable_temp_instance() -> None:
joined = "\n".join(" ".join(command) for command in commands)
assert "--ephemeral" not in joined
- assert "incus launch images:ubuntu/24.04/cloud avibe-regression-base-build --storage default --network incusbr0" in joined
+ assert "incus --project default launch images:ubuntu/24.04/cloud avibe-regression-base-build --storage default --network incusbr0" in joined
assert "https://deb.nodesource.com/setup_20.x" in joined
assert "useradd --create-home --shell /bin/bash --groups sudo avibe" in joined
backend_install = joined.split("sudo -H -u avibe -- bash -s <<'AVIBE_BACKENDS'\n", 1)[1].split("\nAVIBE_BACKENDS", 1)[0]
@@ -859,10 +859,50 @@ def test_build_base_uses_publishable_temp_instance() -> None:
# Backends must not be root-global: the non-root avibe user owns them and self-updates.
assert "/usr/local/bin/opencode" not in joined
assert "cloud-init clean --logs || true" in joined
- assert "incus publish avibe-regression-base-build --alias avibe-regression-base-current" in joined
+ assert "incus --project default publish avibe-regression-base-build --alias avibe-regression-base-current" in joined
subprocess.run(["bash", "-n"], input=next(command[-1] for command in commands if "apt-get update" in command[-1]), text=True, check=True)
[email protected]("dry_run", [True, False], ids=["dry-run", "real"])
+def test_build_base_pins_every_incus_call_to_the_image_store_project(
+ monkeypatch: pytest.MonkeyPatch, dry_run: bool
+) -> None:
+ """#2235: a target project holds one instance and reads images from `default`,
+ so build-base must not inherit whichever project the client has selected."""
+ generated: list[list[str]] = []
+ executed: list[list[str]] = []
+
+ class RecordingRunner(incus_regression.Runner):
+ def run(self, command, **kwargs):
+ generated.append(list(command))
+ return super().run(command, **kwargs)
+
+ def incus_boundary(command, **kwargs):
+ executed.append(list(command))
+ return subprocess.CompletedProcess(command, 0, "", "")
+
+ monkeypatch.setenv("INCUS_CMD", "test-incus")
+ monkeypatch.setattr(incus_regression, "Runner", RecordingRunner)
+ monkeypatch.setattr(incus_regression.subprocess, "run", incus_boundary)
+ args = argparse.Namespace(
+ dry_run=dry_run,
+ remote=None,
+ source_image="images:ubuntu/24.04/cloud",
+ temp_instance="test-temp",
+ image="test-image",
+ storage_pool="default",
+ network="incusbr0",
+ )
+
+ assert incus_regression.build_base_image(args) == 0
+
+ assert all(command[:3] == ["test-incus", "--project", "default"] for command in generated)
+ assert [command[3] for command in generated] == [
+ "delete", "launch", "exec", "exec", "stop", "image", "publish", "delete",
+ ]
+ assert executed == ([] if dry_run else generated)
+
+
def _build_base_script_and_runner(monkeypatch: pytest.MonkeyPatch, tmp_path: Path, *, fail_stage: str = ""):
"""INCUS-BOOTSTRAP-001: execute the recipe without Incus or real installers."""
bin_dir = tmp_path / "bin"
@@ -886,8 +926,10 @@ def _build_base_script_and_runner(monkeypatch: pytest.MonkeyPatch, tmp_path: Pat
)
path.chmod(0o755)
- for name in ("apt-get", "useradd", "cloud-init", "node", "askill"):
+ for name in ("apt-get", "useradd", "node", "askill"):
write_stub(name, 'printf "%s complete\\n" "${0##*/}"\n')
+ # Both the first-boot wait and the final clean go through cloud-init; record which.
+ write_stub("cloud-init", 'printf "cloud-init %s\\n" "$*" >> "$TEST_TRACE"\n')
write_stub("id", "exit 1\n")
write_stub(
"sudo",
@@ -942,7 +984,7 @@ esac
def run(command, *, check=False, **kwargs):
assert command[0] == "test-incus", "Only the Incus boundary is stubbed"
commands.append(command)
- if command[1] == "exec":
+ if command[3] == "exec":
# Execute the captured body, never a login shell: profiles may reset
# PATH/HOME and escape the stubs. Inherit no credentials or BASH_ENV.
result = real_run(
@@ -988,15 +1030,17 @@ def test_build_base_executes_backend_heredoc_and_post_bootstrap(tmp_path: Path,
assert (service_home / ".npmrc").read_bytes() == f"prefix={service_home}/.npm-global\n".encode()
assert not (outer_home / ".npmrc").exists()
events = (tmp_path / "trace").read_text(encoding="utf-8").splitlines()
+ # #2235: a freshly launched container has no network until first boot finishes.
+ assert events[:3] == [f"cloud-init|{outer_home}", "cloud-init status --wait", f"apt-get|{outer_home}"]
assert events[events.index(f"sudo|{outer_home}") + 1:] == [
f"npm|{service_home}", f"curl|{service_home}",
f"claude|{service_home}", f"codex|{service_home}", f"opencode|{service_home}",
f"curl|{outer_home}", f"askill|{outer_home}", f"node|{outer_home}", f"npm|{outer_home}",
- f"cloud-init|{outer_home}",
+ f"cloud-init|{outer_home}", "cloud-init clean --logs",
]
assert "askill complete\n" in results[0].stdout
assert results[0].stderr == ""
- assert sum(command[1] == "publish" for command in commands) == 1
+ assert sum(command[3] == "publish" for command in commands) == 1
for name in ("claude", "codex", "opencode"):
assert (service_home / ".local/bin" / name).is_file()
@@ -1013,7 +1057,7 @@ def test_build_base_backend_failure_prevents_publish(
assert excinfo.value.returncode == exit_code
events = (tmp_path / "trace").read_text(encoding="utf-8").splitlines()
assert f"askill|{outer_home}" not in events
- assert [command[1] for command in commands] == ["delete", "launch", "exec"]
+ assert [command[3] for command in commands] == ["delete", "launch", "exec"]
def test_source_exclude_drops_runtime_and_dependency_dirs() -> None: