fix(issue-45): MAM herdr servers start with restore-on-restart off; resume closes its own restored empty shell (v4.8.5) #48

Merged
Godopu merged 14 commits from fix/issue-45 into main 2026-10-05 09:56:40 +00:00
2 changed files with 16 additions and 1 deletions
Showing only changes of commit eedcebcc12 - Show all commits

No files matched your search

+8 -1
View File
@@ -32,7 +32,6 @@ import os
import re import re
import sys import sys
import tempfile import tempfile
import tomllib
from typing import List, Mapping, Optional, Tuple from typing import List, Mapping, Optional, Tuple
MARKER = "# generated by multi-agent-mux (Issue #45) - do not edit" MARKER = "# generated by multi-agent-mux (Issue #45) - do not edit"
@@ -42,6 +41,11 @@ FALLBACK_NAME = "herdr-server-config.toml"
KEY = "resume_agents_on_restore" KEY = "resume_agents_on_restore"
MINIMAL = f"[session]\n{KEY} = false\n" MINIMAL = f"[session]\n{KEY} = false\n"
try:
import tomllib
except ImportError: # Python < 3.11: no parser to check a merge with
tomllib = None
_SESSION_HEADER = re.compile(r"^\s*\[\s*session\s*\]\s*(#.*)?$") _SESSION_HEADER = re.compile(r"^\s*\[\s*session\s*\]\s*(#.*)?$")
_ANY_HEADER = re.compile(r"^\s*\[") _ANY_HEADER = re.compile(r"^\s*\[")
_KEY_LINE = re.compile(rf"^\s*{KEY}\s*=") _KEY_LINE = re.compile(rf"^\s*{KEY}\s*=")
@@ -107,6 +111,9 @@ def server_config_text(user_text: Optional[str]) -> Tuple[str, List[str]]:
always has session.resume_agents_on_restore = false.""" always has session.resume_agents_on_restore = false."""
if not user_text or not user_text.strip(): if not user_text or not user_text.strip():
return MINIMAL, [] return MINIMAL, []
if tomllib is None:
return MINIMAL, [f"this Python has no tomllib (3.11+); the MAM server uses only {KEY} = false, "
"without the rest of your settings"]
try: try:
user = tomllib.loads(user_text) user = tomllib.loads(user_text)
except tomllib.TOMLDecodeError as e: except tomllib.TOMLDecodeError as e:
+8
View File
@@ -71,6 +71,14 @@ def test_a_bad_value_type_falls_back_to_minimal():
assert warnings == [] assert warnings == []
def test_without_tomllib_restore_is_still_off(monkeypatch):
# The shim runs a bare `python3`; on one older than 3.11 an import error
# would leave the server with restore on. Off wins over the user's settings.
monkeypatch.setattr(hc, "tomllib", None)
text, warnings = hc.server_config_text("[ui]\nconfirm_close = false\n")
assert text == hc.MINIMAL and "no tomllib" in warnings[0]
def _env(tmp_path, **kw): def _env(tmp_path, **kw):
env = {"HOME": str(tmp_path / "home")} env = {"HOME": str(tmp_path / "home")}
env.update(kw) env.update(kw)