Files
alzeo/tests/installer_wall.py
T
Hasan BasbunarandClaude Opus 5.5 cd79ea7b09 cockpit: the pins are read again when one is missing, and a scan that still misses one concludes nothing
The fourth review (of 46579ff) found what that fix still missed: a target whose draft's pin was not read
stayed "incomplete" with a Download; an installer cut inside its PART lines named fewer parts unseen; the
upstream view kept a partial scan for an hour; and a scan was never cached while partial, so a lasting
cause rescanned on every call.

read_pins reads every pin file and every TARGET_FILES target's parts, and reads them again (3 tries,
0.5 s apart) while a pin of rg.PIN_MODELS, or a part from 1 to N, is missing: a checkout rewrites a file in
an instant. What is still missed is said in "partial" (beside the Scan button), every revision that would
read stray reads "unknown" and is kept, and a target reads "unknown" ("not read", no Download) only when
its own pin, its draft's or its parts are missing. Such a scan is cached as any other; the upstream view
keeps none for its hour. The tests fail on v1.48.1 and on 46579ff, and a mutant of each check is caught
(one read, the draft unchecked, the parts unchecked).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 16:43:39 +01:00

193 lines
9.3 KiB
Python

"""Installer runs that end where the test says they end, on whatever machine runs the suite.
Six test files run install.sh or get.sh whole and count on one refusal to stop the run early.
Past it, step 1 asks nvidia-smi and docker about the machine and sudo for a ticket, step 2
pulls, step 6 writes the checkpoint configs in the HF cache, and get.sh fetches and resets
the checkout it is started from. Nothing checked that the refusal held: a refusal that moved
down would have run the rest for real on the box the suite ran on, get.sh was started from
the real checkout, and the tests read the box's own units in /etc (found in review,
2026-09-24).
walled() is a copy of the script that ends at a wall: a line that prints WALL and exits
before the part that acts on the machine, so a refusal that does not fire shows up as the
wall and nothing past it can run. The copy reads its units from a directory the test owns,
never /etc/systemd/system. fence() is a PATH entry that answers for the commands that act on
the box: each one records its call and fails, except `systemctl is-enabled`, which answers
from the units the test says are enabled.
"""
import atexit
import datetime
import functools
import importlib.util
import json
import os
import pathlib
import shutil
import stat
import tempfile
REPO = pathlib.Path(__file__).resolve().parents[1]
WALL = "WALL: the run went past the refusal under test"
UNITS = "/etc/systemd/system/"
REAL_UNITS = "the box's own units"
# Where each script's run stops. install.sh: the first line of step 1, which is the first
# thing that probes the machine; or, for the one test that means to run step 1, the line
# that ends it. get.sh: the first line after its root refusal.
BEFORE_STEP_1 = 'step "1/10 Preflight checks"\n'
AFTER_STEP_1 = 'echo "OK (aarch64, ${TOTAL_GIB} GiB of memory: a ${MEM_CLASS} GB box, ${FREE_DISK_GB} GiB free)"\n'
GET_PAST_ROOT = ' REPO_URL="https://github.com/hasso5703/alzeo"\n'
# Every directory this makes lives under one root, removed when the process ends: the suite
# runs on the box it tests, and /tmp there held 7,200 directories other tests left behind.
_ROOT = []
def _tmp(prefix):
if not _ROOT:
_ROOT.append(tempfile.mkdtemp(prefix="installer-wall-"))
atexit.register(shutil.rmtree, _ROOT[0], True)
return pathlib.Path(tempfile.mkdtemp(prefix=prefix, dir=_ROOT[0]))
# Every command the installers use to act on the machine or reach the network.
FENCED = ("docker", "sudo", "nvidia-smi", "systemctl", "journalctl", "curl", "wget", "git",
"pip", "pip3", "hf", "huggingface-cli", "tailscale", "opencode", "loginctl")
def walled(script="install.sh", at=None, after=False, units=None):
"""Path of a copy of `script` (a repo file) that exits at the wall.
at: the line the wall goes before (or after, with after=True); the default for
install.sh is the first line of step 1, for get.sh the line after the root refusal.
units: the directory standing in for /etc/systemd/system (a fresh empty one by
default); every mention of that path in the copy is pointed at it. The box's own units
are read only with units=REAL_UNITS, by the one test that is about the box it runs on."""
text = (REPO / script).read_text()
at = at or (BEFORE_STEP_1 if script == "install.sh" else GET_PAST_ROOT)
if text.count(at) != 1:
raise AssertionError(f"{script} no longer has the line the wall goes at: {at!r}")
wall = f'echo "{WALL}"; exit 97\n'
text = text.replace(at, at + wall if after else wall + at, 1)
if units != REAL_UNITS:
units = pathlib.Path(units or _tmp("units-"))
text = text.replace(UNITS, f"{units}/")
if "/etc/systemd" in text[:text.index(wall)]:
raise AssertionError(f"{script} reads units under a path this copy does not redirect")
d = _tmp("walled-")
copy = d / pathlib.Path(script).name
copy.write_text(text)
copy.chmod(0o755)
# the library the installers source from their own directory (since v1.30), its units
# pointed where the copy's are
lanes = (REPO / "lanes.sh").read_text()
if units != REAL_UNITS:
lanes = lanes.replace("/etc/systemd/system", str(units))
(d / "lanes.sh").write_text(lanes)
# and the fetch they run (since v1.31), which they check is there before mounting it
(d / "ckpt-fetch.py").write_text((REPO / "ckpt-fetch.py").read_text())
# and conformity.py (since v1.36.0), which the convergence asks whether an installed value
# is a default of an older release or a choice
(d / "conformity.py").write_text((REPO / "conformity.py").read_text())
# and boxmem.py (since the 64 GB DGX Spark), which says the box's memory class
(d / "boxmem.py").write_text((REPO / "boxmem.py").read_text())
# and the side lanes' installers, whose defaults it recommends (since v1.36.0): read only,
# so written without the execute bit, and a run that reached one would stop on it. Every one
# conformity.py reads (its SIDE), not a list of them here: kept by hand, it missed the Unsloth
# GGUF lane's (v1.49.0), and the list before step 1 failed on any box with that lane's unit
for side in side_installers():
(d / side).write_text((REPO / side).read_text())
# and the head of the CHANGELOG, whose first heading names the release the list before
# step 1 compares the box with (since v1.36.0)
(d / "CHANGELOG.md").write_text("".join((REPO / "CHANGELOG.md").read_text().splitlines(keepends=True)[:3]))
return str(copy)
@functools.lru_cache(maxsize=1)
def side_installers():
"""The installers conformity.py reads its side lanes' values from (its SIDE), sorted (read once)."""
spec = importlib.util.spec_from_file_location("conformity_for_the_wall", REPO / "conformity.py")
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
return tuple(sorted({script for script, _ in mod.SIDE.values()}))
def units_dir(units=None):
"""A directory standing in for /etc/systemd/system, holding `units` ({name: text})."""
d = _tmp("units-")
for name, text in (units or {}).items():
(d / name).write_text(text)
return str(d)
def fence(enabled=()):
"""(PATH entry, record file). Put the entry first on PATH: each command in FENCED
appends its argv to the record and exits 97; `systemctl is-enabled [--quiet] UNIT`
answers 0 for the units in `enabled`, 1 for the others, and records nothing."""
d = _tmp("fence-")
record = d / "calls"
record.touch()
for name in FENCED:
body = f'#!/bin/sh\necho "{name} $*" >> "{record}"\nexit 97\n'
if name == "systemctl":
cases = "".join(f' *" {u}") exit 0 ;;\n' for u in enabled)
body = ('#!/bin/sh\ncase "$1" in\n is-enabled)\n case " $*" in\n' + cases +
' esac\n exit 1 ;;\nesac\n' + body.split("\n", 1)[1])
(d / name).write_text(body)
(d / name).chmod((d / name).stat().st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
return str(d), record
def meminfo_128():
"""A /proc/meminfo of the reference box, a 128 GB DGX Spark (121.6 GiB of MemTotal)."""
path = _tmp("meminfo-") / "meminfo"
path.write_text("MemTotal: 127533104 kB\nMemAvailable: 121000000 kB\n")
return path
def fenced_env(home=None, enabled=(), first=None, **extra):
"""(env, record): a minimal environment whose PATH starts with the fence (after
`first`, a directory of the test's own stubs, when given) and a throwaway HOME.
install.sh reads the box's class and its GiB from QWEN38_MEMINFO (/proc/meminfo by
default): a walled run reads a 128 GB box's unless the test gives its own, so it does not
depend on the machine the tests run on (on a 64 GB one, 10 of the context mode's tests
failed, found in review, 2026-10-23)."""
entry, record = fence(enabled)
path = ":".join(p for p in (first, entry, "/usr/local/bin:/usr/bin:/bin") if p)
env = {"PATH": path, "HOME": str(home or _tmp("home-"))}
env.update({k: str(v) for k, v in extra.items()})
env.setdefault("QWEN38_MEMINFO", str(meminfo_128()))
return env, record
def reached(record):
"""What the run asked the fenced commands for, one line per call."""
return pathlib.Path(record).read_text().splitlines()
def box_home(key_at=None, record=None):
"""A HOME whose ~/.config/qwen38 holds an API key last written at `key_at` (an ISO instant;
none when None), the age conformity.py gives a box with no installed.json, and that file
when `record` ({setting: value} of recorded choices) is given."""
home = _tmp("home-")
cfg = home / ".config/qwen38"
cfg.mkdir(parents=True)
if key_at:
(cfg / "api-key").write_text("not-a-key\n")
t = datetime.datetime.fromisoformat(key_at).timestamp()
os.utime(cfg / "api-key", (t, t))
if record is not None:
(cfg / "installed.json").write_text(json.dumps({
"schema": 1, "release": "v1.36.0", "commit": "0" * 40, "path": "full",
"box_since": "2026-09-05T09:00:00+00:00", "box_since_from": "api-key",
"choices": {k: {"value": v, "since": "2026-10-20T08:00:00+00:00", "how": "env"}
for k, v in record.items()}}))
return str(home)
def cwd():
"""A directory that is not a clone of this repo: get.sh uses the checkout it is started
from, and the real one is the last place a test should start it."""
return str(_tmp("cwd-"))