Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
69dd5d9
Rewrite modpack groups around flat TOML ids, sparse client intent, an…
Skidamek Nov 27, 2026
3c056fc
Adopt toml-edit 0.3.0 dynamic tables, atomic edits, and tableMap in T…
Skidamek Nov 27, 2026
68f9e2f
Deduplicate persisted client selection fields into SelectionJsons.Sel…
Skidamek Nov 27, 2026
00bb3ba
Extract GroupSelectionScreen.Session, preserve scroll, and polish layout
Skidamek Nov 27, 2026
0605636
Migrate autotester to server.toml, fix Forge downloads, and add group…
Skidamek Nov 27, 2026
bf5e17e
toml-edit 0.4.0
Skidamek Nov 28, 2026
a4769a5
Support OS-scoped REQUIRED groups, pairwise conflicts, and cleaner se…
Skidamek Nov 28, 2026
e4fa9e4
Show included automatic groups and match list buttons to group cards
Skidamek Nov 28, 2026
889adef
Use neutral vanilla list chrome, ghost controls, and read-only includ…
Skidamek Nov 28, 2026
d714899
Tighten server-config and pack-content docs
Skidamek Nov 28, 2026
aa4c09f
Add padlock icon to included rows and ground list buttons in neutral …
Skidamek Nov 28, 2026
d8d6f76
Square folder plates to 32x32 and center card text and padlock
Skidamek Nov 28, 2026
54ea597
Migrate breaks-with to conflicts and client selections from v1 to v2
Skidamek Nov 28, 2026
aad94c9
Rename DO_NOT_CHANGE_IT to version in selection and relay consent stores
Skidamek Nov 28, 2026
5243c94
Notify players on UpdatePreviewScreen when new optional groups are added
Skidamek Nov 28, 2026
11fa0bf
Convert rc.7 active state manifests on read and allow clearing unavai…
Skidamek Nov 28, 2026
28155e6
Use schemaVersion for every persisted version field and trim comments
Skidamek Nov 28, 2026
e2d5311
Run rc.7 document migration as a Gson type factory instead of a deser…
Skidamek Nov 28, 2026
f0efc46
Give GroupSelectionResolver one named phase per selection step
Skidamek Nov 28, 2026
b7a68b6
Let the group validator ask the resolver instead of re-deriving activ…
Skidamek Nov 28, 2026
62dc2c8
Own category membership in GroupManifest and share the bulk toggle ta…
Skidamek Nov 28, 2026
b75ce12
Give list rows named factories and share the card text layout
Skidamek Nov 28, 2026
8af2f3e
Drop selectable-group payload nothing reads
Skidamek Nov 28, 2026
bebc34f
Share the empty-folder check and say why the absence check skips a pl…
Skidamek Nov 28, 2026
1798ce0
Migrate rc.7 documents at their owners instead of inside Gson binding
Skidamek Nov 28, 2026
7948ab2
Expand rc.7 category subscriptions into the group picks they stood for
Skidamek Nov 28, 2026
82e1f82
Split rc.7 policy and client selection migrations
Skidamek Nov 28, 2026
39f267a
Migrate the selection of stored rc.7 instance trees on read and rebui…
Skidamek Nov 29, 2026
5541fdb
Report saved group picks this platform cannot install, keep TOML defa…
Skidamek Nov 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 64 additions & 10 deletions autotester/automodpack_autotester/harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
from __future__ import annotations

import json
import re
import secrets
import time
import tomllib
from contextlib import contextmanager
from copy import deepcopy
from dataclasses import dataclass, field
Expand Down Expand Up @@ -103,19 +105,23 @@ def client(self, name: str = "default") -> ClientProcess:
return self._clients[name]

