From d23385f0b348d379483ef5a4d6b9e3959993a212 Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Tue, 17 Nov 2026 17:12:09 -0800 Subject: [PATCH 1/6] fix(bundle): register fails when a computer env it writes has no build a deploy can boot A registration whose compose of a computer env failed, a builder's disk full say, wrote the env and the tasks that deploy it and exited 0, though no deploy could boot it. With bootable, as a registration materializes, a computer env written or reused whose compose recorded builds but none ready or unverified stops it once every entity is written, before any task or eval, naming each build's status and reason. Registering again composes what it has left. Co-Authored-By: Claude Opus 5.5 --- src/agent_env/bundle/materialize.py | 29 +++++++++++++++++- src/agent_env/bundle/register.py | 6 ++-- src/agent_env/cli/bundle.py | 3 +- tst/unit/bundle/computer_env_folder_test.py | 34 +++++++++++++++++++++ tst/unit/bundle/register_test.py | 32 +++++++++++++++++++ 5 files changed, 100 insertions(+), 4 deletions(-) diff --git a/src/agent_env/bundle/materialize.py b/src/agent_env/bundle/materialize.py index ef3990380..8558162b5 100644 --- a/src/agent_env/bundle/materialize.py +++ b/src/agent_env/bundle/materialize.py @@ -30,6 +30,7 @@ from agent_env.env import Env from agent_env.env.envs.computer.env import ComputerEnv from agent_env.env.envs.computer.utils import composer +from agent_env.env.envs.computer.utils.composed import BUILT, stale from agent_env.env.envs.computer.utils.composer import Composing from agent_env.env.registry import get_env_registry from agent_env.eval import Eval, EvalTask @@ -91,6 +92,7 @@ def materialize( composing: Composing = Composing(), on_progress: Callable[[Write, str], None] | None = None, sandbox: str | None = None, + bootable: bool = False, ) -> Materialization: """Write ``plan``'s entities, tasks and evals. The first write that fails stops it, and every earlier one stays: they're in the ledger, so the next run reuses them. ``on_wait`` is called when another run @@ -107,7 +109,9 @@ def materialize( reading what the run would write first isn't preflighted, since the store doesn't hold it yet. Each computer env written is composed as ``composing`` says, and so is what one reused has left, as ``agent-env - env build`` does; ``on_progress``, when given, is told how each goes, a line at a time with its write. + env build`` does; ``on_progress``, when given, is told how each goes, a line at a time with its write. With + ``bootable``, as a registration has it, a computer env written or reused whose compose left no build a deploy can + boot stops it once every entity is written, before any task or eval, raising BundleError naming each such env. ``ledger`` keeps the rows, this run's in the ``@local`` namespace's store unless given; it also says whether each task and eval names the versions it reads (``Ledger.pins_references``) and whether each image the bundle builds is @@ -122,6 +126,7 @@ def materialize( evals = [write for write in plan.writes if write.kind is BundleKind.EVAL] done: dict[tuple[str, str], Materialized] = {} left: list[str] = [] + unbootable: list[str] = [] def through_ledger(write: Write, write_fn: Callable[[], int]) -> None: with _noted(plan, write, "checking" if dry_run else "writing"): @@ -151,6 +156,11 @@ def through_ledger(write: Write, write_fn: Callable[[], int]) -> None: if write.kind is BundleKind.ENV and done[_key(write)].reused and _compose_reused( write, done[_key(write)].version, _composing(composing, on_progress, write), dry_run): left.append(write.id) + if bootable and not dry_run and write.kind is BundleKind.ENV and ( + why := _unbootable(plan, write, done[_key(write)].version)): + unbootable.append(why) + if unbootable: + raise BundleError(unbootable) unwritten = {_key(item.write) for item in done.values() if not item.reused} if dry_run else set() written = done if ledger.pins_references else None built, problems, unchecked = {}, [], [] @@ -338,6 +348,23 @@ def _compose_reused(write: Write, version: int, composing: Composing, dry_run: b return True +def _unbootable(plan: Plan, write: Write, version: int) -> str | None: + """Why the computer env ``write`` left at ``version`` can't be deployed, when its compose recorded builds but none a + deploy boots: each failed, was skipped, or another agent-env recorded it.""" + env = Env.get(write.id, version) + if not isinstance(env, ComputerEnv) or env.computer is None: + return None + records = [(f"{form}/{arch}", record) for form, by_arch in env.metadata.get("composed", {}).items() + for arch, record in by_arch.items()] + if not records or any(record.get("status") in BUILT and not stale(record) for _, record in records): + return None + statuses = env.build_statuses() + builds = "; ".join(f"{pair} {statuses[pair]}" + (f" ({reason[:300]})" if (reason := record.get("reason")) else "") + for pair, record in records) + return (f"{_path(plan, write)}: {write.id} v{version} has no build a deploy can boot ({builds}); register again " + f"to compose them again, or run agent-env env build --id {write.id} --version {version}") + + def _write_env(plan: Plan, write: Write, composing: Composing = Composing()) -> int: entry = write.source.entry cls = get_env_registry()[entry.type] diff --git a/src/agent_env/bundle/register.py b/src/agent_env/bundle/register.py index 2924bbeb9..a0b2efa09 100644 --- a/src/agent_env/bundle/register.py +++ b/src/agent_env/bundle/register.py @@ -92,7 +92,9 @@ def register_bundle( the env's, emulating an arch no link runs natively unless ``emulate`` is False, which leaves it skipped. It turns namespace routing on while it runs. Raises BundleError listing every problem found before anything is - written; a write that fails stops it, and every earlier one stays, in the ledger, for the next run to reuse.""" + written; a write that fails stops it, and every earlier one stays, in the ledger, for the next run to reuse. So does + a computer env whose compose left no build a deploy can boot, once every entity is written and before any task: + registering again composes what it has left.""" composing = Composing(build_sandbox_provider(sandbox) if sandbox else None, emulate) with namespace_routing(): bundle = parse_bundle(Path(root)) @@ -116,7 +118,7 @@ def register_bundle( on_wait=lambda: say("waiting for another agent-env run to finish writing this bundle's ids"), on_build=lambda write: say(f" {_label(registered, write)}: building with docker and pushing"), on_write=lambda done: say(f" {registered_line(registered, done)}"), composing=composing, - on_progress=lambda write, line: say(f" {_label(registered, write)}: {line}")) + on_progress=lambda write, line: say(f" {_label(registered, write)}: {line}"), bootable=True) return Registration(registered, materialization, ids, tuple(_floating(registered)), identity, shared, requires) diff --git a/src/agent_env/cli/bundle.py b/src/agent_env/cli/bundle.py index 5f635c9ca..bb2cc494c 100644 --- a/src/agent_env/cli/bundle.py +++ b/src/agent_env/cli/bundle.py @@ -109,7 +109,8 @@ def register(folder: Path, tasks: tuple[str, ...], evals: tuple[str, ...], prefi registration. The plugin packages the bundle's bundle.toml requires must be installed, as for a run; a folder with no bundle.toml that uses plugin packages is given one. An id the store holds already takes a new version, whoever wrote it. A store other than this machine's is written only after you confirm, or with --yes. Registering - again writes only what changed since.""" + again writes only what changed since. A computer env whose compose leaves no build a deploy can boot fails the + registration once every entity is written, before any task: registering again composes it again.""" options = {"tasks": tasks, "evals": evals, "prefix": prefix, "sandbox": sandbox, "emulate": not no_emulate} click.echo(f"Registering {folder} into:") for line in describe_target(): diff --git a/tst/unit/bundle/computer_env_folder_test.py b/tst/unit/bundle/computer_env_folder_test.py index 9f4b9392c..63f76ee40 100644 --- a/tst/unit/bundle/computer_env_folder_test.py +++ b/tst/unit/bundle/computer_env_folder_test.py @@ -15,9 +15,12 @@ from agent_env.bundle.run import dry_run_bundle from agent_env.env import Env from agent_env.env.envs.computer.utils.composed import composition +from agent_env.env.envs.computer.utils import composer as composer_module from agent_env.env.envs.computer.utils.composer import Composing from agent_env.env.envs.computer.env import ComputerEnv from agent_env.env.envs.multi_env import MultiEnv +from agent_env.store.base import NotFoundError +from agent_env.task import Task from agent_env.providers.sandbox_providers.local_docker.provider import LocalSandboxProvider from tst.unit.bundle._support import layout, local_builds from tst.unit.bundle.computer_app_env_test import APP, TOML as APP_TOML @@ -108,6 +111,37 @@ def test_a_reused_computer_env_composes_what_it_has_left_on_the_runs_provider_an ("disk", "amd64"), ("disk", "arm64")])] +def test_a_computer_env_no_deploy_could_boot_stops_its_tasks_until_composing_it_again_builds_one(tmp_path, composed, + monkeypatch): + """With ``bootable``, as a registration materializes: the env stays written, and its reuse composes what it has + left.""" + results = iter(["failed", "ready"]) + + def compose(env, pairs=None, composing=Composing()): + composed.append(pairs) + env.update_metadata({**env.metadata, "composed": {"container": { + "amd64": {"status": next(results), "composer": composition()}, + "arm64": {"status": "ready", "composer": "another agent-env's"}}}}) + + monkeypatch.setattr(composer_module, "compose", compose) + root = _bundle(tmp_path / "desk") + env_id, task_id = (f"{_plan(root).bundle.bundle.id_root}/{name}" for name in ("desktop", "t")) + + with pytest.raises(BundleError) as stopped: + materialize(_plan(root), build_here=local_builds(_plan(root)), bootable=True) + assert stopped.value.problems == ( + f"envs/desktop: {env_id} v1 has no build a deploy can boot (container/amd64 failed; container/arm64 ready, by " + f"another composer); register again to compose them again, or run agent-env env build --id {env_id} " + "--version 1",) + with pytest.raises(NotFoundError): + Task.get(task_id) + + again = materialize(_plan(root), build_here=local_builds(_plan(root)), bootable=True) + + assert composed == [None, [("container", "amd64"), ("container", "arm64"), ("disk", "amd64"), ("disk", "arm64")]] + assert [done.write.id for done in again.writes if not done.reused] == [task_id] + + def test_a_dry_run_says_what_it_would_compose_of_a_reused_computer_env(tmp_path, composed): """Only the forms its deploys on the run's sandbox boot: local Docker's, the containers.""" root = _bundle(tmp_path / "desk") diff --git a/tst/unit/bundle/register_test.py b/tst/unit/bundle/register_test.py index 9584dfd94..b8d1d1e3b 100644 --- a/tst/unit/bundle/register_test.py +++ b/tst/unit/bundle/register_test.py @@ -19,6 +19,8 @@ from agent_env.bundle import register as register_module from agent_env.artifact.artifacts import computer as computer_artifact_module from agent_env.env import store as env_store_module +from agent_env.env.envs.computer.utils import composer as composer_module +from agent_env.env.envs.computer.utils.composed import composition from agent_env.env.published_images import COMPUTER_IMAGES from agent_env.bundle.register import REGISTRATIONS, _remote_name, register_bundle from agent_env.cli import cli @@ -511,6 +513,36 @@ def test_chromium_registers_into_a_shared_store_with_its_driver_and_base_compute assert (chromium.type, chromium.computer.id, chromium.driver.id) == ("computer_app", "ubuntu-24.04-browser", "page") +def test_a_computer_env_whose_compose_leaves_nothing_a_deploy_boots_fails_the_registration_before_its_tasks( + home, composed, monkeypatch): + """As a builder whose disk filled.""" + for module in (register_module, env_store_module): + monkeypatch.setattr(module, "shared_store", lambda store: True) + bases = {image.ref() for image in COMPUTER_IMAGES} + monkeypatch.setattr("agent_env.env.published_images._registry_digest", lambda ref: DIGEST if ref in bases else None) + monkeypatch.setattr(computer_artifact_module, "_inspect", + lambda image, arches, read: computer_artifact_module._unread(arches, "no registry in a test")) + + def compose(env, pairs=None, composing=None): + env.update_metadata({**env.metadata, "composed": {"container": { + "amd64": {"status": "failed", "reason": "no space left on device", "composer": composition()}, + "arm64": {"status": "skipped", "reason": "no link runs linux/arm64 natively", "composer": composition()}}}}) + + monkeypatch.setattr(composer_module, "compose", compose) + files = {"envs/desktop/env.toml": 'type = "computer"\ncomputer = "ubuntu-24.04"\ndriver = "reference"\n', + "tasks/t.json": json.dumps([{"id": "env", "type": "deploy_env", "env_id": "desktop"}])} + + result = CliRunner().invoke(cli, ["bundle", "register", str(layout(home / "desk", files)), "--yes"]) + + assert result.exit_code == 1, result.output + assert ("envs/desktop: desk-desktop v1 has no build a deploy can boot (container/amd64 failed (no space left on " + "device); container/arm64 skipped (no link runs linux/arm64 natively)); register again to compose them " + "again, or run agent-env env build --id desk-desktop --version 1") in result.output + assert Env.get("desk-desktop").version == 1 + with pytest.raises(NotFoundError): + Task.get("desk-t") + + def test_a_write_that_fails_leaves_no_pending_row(home, monkeypatch): def failing(*args, **kwargs): raise RuntimeError("the store went away") From 2431a6d1bc3fab77a57a038633578fe637b97fa9 Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Tue, 17 Nov 2026 17:22:51 -0800 Subject: [PATCH 2/6] fix(bundle): the unbootable message says no task was written and how a skipped arch builds Co-Authored-By: Claude Opus 5.5 --- src/agent_env/bundle/materialize.py | 7 +++++-- tst/unit/bundle/computer_env_folder_test.py | 4 ++-- tst/unit/bundle/register_test.py | 6 ++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/agent_env/bundle/materialize.py b/src/agent_env/bundle/materialize.py index 8558162b5..ea612d01b 100644 --- a/src/agent_env/bundle/materialize.py +++ b/src/agent_env/bundle/materialize.py @@ -361,8 +361,11 @@ def _unbootable(plan: Plan, write: Write, version: int) -> str | None: statuses = env.build_statuses() builds = "; ".join(f"{pair} {statuses[pair]}" + (f" ({reason[:300]})" if (reason := record.get("reason")) else "") for pair, record in records) - return (f"{_path(plan, write)}: {write.id} v{version} has no build a deploy can boot ({builds}); register again " - f"to compose them again, or run agent-env env build --id {write.id} --version {version}") + how = (", emulating a skipped arch or on a --sandbox that runs it natively" + if any(record.get("status") == "skipped" for _, record in records) else "") + return (f"{_path(plan, write)}: {write.id} v{version} has no build a deploy can boot ({builds}), so no task was " + f"written: register again to compose what it left{how}, or compose it with agent-env env build --id " + f"{write.id} --version {version} and then register again") def _write_env(plan: Plan, write: Write, composing: Composing = Composing()) -> int: diff --git a/tst/unit/bundle/computer_env_folder_test.py b/tst/unit/bundle/computer_env_folder_test.py index 63f76ee40..294c8a779 100644 --- a/tst/unit/bundle/computer_env_folder_test.py +++ b/tst/unit/bundle/computer_env_folder_test.py @@ -131,8 +131,8 @@ def compose(env, pairs=None, composing=Composing()): materialize(_plan(root), build_here=local_builds(_plan(root)), bootable=True) assert stopped.value.problems == ( f"envs/desktop: {env_id} v1 has no build a deploy can boot (container/amd64 failed; container/arm64 ready, by " - f"another composer); register again to compose them again, or run agent-env env build --id {env_id} " - "--version 1",) + f"another composer), so no task was written: register again to compose what it left, or compose it with " + f"agent-env env build --id {env_id} --version 1 and then register again",) with pytest.raises(NotFoundError): Task.get(task_id) diff --git a/tst/unit/bundle/register_test.py b/tst/unit/bundle/register_test.py index b8d1d1e3b..ab1c81fb1 100644 --- a/tst/unit/bundle/register_test.py +++ b/tst/unit/bundle/register_test.py @@ -536,8 +536,10 @@ def compose(env, pairs=None, composing=None): assert result.exit_code == 1, result.output assert ("envs/desktop: desk-desktop v1 has no build a deploy can boot (container/amd64 failed (no space left on " - "device); container/arm64 skipped (no link runs linux/arm64 natively)); register again to compose them " - "again, or run agent-env env build --id desk-desktop --version 1") in result.output + "device); container/arm64 skipped (no link runs linux/arm64 natively)), so no task was written: register " + "again to compose what it left, emulating a skipped arch or on a --sandbox that runs it natively, or " + "compose it with agent-env env build --id desk-desktop --version 1 and then register again" + ) in result.output assert Env.get("desk-desktop").version == 1 with pytest.raises(NotFoundError): Task.get("desk-t") From 8a6686e3c158cf5cc20ba53da9dfc8c75c6fc836 Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Tue, 17 Nov 2026 17:18:11 -0800 Subject: [PATCH 3/6] feat(bundle): register --deploys-on composes only the forms the tasks' deploys boot bundle register composed every form a computer env's base declares, so a bundle whose deploys all boot containers composed a disk form too, which no deploy boots: 21 minutes and about 13 GB for one desktop. With --deploys-on, the provider or chain the registered tasks will deploy on, each computer env composes only the forms those deploys boot, as agent-env run does (Composing forms_of=deploys); a deploy that boots another form composes it first. Without it, register composes every form, as before. Whether a computer env has a build a deploy can boot is now judged on those forms alone. Co-Authored-By: Claude Opus 5.5 --- src/agent_env/bundle/materialize.py | 11 ++--- src/agent_env/bundle/register.py | 9 +++- src/agent_env/cli/bundle.py | 9 +++- tst/unit/bundle/register_test.py | 65 +++++++++++++++++++++++++---- 4 files changed, 77 insertions(+), 17 deletions(-) diff --git a/src/agent_env/bundle/materialize.py b/src/agent_env/bundle/materialize.py index ea612d01b..878f2c4d6 100644 --- a/src/agent_env/bundle/materialize.py +++ b/src/agent_env/bundle/materialize.py @@ -157,7 +157,7 @@ def through_ledger(write: Write, write_fn: Callable[[], int]) -> None: write, done[_key(write)].version, _composing(composing, on_progress, write), dry_run): left.append(write.id) if bootable and not dry_run and write.kind is BundleKind.ENV and ( - why := _unbootable(plan, write, done[_key(write)].version)): + why := _unbootable(plan, write, done[_key(write)].version, composing)): unbootable.append(why) if unbootable: raise BundleError(unbootable) @@ -348,13 +348,14 @@ def _compose_reused(write: Write, version: int, composing: Composing, dry_run: b return True -def _unbootable(plan: Plan, write: Write, version: int) -> str | None: - """Why the computer env ``write`` left at ``version`` can't be deployed, when its compose recorded builds but none a - deploy boots: each failed, was skipped, or another agent-env recorded it.""" +def _unbootable(plan: Plan, write: Write, version: int, composing: Composing) -> str | None: + """Why the computer env ``write`` left at ``version`` can't be deployed, when its compose recorded builds of + ``composing``'s forms but none a deploy boots: each failed, was skipped, or another agent-env recorded it.""" env = Env.get(write.id, version) if not isinstance(env, ComputerEnv) or env.computer is None: return None - records = [(f"{form}/{arch}", record) for form, by_arch in env.metadata.get("composed", {}).items() + forms = composing.forms(env, composing.provider()) + records = [(f"{form}/{arch}", record) for form, by_arch in env.metadata.get("composed", {}).items() if form in forms for arch, record in by_arch.items()] if not records or any(record.get("status") in BUILT and not stale(record) for _, record in records): return None diff --git a/src/agent_env/bundle/register.py b/src/agent_env/bundle/register.py index a0b2efa09..6a990e688 100644 --- a/src/agent_env/bundle/register.py +++ b/src/agent_env/bundle/register.py @@ -82,6 +82,7 @@ def register_bundle( on_progress: Callable[[str], None] | None = None, sandbox: str | None = None, emulate: bool = True, + deploys_on: str | None = None, ) -> Registration: """Register the bundle at ``root``: ``tasks`` and ``evals`` by name, or with neither every task and eval it has, or every entity when it has none, with what they reference. ``prefix`` opens each entry's registry id, the folder's @@ -89,13 +90,17 @@ def register_bundle( is given a line for each write, as it's checked or written, and before each image is built. A folder with no bundle.toml that uses plugin packages is given one, or told what to declare, as ``declaring`` says: by default as a run of the folder would (``declaring_for``). ``sandbox`` is the provider its computer envs compose on, by default - the env's, emulating an arch no link runs natively unless ``emulate`` is False, which leaves it skipped. + the env's, emulating an arch no link runs natively unless ``emulate`` is False, which leaves it skipped. With + ``deploys_on``, the provider its tasks' deploys will boot them on, each composes only the forms those deploys boot, + as a run does; without it, every form its base declares. It turns namespace routing on while it runs. Raises BundleError listing every problem found before anything is written; a write that fails stops it, and every earlier one stays, in the ledger, for the next run to reuse. So does a computer env whose compose left no build a deploy can boot, once every entity is written and before any task: registering again composes what it has left.""" - composing = Composing(build_sandbox_provider(sandbox) if sandbox else None, emulate) + composing = Composing(build_sandbox_provider(sandbox) if sandbox else None, emulate, + forms_of="deploys" if deploys_on else "base", + deploys_on=build_sandbox_provider(deploys_on) if deploys_on else None) with namespace_routing(): bundle = parse_bundle(Path(root)) resolved = resolve_bundle(bundle) diff --git a/src/agent_env/cli/bundle.py b/src/agent_env/cli/bundle.py index bb2cc494c..4d40c8500 100644 --- a/src/agent_env/cli/bundle.py +++ b/src/agent_env/cli/bundle.py @@ -92,8 +92,12 @@ def _report(imported: BundleImport, folder: Path) -> None: @click.option("--no-emulate", is_flag=True, help="Skip, rather than emulate, an arch no link of the sandbox provider runs natively; a later register " "or env build builds it.") +@click.option("--deploys-on", default=None, + help="The sandbox provider the registered tasks will deploy the bundle's computer envs on, comma-separated " + "for a chain: each composes only the forms those deploys boot, as agent-env run does, rather than " + "every form its base declares. A deploy that boots another form composes it first.") def register(folder: Path, tasks: tuple[str, ...], evals: tuple[str, ...], prefix: str | None, - dry_run: bool, yes: bool, sandbox: str | None, no_emulate: bool): + dry_run: bool, yes: bool, sandbox: str | None, no_emulate: bool, deploys_on: str | None): """Write the bundle at FOLDER into the configured stores under registry ids, so whatever runs the stores' tasks runs what the folder runs. @@ -111,7 +115,8 @@ def register(folder: Path, tasks: tuple[str, ...], evals: tuple[str, ...], prefi whoever wrote it. A store other than this machine's is written only after you confirm, or with --yes. Registering again writes only what changed since. A computer env whose compose leaves no build a deploy can boot fails the registration once every entity is written, before any task: registering again composes it again.""" - options = {"tasks": tasks, "evals": evals, "prefix": prefix, "sandbox": sandbox, "emulate": not no_emulate} + options = {"tasks": tasks, "evals": evals, "prefix": prefix, "sandbox": sandbox, "emulate": not no_emulate, + "deploys_on": deploys_on} click.echo(f"Registering {folder} into:") for line in describe_target(): click.echo(f" {line}") diff --git a/tst/unit/bundle/register_test.py b/tst/unit/bundle/register_test.py index ab1c81fb1..faa909c39 100644 --- a/tst/unit/bundle/register_test.py +++ b/tst/unit/bundle/register_test.py @@ -6,6 +6,7 @@ import subprocess from dataclasses import fields from pathlib import Path +from types import SimpleNamespace import pytest from click.testing import CliRunner @@ -513,26 +514,59 @@ def test_chromium_registers_into_a_shared_store_with_its_driver_and_base_compute assert (chromium.type, chromium.computer.id, chromium.driver.id) == ("computer_app", "ubuntu-24.04-browser", "page") -def test_a_computer_env_whose_compose_leaves_nothing_a_deploy_boots_fails_the_registration_before_its_tasks( - home, composed, monkeypatch): - """As a builder whose disk filled.""" +def _desktop(home, monkeypatch, compose): + """A bundle of a computer env on the shipped base and driver, registered into a shared store as the hub is, under + their aliases, ``compose`` standing in for the composer.""" for module in (register_module, env_store_module): monkeypatch.setattr(module, "shared_store", lambda store: True) bases = {image.ref() for image in COMPUTER_IMAGES} monkeypatch.setattr("agent_env.env.published_images._registry_digest", lambda ref: DIGEST if ref in bases else None) monkeypatch.setattr(computer_artifact_module, "_inspect", lambda image, arches, read: computer_artifact_module._unread(arches, "no registry in a test")) + monkeypatch.setattr(composer_module, "compose", compose) + files = {"envs/desktop/env.toml": 'type = "computer"\ncomputer = "ubuntu-24.04"\ndriver = "reference"\n', + "tasks/t.json": json.dumps([{"id": "env", "type": "deploy_env", "env_id": "desktop"}])} + return layout(home / "desk", files) + + +def _link(containers=(), disks=()): + """A sandbox provider that runs containers of ``containers`` and boots disks of ``disks`` natively.""" + link = SimpleNamespace(native_platforms=lambda: frozenset(f"linux/{arch}" for arch in containers), + disk_image_platforms=lambda: frozenset(f"linux/{arch}" for arch in disks), ON_THIS_MACHINE=True) + link.links = (link,) + return link + + +_DEPLOYS_ON = {"docker": _link(["amd64"]), "vms": _link(disks=["amd64"]), + "chain": SimpleNamespace(links=(_link(["amd64"]), _link(disks=["amd64"])))} + + +@pytest.mark.parametrize("deploys_on, forms", [(None, ["container", "disk"]), ("docker", ["container"]), + ("vms", ["disk"]), ("chain", ["container", "disk"])]) +def test_a_registration_composes_the_forms_its_deploys_boot_on_the_provider_it_names_else_every_form( + home, composed, monkeypatch, deploys_on, forms): + composings = [] + root = _desktop(home, monkeypatch, lambda env, pairs=None, composing=None: composings.append(composing)) + monkeypatch.setattr(register_module, "build_sandbox_provider", _DEPLOYS_ON.__getitem__) + + result = CliRunner().invoke(cli, ["bundle", "register", str(root), "--yes", + *(["--deploys-on", deploys_on] if deploys_on else [])]) + + assert result.exit_code == 0, result.output + [used] = composings + assert used.forms(Env.get("desk-desktop"), used.provider()) == forms + assert (used.sandbox_provider, used.deploys_on) == (None, _DEPLOYS_ON.get(deploys_on)) + +def test_a_computer_env_whose_compose_leaves_nothing_a_deploy_boots_fails_the_registration_before_its_tasks( + home, composed, monkeypatch): + """As a builder whose disk filled.""" def compose(env, pairs=None, composing=None): env.update_metadata({**env.metadata, "composed": {"container": { "amd64": {"status": "failed", "reason": "no space left on device", "composer": composition()}, "arm64": {"status": "skipped", "reason": "no link runs linux/arm64 natively", "composer": composition()}}}}) - monkeypatch.setattr(composer_module, "compose", compose) - files = {"envs/desktop/env.toml": 'type = "computer"\ncomputer = "ubuntu-24.04"\ndriver = "reference"\n', - "tasks/t.json": json.dumps([{"id": "env", "type": "deploy_env", "env_id": "desktop"}])} - - result = CliRunner().invoke(cli, ["bundle", "register", str(layout(home / "desk", files)), "--yes"]) + result = CliRunner().invoke(cli, ["bundle", "register", str(_desktop(home, monkeypatch, compose)), "--yes"]) assert result.exit_code == 1, result.output assert ("envs/desktop: desk-desktop v1 has no build a deploy can boot (container/amd64 failed (no space left on " @@ -545,6 +579,21 @@ def compose(env, pairs=None, composing=None): Task.get("desk-t") +def test_a_registration_for_deploys_that_boot_containers_fails_on_a_failed_container_whatever_disk_was_built( + home, composed, monkeypatch): + def compose(env, pairs=None, composing=None): + env.update_metadata({**env.metadata, "composed": { + "container": {"amd64": {"status": "failed", "composer": composition()}}, + "disk": {"amd64": {"status": "unverified", "image": "disk", "composer": composition()}}}}) + + root = _desktop(home, monkeypatch, compose) + monkeypatch.setattr(register_module, "build_sandbox_provider", _DEPLOYS_ON.__getitem__) + + result = CliRunner().invoke(cli, ["bundle", "register", str(root), "--yes", "--deploys-on", "docker"]) + + assert result.exit_code == 1 and "has no build a deploy can boot (container/amd64 failed), so" in result.output + + def test_a_write_that_fails_leaves_no_pending_row(home, monkeypatch): def failing(*args, **kwargs): raise RuntimeError("the store went away") From 359bd1ac32ef5a83fb9e29e2bfa54f974352dafb Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Tue, 17 Nov 2026 17:35:45 -0800 Subject: [PATCH 4/6] refactor(bundle): name how much of a build's reason the unbootable problem quotes Co-Authored-By: Claude Opus 5.5 --- src/agent_env/bundle/materialize.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/agent_env/bundle/materialize.py b/src/agent_env/bundle/materialize.py index ea612d01b..b5dedd51a 100644 --- a/src/agent_env/bundle/materialize.py +++ b/src/agent_env/bundle/materialize.py @@ -50,6 +50,10 @@ from .plan import Plan, Write, artifact_writer, env_writer, unpinned_store_refs from .resolve import BuiltImage, BundleImage, ReferencedImage, build_step +#: How much of each build's reason the problem naming a computer env no deploy can boot quotes: a failed build's reason +#: holds the build's error, which can run to pages. +_REASON_CHARS = 300 + @dataclass(frozen=True) class Materialized: @@ -359,8 +363,8 @@ def _unbootable(plan: Plan, write: Write, version: int) -> str | None: if not records or any(record.get("status") in BUILT and not stale(record) for _, record in records): return None statuses = env.build_statuses() - builds = "; ".join(f"{pair} {statuses[pair]}" + (f" ({reason[:300]})" if (reason := record.get("reason")) else "") - for pair, record in records) + quoted = {pair: f" ({record['reason'][:_REASON_CHARS]})" for pair, record in records if record.get("reason")} + builds = "; ".join(f"{pair} {statuses[pair]}{quoted.get(pair, '')}" for pair, _ in records) how = (", emulating a skipped arch or on a --sandbox that runs it natively" if any(record.get("status") == "skipped" for _, record in records) else "") return (f"{_path(plan, write)}: {write.id} v{version} has no build a deploy can boot ({builds}), so no task was " From 22f7b4ae5867e3ec131b3145205333004e2671d7 Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Tue, 17 Nov 2026 20:50:59 -0800 Subject: [PATCH 5/6] feat(bundle): register's --sandbox is where its tasks deploy, so it composes only what deploys there boot --deploys-on asked for a second provider beside --sandbox, and agent-env run asks for one: the sandbox its deploys are on. So --sandbox now says it for a registration too: each computer env composes on it only the forms its deploys there boot, as a run does. Without it, every form its base declares, on the env's provider, as before. Co-Authored-By: Claude Opus 5.5 --- src/agent_env/bundle/register.py | 12 +++++------- src/agent_env/cli/bundle.py | 15 ++++++--------- tst/unit/bundle/register_test.py | 22 +++++++++++----------- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/agent_env/bundle/register.py b/src/agent_env/bundle/register.py index 6a990e688..437eb9210 100644 --- a/src/agent_env/bundle/register.py +++ b/src/agent_env/bundle/register.py @@ -82,25 +82,23 @@ def register_bundle( on_progress: Callable[[str], None] | None = None, sandbox: str | None = None, emulate: bool = True, - deploys_on: str | None = None, ) -> Registration: """Register the bundle at ``root``: ``tasks`` and ``evals`` by name, or with neither every task and eval it has, or every entity when it has none, with what they reference. ``prefix`` opens each entry's registry id, the folder's name and a dash unless given. An id the store holds already takes a new version, whoever wrote it. ``on_progress`` is given a line for each write, as it's checked or written, and before each image is built. A folder with no bundle.toml that uses plugin packages is given one, or told what to declare, as ``declaring`` says: by default as a - run of the folder would (``declaring_for``). ``sandbox`` is the provider its computer envs compose on, by default - the env's, emulating an arch no link runs natively unless ``emulate`` is False, which leaves it skipped. With - ``deploys_on``, the provider its tasks' deploys will boot them on, each composes only the forms those deploys boot, - as a run does; without it, every form its base declares. + run of the folder would (``declaring_for``). ``sandbox`` is the provider its tasks deploy on: each computer env + composes there only the forms its deploys there boot, as a run does, emulating an arch no link runs natively unless + ``emulate`` is False, which leaves it skipped. Without it, each composes every form its base declares, on the env's + provider. It turns namespace routing on while it runs. Raises BundleError listing every problem found before anything is written; a write that fails stops it, and every earlier one stays, in the ledger, for the next run to reuse. So does a computer env whose compose left no build a deploy can boot, once every entity is written and before any task: registering again composes what it has left.""" composing = Composing(build_sandbox_provider(sandbox) if sandbox else None, emulate, - forms_of="deploys" if deploys_on else "base", - deploys_on=build_sandbox_provider(deploys_on) if deploys_on else None) + forms_of="deploys" if sandbox else "base") with namespace_routing(): bundle = parse_bundle(Path(root)) resolved = resolve_bundle(bundle) diff --git a/src/agent_env/cli/bundle.py b/src/agent_env/cli/bundle.py index 4d40c8500..51bf8ab9d 100644 --- a/src/agent_env/cli/bundle.py +++ b/src/agent_env/cli/bundle.py @@ -87,17 +87,15 @@ def _report(imported: BundleImport, folder: Path) -> None: @click.option("--dry-run", is_flag=True, help="Check everything and say what would be written; write nothing.") @click.option("--yes", is_flag=True, help="Write to a store other than this machine's own without asking.") @click.option("--sandbox", default=None, - help="The sandbox provider the bundle's computer envs compose on, by default the env's; comma-separated " - "for a chain, each arch going to the first link that runs it natively.") + help="The sandbox provider the registered tasks deploy on, comma-separated for a chain: each computer env " + "composes there, each arch on the first link that runs it natively, only the forms its deploys there " + "boot, as agent-env run does. Without it, every form its base declares, on the env's provider. A " + "deploy that boots a form not composed composes it first.") @click.option("--no-emulate", is_flag=True, help="Skip, rather than emulate, an arch no link of the sandbox provider runs natively; a later register " "or env build builds it.") -@click.option("--deploys-on", default=None, - help="The sandbox provider the registered tasks will deploy the bundle's computer envs on, comma-separated " - "for a chain: each composes only the forms those deploys boot, as agent-env run does, rather than " - "every form its base declares. A deploy that boots another form composes it first.") def register(folder: Path, tasks: tuple[str, ...], evals: tuple[str, ...], prefix: str | None, - dry_run: bool, yes: bool, sandbox: str | None, no_emulate: bool, deploys_on: str | None): + dry_run: bool, yes: bool, sandbox: str | None, no_emulate: bool): """Write the bundle at FOLDER into the configured stores under registry ids, so whatever runs the stores' tasks runs what the folder runs. @@ -115,8 +113,7 @@ def register(folder: Path, tasks: tuple[str, ...], evals: tuple[str, ...], prefi whoever wrote it. A store other than this machine's is written only after you confirm, or with --yes. Registering again writes only what changed since. A computer env whose compose leaves no build a deploy can boot fails the registration once every entity is written, before any task: registering again composes it again.""" - options = {"tasks": tasks, "evals": evals, "prefix": prefix, "sandbox": sandbox, "emulate": not no_emulate, - "deploys_on": deploys_on} + options = {"tasks": tasks, "evals": evals, "prefix": prefix, "sandbox": sandbox, "emulate": not no_emulate} click.echo(f"Registering {folder} into:") for line in describe_target(): click.echo(f" {line}") diff --git a/tst/unit/bundle/register_test.py b/tst/unit/bundle/register_test.py index faa909c39..dab1d13c4 100644 --- a/tst/unit/bundle/register_test.py +++ b/tst/unit/bundle/register_test.py @@ -537,25 +537,25 @@ def _link(containers=(), disks=()): return link -_DEPLOYS_ON = {"docker": _link(["amd64"]), "vms": _link(disks=["amd64"]), - "chain": SimpleNamespace(links=(_link(["amd64"]), _link(disks=["amd64"])))} +_SANDBOXES = {"docker": _link(["amd64"]), "vms": _link(disks=["amd64"]), + "chain": SimpleNamespace(links=(_link(["amd64"]), _link(disks=["amd64"])))} -@pytest.mark.parametrize("deploys_on, forms", [(None, ["container", "disk"]), ("docker", ["container"]), - ("vms", ["disk"]), ("chain", ["container", "disk"])]) -def test_a_registration_composes_the_forms_its_deploys_boot_on_the_provider_it_names_else_every_form( - home, composed, monkeypatch, deploys_on, forms): +@pytest.mark.parametrize("sandbox, forms", [(None, ["container", "disk"]), ("docker", ["container"]), + ("vms", ["disk"]), ("chain", ["container", "disk"])]) +def test_a_registration_composes_on_its_sandbox_the_forms_its_deploys_there_boot_else_every_form( + home, composed, monkeypatch, sandbox, forms): composings = [] root = _desktop(home, monkeypatch, lambda env, pairs=None, composing=None: composings.append(composing)) - monkeypatch.setattr(register_module, "build_sandbox_provider", _DEPLOYS_ON.__getitem__) + monkeypatch.setattr(register_module, "build_sandbox_provider", _SANDBOXES.__getitem__) result = CliRunner().invoke(cli, ["bundle", "register", str(root), "--yes", - *(["--deploys-on", deploys_on] if deploys_on else [])]) + *(["--sandbox", sandbox] if sandbox else [])]) assert result.exit_code == 0, result.output [used] = composings assert used.forms(Env.get("desk-desktop"), used.provider()) == forms - assert (used.sandbox_provider, used.deploys_on) == (None, _DEPLOYS_ON.get(deploys_on)) + assert used.sandbox_provider is _SANDBOXES.get(sandbox) def test_a_computer_env_whose_compose_leaves_nothing_a_deploy_boots_fails_the_registration_before_its_tasks( @@ -587,9 +587,9 @@ def compose(env, pairs=None, composing=None): "disk": {"amd64": {"status": "unverified", "image": "disk", "composer": composition()}}}}) root = _desktop(home, monkeypatch, compose) - monkeypatch.setattr(register_module, "build_sandbox_provider", _DEPLOYS_ON.__getitem__) + monkeypatch.setattr(register_module, "build_sandbox_provider", _SANDBOXES.__getitem__) - result = CliRunner().invoke(cli, ["bundle", "register", str(root), "--yes", "--deploys-on", "docker"]) + result = CliRunner().invoke(cli, ["bundle", "register", str(root), "--yes", "--sandbox", "docker"]) assert result.exit_code == 1 and "has no build a deploy can boot (container/amd64 failed), so" in result.output From 3b1b07a21015808f74e5959d71b21382fbdfebf1 Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Tue, 17 Nov 2026 21:56:05 -0800 Subject: [PATCH 6/6] feat(bundle): register's --sandbox picks the forms as run's does, and the compose stays on this machine register --sandbox X both moved the compose to X and picked X's forms, so composing here for deploys on Modal was gone: --sandbox modal_vm sent the builds to Modal VMs, which refuse this machine's local stores. It now means what run's --sandbox means (Composing.for_run): the forms deploys on X boot, composed on the env's provider, this machine's Docker unless the config names another. Without it, every form, as before. env build keeps --sandbox for where it builds, so the unbootable message names it there. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 2 +- src/agent_env/bundle/materialize.py | 6 +++--- src/agent_env/bundle/register.py | 11 +++++------ src/agent_env/cli/bundle.py | 12 ++++++------ tst/unit/bundle/computer_env_folder_test.py | 2 +- tst/unit/bundle/register_test.py | 9 ++++----- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index d547c1c53..f1eb86348 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -123,7 +123,7 @@ and deserialized through a registry. | Package | Contents | |---|---| -| `env/` | `Env` base class: a subclass declares `type`, implements `from_dict` and `async deploy(...) -> DeployedEnv`, and may override `reset`, `close` and `load_file_artifact_universe`; teardown closes each env a run deployed before terminating its sandboxes by id. Built-ins in `env/envs/`: `MCPServerEnv` (`mcp_server`), `MultiEnv` (`multi`, MCP servers plus websites and computers; its website browser is the one its `browser_envs` names, none for `[]`, else the run's when it has websites: an MCP server env such as `playwright-mcp` runs among the gateway's MCP servers, and a browser computer such as `chromium` on a sandbox of its own as one more computer child, sized by its `child_envs` entry, its tools under its name and `_`, routing the multi env's synthetic sites unless that entry's `site_routing` says, its network its own env's, as any computer child's; a website env deployed alone refuses a browser computer as the run's browser), `ServiceDBEnv` (`service_db`, PostgreSQL), `WebsiteEnv` (`website`, one site: a server image, `backend_image` in its env.toml, serving the pages and API, ready when its card's `website/v1` `ready` answers a `WebsiteReadiness` that says so, as `agentenv_protocol.website` (`website_readiness`, `env_readiness`) defines a website env's health for the deploy and `DeployedEnv.readiness()` alike, or, for a card without `ready`, when its `health` path answers 200, which is deprecated; its env.toml's `ready_timeout_s`, how long it may take from its server's container starting to ready, is that container's health check `start_period` and what the deploy waits, or its card's `ready` timeout if longer, and its `shm_mb` is the container's `shm_size`, each left to the gateway and Docker without them; the gateway container's `env/gateway/constants.py` mirrors the URI and op, a test keeping them equal; a separate frontend image is deprecated, warned of at put and optional in a bundle, and a stored `backend_docker_image_artifact` reads as the server image; a live one, `live = true`, is a real site whose server serves none of its pages, its `live`, `domains` and `allow_hosts` read at put from its server's `@website(...)` (`utils/card_naming.py` `WebsiteSource`) unless given, its `settings`' secrets only as references the gateway resolves as it writes the site's container (`WEBSITE_SETTINGS_ENV`); the gateway gives it no site route, a computer's site table leaves it out, a computer whose network is an allowlist is let reach its names (`MultiEnv.live_hosts`), a browser alone's forward port takes them straight to the real site (`site_proxy.py` `direct`), as the browser base's stand-in proxy takes any host, refusing nothing, each proxy logging each such connection as a JSON line, and a run that deploys one is marked live, `reproducible: false`), `GatewayEnv` (`gateway_server`), `ComputerDriverEnv` (`computer_driver`, `env/envs/computer/driver_env.py`: a computer driver's files and what its class declares for each platform it supports, read at put in a process of its own, `agentenv_protocol.computer._declare`, where the driver's own dependencies needn't be installed, with the `port` it serves on and its install by OS, `[install.]`, or for one distribution `[install."/"]`, which replaces its OS type's there, as its `known_failures` do (`env/envs/computer/utils/install.py`): files, apt `packages` with extra `sources`, a `python` requirements file for a venv, `downloads` by URL and sha256, `run` scripts, the services the base's init runs, and `ports`; it deploys only as a computer env's driver), `ComputerEnv` (`computer`, in `env/envs/computer/`: a base computer and a driver, matched at put by gate 1 before anything is stored, then composed by `composer.py` into an image for each form and arch on a builder of the put's sandbox provider, by default the env's (`utils/builder.py`; `--sandbox` on `env build`, `bundle register` and `run`): this machine's Docker for `local`, else a VM of the provider, which fetches the put's stored files by signed URL, takes the rest inline and pushes to the image store itself, so it builds only with stores a remote VM reaches; each arch goes to the first link that runs it natively, else one that emulates it (a VM registers QEMU; `--no-emulate` leaves it `skipped` instead, for a later put), and its pair records the provider that built it (`builder`); a run or register that reuses a computer env composes what it has left (`pending`), a run only the forms its sandbox's deploys boot (`booted_forms`: on each link, the first form it boots natively, by the deploy's own rule, `boot.first_native`; a compose of a disk adds its container), and a deploy composes first what it boots that no compose started, and a container it runs natively that was built but not probed, as one whose probe a setting that didn't resolve stopped, booting it only once ready (`ComputerEnv.compose_unstarted`); tagged `agentenv-computers:` in the image store by a key of the image's Dockerfile, build context and lock so any env with the same inputs reuses it; every layer's packages, requirements and downloads are resolved at put in a container of the base for each arch (`utils/packages.py`, `utils/resolve_in_base.py`), stored in the object store by sha256 under `agentenv-packages/`, and listed in a lock stored by a digest of its inputs, which any env with the same inputs reuses, and builds install only the lock's files, every install step `RUN --network=none`; each pair's status goes into its metadata, `composed`, the arches built are written as its computer, a `computer` artifact over one index, and `agent-env env build` resumes what a put left; gate 3 (`utils/probing.py`) then boots each native build on the put's sandbox provider and probes it at `full`, making it `ready` or `failed`, and a build no provider runs natively stays `unverified`. Its deploy, through the `computer` env provider (`providers/env_providers/env_computer_provider.py`), boots its first `ready` build on a sandbox provider that runs its arch natively (`native_platforms()`), with no gateway in front and the driver's card as the env card, its `/dev/shm` the most its apps' Linux installs ask for (`shm_mb`, in MiB, which its composed computer and the deploy record keep; `--shm-size` on a container, `AGENTENV_SHM_MB` read by a Linux disk's init, passed only to a provider whose `SHARED_MEMORY` says it gives that much, else the sandbox's default, which the deploy logs), then checks its `display`; `deploy_env` `env_params` take a `form`, `computer_settings` (deploy-phase values of the base's settings; a secret one, here or on the env, only as a bare `secret:`/`env:` reference) and `driver_settings` (the driver's `ComputerSettings`, such as its default coordinate space); a `network` that allows nothing runs it on local Docker's internal network behind a relay (`providers/sandbox_providers/local_docker/relay/`); `reset` and `close` have the driver end its recordings first (`computer-recording/v1` `end_all`, each uploading what's left and its manifest under the grant it started with), and `reset` then boots a fresh container in its place (`reset_container`), keeping the computer's address but not an agent's MCP session to the old driver; its `load_file_artifact_universe` writes files under the session user's home through the driver's `data/add`, `Downloads` by default, each file's bytes through a read grant when the store's grants reach it and its network allows everything, else inline (`env/envs/computer/utils/inside.py`)), `ComputerAppEnv` (`computer_app`, `env/envs/computer/app_env.py`: an app on a computer, a `ComputerAppEnvironment` class its env.toml's `module` names, read at put by the same `_declare`, which declares each OS with its own decorator (`@linux(...)`, or `@install(os_type, spec)` for any OS type; `@linux(distribution=...)` or `@install("/", spec)` for one distribution, which replaces its OS type's there) holding its install, its launch and, optionally, a skill and settings and build settings that add to the class's there, and install steps and ready checks for every OS or those their `os=` names; everything that reads its settings, launch or steps asks for the computer's OS type; deployed alone it is a one-app computer env, a `ComputerEnv` of the computer and driver its env.toml names, the composer installing it under `/opt/agentenv/apps//` with its services as supervisord programs beside its own server (`agentenv_protocol.computer.serve_app`, in a venv with the protocol's `app` extra, on `.agentenv/server.sock` in its folder), which adds its launcher, launches a `boot` app once per boot and says through `computer-app/v1` whether it's ready, as the driver's `computer-ready` asks, its card named after it, and `env_params` `app_settings` handing it values of its `Settings` in `AGENTENV_APP_SETTINGS`, a secret one only as a bare reference, over its env.toml's `[settings]` and a computer env's `settings` beside it in `apps`, each by top-level field (`params.app_settings`; checked at put, a required one left to the deploy; the deploy record keeps the merged values as `app_settings`, secrets withheld); its env.toml's `build_settings`, values of its `BuildSettings` checked at put, are written to `.agentenv/build_settings.json` in its folder, so they're part of the image's key, its install steps read them, and a deploy can't change them). An env type whose services take environment data defines `load_environment_artifact` and `load_environment_universe_artifact`; `load_artifact` refuses an environment artifact aimed at a type that doesn't, at save and before it loads. An env built on the protocol SDK can serve agents a skill (`@agent_skill`, `skill/v1`), which `add_skills` `env_ids` installs under its environment name (behind a gateway, each server's under that server's name); a skill with files beside its SKILL.md goes as a bundle stored once per content under `agentenv-env-skills/` in the object store. `env/gateway/gateway.py` is the env-side gateway server, container-only code. Its site route, `/website//`, never forwards a site's data plane or card (`/agentenv/…`, `/.well-known/agent-env.json`), which agentenv reaches through `/svc//`; a site with no frontend image is served by its server image there. A request from a computer's site proxy names its computer (`AgentEnv-Computer`, sent from the proxy's private upstream headers, a page's own copy and any `AgentEnv-Role` it sends dropped) and takes the role driving that computer now (the gateway's computers being those `COMPUTERS` names, a multi env's, with or without a control token): the last to make an input call to its tools, as the call starts, through `/mcp`, `/step` or a trigger action under its `as` (`Gateway._drive`); without one, or from a computer the gateway doesn't front, it is `default`, the role read once per request. `changes/v1` (`ChangeAttribution`) counts no write window for a call to a computer's tools, a trigger action's included, so a write the computer's browser made goes to its request and one another party made during the call to that party. Its CDP route, `/browser//cdp//` (`env/gateway/browser_proxy.py`), reaches the website browser behind the `/svc` child ``, found from that child's card (it, or an app among its children, offering `browser/v1` `cdp` with `/cdp/` in its `computer-app/v1` `agent_routes`): it relays the browser's discovery and WebSocket both ways, each leg pinged every 20 s, and every CDP address the browser hands out, in `json/version`, `json/list` and its `cdp` answer through `/svc//`, comes back at the gateway, everything before `/cdp//` becoming the address the caller reached the gateway at and `/browser/`, keeping the https or wss of an address the browser minted under an origin its caller named, as `browser_connect_cdp` names the agent's, since a tunnel that ends TLS, as Modal's, may send no `X-Forwarded-Proto`; each connection is a `browser_connection` trajectory event, without its token. Its clock (`env/gateway/clock.py`) has one opaque version, a per-boot id and a count, that every `set_time`, `advance` and `clear` changes; `set_rate` (`/clock/set-rate`) changes an armed clock's rate from its time at the write, keeping its `t0` and generation as `advance` does, so time triggers keep their marks. Every clock change goes through `Gateway._change_clock`, which wakes the triggers when the change kept the clock's generation, answers the held watches and waits for the followers. Its followers, the computers on it (`CLOCK_FOLLOWER_TOKENS`, each child whose card serves `clock/v1` `sync_time`, by its read token, its control token for now), long-poll `/clock/watch` naming the version they show, each watch held up to the card's `hold_s` (`env/gateway/clock_followers.py`), and a write given `wait_followers_s` waits for each, answering 504 naming those behind, but not for one that hasn't watched for longer than a hold and a reconnect (`ClockFollowers.QUIET_S`), which it names at once with when each last watched; a restarted gateway is unarmed. While its clock is armed it serves agents `get_time` (`env/gateway/get_time.py`), which answers in UTC and also in the universe's zone, the one `sync_env_clock`'s `timezone` armed it in, or in an IANA `time_zone` it's given; executors' working `hours` (`env/gateway/triggers.py`) take a fixed `utc_offset` or an IANA `time_zone`. | +| `env/` | `Env` base class: a subclass declares `type`, implements `from_dict` and `async deploy(...) -> DeployedEnv`, and may override `reset`, `close` and `load_file_artifact_universe`; teardown closes each env a run deployed before terminating its sandboxes by id. Built-ins in `env/envs/`: `MCPServerEnv` (`mcp_server`), `MultiEnv` (`multi`, MCP servers plus websites and computers; its website browser is the one its `browser_envs` names, none for `[]`, else the run's when it has websites: an MCP server env such as `playwright-mcp` runs among the gateway's MCP servers, and a browser computer such as `chromium` on a sandbox of its own as one more computer child, sized by its `child_envs` entry, its tools under its name and `_`, routing the multi env's synthetic sites unless that entry's `site_routing` says, its network its own env's, as any computer child's; a website env deployed alone refuses a browser computer as the run's browser), `ServiceDBEnv` (`service_db`, PostgreSQL), `WebsiteEnv` (`website`, one site: a server image, `backend_image` in its env.toml, serving the pages and API, ready when its card's `website/v1` `ready` answers a `WebsiteReadiness` that says so, as `agentenv_protocol.website` (`website_readiness`, `env_readiness`) defines a website env's health for the deploy and `DeployedEnv.readiness()` alike, or, for a card without `ready`, when its `health` path answers 200, which is deprecated; its env.toml's `ready_timeout_s`, how long it may take from its server's container starting to ready, is that container's health check `start_period` and what the deploy waits, or its card's `ready` timeout if longer, and its `shm_mb` is the container's `shm_size`, each left to the gateway and Docker without them; the gateway container's `env/gateway/constants.py` mirrors the URI and op, a test keeping them equal; a separate frontend image is deprecated, warned of at put and optional in a bundle, and a stored `backend_docker_image_artifact` reads as the server image; a live one, `live = true`, is a real site whose server serves none of its pages, its `live`, `domains` and `allow_hosts` read at put from its server's `@website(...)` (`utils/card_naming.py` `WebsiteSource`) unless given, its `settings`' secrets only as references the gateway resolves as it writes the site's container (`WEBSITE_SETTINGS_ENV`); the gateway gives it no site route, a computer's site table leaves it out, a computer whose network is an allowlist is let reach its names (`MultiEnv.live_hosts`), a browser alone's forward port takes them straight to the real site (`site_proxy.py` `direct`), as the browser base's stand-in proxy takes any host, refusing nothing, each proxy logging each such connection as a JSON line, and a run that deploys one is marked live, `reproducible: false`), `GatewayEnv` (`gateway_server`), `ComputerDriverEnv` (`computer_driver`, `env/envs/computer/driver_env.py`: a computer driver's files and what its class declares for each platform it supports, read at put in a process of its own, `agentenv_protocol.computer._declare`, where the driver's own dependencies needn't be installed, with the `port` it serves on and its install by OS, `[install.]`, or for one distribution `[install."/"]`, which replaces its OS type's there, as its `known_failures` do (`env/envs/computer/utils/install.py`): files, apt `packages` with extra `sources`, a `python` requirements file for a venv, `downloads` by URL and sha256, `run` scripts, the services the base's init runs, and `ports`; it deploys only as a computer env's driver), `ComputerEnv` (`computer`, in `env/envs/computer/`: a base computer and a driver, matched at put by gate 1 before anything is stored, then composed by `composer.py` into an image for each form and arch on a builder of the put's sandbox provider, by default the env's (`utils/builder.py`; `--sandbox` on `env build`): this machine's Docker for `local`, else a VM of the provider, which fetches the put's stored files by signed URL, takes the rest inline and pushes to the image store itself, so it builds only with stores a remote VM reaches; each arch goes to the first link that runs it natively, else one that emulates it (a VM registers QEMU; `--no-emulate` leaves it `skipped` instead, for a later put), and its pair records the provider that built it (`builder`); a run or register that reuses a computer env composes what it has left (`pending`), a run, and a register given a `--sandbox`, only the forms its sandbox's deploys boot (`booted_forms`: on each link, the first form it boots natively, by the deploy's own rule, `boot.first_native`; a compose of a disk adds its container), and a deploy composes first what it boots that no compose started, and a container it runs natively that was built but not probed, as one whose probe a setting that didn't resolve stopped, booting it only once ready (`ComputerEnv.compose_unstarted`); tagged `agentenv-computers:` in the image store by a key of the image's Dockerfile, build context and lock so any env with the same inputs reuses it; every layer's packages, requirements and downloads are resolved at put in a container of the base for each arch (`utils/packages.py`, `utils/resolve_in_base.py`), stored in the object store by sha256 under `agentenv-packages/`, and listed in a lock stored by a digest of its inputs, which any env with the same inputs reuses, and builds install only the lock's files, every install step `RUN --network=none`; each pair's status goes into its metadata, `composed`, the arches built are written as its computer, a `computer` artifact over one index, and `agent-env env build` resumes what a put left; gate 3 (`utils/probing.py`) then boots each native build on the put's sandbox provider and probes it at `full`, making it `ready` or `failed`, and a build no provider runs natively stays `unverified`. Its deploy, through the `computer` env provider (`providers/env_providers/env_computer_provider.py`), boots its first `ready` build on a sandbox provider that runs its arch natively (`native_platforms()`), with no gateway in front and the driver's card as the env card, its `/dev/shm` the most its apps' Linux installs ask for (`shm_mb`, in MiB, which its composed computer and the deploy record keep; `--shm-size` on a container, `AGENTENV_SHM_MB` read by a Linux disk's init, passed only to a provider whose `SHARED_MEMORY` says it gives that much, else the sandbox's default, which the deploy logs), then checks its `display`; `deploy_env` `env_params` take a `form`, `computer_settings` (deploy-phase values of the base's settings; a secret one, here or on the env, only as a bare `secret:`/`env:` reference) and `driver_settings` (the driver's `ComputerSettings`, such as its default coordinate space); a `network` that allows nothing runs it on local Docker's internal network behind a relay (`providers/sandbox_providers/local_docker/relay/`); `reset` and `close` have the driver end its recordings first (`computer-recording/v1` `end_all`, each uploading what's left and its manifest under the grant it started with), and `reset` then boots a fresh container in its place (`reset_container`), keeping the computer's address but not an agent's MCP session to the old driver; its `load_file_artifact_universe` writes files under the session user's home through the driver's `data/add`, `Downloads` by default, each file's bytes through a read grant when the store's grants reach it and its network allows everything, else inline (`env/envs/computer/utils/inside.py`)), `ComputerAppEnv` (`computer_app`, `env/envs/computer/app_env.py`: an app on a computer, a `ComputerAppEnvironment` class its env.toml's `module` names, read at put by the same `_declare`, which declares each OS with its own decorator (`@linux(...)`, or `@install(os_type, spec)` for any OS type; `@linux(distribution=...)` or `@install("/", spec)` for one distribution, which replaces its OS type's there) holding its install, its launch and, optionally, a skill and settings and build settings that add to the class's there, and install steps and ready checks for every OS or those their `os=` names; everything that reads its settings, launch or steps asks for the computer's OS type; deployed alone it is a one-app computer env, a `ComputerEnv` of the computer and driver its env.toml names, the composer installing it under `/opt/agentenv/apps//` with its services as supervisord programs beside its own server (`agentenv_protocol.computer.serve_app`, in a venv with the protocol's `app` extra, on `.agentenv/server.sock` in its folder), which adds its launcher, launches a `boot` app once per boot and says through `computer-app/v1` whether it's ready, as the driver's `computer-ready` asks, its card named after it, and `env_params` `app_settings` handing it values of its `Settings` in `AGENTENV_APP_SETTINGS`, a secret one only as a bare reference, over its env.toml's `[settings]` and a computer env's `settings` beside it in `apps`, each by top-level field (`params.app_settings`; checked at put, a required one left to the deploy; the deploy record keeps the merged values as `app_settings`, secrets withheld); its env.toml's `build_settings`, values of its `BuildSettings` checked at put, are written to `.agentenv/build_settings.json` in its folder, so they're part of the image's key, its install steps read them, and a deploy can't change them). An env type whose services take environment data defines `load_environment_artifact` and `load_environment_universe_artifact`; `load_artifact` refuses an environment artifact aimed at a type that doesn't, at save and before it loads. An env built on the protocol SDK can serve agents a skill (`@agent_skill`, `skill/v1`), which `add_skills` `env_ids` installs under its environment name (behind a gateway, each server's under that server's name); a skill with files beside its SKILL.md goes as a bundle stored once per content under `agentenv-env-skills/` in the object store. `env/gateway/gateway.py` is the env-side gateway server, container-only code. Its site route, `/website//`, never forwards a site's data plane or card (`/agentenv/…`, `/.well-known/agent-env.json`), which agentenv reaches through `/svc//`; a site with no frontend image is served by its server image there. A request from a computer's site proxy names its computer (`AgentEnv-Computer`, sent from the proxy's private upstream headers, a page's own copy and any `AgentEnv-Role` it sends dropped) and takes the role driving that computer now (the gateway's computers being those `COMPUTERS` names, a multi env's, with or without a control token): the last to make an input call to its tools, as the call starts, through `/mcp`, `/step` or a trigger action under its `as` (`Gateway._drive`); without one, or from a computer the gateway doesn't front, it is `default`, the role read once per request. `changes/v1` (`ChangeAttribution`) counts no write window for a call to a computer's tools, a trigger action's included, so a write the computer's browser made goes to its request and one another party made during the call to that party. Its CDP route, `/browser//cdp//` (`env/gateway/browser_proxy.py`), reaches the website browser behind the `/svc` child ``, found from that child's card (it, or an app among its children, offering `browser/v1` `cdp` with `/cdp/` in its `computer-app/v1` `agent_routes`): it relays the browser's discovery and WebSocket both ways, each leg pinged every 20 s, and every CDP address the browser hands out, in `json/version`, `json/list` and its `cdp` answer through `/svc//`, comes back at the gateway, everything before `/cdp//` becoming the address the caller reached the gateway at and `/browser/`, keeping the https or wss of an address the browser minted under an origin its caller named, as `browser_connect_cdp` names the agent's, since a tunnel that ends TLS, as Modal's, may send no `X-Forwarded-Proto`; each connection is a `browser_connection` trajectory event, without its token. Its clock (`env/gateway/clock.py`) has one opaque version, a per-boot id and a count, that every `set_time`, `advance` and `clear` changes; `set_rate` (`/clock/set-rate`) changes an armed clock's rate from its time at the write, keeping its `t0` and generation as `advance` does, so time triggers keep their marks. Every clock change goes through `Gateway._change_clock`, which wakes the triggers when the change kept the clock's generation, answers the held watches and waits for the followers. Its followers, the computers on it (`CLOCK_FOLLOWER_TOKENS`, each child whose card serves `clock/v1` `sync_time`, by its read token, its control token for now), long-poll `/clock/watch` naming the version they show, each watch held up to the card's `hold_s` (`env/gateway/clock_followers.py`), and a write given `wait_followers_s` waits for each, answering 504 naming those behind, but not for one that hasn't watched for longer than a hold and a reconnect (`ClockFollowers.QUIET_S`), which it names at once with when each last watched; a restarted gateway is unarmed. While its clock is armed it serves agents `get_time` (`env/gateway/get_time.py`), which answers in UTC and also in the universe's zone, the one `sync_env_clock`'s `timezone` armed it in, or in an IANA `time_zone` it's given; executors' working `hours` (`env/gateway/triggers.py`) take a fixed `utc_offset` or an IANA `time_zone`. | | `artifact/` | Immutable versioned artifacts; every `put()` creates a new version. The document goes to the document store, binary payloads to the object store. Every artifact but an environment universe, whose `metadata` key holds its legacy metadata file ids, carries a `metadata` dict outside its versioned fields, changed by compare-and-swap (`merge_metadata`). Built-ins: `CliArtifact` (`cli`), `ComputerArtifact` (`computer`, a base computer: its architectures, OS, session user, settings and container form, whose image `put` reads from its registry into `metadata.validated_images`), `FileArtifact` (`file`), `FileArtifactUniverse` (`file_artifact_universe`), `DockerImageArtifact` (`docker_image`), `EnvironmentArtifact` (`environment`: its environment's files by path, stored as the one wrapped `file_artifact_ref` every environment artifact had when it has one file at its filename, else as `file_artifact_refs`; `get_file_artifacts()` reads either, and a load hands each file to the env's `data/add` with its path, which a pre-v1 load, taking one file, refuses), `EnvironmentUniverseArtifact` (`environment_universe`), `SkillArtifact` (`skill`); `[artifacts] type_aliases` maps another stored spelling of a type onto one of them. A `DockerImageArtifact` holds a tar.gz of its image, or, written by `put_ref` (`--image-ref` on `env mcp-server put` and `a2a-agent put`), only a registry reference with its tag pinned to a digest, which sandboxes pull, or a published image's tag with its `image_digest` and its build context, which sandboxes pull by the digest and build from the context when they can't (the infra images, and a bundle agent built from a shipped agent's sources, `Plan.published`), or, written by `put_context`, only its build context, which a VM sandbox builds before running it (`VmSandbox.load_docker_images`) and Modal builds before creating its container (`ModalSandboxProvider.prepare_image`, outside a fallback chain's deadline); anything else that runs images by name (a container on the local provider, a lone server on any provider but Modal) refuses such an image. A build context (`utils/docker/context.py`) is what `docker build` would send, `.dockerignore` applied, written so equal files give equal bytes and an equal `source_digest`. | | `task/`, `task_step/` | A `Task` holds its `TaskStep`s inline; `Task.run()` executes them as a DAG. `depends_on` (None means all prior steps) gates a step, independent steps run concurrently, `fail_task_on_error` makes a failure fatal or tolerated, `retry_config` rolls a failed span back through the step journal and re-dispatches it. Built-in steps live in `task_step/task_steps/` (`deploy_env`, `deploy_agent`, `prompt_agent`, the verifiers under `verifiers/`, among them `start_computer_recording` and `end_computer_recording`, `start_browser_recording` and `end_browser_recording` (`browser-recording/v1`: one recording per context, a lease's or the default one's, with a video of the tab its agent is on, its context's log, the browser's network log as HAR and opt-in frames keyed to the action log, the contexts its agents make recorded with it, one universe per recording, anything missing failing the run), and more). On an env whose card serves computer-exec/v1 (a computer), `run_code` with `env_id` and `run_container_unit_tests_verifier` with `env_id` run inside it as its session user through the driver: files staged with `data/add` and read with `data/get`, commands run with `run`; `env_outcome_verifier` hands a `verify` that takes an `env_url` keyword the env's address. A computer's framework-only routes (everything but MCP and the card) take the per-deploy control token its provider boots it with (`DeployedEnv.control_token`, `AGENTENV_CONTROL_TOKEN`), a multi env's computers the multi env's own, which its gateway passes on only on their `/svc` routes and its clock watch (`CONTROL_TOKEN_CHILDREN`); framework calls send `deployed.control_headers`, `Task.run` runs every step under `protocol_v1.authorized` with each deployed env's (a `verify` included), and a `run_code` script inside the computer gets `input["env"]["headers"]`. `teardown_run` and the `teardown_sandboxes` step share one core (`task/teardown.py` `tear_down`): the recordings the run left open end with fresh grants, each env still up closes (`Env.close`; a computer env ends any recording still open), what stayed open is registered from its namespace, then every sandbox is terminated by id. `task/episode/` runs a task with some of its agents played from outside, as a training loop does (`EpisodeSpec`). | | `store/` | Four store ABCs with local and cloud implementations: `DocumentStore` (SQLite, MongoDB, DynamoDB, Firestore with MongoDB compatibility), `ObjectStore` (filesystem, S3, Cloud Storage), `ImageStore` (local OCI registry, ECR), `SecretStore` (env vars or file, AWS Secrets Manager, Google Cloud Secret Manager). `VersionedEntityStore` implements the shared versioned get/put logic, `QueryBuilder` is the immutable chained query API, `store/base.py` holds the error types. `store/routing.py` is the local namespaces, `@local` and `@hf` (`is_local_id`), each with a documents file of its own: while the CLI or a `build_app` server runs, a local id and what a local task's run records go to local stores beside the configured ones, and that run's writes to the configured stores are refused. A new backend must pass the conformance kits in `tst/store/`. | diff --git a/src/agent_env/bundle/materialize.py b/src/agent_env/bundle/materialize.py index 67ccaae30..35c6a96f6 100644 --- a/src/agent_env/bundle/materialize.py +++ b/src/agent_env/bundle/materialize.py @@ -366,11 +366,11 @@ def _unbootable(plan: Plan, write: Write, version: int, composing: Composing) -> statuses = env.build_statuses() quoted = {pair: f" ({record['reason'][:_REASON_CHARS]})" for pair, record in records if record.get("reason")} builds = "; ".join(f"{pair} {statuses[pair]}{quoted.get(pair, '')}" for pair, _ in records) - how = (", emulating a skipped arch or on a --sandbox that runs it natively" + how = (", on a --sandbox that runs a skipped arch natively" if any(record.get("status") == "skipped" for _, record in records) else "") return (f"{_path(plan, write)}: {write.id} v{version} has no build a deploy can boot ({builds}), so no task was " - f"written: register again to compose what it left{how}, or compose it with agent-env env build --id " - f"{write.id} --version {version} and then register again") + f"written: register again to compose what it left, or compose it with agent-env env build --id " + f"{write.id} --version {version}{how}, and then register again") def _write_env(plan: Plan, write: Write, composing: Composing = Composing()) -> int: diff --git a/src/agent_env/bundle/register.py b/src/agent_env/bundle/register.py index 437eb9210..bb8b75551 100644 --- a/src/agent_env/bundle/register.py +++ b/src/agent_env/bundle/register.py @@ -88,17 +88,16 @@ def register_bundle( name and a dash unless given. An id the store holds already takes a new version, whoever wrote it. ``on_progress`` is given a line for each write, as it's checked or written, and before each image is built. A folder with no bundle.toml that uses plugin packages is given one, or told what to declare, as ``declaring`` says: by default as a - run of the folder would (``declaring_for``). ``sandbox`` is the provider its tasks deploy on: each computer env - composes there only the forms its deploys there boot, as a run does, emulating an arch no link runs natively unless - ``emulate`` is False, which leaves it skipped. Without it, each composes every form its base declares, on the env's - provider. + run of the folder would (``declaring_for``). ``sandbox`` is the provider its tasks deploy on, as a run's is: each + computer env composes only the forms its deploys there boot, and without it every form its base declares. Either + way it composes on the env's provider, emulating an arch no link of that one runs natively unless ``emulate`` is + False, which leaves it skipped. It turns namespace routing on while it runs. Raises BundleError listing every problem found before anything is written; a write that fails stops it, and every earlier one stays, in the ledger, for the next run to reuse. So does a computer env whose compose left no build a deploy can boot, once every entity is written and before any task: registering again composes what it has left.""" - composing = Composing(build_sandbox_provider(sandbox) if sandbox else None, emulate, - forms_of="deploys" if sandbox else "base") + composing = Composing.for_run(build_sandbox_provider(sandbox), emulate) if sandbox else Composing(None, emulate) with namespace_routing(): bundle = parse_bundle(Path(root)) resolved = resolve_bundle(bundle) diff --git a/src/agent_env/cli/bundle.py b/src/agent_env/cli/bundle.py index 51bf8ab9d..b33996231 100644 --- a/src/agent_env/cli/bundle.py +++ b/src/agent_env/cli/bundle.py @@ -87,13 +87,13 @@ def _report(imported: BundleImport, folder: Path) -> None: @click.option("--dry-run", is_flag=True, help="Check everything and say what would be written; write nothing.") @click.option("--yes", is_flag=True, help="Write to a store other than this machine's own without asking.") @click.option("--sandbox", default=None, - help="The sandbox provider the registered tasks deploy on, comma-separated for a chain: each computer env " - "composes there, each arch on the first link that runs it natively, only the forms its deploys there " - "boot, as agent-env run does. Without it, every form its base declares, on the env's provider. A " - "deploy that boots a form not composed composes it first.") + help="The sandbox provider the registered tasks deploy on, comma-separated for a chain, as agent-env " + "run's: each computer env composes only the forms its deploys there boot, and without it every form " + "its base declares, on this machine either way. A deploy that boots a form not composed composes it " + "first.") @click.option("--no-emulate", is_flag=True, - help="Skip, rather than emulate, an arch no link of the sandbox provider runs natively; a later register " - "or env build builds it.") + help="Skip, rather than emulate, a computer env's arch the provider it composes on doesn't run " + "natively; a later register or env build builds it.") def register(folder: Path, tasks: tuple[str, ...], evals: tuple[str, ...], prefix: str | None, dry_run: bool, yes: bool, sandbox: str | None, no_emulate: bool): """Write the bundle at FOLDER into the configured stores under registry ids, so whatever runs the stores' tasks diff --git a/tst/unit/bundle/computer_env_folder_test.py b/tst/unit/bundle/computer_env_folder_test.py index 294c8a779..ea814bf53 100644 --- a/tst/unit/bundle/computer_env_folder_test.py +++ b/tst/unit/bundle/computer_env_folder_test.py @@ -132,7 +132,7 @@ def compose(env, pairs=None, composing=Composing()): assert stopped.value.problems == ( f"envs/desktop: {env_id} v1 has no build a deploy can boot (container/amd64 failed; container/arm64 ready, by " f"another composer), so no task was written: register again to compose what it left, or compose it with " - f"agent-env env build --id {env_id} --version 1 and then register again",) + f"agent-env env build --id {env_id} --version 1, and then register again",) with pytest.raises(NotFoundError): Task.get(task_id) diff --git a/tst/unit/bundle/register_test.py b/tst/unit/bundle/register_test.py index dab1d13c4..77f3996ba 100644 --- a/tst/unit/bundle/register_test.py +++ b/tst/unit/bundle/register_test.py @@ -543,7 +543,7 @@ def _link(containers=(), disks=()): @pytest.mark.parametrize("sandbox, forms", [(None, ["container", "disk"]), ("docker", ["container"]), ("vms", ["disk"]), ("chain", ["container", "disk"])]) -def test_a_registration_composes_on_its_sandbox_the_forms_its_deploys_there_boot_else_every_form( +def test_a_registration_composes_here_the_forms_its_deploys_on_its_sandbox_boot_else_every_form( home, composed, monkeypatch, sandbox, forms): composings = [] root = _desktop(home, monkeypatch, lambda env, pairs=None, composing=None: composings.append(composing)) @@ -555,7 +555,7 @@ def test_a_registration_composes_on_its_sandbox_the_forms_its_deploys_there_boot assert result.exit_code == 0, result.output [used] = composings assert used.forms(Env.get("desk-desktop"), used.provider()) == forms - assert used.sandbox_provider is _SANDBOXES.get(sandbox) + assert (used.sandbox_provider, used.deploys_on) == (None, _SANDBOXES.get(sandbox)) def test_a_computer_env_whose_compose_leaves_nothing_a_deploy_boots_fails_the_registration_before_its_tasks( @@ -571,9 +571,8 @@ def compose(env, pairs=None, composing=None): assert result.exit_code == 1, result.output assert ("envs/desktop: desk-desktop v1 has no build a deploy can boot (container/amd64 failed (no space left on " "device); container/arm64 skipped (no link runs linux/arm64 natively)), so no task was written: register " - "again to compose what it left, emulating a skipped arch or on a --sandbox that runs it natively, or " - "compose it with agent-env env build --id desk-desktop --version 1 and then register again" - ) in result.output + "again to compose what it left, or compose it with agent-env env build --id desk-desktop --version 1, on a " + "--sandbox that runs a skipped arch natively, and then register again") in result.output assert Env.get("desk-desktop").version == 1 with pytest.raises(NotFoundError): Task.get("desk-t")