Files
hermes-agent/tests/scripts/test_termux_agent_assembly.py
ethernet 1bf588234c refactor(build): share product recipes across distributions
Build TUI, web, desktop UI and runnable agent products from explicit
prepared inputs. Keep dependency preparation separate from distribution
packaging, with PM and native builds sharing uv environment construction.

Docker copies compiled frontend products instead of build dependencies.
Nix retains uv2nix environments and consumes shared assembly through store
references. Native desktop and Termux use the same launcher and frontend
contracts. Preserve the independent PM runtime and source imports from
arbitrary working directories.

Keep failed frontend builds from replacing the previous product, reject
source/output overlap, and bound dependency-process output draining.
Include hermes_wisdom in the Nix wheel: real CLI smoke tests exposed its
missing package declaration on the base revision too.

Verified focused Python and JavaScript suites, Docker build/runtime checks,
Nix desktop and CLI/ACP checks, standalone TUI and packaged Electron PTY,
and real full-Chromium interaction. Native signed installers, Android device
installation and the full repository suite remain CI verification.
2026-09-11 13:16:55 -04:00

51 lines
2.6 KiB
Python

"""Bionic assembly consumes prepared bytes without running foreign binaries."""
import json
from pathlib import Path
import shutil
from scripts.build.inputs import RESOURCE_ENV, dependency_site
from scripts.termux.payload_facts import write_facts
def test_bionic_facts_and_agent_keep_fixed_prefix_and_tui_only(tmp_path):
from pm.lock import Lockfile, Facts
from pm.registry import get_package
payload = tmp_path / "payload"
repo = payload / "app"
(repo / "pm").mkdir(parents=True)
lock = repo / "pm/lock.json"
shutil.copy2(Path(__file__).resolve().parents[2] / "pm/lock.json", lock)
(repo / "pyproject.toml").write_text('[project]\nname="fixture"\nversion="1"\n[project.scripts]\nprobe="entry:main"\n', encoding="utf-8")
(repo / "install-stamp.json").write_text('{"distribution":"apt-termux","payload":"bundled"}', encoding="utf-8")
for name in RESOURCE_ENV:
(repo / name).mkdir()
target = "linux-arm64-bionic"
tools = ("python", "node", "uv", "npm", "ffmpeg", "ripgrep")
for name in tools:
executable = get_package(name).binary(payload / "tools" / name, target)
executable.parent.mkdir(parents=True, exist_ok=True)
executable.write_bytes(b"foreign binary must not be executed")
executable.chmod(0o755)
python = get_package("python").binary(payload / "tools/python", target)
site = dependency_site(payload / "venv", Lockfile(lock).version("python"), target)
site.mkdir(parents=True)
pm = payload / "pm-runtime"
(pm / "deps").mkdir(parents=True)
(pm / "pm-runtime.json").write_text(json.dumps({"python": "../" + python.relative_to(payload).as_posix(), "sitePackages": "deps"}), encoding="utf-8")
tui = tmp_path / "tui-product"
(tui / "dist").mkdir(parents=True)
(tui / "dist/entry.js").write_text("built", encoding="utf-8")
(tui / "package.json").write_text('{"type":"module"}', encoding="utf-8")
build_set = tmp_path / "build-set.txt"
build_set.write_text("native-fixture\n", encoding="utf-8")
write_facts(payload, lock, build_set, tui)
manifest = json.loads((payload / "manifest.json").read_text())
assert manifest["runtime"]["commands"] == {"probe": "bin/probe"}
assert manifest["runtime"]["sitePackages"] == site.relative_to(payload).as_posix()
assert (repo / "hermes_cli/tui_dist/entry.js").read_text() == "built"
assert not (repo / "hermes_cli/web_dist").exists()
assert json.loads((payload / "native-wheels.json").read_text()) == ["native-fixture"]
facts = Facts(payload / "tools/facts.json", strict=True)
assert all(facts.get(name)["target"] == target for name in tools)