def configure_server(self, *, connection_mode: str = "HOLEPUNCH", overrides: dict[str, Any] | None = None) -> Path:
"""Write automodpack-server.json into the server dir before starting."""
"""Write automodpack/server.toml into the server dir before starting."""
cfg = deepcopy((self.settings.get("automodpack") or {}).get("config") or {})
cfg["connectionMode"] = connection_mode.upper()
if connection_mode.upper() in ("HTTP", "HTTPS"):
cfg["bindAddress"] = "0.0.0.0"
cfg["bindPort"] = self.server.endpoint_port
cfg["advertisedEndpointHost"] = self.server.host
cfg["advertisedEndpointPort"] = self.server.endpoint_port
network = cfg.setdefault("network", {})
mode = connection_mode.upper()
network["connection-mode"] = mode
if mode in ("HTTP", "HTTPS"):
network["bind-address"] = "0.0.0.0"
network["bind-port"] = self.server.endpoint_port
network["advertised-host"] = self.server.host
network["advertised-port"] = self.server.endpoint_port
if overrides:
cfg.update(overrides)
cfg_path = self.server.server_dir / "automodpack" / "automodpack-server.json"
_deep_merge(cfg, overrides)
rendered = _dump_toml(cfg)
tomllib.loads(rendered)
cfg_path = self.server.server_dir / "automodpack" / "server.toml"
cfg_path.parent.mkdir(parents=True, exist_ok=True)
cfg_path.write_text(json.dumps(cfg, indent=2) + "\n", encoding="utf-8")
cfg_path.write_text(rendered, encoding="utf-8")
return cfg_path

def stage_server_file(self, rel_path: str, content: str | bytes) -> Path:
Expand Down Expand Up @@ -163,6 +169,54 @@ def close(self, *, passed: bool) -> None:
prune_passed_case(self.case_dir)


_BARE_KEY_RE = re.compile(r"^[A-Za-z0-9_-]+$")


def _deep_merge(base: dict[str, Any], patch: dict[str, Any]) -> None:
for key, val in patch.items():
if isinstance(val, dict) and isinstance(base.get(key), dict):
_deep_merge(base[key], val)
else:
base[key] = deepcopy(val)


def _format_key(key: str) -> str:
return key if _BARE_KEY_RE.match(key) else json.dumps(key)


def _format_value(value: Any) -> str:
if isinstance(value, bool):
return "true" if value else "false"
if isinstance(value, int):
return str(value)
if isinstance(value, float):
return repr(value)
if isinstance(value, str):
return json.dumps(value)
if isinstance(value, (list, tuple)):
return "[" + ", ".join(_format_value(v) for v in value) + "]"
raise TypeError(f"Unsupported TOML value: {value!r}")


def _emit_table(lines: list[str], data: dict[str, Any], prefix: tuple[str, ...]) -> None:
scalars = [(k, v) for k, v in data.items() if not isinstance(v, dict)]
tables = [(k, v) for k, v in data.items() if isinstance(v, dict)]
if prefix and (scalars or not tables):
if lines:
lines.append("")
lines.append("[" + ".".join(_format_key(p) for p in prefix) + "]")
for k, v in scalars:
lines.append(f"{_format_key(k)} = {_format_value(v)}")
for k, v in tables:
_emit_table(lines, v, (*prefix, k))


def _dump_toml(data: dict[str, Any]) -> str:
lines: list[str] = []
_emit_table(lines, data, ())
return "\n".join(lines) + ("\n" if lines else "")


def run_scenario_fn(
fn: Callable[[TestCase], None],
*,
Expand Down
13 changes: 11 additions & 2 deletions autotester/automodpack_autotester/hmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,16 @@ def target_hmc_cache(target: Target) -> Path:
return shared_cache_root() / "hmc" / target.id


def write_hmc_config(config_root: Path, mc_cache: Path, game_dir: Path, java_home: Path, *, username: str | None = None, user_uuid: str | None = None) -> None:
def write_hmc_config(
config_root: Path,
mc_cache: Path,
game_dir: Path,
java_home: Path,
*,
username: str | None = None,
user_uuid: str | None = None,
xvfb_check: bool = False,
) -> None:
cfg_dir = config_root / "headlessmc"
cfg_dir.mkdir(parents=True, exist_ok=True)
props = {
Expand All @@ -115,7 +124,7 @@ def write_hmc_config(config_root: Path, mc_cache: Path, game_dir: Path, java_hom
"hmc.java.versions": java_home.as_posix(),
"hmc.launcher.crash-report-watcher": "true",
"hmc.jline.enabled": "false",
"hmc.xvfb.check": "false",
"hmc.xvfb.check": "true" if xvfb_check else "false",
}
if username:
props["hmc.offline.username"] = username
Expand Down
79 changes: 55 additions & 24 deletions autotester/automodpack_autotester/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ClientProcess(Protocol):
token: str
bridge: BridgeClient | None

def start(self, *, fast_timers: bool = True, render: bool = False, extra_jvm_args: list[str] | None = None) -> None: ...
def start(self, *, fast_timers: bool = True, render: bool = False, extra_jvm_args: list[str] | None = None, resolution: tuple[int, int] | None = None) -> None: ...
def stop(self, *, force: bool = True) -> None: ...
def wait_ready(self, timeout: float = 180.0) -> BridgeClient: ...
def wait_exit(self, timeout: float = 60.0) -> int: ...
Expand Down Expand Up @@ -95,10 +95,7 @@ def _prepare_dir(self) -> None:
mods_dir.mkdir(parents=True, exist_ok=True)
dest_jar = mods_dir / self.artifact.name
if not dest_jar.exists():
try:
os.link(self.artifact, dest_jar)
except OSError:
shutil.copy2(self.artifact, dest_jar)
shutil.copy2(self.artifact, dest_jar)
self._materialized = True
write_server_properties(
self.server_dir,
Expand Down Expand Up @@ -156,6 +153,17 @@ def logs(self, tail: int = 120) -> str:
return self._proc.tailer.tail(tail) if self._proc is not None else (self.log_path.read_text(encoding="utf-8", errors="replace") if self.log_path.is_file() else "")


def linux_render_wrapper(width: int = 1280, height: int = 720) -> list[str] | None:
"""Return a virtual display command prefix on Linux (`xvfb-run` first, then `gamescope` headless)."""
xvfb = shutil.which("xvfb-run")
if xvfb:
return [xvfb, "-a", "-s", f"-screen 0 {width}x{height}x24"]
gamescope = shutil.which("gamescope")
if gamescope:
return [gamescope, "--backend", "headless", "-W", str(width), "-H", str(height), "--"]
return None


class LocalClient:
"""Native HeadlessMC 3 Minecraft client running directly on the host OS (no Docker)."""

Expand All @@ -171,41 +179,46 @@ def __init__(self, name: str, target: Target, settings: dict, client_root: Path,
self._proc: ManagedProcess | None = None
self.log_path = client_root / f"client-{name}.log"
self._prepared = False
self._render = False

def _prepare(self) -> tuple[Path, Path, Path]:
def _prepare(self, *, xvfb_check: bool = False, gui_scale: int | None = None) -> tuple[Path, Path, Path]:
home = java_home(self.settings, self.target.java)
mc_cache = ensure_profile_prepared(self.target, self.settings, home)
self.game_dir.mkdir(parents=True, exist_ok=True)
mods_dir = self.game_dir / "mods"
mods_dir.mkdir(parents=True, exist_ok=True)
dest_jar = mods_dir / self.artifact.name
if not dest_jar.exists():
try:
os.link(self.artifact, dest_jar)
except OSError:
shutil.copy2(self.artifact, dest_jar)
shutil.copy2(self.artifact, dest_jar)
seed_fml_toml(self.game_dir, self.target)
options_txt = self.game_dir / "options.txt"
if not options_txt.is_file():
options_txt.write_text("onboardAccessibility:false\nskipMultiplayerWarning:true\n", encoding="utf-8")
extra = f"guiScale:{gui_scale}\n" if gui_scale is not None else ""
options_txt.write_text(f"onboardAccessibility:false\nskipMultiplayerWarning:true\n{extra}", encoding="utf-8")
elif gui_scale is not None:
lines = [line for line in options_txt.read_text(encoding="utf-8").splitlines() if not line.startswith("guiScale:")]
lines.append(f"guiScale:{gui_scale}")
options_txt.write_text("\n".join(lines) + "\n", encoding="utf-8")
import uuid

player_name = f"amp_{self.name}"[:16]
player_uuid = str(uuid.uuid3(uuid.NAMESPACE_DNS, f"OfflinePlayer:{player_name}"))
cfg_root = self.client_root / "hmc-config"
write_hmc_config(cfg_root, mc_cache, self.game_dir, home, username=player_name, user_uuid=player_uuid)
write_hmc_config(cfg_root, mc_cache, self.game_dir, home, username=player_name, user_uuid=player_uuid, xvfb_check=xvfb_check)
self._prepared = True
return mc_cache, home, cfg_root

def start(self, *, fast_timers: bool = True, render: bool = False, extra_jvm_args: list[str] | None = None) -> None:
def start(self, *, fast_timers: bool = True, render: bool = False, extra_jvm_args: list[str] | None = None, resolution: tuple[int, int] | None = None) -> None:
if self.bridge is not None:
self.bridge.close()
self.bridge = None
# Clear previous bridge-state.json so wait_ready waits for THIS launch's port.
state_file = self.game_dir / "automodpack" / "autotest" / "bridge-state.json"
state_file.unlink(missing_ok=True)

mc_cache, home, cfg_root = self._prepare()
self._render = render
width, height = resolution or ((1280, 720) if render else (854, 480))
mc_cache, home, cfg_root = self._prepare(xvfb_check=render, gui_scale=2 if render else None)
hmc_bin = ensure_hmc_binary(self.settings)
memory = str((self.settings.get("jvm") or {}).get("clientMemory", "1G"))
jvm_args = [
Expand All @@ -228,16 +241,14 @@ def start(self, *, fast_timers: bool = True, render: bool = False, extra_jvm_arg
*([] if render else ["-lwjgl"]),
"--jvm",
" ".join(jvm_args),
"--game",
"--width 854 --height 480",
"--resolution",
"854x480",
f"{width}x{height}",
]
if render and not sys.platform.startswith("win"):
xvfb = shutil.which("xvfb-run")
if not xvfb:
raise RuntimeError("render=True requires xvfb-run on Linux")
argv = [xvfb, "-a", *argv]
wrapper = linux_render_wrapper(width, height)
if not wrapper:
raise RuntimeError("render=True requires xvfb-run or gamescope on Linux")
argv = [*wrapper, *argv]
env = hmc_env(mc_cache, home, cfg_root)
self._proc = ManagedProcess(argv, cwd=self.game_dir, env=env, log_path=self.log_path)
self._proc.start()
Expand All @@ -254,10 +265,20 @@ def wait_ready(self, timeout: float = 180.0) -> BridgeClient:
if client is not None:
try:
client.ping()
self.bridge = client
return client
except Exception:
client.close()
time.sleep(0.05)
continue
if self._render and "forcing headless mode" in self.logs(200).lower():
client.close()
self.stop(force=True)
raise RuntimeError(
"HeadlessMC forced stub-LWJGL headless mode despite render=True. "
"Offline rendered UI requires Xvfb (xvfb-run) on Linux with hmc.xvfb.check=true, "
"or a logged-in Microsoft account."
)
self.bridge = client
return client
time.sleep(0.05)
raise TimeoutError(f"Client {self.name!r} bridge did not become ready within {timeout:.0f}s\n--- log tail ---\n{self.logs(60)}")

Expand Down Expand Up @@ -321,7 +342,7 @@ def __init__(self):
name="local",
os_family=os_family,
native_windows_ntfs=(os_family == "windows"),
rendered_ui=bool(os_family == "windows" or shutil.which("xvfb-run")),
rendered_ui=bool(os_family == "linux" and shutil.which("xvfb-run")),
)

def prerequisites(self, settings: dict, targets: list[Target]) -> list[tuple[str, bool, str]]:
Expand All @@ -337,6 +358,16 @@ def prerequisites(self, settings: dict, targets: list[Target]) -> list[tuple[str
except Exception as e:
checks.append((f"java-{t.java}", False, str(e)))
checks.append(("provider", True, f"local ({self.capabilities.os_family}, zero-docker)"))
if self.capabilities.os_family == "linux":
if shutil.which("xvfb-run"):
render_backend = "xvfb-run"
elif shutil.which("gamescope"):
render_backend = "gamescope (offline rendering requires xvfb-run or Microsoft account)"
else:
render_backend = "none"
else:
render_backend = "native"
checks.append(("renderedUi", True, render_backend))
return checks

def create_server(self, target: Target, settings: dict, server_dir: Path, artifact: Path) -> ServerProcess:
Expand Down
2 changes: 1 addition & 1 deletion autotester/automodpack_autotester/scenarios/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def list_scenarios() -> list[ScenarioSpec]:


def _load_all() -> None:
from . import compat, edge, faults, gate, offline, release, transport # noqa: F401
from . import compat, edge, faults, gate, groups, offline, release, transport # noqa: F401


# --- Shared AutoModpack UI / sync flow helpers ---
Expand Down
Loading